Class: Locomotive::Mounter::Writer::Runner
- Inherits:
-
Object
- Object
- Locomotive::Mounter::Writer::Runner
- Defined in:
- lib/locomotive/mounter/writer/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
-
#force? ⇒ Boolean
By setting the force option to true, some resources (site, content assets, …etc) may overide the content of the remote engine during the push operation.
-
#initialize(kind) ⇒ Runner
constructor
A new instance of Runner.
-
#prepare ⇒ Object
Before starting to write anything Can be defined by writer runners.
-
#run!(parameters = {}) ⇒ Object
Write the data of a mounting point instance to a target folder.
-
#write_all ⇒ Object
Execute all the writers.
-
#writers ⇒ Array
List of all the writers.
Constructor Details
#initialize(kind) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 14 15 16 |
# File 'lib/locomotive/mounter/writer/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/writer/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/writer/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/writer/runner.rb', line 7 def parameters @parameters end |
Instance Method Details
#force? ⇒ Boolean
By setting the force option to true, some resources (site, content assets, …etc) may overide the content of the remote engine during the push operation. By default, its value is false.
65 66 67 |
# File 'lib/locomotive/mounter/writer/runner.rb', line 65 def force? self.parameters[:force] || false end |
#prepare ⇒ Object
Before starting to write anything Can be defined by writer runners
34 35 |
# File 'lib/locomotive/mounter/writer/runner.rb', line 34 def prepare end |
#run!(parameters = {}) ⇒ Object
Write the data of a mounting point instance to a target folder
22 23 24 25 26 27 28 29 30 |
# File 'lib/locomotive/mounter/writer/runner.rb', line 22 def run!(parameters = {}) self.parameters = parameters.symbolize_keys self.mounting_point = self.parameters.delete(:mounting_point) self.prepare self.write_all end |
#write_all ⇒ Object
Execute all the writers
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/locomotive/mounter/writer/runner.rb', line 46 def write_all only = parameters[:only].try(:map) do |name| "#{name}_writer".camelize end.try(:insert, 0, 'SiteWriter') self.writers.each do |klass| next if only && !only.include?(klass.name.demodulize) writer = klass.new(self.mounting_point, self) writer.prepare writer.write end end |
#writers ⇒ Array
List of all the writers
41 42 43 |
# File 'lib/locomotive/mounter/writer/runner.rb', line 41 def writers raise Locomotive::Mounter::ImplementationIsMissingException.new("[#{self.kind}] Writers are missing") end |