Class: Inventory
- Inherits:
-
Object
- Object
- Inventory
- Defined in:
- lib/inventory-1.0.rb,
lib/inventory/version.rb,
lib/inventory/rake/tasks-1.0.rb
Defined Under Namespace
Modules: Dependency, Rake Classes: Dependencies
Constant Summary collapse
- Version =
Inventory.new(1, 1, 0){ def dependencies Dependencies.new{ development 'lookout', 3, 0, 0 development 'yard', 0, 7, 0 } end def libs %w' inventory/dependency.rb inventory/dependencies.rb inventory/dependencies/development.rb inventory/dependencies/optional.rb inventory/dependencies/runtime.rb ' end def additional_libs super + %w' inventory/rake/tasks-1.0.rb inventory/rake/tasks/check.rb inventory/rake/tasks/clean.rb inventory/rake/tasks/gem.rb inventory/rake/tasks/inventory.rb ' end }
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#package_path ⇒ Object
readonly
Returns the value of attribute package_path.
-
#package_require ⇒ Object
readonly
Returns the value of attribute package_require.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#srcdir ⇒ Object
readonly
Returns the value of attribute srcdir.
Instance Method Summary collapse
- #additional_files ⇒ Object
- #additional_libs ⇒ Object
- #additional_unit_tests ⇒ Object
- #all_libs ⇒ Object
- #all_unit_tests ⇒ Object
- #dependencies ⇒ Object
- #files ⇒ Object
-
#initialize(major, minor, patch, path = (m = /\A(.*):\d+(?::in .*)?\z/.match(caller.first) and m[1]), &block) ⇒ Inventory
constructor
A new instance of Inventory.
- #inspect ⇒ Object
- #lib_directories ⇒ Object
- #lib_files ⇒ Object
- #libs ⇒ Object
- #load ⇒ Object
- #loads ⇒ Object
- #package ⇒ Object
- #requires ⇒ Object
- #test_files ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
- #unit_test_files ⇒ Object
- #unit_tests ⇒ Object
- #version_require ⇒ Object
Constructor Details
#initialize(major, minor, patch, path = (m = /\A(.*):\d+(?::in .*)?\z/.match(caller.first) and m[1]), &block) ⇒ Inventory
Returns a new instance of Inventory.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/inventory-1.0.rb', line 4 def initialize(major, minor, patch, path = (m = /\A(.*):\d+(?::in .*)?\z/.match(caller.first) and m[1]), &block) @major, @minor, @patch = major, minor, patch raise ArgumentError, 'default value of path argument could not be calculated' unless path @path = path @srcdir, _, @package_path = File.dirname(File.(path)).rpartition('/lib/') @package_require = '%s-%d.0' % [package, major] raise ArgumentError, 'path is not of the form PATH/lib/PACKAGE/version.rb: %s' % path if @srcdir.empty? instance_exec(&Proc.new) if block_given? end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
114 115 116 |
# File 'lib/inventory-1.0.rb', line 114 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
114 115 116 |
# File 'lib/inventory-1.0.rb', line 114 def minor @minor end |
#package_path ⇒ Object (readonly)
Returns the value of attribute package_path.
114 115 116 |
# File 'lib/inventory-1.0.rb', line 114 def package_path @package_path end |
#package_require ⇒ Object (readonly)
Returns the value of attribute package_require.
114 115 116 |
# File 'lib/inventory-1.0.rb', line 114 def package_require @package_require end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
114 115 116 |
# File 'lib/inventory-1.0.rb', line 114 def patch @patch end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
114 115 116 |
# File 'lib/inventory-1.0.rb', line 114 def path @path end |
#srcdir ⇒ Object (readonly)
Returns the value of attribute srcdir.
114 115 116 |
# File 'lib/inventory-1.0.rb', line 114 def srcdir @srcdir end |
Instance Method Details
#additional_files ⇒ Object
91 92 93 94 95 96 |
# File 'lib/inventory-1.0.rb', line 91 def additional_files %w' README Rakefile ' end |
#additional_libs ⇒ Object
59 60 61 |
# File 'lib/inventory-1.0.rb', line 59 def additional_libs [package_require, version_require].map{ |e| '%s.rb' % e } end |
#additional_unit_tests ⇒ Object
75 76 77 |
# File 'lib/inventory-1.0.rb', line 75 def additional_unit_tests [] end |
#all_libs ⇒ Object
63 64 65 |
# File 'lib/inventory-1.0.rb', line 63 def all_libs libs + additional_libs end |
#all_unit_tests ⇒ Object
79 80 81 |
# File 'lib/inventory-1.0.rb', line 79 def all_unit_tests unit_tests + additional_unit_tests end |
#dependencies ⇒ Object
41 42 43 44 45 |
# File 'lib/inventory-1.0.rb', line 41 def dependencies Dependencies.new{ development 'inventory', Version.major, Version.minor, Version.patch } end |
#files ⇒ Object
98 99 100 |
# File 'lib/inventory-1.0.rb', line 98 def files lib_files + test_files + additional_files end |
#inspect ⇒ Object
110 111 112 |
# File 'lib/inventory-1.0.rb', line 110 def inspect '#<%s: %s %s>' % [self.class, package, self] end |
#lib_directories ⇒ Object
26 27 28 |
# File 'lib/inventory-1.0.rb', line 26 def lib_directories %w'lib' end |
#lib_files ⇒ Object
67 68 69 |
# File 'lib/inventory-1.0.rb', line 67 def lib_files all_libs.map{ |e| 'lib/%s' % e } end |
#libs ⇒ Object
55 56 57 |
# File 'lib/inventory-1.0.rb', line 55 def libs [] end |
#load ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/inventory-1.0.rb', line 30 def load requires.each do |requirement| require requirement end dependencies.require loads.each do |load| Kernel.load File.('lib/%s' % load, srcdir) end self end |
#loads ⇒ Object
51 52 53 |
# File 'lib/inventory-1.0.rb', line 51 def loads libs end |
#package ⇒ Object
18 19 20 |
# File 'lib/inventory-1.0.rb', line 18 def package package_path.gsub('/', '-') end |
#requires ⇒ Object
47 48 49 |
# File 'lib/inventory-1.0.rb', line 47 def requires [] end |
#test_files ⇒ Object
87 88 89 |
# File 'lib/inventory-1.0.rb', line 87 def test_files unit_test_files end |
#to_a ⇒ Object
102 103 104 |
# File 'lib/inventory-1.0.rb', line 102 def to_a files end |
#to_s ⇒ Object
106 107 108 |
# File 'lib/inventory-1.0.rb', line 106 def to_s '%d.%d.%d' % [major, minor, patch] end |
#unit_test_files ⇒ Object
83 84 85 |
# File 'lib/inventory-1.0.rb', line 83 def unit_test_files all_unit_tests.map{ |e| 'test/unit/%s' % e } end |
#unit_tests ⇒ Object
71 72 73 |
# File 'lib/inventory-1.0.rb', line 71 def unit_tests all_libs end |
#version_require ⇒ Object
22 23 24 |
# File 'lib/inventory-1.0.rb', line 22 def version_require File.join(package_path, 'version') end |