Class: Shipyard::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/shipyard/manifest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#mapsObject (readonly)

Returns the value of attribute maps.



3
4
5
# File 'lib/shipyard/manifest.rb', line 3

def maps
  @maps
end

#rowObject (readonly)

Returns the value of attribute row.



3
4
5
# File 'lib/shipyard/manifest.rb', line 3

def row
  @row
end

#tableObject (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