diff options
author | elijah <elijah@riseup.net> | 2013-02-12 21:33:39 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-02-12 21:33:39 -0800 |
commit | 71ec0edea3f87fb69222dbb6fe025c2211402ca2 (patch) | |
tree | 5490323e8686df14165ccf5f37fa2d691fc99b88 /lib/site_configuration.rb | |
parent | 00c785b728c5d97335b87e3eb7d10b9ad0c46d35 (diff) |
added capacity for pulling static pages from multiple directory source trees.
Diffstat (limited to 'lib/site_configuration.rb')
-rw-r--r-- | lib/site_configuration.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/site_configuration.rb b/lib/site_configuration.rb new file mode 100644 index 0000000..62ad854 --- /dev/null +++ b/lib/site_configuration.rb @@ -0,0 +1,50 @@ +# +# A class for a site's configuration. +# Site configuration file is eval'ed in the context of an instance of SiteConfiguration +# + +require 'pathname' + +class SiteConfiguration + + attr_accessor :title + attr_accessor :pagination_size + attr_accessor :mount_points + attr_reader :file_path + + ## + ## CLASS METHODS + ## + + def self.load(config_file) + SiteConfiguration.new(config_file) + end + + ## + ## INSTANCE METHODS + ## + + # + # accepts a file_path to a configuration file. + # + def initialize(file_path) + @file_path = file_path + @site_title = "untitled" + @pagination_size = 20 + @mount_points = [] + self.eval + end + + def pages(directory_source, options={}) + @mount_points << SiteMountPoint.new(self, directory_source, options) + end + + def pages_changed? + @mount_points.detect {|mp| mp.changed?} + end + + def eval + self.instance_eval(File.read(@file_path), @file_path) + end + +end |