Class: Locomotive::Mounter::Reader::Runner
- Inherits:
-
Object
- Object
- Locomotive::Mounter::Reader::Runner
- Defined in:
- lib/locomotive/mounter/reader/runner.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#mounting_point ⇒ Object
Returns the value of attribute mounting_point.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
Instance Method Summary collapse
-
#initialize(kind) ⇒ Runner
constructor
A new instance of Runner.
-
#prepare ⇒ Object
Before building the mounting point.
-
#readers ⇒ Array
Ordered list of atomic readers.
-
#reload(*list) ⇒ Object
Reload with the same origin parameters a part of a site from a list of resources each described by a simple name (site, pages, …etc) taken from the corresponding reader class name.
-
#run!(parameters = {}) ⇒ Object
Read the content of a site (pages, snippets, …etc) and create the corresponding mounting point.
Constructor Details
#initialize(kind) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 14 15 16 |
# File 'lib/locomotive/mounter/reader/runner.rb', line 9 def initialize(kind) self.kind = kind # avoid to load all the ruby files at the startup, only when we need it base_dir = File.join(File.dirname(__FILE__), kind.to_s) require File.join(base_dir, 'base.rb') Dir[File.join(base_dir, '*.rb')].each { |lib| require lib } end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
7 8 9 |
# File 'lib/locomotive/mounter/reader/runner.rb', line 7 def kind @kind end |
#mounting_point ⇒ Object
Returns the value of attribute mounting_point.
7 8 9 |
# File 'lib/locomotive/mounter/reader/runner.rb', line 7 def mounting_point @mounting_point end |
#parameters ⇒ Object
Returns the value of attribute parameters.
7 8 9 |
# File 'lib/locomotive/mounter/reader/runner.rb', line 7 def parameters @parameters end |
Instance Method Details
#prepare ⇒ Object
Before building the mounting point. Can be defined by reader runners
56 57 |
# File 'lib/locomotive/mounter/reader/runner.rb', line 56 def prepare end |
#readers ⇒ Array
Ordered list of atomic readers
63 64 65 |
# File 'lib/locomotive/mounter/reader/runner.rb', line 63 def readers raise Locomotive::Mounter::ImplementationIsMissingException.new('readers are missing') end |
#reload(*list) ⇒ Object
Reload with the same origin parameters a part of a site from a list of resources each described by a simple name (site, pages, …etc) taken from the corresponding reader class name.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/locomotive/mounter/reader/runner.rb', line 38 def reload(*list) Locomotive::Mounter.with_locale(self.mounting_point.default_locale) do [*list].flatten.each do |name| reader_name = "#{name.to_s.camelize}Reader" reader = self.readers.detect do |_reader| _reader.name.demodulize == reader_name end if reader self.mounting_point.register_resource(name, reader.new(self).read) end end end end |
#run!(parameters = {}) ⇒ Object
Read the content of a site (pages, snippets, …etc) and create the corresponding mounting point.
24 25 26 27 28 29 30 |
# File 'lib/locomotive/mounter/reader/runner.rb', line 24 def run!(parameters = {}) self.parameters = parameters.symbolize_keys self.prepare self.build_mounting_point end |