inventory 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -3
- data/lib/inventory-1.0.rb +17 -1
- data/lib/inventory/dependencies.rb +54 -0
- data/lib/inventory/dependencies/development.rb +10 -0
- data/lib/inventory/dependencies/optional.rb +5 -0
- data/lib/inventory/dependencies/runtime.rb +9 -0
- data/lib/inventory/dependency.rb +33 -0
- data/lib/inventory/rake/tasks/gem.rb +48 -11
- data/lib/inventory/version.rb +18 -1
- data/test/unit/inventory/dependencies.rb +9 -0
- data/test/unit/inventory/dependencies/development.rb +4 -0
- data/test/unit/inventory/dependencies/optional.rb +4 -0
- data/test/unit/inventory/dependencies/runtime.rb +4 -0
- data/test/unit/inventory/dependency.rb +4 -0
- metadata +15 -5
data/Rakefile
CHANGED
@@ -10,8 +10,5 @@ Inventory::Rake::Tasks.define Inventory::Version, :gem => proc{ |_, s|
|
|
10
10
|
s.author = 'Nikolai Weibull'
|
11
11
|
s.email = 'now@bitwi.se'
|
12
12
|
s.homepage = 'https://github.com/now/inventory'
|
13
|
-
|
14
|
-
s.add_development_dependency 'lookout', '~> 3.0'
|
15
|
-
s.add_development_dependency 'yard', '~> 0.7.0'
|
16
13
|
}
|
17
14
|
Lookout::Rake::Tasks::Test.new
|
data/lib/inventory-1.0.rb
CHANGED
@@ -12,7 +12,7 @@ class Inventory
|
|
12
12
|
raise ArgumentError,
|
13
13
|
'path is not of the form PATH/lib/PACKAGE/version.rb: %s' % path if
|
14
14
|
@srcdir.empty?
|
15
|
-
instance_exec(&
|
15
|
+
instance_exec(&Proc.new) if block_given?
|
16
16
|
end
|
17
17
|
|
18
18
|
def package
|
@@ -31,12 +31,19 @@ class Inventory
|
|
31
31
|
requires.each do |requirement|
|
32
32
|
require requirement
|
33
33
|
end
|
34
|
+
dependencies.require
|
34
35
|
loads.each do |load|
|
35
36
|
Kernel.load File.expand_path('lib/%s' % load, srcdir)
|
36
37
|
end
|
37
38
|
self
|
38
39
|
end
|
39
40
|
|
41
|
+
def dependencies
|
42
|
+
Dependencies.new{
|
43
|
+
development 'inventory', Version.major, Version.minor, Version.patch
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
40
47
|
def requires
|
41
48
|
[]
|
42
49
|
end
|
@@ -106,6 +113,15 @@ class Inventory
|
|
106
113
|
|
107
114
|
attr_reader :major, :minor, :patch, :path, :srcdir, :package_path, :package_require
|
108
115
|
|
116
|
+
# %w'
|
117
|
+
# inventory/dependencies.rb
|
118
|
+
# inventory/dependency.rb
|
119
|
+
# '.each do |load|
|
120
|
+
## Kernel.load File.expand_path('../%s' % load, __FILE__)
|
121
|
+
# end
|
109
122
|
load File.expand_path('../inventory/version.rb', __FILE__)
|
123
|
+
Version.loads.each do |load|
|
124
|
+
Kernel.load File.expand_path('../%s' % load, __FILE__)
|
125
|
+
end
|
110
126
|
end
|
111
127
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
class Inventory::Dependencies
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def initialize(*dependencies)
|
7
|
+
@dependencies = dependencies
|
8
|
+
instance_exec(&Proc.new) if block_given?
|
9
|
+
end
|
10
|
+
|
11
|
+
def +(other)
|
12
|
+
self.class.new(*(dependencies + other.dependencies))
|
13
|
+
end
|
14
|
+
|
15
|
+
def each
|
16
|
+
return enum_for(__method__) unless block_given?
|
17
|
+
dependencies.each do |dependency|
|
18
|
+
yield dependency
|
19
|
+
end
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def require
|
24
|
+
map{ |dependency| dependency.require }
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_to_gem_specification(specification)
|
28
|
+
each do |dependency|
|
29
|
+
dependency.add_to_gem_specification specification
|
30
|
+
end
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
attr_reader :dependencies
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def development(name, major, minor, patch)
|
41
|
+
dependencies << Development.new(name, major, minor, patch)
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def runtime(name, major, minor, patch)
|
46
|
+
dependencies << Runtime.new(name, major, minor, patch)
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
def optional(name, major, minor, patch)
|
51
|
+
dependencies << Optional.new(name, major, minor, patch)
|
52
|
+
self
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Inventory::Dependency
|
4
|
+
def initialize(name, major, minor, patch, options = {})
|
5
|
+
@name, @major, @minor, @patch = name, major, minor, patch
|
6
|
+
instance_exec(&Proc.new) if block_given?
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
'%d.%d.%d' % [major, minor, patch]
|
11
|
+
end
|
12
|
+
|
13
|
+
def feature
|
14
|
+
'%s-%d.0' % [name, major]
|
15
|
+
end
|
16
|
+
|
17
|
+
def require
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_to_gem_specification(specification)
|
22
|
+
specification.add_runtime_dependency name, gem_requirement
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :name, :major, :minor, :patch
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def gem_requirement
|
31
|
+
'~> %s' % (major > 0 ? '%d.%d' % [major, minor] : to_s)
|
32
|
+
end
|
33
|
+
end
|
@@ -18,6 +18,8 @@ class Inventory::Rake::Tasks::Gem
|
|
18
18
|
s.files = @inventory.files # TODO: We can skip #files and rely on #to_a
|
19
19
|
|
20
20
|
s.require_paths = @inventory.lib_directories
|
21
|
+
|
22
|
+
@inventory.dependencies.add_to_gem_specification s
|
21
23
|
})
|
22
24
|
yield self, @specification if block_given?
|
23
25
|
define
|
@@ -36,7 +38,7 @@ class Inventory::Rake::Tasks::Gem
|
|
36
38
|
file gemspec => %w'Rakefile README' + [@inventory.path] do |t|
|
37
39
|
tmp = '%s.tmp' % t.name
|
38
40
|
rm([t.name, tmp], :force => true)
|
39
|
-
|
41
|
+
rake_output_message 'gem specification --ruby %s > %s' %
|
40
42
|
[@specification.name, tmp] if verbose
|
41
43
|
File.open(tmp, 'wb') do |f|
|
42
44
|
f.write @specification.to_ruby
|
@@ -52,7 +54,7 @@ class Inventory::Rake::Tasks::Gem
|
|
52
54
|
task :'gem:dist' => [:'inventory:check', @specification.file_name]
|
53
55
|
file @specification.file_name => @specification.files do
|
54
56
|
require 'rubygems' unless defined? Gem
|
55
|
-
|
57
|
+
rake_output_message 'gem build %s' % gemspec if verbose
|
56
58
|
Gem::Builder.new(@specification).build
|
57
59
|
end
|
58
60
|
|
@@ -65,7 +67,7 @@ class Inventory::Rake::Tasks::Gem
|
|
65
67
|
require 'rubygems' unless defined? Gem
|
66
68
|
require 'rubygems/installer' unless defined? Gem::Installer
|
67
69
|
checkdir = @specification.full_name
|
68
|
-
|
70
|
+
rake_output_message 'gem unpack %s --target %s' %
|
69
71
|
[@specification.file_name, checkdir] if verbose
|
70
72
|
Gem::Installer.new(@specification.file_name, :unpack => true).
|
71
73
|
unpack File.expand_path(checkdir)
|
@@ -76,32 +78,67 @@ class Inventory::Rake::Tasks::Gem
|
|
76
78
|
rm_r checkdir
|
77
79
|
end
|
78
80
|
|
81
|
+
desc 'Install dependencies on the local system' unless
|
82
|
+
Rake::Task.task_defined? :'deps:install'
|
83
|
+
task :'deps:install' => :':gem:deps:install'
|
84
|
+
|
85
|
+
desc 'Install dependencies in ruby gem directory'
|
86
|
+
task :'gem:deps:install' do
|
87
|
+
require 'rubygems' unless defined? Gem
|
88
|
+
require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
|
89
|
+
@specification.dependencies.each do |dependency|
|
90
|
+
rake_output_message "gem install %s -v '%s'" % [dependency.name, dependency.requirement] if verbose
|
91
|
+
Gem::DependencyInstaller.new.install dependency.name, dependency.requirement
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
desc 'Install dependencies for the current user' unless
|
96
|
+
Rake::Task.task_defined? :'deps:install:user'
|
97
|
+
task :'deps:install:user' => :':gem:deps:install:user'
|
98
|
+
|
99
|
+
desc 'Install dependencies for the current user'
|
100
|
+
task :'gem:deps:install:user' do
|
101
|
+
require 'rubygems' unless defined? Gem
|
102
|
+
require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
|
103
|
+
@specification.dependencies.each do |dependency|
|
104
|
+
rake_output_message "gem install --user-install --bindir %s %s -v '%s'" %
|
105
|
+
[Gem.bindir(Gem.user_dir), dependency.name, dependency.requirement] if verbose
|
106
|
+
Gem::DependencyInstaller.
|
107
|
+
new(:user_install => true,
|
108
|
+
:bindir => Gem.bindir(Gem.user_dir)).
|
109
|
+
install dependency.name, dependency.requirement
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
79
113
|
desc 'Install distribution files on the local system' unless
|
80
114
|
Rake::Task.task_defined? :install
|
81
115
|
task :install => :'gem:install'
|
82
116
|
|
83
|
-
desc 'Install %s
|
117
|
+
desc 'Install %s in ruby gem directory' %
|
84
118
|
@specification.file_name
|
85
119
|
task :'gem:install' => :'gem:dist' do |t|
|
86
120
|
require 'rubygems' unless defined? Gem
|
87
121
|
require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
|
88
|
-
|
89
|
-
Gem::DependencyInstaller.
|
122
|
+
rake_output_message 'gem install %s' % @specification.file_name if verbose
|
123
|
+
Gem::DependencyInstaller.
|
124
|
+
new(:ignore_dependencies => true).
|
125
|
+
install @specification.file_name
|
90
126
|
end
|
91
127
|
|
92
128
|
desc 'Install distribution files for the current user' unless
|
93
129
|
Rake::Task.task_defined? :'install:user'
|
94
130
|
task :'install:user' => :'gem:install:user'
|
95
131
|
|
96
|
-
desc 'Install %s
|
132
|
+
desc 'Install %s in user gem directory' %
|
97
133
|
@specification.file_name
|
98
134
|
task :'gem:install:user' => :'gem:dist' do
|
99
135
|
require 'rubygems' unless defined? Gem
|
100
136
|
require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
|
101
|
-
|
137
|
+
rake_output_message 'gem install --user-install --bindir %s %s' %
|
102
138
|
[Gem.bindir(Gem.user_dir), @specification.file_name] if verbose
|
103
139
|
Gem::DependencyInstaller.
|
104
|
-
new(:
|
140
|
+
new(:ignore_dependencies => true,
|
141
|
+
:user_install => true,
|
105
142
|
:bindir => Gem.bindir(Gem.user_dir)).
|
106
143
|
install @specification.file_name
|
107
144
|
end
|
@@ -116,7 +153,7 @@ class Inventory::Rake::Tasks::Gem
|
|
116
153
|
# TODO: I have absolutely no idea why this is needed, but it is.
|
117
154
|
require 'rubygems/user_interaction' unless defined? Gem::UserInteraction
|
118
155
|
require 'rubygems/uninstaller' unless defined? Gem::Uninstaller
|
119
|
-
|
156
|
+
rake_output_message 'gem uninstall --executables %s' % @specification.name if verbose
|
120
157
|
Gem::Uninstaller.new(@specification.name,
|
121
158
|
:executables => true,
|
122
159
|
:version => @specification.version).uninstall
|
@@ -132,7 +169,7 @@ class Inventory::Rake::Tasks::Gem
|
|
132
169
|
# TODO: I have absolutely no idea why this is needed, but it is.
|
133
170
|
require 'rubygems/user_interaction' unless defined? Gem::UserInteraction
|
134
171
|
require 'rubygems/uninstaller' unless defined? Gem::Uninstaller
|
135
|
-
|
172
|
+
rake_output_message 'gem uninstall --executables --install-dir %s %s' %
|
136
173
|
[Gem.user_dir, @specification.name] if verbose
|
137
174
|
Gem::Uninstaller.new(@specification.name,
|
138
175
|
:executables => true,
|
data/lib/inventory/version.rb
CHANGED
@@ -1,7 +1,24 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
class Inventory
|
4
|
-
Version = Inventory.new(1,
|
4
|
+
Version = Inventory.new(1, 1, 0){
|
5
|
+
def dependencies
|
6
|
+
Dependencies.new{
|
7
|
+
development 'lookout', 3, 0, 0
|
8
|
+
development 'yard', 0, 7, 0
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def libs
|
13
|
+
%w'
|
14
|
+
inventory/dependency.rb
|
15
|
+
inventory/dependencies.rb
|
16
|
+
inventory/dependencies/development.rb
|
17
|
+
inventory/dependencies/optional.rb
|
18
|
+
inventory/dependencies/runtime.rb
|
19
|
+
'
|
20
|
+
end
|
21
|
+
|
5
22
|
def additional_libs
|
6
23
|
super + %w'
|
7
24
|
inventory/rake/tasks-1.0.rb
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inventory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: lookout
|
16
|
-
requirement: &
|
16
|
+
requirement: &3940080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *3940080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yard
|
27
|
-
requirement: &
|
27
|
+
requirement: &3938508 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.7.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *3938508
|
36
36
|
description: ! " Inventory\n\n Inventory allows
|
37
37
|
you to create inventories of your Ruby projects. These\n inventories can then
|
38
38
|
be used to load the project, create gem specifications\n and gems, run unit tests,
|
@@ -42,6 +42,11 @@ executables: []
|
|
42
42
|
extensions: []
|
43
43
|
extra_rdoc_files: []
|
44
44
|
files:
|
45
|
+
- lib/inventory/dependency.rb
|
46
|
+
- lib/inventory/dependencies.rb
|
47
|
+
- lib/inventory/dependencies/development.rb
|
48
|
+
- lib/inventory/dependencies/optional.rb
|
49
|
+
- lib/inventory/dependencies/runtime.rb
|
45
50
|
- lib/inventory-1.0.rb
|
46
51
|
- lib/inventory/version.rb
|
47
52
|
- lib/inventory/rake/tasks-1.0.rb
|
@@ -49,6 +54,11 @@ files:
|
|
49
54
|
- lib/inventory/rake/tasks/clean.rb
|
50
55
|
- lib/inventory/rake/tasks/gem.rb
|
51
56
|
- lib/inventory/rake/tasks/inventory.rb
|
57
|
+
- test/unit/inventory/dependency.rb
|
58
|
+
- test/unit/inventory/dependencies.rb
|
59
|
+
- test/unit/inventory/dependencies/development.rb
|
60
|
+
- test/unit/inventory/dependencies/optional.rb
|
61
|
+
- test/unit/inventory/dependencies/runtime.rb
|
52
62
|
- test/unit/inventory-1.0.rb
|
53
63
|
- test/unit/inventory/version.rb
|
54
64
|
- test/unit/inventory/rake/tasks-1.0.rb
|