Class: Laze::Secretary
- Inherits:
-
Object
- Object
- Laze::Secretary
- Defined in:
- lib/laze/secretary.rb
Overview
The Secretary combines all other classes to a working application and serves as a central point of information for other classes that need to know stuff that are none of their primary concern.
The secretary keeps track of the build options and the storage and target engines that are currently used.
Class Attribute Summary collapse
-
.current ⇒ Object
Since there should only be a singe secretary object, we let the singleton class keep track of the current instance.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Options that tell Laze what to do and how to do it.
Class Method Summary collapse
-
.site_config ⇒ Object
Read configuration from the laze.yml file in the current directory.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Secretary
constructor
:nodoc:.
-
#run ⇒ Object
Run laze to build the output website.
-
#store ⇒ Object
The current storage engine.
-
#target ⇒ Object
The current target deployment engine.
Constructor Details
#initialize(options = {}) ⇒ Secretary
:nodoc:
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/laze/secretary.rb', line 30 def initialize( = {}) #:nodoc: = { :store => :filesystem, :target => :filesystem, :source => '.', :directory => 'output', :minify_js => false, :minify_css => false, :loglevel => :warn, :logfile => 'stderr' } @options = .merge(self.class.site_config).merge() # Set the logger options logger = Logger.new((@options[:logfile] == 'stderr' ? STDERR : @options[:logfile])) logger.level = Logger.const_get(@options[:loglevel].to_s.upcase) logger.datetime_format = "%H:%M:%S" Laze.const_set('LOGGER', logger) unless Laze.const_defined?('LOGGER') Secretary.current = self end |
Class Attribute Details
.current ⇒ Object
Since there should only be a singe secretary object, we let the singleton class keep track of the current instance.
16 17 18 |
# File 'lib/laze/secretary.rb', line 16 def current @current end |
Instance Attribute Details
#options ⇒ Object (readonly)
Options that tell Laze what to do and how to do it.
11 12 13 |
# File 'lib/laze/secretary.rb', line 11 def @options end |
Class Method Details
.site_config ⇒ Object
Read configuration from the laze.yml file in the current directory. – TODO: make sure this reads from the source directory, not the current.
21 22 23 24 25 26 27 |
# File 'lib/laze/secretary.rb', line 21 def site_config if File.exists?('laze.yml') YAML.load_file('laze.yml').symbolize_keys else {} end end |
Instance Method Details
#run ⇒ Object
Run laze to build the output website.
63 64 65 66 67 68 69 70 71 |
# File 'lib/laze/secretary.rb', line 63 def run Laze.debug 'Starting source processing' target.reset store.each do |item| target.create item end target.save Laze.debug 'Source processing ready' end |