Class: Inventory::Rake::Tasks::Inventory
- Inherits:
-
Object
- Object
- Inventory::Rake::Tasks::Inventory
- Includes:
- Rake::DSL
- Defined in:
- lib/inventory-rake-1.0/tasks/inventory.rb
Overview
Tasks related to the inventory.
Instance Attribute Summary collapse
-
#inventory ⇒ Inventory
writeonly
The inventory to use: VALUE.
-
#pattern ⇒ String
writeonly
The pattern to use: VALUE.
Instance Method Summary collapse
-
#define ⇒ Object
Defines the following task:.
-
#initialize(options = {}) {|?| ... } ⇒ Inventory
constructor
Sets up tasks based on INVENTORY, optionally yields the task object for further customization, then #defines the tasks.
Constructor Details
#initialize(options = {}) {|?| ... } ⇒ Inventory
Sets up tasks based on INVENTORY, optionally yields the task object for further customization, then #defines the tasks.
18 19 20 21 22 23 |
# File 'lib/inventory-rake-1.0/tasks/inventory.rb', line 18 def initialize( = {}) self.inventory = .fetch(:inventory, Inventory::Rake::Tasks.inventory) self.pattern = .fetch(:pattern, '{ext/**/*.{[ch],rb},{lib,test}/**/*.rb}') yield self if block_given? define end |
Instance Attribute Details
#inventory=(value) ⇒ Inventory (writeonly)
Returns The inventory to use: VALUE.
45 46 47 |
# File 'lib/inventory-rake-1.0/tasks/inventory.rb', line 45 def inventory=(value) @inventory = value end |
#pattern=(value) ⇒ String (writeonly)
Returns The pattern to use: VALUE.
49 50 51 |
# File 'lib/inventory-rake-1.0/tasks/inventory.rb', line 49 def pattern=(value) @pattern = value end |
Instance Method Details
#define ⇒ Object
Defines the following task:
<dl>
<dt>inventory:check</dt>
<dd>Check that the inventory is correct by looking for files not listed
in the inventory that match the pattern and for files listed in the
inventory that don’t exist; depends on distclean.</dd>
</dl>
33 34 35 36 37 38 39 40 41 |
# File 'lib/inventory-rake-1.0/tasks/inventory.rb', line 33 def define desc 'Check that the inventory is correct' task :'inventory:check' => :distclean do diff = ((Dir[@pattern] - @inventory.files).map{ |e| '%s: file not listed in inventory' % e } + @inventory.files.reject{ |e| File.exist? e }.map{ |e| '%s: file listed in inventory does not exist' % e }) fail diff.join("\n") unless diff.empty? # TODO: puts 'inventory checks out' if verbose end end |