Class: Magneto::Application
- Inherits:
-
Object
- Object
- Magneto::Application
- Defined in:
- lib/magneto/application.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/magneto/application.rb', line 7 def initialize super @options = {} @config_path = 'config.yaml' @config = { :source_path => '.', :output_path => 'output', :hidden_files => false, :remove_obsolete => false, :auto_regeneration => false } @filters = {} @site = nil end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/magneto/application.rb', line 5 def config @config end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
5 6 7 |
# File 'lib/magneto/application.rb', line 5 def filters @filters end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
5 6 7 |
# File 'lib/magneto/application.rb', line 5 def site @site end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/magneto/application.rb', line 22 def run load_configuration @config.deep_merge! @options [:source_path, :output_path].each do |path| @config[path] = File.(@config[path]) @config[path].freeze end load_plugins find_filters @site = Site.new(@config, @filters) if @config[:auto_regeneration] puts 'Automatic regeneration enabled.' require 'directory_watcher' dw = DirectoryWatcher.new(@config[:source_path]) dw.glob = [@config[:hidden_files] ? 'items/**/{.[^.],}*' : 'items/**/*', 'templates/*.*', 'script.rb'] dw.interval = 1 dw.add_observer { |*args| @site.generate } dw.start gets dw.stop else @site.generate end exit end |