Class: Bow::Inventory
- Inherits:
-
Object
- Object
- Bow::Inventory
- Defined in:
- lib/bow/inventory.rb
Constant Summary collapse
- DEFAULT_RAKEFILES =
[ 'Rakefile', 'rakefile', 'Rakefile.rb', 'rakefile.rb' ].freeze
- DEFAULT_TARGETFILES =
[ # 'bow.yaml', # 'bow.rb', 'targets.json' ].freeze
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#rakefile ⇒ Object
readonly
Returns the value of attribute rakefile.
-
#targetfile ⇒ Object
readonly
Returns the value of attribute targetfile.
Instance Method Summary collapse
- #ensure! ⇒ Object
-
#initialize ⇒ Inventory
constructor
A new instance of Inventory.
- #parse ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Inventory
Returns a new instance of Inventory.
22 23 24 25 26 |
# File 'lib/bow/inventory.rb', line 22 def initialize @rakefiles = DEFAULT_RAKEFILES.dup @targetfiles = DEFAULT_TARGETFILES.dup @original_dir = Dir.pwd end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
20 21 22 |
# File 'lib/bow/inventory.rb', line 20 def location @location end |
#rakefile ⇒ Object (readonly)
Returns the value of attribute rakefile.
20 21 22 |
# File 'lib/bow/inventory.rb', line 20 def rakefile @rakefile end |
#targetfile ⇒ Object (readonly)
Returns the value of attribute targetfile.
20 21 22 |
# File 'lib/bow/inventory.rb', line 20 def targetfile @targetfile end |
Instance Method Details
#ensure! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bow/inventory.rb', line 41 def ensure! parse [ ['Rakefile', @rakefile, @rakefiles], ['Target file', @targetfile, @targetfiles] ].each do |name, file, variants| unless file raise "No #{name} found (looking for: #{variants.join(', ')})" end end self end |
#parse ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/bow/inventory.rb', line 28 def parse return if @inventory_loaded rakefile, targetfile, @location = inventory_location @rakefile = File.join(@location, rakefile) if rakefile @targetfile = File.join(@location, targetfile) if targetfile @inventory_loaded = true end |
#valid? ⇒ Boolean
36 37 38 39 |
# File 'lib/bow/inventory.rb', line 36 def valid? parse !!(rakefile && targetfile && location) end |