From 71ec0edea3f87fb69222dbb6fe025c2211402ca2 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 12 Feb 2013 21:33:39 -0800 Subject: added capacity for pulling static pages from multiple directory source trees. --- lib/site_configuration.rb | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 lib/site_configuration.rb (limited to 'lib/site_configuration.rb') 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 -- cgit v1.2.3