Class: Shipyard::Manifest
- Inherits:
-
Object
- Object
- Shipyard::Manifest
- Defined in:
- lib/shipyard/manifest.rb
Instance Attribute Summary collapse
-
#maps ⇒ Object
readonly
Returns the value of attribute maps.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #database(sequel = nil) ⇒ Object
- #destination_for(filename) ⇒ Object
-
#initialize(filename, table) ⇒ Manifest
constructor
A new instance of Manifest.
- #map(template, dst) ⇒ Object
- #output_dir(dir = nil) ⇒ Object
Constructor Details
#initialize(filename, table) ⇒ Manifest
Returns a new instance of Manifest.
5 6 7 8 9 10 |
# File 'lib/shipyard/manifest.rb', line 5 def initialize(filename, table) @table = table @row = ActiveSupport::Inflector.singularize(table) @maps = {} open(filename) { |file| instance_eval(file.read) } end |
Instance Attribute Details
#maps ⇒ Object (readonly)
Returns the value of attribute maps.
3 4 5 |
# File 'lib/shipyard/manifest.rb', line 3 def maps @maps end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
3 4 5 |
# File 'lib/shipyard/manifest.rb', line 3 def row @row end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
3 4 5 |
# File 'lib/shipyard/manifest.rb', line 3 def table @table end |
Instance Method Details
#database(sequel = nil) ⇒ Object
12 13 14 15 |
# File 'lib/shipyard/manifest.rb', line 12 def database(sequel = nil) @database = sequel if !!sequel @database end |
#destination_for(filename) ⇒ Object
26 27 28 |
# File 'lib/shipyard/manifest.rb', line 26 def destination_for(filename) @maps[filename.gsub(/\.erb/, '').to_sym] end |
#map(template, dst) ⇒ Object
22 23 24 |
# File 'lib/shipyard/manifest.rb', line 22 def map(template, dst) @maps[template.to_sym] = dst end |
#output_dir(dir = nil) ⇒ Object
17 18 19 20 |
# File 'lib/shipyard/manifest.rb', line 17 def output_dir(dir = nil) @output_dir = dir if !!dir @output_dir end |