inventory 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +20 -8
- data/Rakefile +1 -5
- data/lib/inventory-1.0.rb +51 -0
- data/lib/inventory-1.0/author.rb +24 -0
- data/lib/inventory-1.0/authors.rb +61 -0
- data/lib/inventory-1.0/dependencies.rb +4 -1
- data/lib/inventory-1.0/license.rb +29 -0
- data/lib/inventory-1.0/licenses.rb +65 -0
- data/lib/inventory-1.0/version.rb +29 -5
- data/test/unit/inventory-1.0.rb +8 -0
- data/test/unit/inventory-1.0/author.rb +4 -0
- data/test/unit/inventory-1.0/authors.rb +4 -0
- data/test/unit/inventory-1.0/license.rb +4 -0
- data/test/unit/inventory-1.0/licenses.rb +4 -0
- metadata +142 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc965739dc38638b27371f7eb89907051b26a5f
|
4
|
+
data.tar.gz: 67606e0bfa029a0b162b5f99b27a960826e690ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8e3deee905958b3d9ce6ba3d3eaef41e6de87309b05161b90522f935629e89c5fb967d62fe3936b39f85b85e8b89ed986b6f0fe78f535a26b81d14545c0a6a0
|
7
|
+
data.tar.gz: baa8868f061e0b100a4c57d503836326fc24cd7804acff4bbaa76e24e4dfb9d3fb9fa5bde28a22c99e3aa5d61f96a97b06b49a708661a7ebb79631839d6d26ce
|
data/README
CHANGED
@@ -44,6 +44,18 @@
|
|
44
44
|
|
45
45
|
class Foo
|
46
46
|
Version = Foo.new(1, 4, 0){
|
47
|
+
authors{
|
48
|
+
author 'A. U. Thor', 'a.u.thor@example.org'
|
49
|
+
}
|
50
|
+
|
51
|
+
homepage 'http://example.org/'
|
52
|
+
|
53
|
+
licenses{
|
54
|
+
license 'LGPLv3+',
|
55
|
+
'GNU Lesser General Public License, version 3 or later',
|
56
|
+
'http://www.gnu.org/licenses/'
|
57
|
+
}
|
58
|
+
|
47
59
|
def dependencies
|
48
60
|
super + Dependencies.new{
|
49
61
|
development 'baz', 1, 3, 0
|
@@ -69,6 +81,11 @@
|
|
69
81
|
allow the Inventory#to_s method to act as if you’d defined Version as
|
70
82
|
‹'1.4.0'›.
|
71
83
|
|
84
|
+
Next follows information about the authors of the project, the project’s
|
85
|
+
homepage, and the project’s licenses. Each author has a name and an email
|
86
|
+
address. The homepage is simply a string URL. Licenses have an
|
87
|
+
abbreviation, a name, and a URL where the license text can be found.
|
88
|
+
|
72
89
|
We then extend the definition of ‹dependencies› by adding another set of
|
73
90
|
dependencies to ‹super›. ‹Super› includes a dependency on the version of
|
74
91
|
the inventory project that’s being used with this project, so you’ll never
|
@@ -131,11 +148,7 @@
|
|
131
148
|
|
132
149
|
load File.expand_path('../lib/foo-1.0/version.rb', __FILE__)
|
133
150
|
|
134
|
-
Inventory::Rake::Tasks.define Foo::Version
|
135
|
-
s.author = 'Your Name'
|
136
|
-
s.email = 'you@example.com'
|
137
|
-
s.homepage = 'https://example.com/'
|
138
|
-
}
|
151
|
+
Inventory::Rake::Tasks.define Foo::Version
|
139
152
|
|
140
153
|
Inventory::Rake::Tasks.unless_installing_dependencies do
|
141
154
|
require 'lookout-rake-3.0'
|
@@ -143,8 +156,7 @@
|
|
143
156
|
end
|
144
157
|
|
145
158
|
It’s ‹Inventory::Rake::Tasks.define› that does the heavy lifting. It takes
|
146
|
-
our inventory and sets up the tasks mentioned above.
|
147
|
-
additional customization of the gem specification.
|
159
|
+
our inventory and sets up the tasks mentioned above.
|
148
160
|
|
149
161
|
As we want to be able to use our Rakefile to install our dependencies for
|
150
162
|
us, the rest of the Rakefile is inside the conditional
|
@@ -184,7 +196,7 @@
|
|
184
196
|
If the guide above doesn’t provide you with all the answers you seek, you
|
185
197
|
may refer to the API¹ for more answers.
|
186
198
|
|
187
|
-
¹ See http://disu.se/software/inventory/api/
|
199
|
+
¹ See http://disu.se/software/inventory/api/Inventory/
|
188
200
|
|
189
201
|
§ Financing
|
190
202
|
|
data/Rakefile
CHANGED
@@ -5,11 +5,7 @@ require 'inventory-1.0'
|
|
5
5
|
|
6
6
|
require 'inventory-rake-1.0'
|
7
7
|
|
8
|
-
Inventory::Rake::Tasks.define Inventory::Version
|
9
|
-
s.author = 'Nikolai Weibull'
|
10
|
-
s.email = 'now@bitwi.se'
|
11
|
-
s.homepage = 'https://github.com/now/inventory'
|
12
|
-
}
|
8
|
+
Inventory::Rake::Tasks.define Inventory::Version
|
13
9
|
|
14
10
|
Inventory::Rake::Tasks.unless_installing_dependencies do
|
15
11
|
require 'lookout-rake-3.0'
|
data/lib/inventory-1.0.rb
CHANGED
@@ -34,6 +34,18 @@
|
|
34
34
|
#
|
35
35
|
# class Foo
|
36
36
|
# Version = Inventory.new(1, 2, 0){
|
37
|
+
# authors{
|
38
|
+
# author 'A. U. Thor', 'a.u.thor@example.org'
|
39
|
+
# }
|
40
|
+
#
|
41
|
+
# homepage 'http://example.org/'
|
42
|
+
#
|
43
|
+
# licenses{
|
44
|
+
# license 'LGPLv3+',
|
45
|
+
# 'GNU Lesser General Public License, version 3 or later',
|
46
|
+
# 'http://www.gnu.org/licenses/'
|
47
|
+
# }
|
48
|
+
#
|
37
49
|
# def dependencies
|
38
50
|
# super + Dependencies.new{
|
39
51
|
# development 'inventory-rake', 1, 3, 0
|
@@ -100,6 +112,45 @@ class Inventory
|
|
100
112
|
self
|
101
113
|
end
|
102
114
|
|
115
|
+
# Sets, when given a block, the authors of the project, otherwise returns
|
116
|
+
# them. The block will be #instance_exec’d inside a new {Authors} object,
|
117
|
+
# allowing you to {Authors#author add} one or more authors.
|
118
|
+
#
|
119
|
+
# @yield [?]
|
120
|
+
# @return [Authors]
|
121
|
+
# @raise [RuntimeError] If no block has been given and no authors have previously been set
|
122
|
+
def authors
|
123
|
+
@authors = Authors.new(&Proc.new) if block_given?
|
124
|
+
raise 'no authors defined in inventory of %s' % self if not defined? @authors or @authors.count == 0
|
125
|
+
@authors
|
126
|
+
end
|
127
|
+
|
128
|
+
# Sets the project homepage to VALUE, or returns it, if VALUE is nil.
|
129
|
+
#
|
130
|
+
# @param [String] value
|
131
|
+
# @return [String]
|
132
|
+
# @raise [RuntimeError] If VALUE is nil and no homepage has previously been
|
133
|
+
# set
|
134
|
+
def homepage(value = nil)
|
135
|
+
return @homepage = value if value
|
136
|
+
raise 'no homepage set in inventory of %s' % self if not defined? @homepage
|
137
|
+
@homepage
|
138
|
+
end
|
139
|
+
|
140
|
+
# Sets, when given a block, the licenses of the project, otherwise returns
|
141
|
+
# them. The block will be #instance_exec’d inside a new {Licenses} object,
|
142
|
+
# allowing you to {Licenses#license add} one or more licenses.
|
143
|
+
#
|
144
|
+
# @yield [?]
|
145
|
+
# @return [Licenses]
|
146
|
+
# @raise [RuntimeError] If no block has been given and no licenses have
|
147
|
+
# previously been set
|
148
|
+
def licenses
|
149
|
+
@licenses = Licenses.new(&Proc.new) if block_given?
|
150
|
+
raise 'no licenses defined in inventory of %s' % self if not defined? @licenses or @licenses.count == 0
|
151
|
+
@licenses
|
152
|
+
end
|
153
|
+
|
103
154
|
# @return [Dependencies] The dependencies of the package
|
104
155
|
# @note The default list of dependencies is an {Dependencies#optional
|
105
156
|
# optional} dependency on the inventory package itself.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# An author of the project stored in the list of {Authors} in the inventory.
|
4
|
+
class Inventory::Author
|
5
|
+
# Sets up a new author NAME that can be contacted at EMAIL.
|
6
|
+
#
|
7
|
+
# @param [String] name
|
8
|
+
# @param [String] email
|
9
|
+
def initialize(name, email)
|
10
|
+
@name, @email = name, email
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String] The {#name} and {#email} of the author on the “name
|
14
|
+
# <email>” format
|
15
|
+
def to_s
|
16
|
+
'%s <%s>' % [name, email]
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [String] The name of the author
|
20
|
+
attr_reader :name
|
21
|
+
|
22
|
+
# @return [String] The email address of the author
|
23
|
+
attr_reader :email
|
24
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Contains zero or more {Author authors} of the project. Authors can be {#+
|
4
|
+
# added} and {#each enumerated}. Authors are set up by passing a block to
|
5
|
+
# {#initialize} and calling {#author} inside it.
|
6
|
+
#
|
7
|
+
# @example Creating a List of Authors
|
8
|
+
# Authors.new{
|
9
|
+
# author 'A. U. Thor', 'a.u.thor@example.org'
|
10
|
+
# author 'W. R. Ither', 'w.r.ither@example.org'
|
11
|
+
# }
|
12
|
+
class Inventory::Authors
|
13
|
+
include Enumerable
|
14
|
+
|
15
|
+
# Creates a new list of AUTHORS and allows more to be added in the
|
16
|
+
# optionally #instance_exec’d block by calling {#author} inside it.
|
17
|
+
#
|
18
|
+
# @param [Author, …] authors
|
19
|
+
# @yield [?]
|
20
|
+
def initialize(*authors)
|
21
|
+
@authors = authors
|
22
|
+
instance_exec(&Proc.new) if block_given?
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Add an {Author} to the list of authors.
|
28
|
+
#
|
29
|
+
# @param (see Inventory::Author#initialize)
|
30
|
+
# @option (see Inventory::Author#initialize)
|
31
|
+
# @return [self]
|
32
|
+
def author(name, email)
|
33
|
+
authors << Inventory::Author.new(name, email)
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
public
|
38
|
+
|
39
|
+
# @return [Authors] The authors of the receiver and those of OTHER
|
40
|
+
def +(other)
|
41
|
+
self.class.new(*(authors + other.authors))
|
42
|
+
end
|
43
|
+
|
44
|
+
# @overload
|
45
|
+
# Enumerates the authors.
|
46
|
+
#
|
47
|
+
# @yieldparam [Author] author
|
48
|
+
# @overload
|
49
|
+
# @return [Enumerator<Author>] An Enumerator over the authors
|
50
|
+
def each
|
51
|
+
return enum_for(__method__) unless block_given?
|
52
|
+
authors.each do |author|
|
53
|
+
yield author
|
54
|
+
end
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
attr_reader :authors
|
61
|
+
end
|
@@ -18,7 +18,7 @@ class Inventory::Dependencies
|
|
18
18
|
# optionally #instance_exec’d block by calling {#development}, {#runtime},
|
19
19
|
# and {#optional} inside it.
|
20
20
|
#
|
21
|
-
# @param [
|
21
|
+
# @param [Dependency, …] dependencies
|
22
22
|
# @yield [?]
|
23
23
|
def initialize(*dependencies)
|
24
24
|
@dependencies = dependencies
|
@@ -32,6 +32,7 @@ class Inventory::Dependencies
|
|
32
32
|
#
|
33
33
|
# @param (see Inventory::Dependency#initialize)
|
34
34
|
# @option (see Inventory::Dependency#initialize)
|
35
|
+
# @return [self]
|
35
36
|
def development(name, major, minor, patch, options = {})
|
36
37
|
dependencies << Development.new(name, major, minor, patch, options)
|
37
38
|
self
|
@@ -42,6 +43,7 @@ class Inventory::Dependencies
|
|
42
43
|
#
|
43
44
|
# @param (see Inventory::Dependency#initialize)
|
44
45
|
# @option (see Inventory::Dependency#initialize)
|
46
|
+
# @return [self]
|
45
47
|
def runtime(name, major, minor, patch, options = {})
|
46
48
|
dependencies << Runtime.new(name, major, minor, patch, options)
|
47
49
|
self
|
@@ -52,6 +54,7 @@ class Inventory::Dependencies
|
|
52
54
|
#
|
53
55
|
# @param (see Inventory::Dependency#initialize)
|
54
56
|
# @option (see Inventory::Dependency#initialize)
|
57
|
+
# @return [self]
|
55
58
|
def optional(name, major, minor, patch, options = {})
|
56
59
|
dependencies << Optional.new(name, major, minor, patch, options)
|
57
60
|
self
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# A license used by the project stored in the list of {Licenses} in the
|
4
|
+
# inventory.
|
5
|
+
class Inventory::License
|
6
|
+
# Sets up a new license NAME, often referred to via ABBREVIATION, than can be
|
7
|
+
# found at URL.
|
8
|
+
#
|
9
|
+
# @param [String] abbreviation
|
10
|
+
# @param [String] name
|
11
|
+
# @param [String] url
|
12
|
+
def initialize(abbreviation, name, url)
|
13
|
+
@abbreviation, @name, @url = abbreviation, name, url
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String] The {#abbreviation} of the license
|
17
|
+
def to_s
|
18
|
+
abbreviation.dup
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String] The abbreviation of the {#name} of the license
|
22
|
+
attr_reader :abbreviation
|
23
|
+
|
24
|
+
# @return [String] The name of the license
|
25
|
+
attr_reader :name
|
26
|
+
|
27
|
+
# @return [String] The URL at which the license can be found
|
28
|
+
attr_reader :url
|
29
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Contains zero or more {License licenses} of the project. Licenses can be {#+
|
4
|
+
# added} and {#each enumerated}. Licenses are set up by passing a block to
|
5
|
+
# {#initialize} and calling {#license} inside it.
|
6
|
+
#
|
7
|
+
# @example Creating a List of Licenses
|
8
|
+
# Licenses.new{
|
9
|
+
# license 'LGPLv3+',
|
10
|
+
# 'GNU Lesser General Public License, version 3 or later',
|
11
|
+
# 'http://www.gnu.org/licenses/'
|
12
|
+
# license 'GPLv3+',
|
13
|
+
# 'GNU General Public License, version 3 or later',
|
14
|
+
# 'http://www.gnu.org/licenses/'
|
15
|
+
# }
|
16
|
+
class Inventory::Licenses
|
17
|
+
include Enumerable
|
18
|
+
|
19
|
+
# Creates a new list of LICENSES and allows more to be added in the
|
20
|
+
# optionally #instance_exec’d block by calling {#license} inside it.
|
21
|
+
#
|
22
|
+
# @param [License, …] licenses
|
23
|
+
# @yield [?]
|
24
|
+
def initialize(*licenses)
|
25
|
+
@licenses = licenses
|
26
|
+
instance_exec(&Proc.new) if block_given?
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
# Add a {License} to the list of licenses.
|
32
|
+
#
|
33
|
+
# @param (see Inventory::License#initialize)
|
34
|
+
# @option (see Inventory::License#initialize)
|
35
|
+
# @return [self]
|
36
|
+
def license(abbreviation, name, url)
|
37
|
+
licenses << Inventory::License.new(abbreviation, name, url)
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
public
|
42
|
+
|
43
|
+
# @return [Licenses] The authors of the receiver and those of OTHER
|
44
|
+
def +(other)
|
45
|
+
self.class.new(*(licenses + other.licenses))
|
46
|
+
end
|
47
|
+
|
48
|
+
# @overload
|
49
|
+
# Enumerates the licenses.
|
50
|
+
#
|
51
|
+
# @yieldparam [License] license
|
52
|
+
# @overload
|
53
|
+
# @return [Enumerator<Author>] An Enumerator over the licenses
|
54
|
+
def each
|
55
|
+
return enum_for(__method__) unless block_given?
|
56
|
+
licenses.each do |license|
|
57
|
+
yield license
|
58
|
+
end
|
59
|
+
self
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
attr_reader :licenses
|
65
|
+
end
|
@@ -1,23 +1,47 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
class Inventory
|
4
|
-
Version = Inventory.new(1,
|
4
|
+
Version = Inventory.new(1, 5, 0){
|
5
|
+
def authors
|
6
|
+
Authors.new{
|
7
|
+
author 'Nikolai Weibull', 'now@disu.se'
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def homepage
|
12
|
+
'http://disu.se/software/inventory'
|
13
|
+
end
|
14
|
+
|
15
|
+
def licenses
|
16
|
+
Licenses.new{
|
17
|
+
license 'LGPLv3+',
|
18
|
+
'GNU Lesser General Public License, version 3 or later',
|
19
|
+
'http://www.gnu.org/licenses/'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
5
23
|
def dependencies
|
6
24
|
Dependencies.new{
|
7
|
-
development 'inventory-rake', 1,
|
25
|
+
development 'inventory-rake', 1, 6, 0
|
26
|
+
development 'inventory-rake-tasks-yard', 1, 4, 0
|
8
27
|
development 'lookout', 3, 0, 0
|
9
28
|
development 'lookout-rake', 3, 0, 0
|
10
|
-
development 'yard', 0, 8,
|
29
|
+
development 'yard', 0, 8, 7
|
30
|
+
development 'yard-heuristics', 1, 2, 0
|
11
31
|
}
|
12
32
|
end
|
13
33
|
|
14
34
|
def package_libs
|
15
|
-
%w[
|
35
|
+
%w[author.rb
|
36
|
+
authors.rb
|
37
|
+
dependency.rb
|
16
38
|
dependencies.rb
|
17
39
|
dependencies/development.rb
|
18
40
|
dependencies/optional.rb
|
19
41
|
dependencies/runtime.rb
|
20
|
-
extension.rb
|
42
|
+
extension.rb
|
43
|
+
license.rb
|
44
|
+
licenses.rb]
|
21
45
|
end
|
22
46
|
}
|
23
47
|
end
|
data/test/unit/inventory-1.0.rb
CHANGED
@@ -16,4 +16,12 @@ Expectations do
|
|
16
16
|
expect 'a-1.0' do
|
17
17
|
Inventory.new(1, 0, 0, 'a/lib/a/version.rb').package_require
|
18
18
|
end
|
19
|
+
|
20
|
+
expect %w[LGPLv3+] do
|
21
|
+
Inventory::Version.licenses.map(&:to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
expect ['Nikolai Weibull <now@disu.se>'] do
|
25
|
+
Inventory::Version.authors.map(&:to_s)
|
26
|
+
end
|
19
27
|
end
|
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inventory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikolai Weibull
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inventory-rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: inventory-rake-tasks-yard
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ~>
|
@@ -58,61 +72,87 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - ~>
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.8.
|
75
|
+
version: 0.8.7
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.7
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard-heuristics
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.2'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
94
|
- - ~>
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
96
|
+
version: '1.2'
|
69
97
|
description: |2
|
70
98
|
Inventory
|
71
99
|
|
72
|
-
Inventory keeps track of the contents of your Ruby
|
100
|
+
Inventory keeps track of the contents of your Ruby┬╣ projects. Such an
|
73
101
|
inventory can be used to load the project, create gem specifications and
|
74
|
-
gems, run unit tests, compile extensions, and verify that the project
|
102
|
+
gems, run unit tests, compile extensions, and verify that the projectΓÇÖs
|
75
103
|
content is what you think it is.
|
76
104
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
Let
|
82
|
-
to use. It
|
83
|
-
structure
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
Here you see a simplified version of a project called
|
105
|
+
┬╣ See http://ruby-lang.org/
|
106
|
+
|
107
|
+
§ Usage
|
108
|
+
|
109
|
+
LetΓÇÖs begin by discussing the project structure that Inventory expects you
|
110
|
+
to use. ItΓÇÖs pretty much exactly the same as the standard Ruby project
|
111
|
+
structure┬╣:
|
112
|
+
|
113
|
+
Γö£ΓöÇΓöÇ README
|
114
|
+
Γö£ΓöÇΓöÇ Rakefile
|
115
|
+
Γö£ΓöÇΓöÇ lib
|
116
|
+
Γöé Γö£ΓöÇΓöÇ foo-1.0
|
117
|
+
Γöé Γöé Γö£ΓöÇΓöÇ bar.rb
|
118
|
+
Γöé Γöé ΓööΓöÇΓöÇ version.rb
|
119
|
+
Γöé ΓööΓöÇΓöÇ foo-1.0.rb
|
120
|
+
ΓööΓöÇΓöÇ test
|
121
|
+
ΓööΓöÇΓöÇ unit
|
122
|
+
Γö£ΓöÇΓöÇ foo-1.0
|
123
|
+
Γöé Γö£ΓöÇΓöÇ bar.rb
|
124
|
+
Γöé ΓööΓöÇΓöÇ version.rb
|
125
|
+
ΓööΓöÇΓöÇ foo-1.0.rb
|
126
|
+
|
127
|
+
Here you see a simplified version of a project called ΓÇ£FooΓÇ¥ΓÇÖs project
|
100
128
|
structure. The only real difference from the standard is that the main
|
101
|
-
entry point into the library is named
|
102
|
-
that the root sub-directory of
|
103
|
-
of
|
104
|
-
be the major version of the project followed by a constant
|
129
|
+
entry point into the library is named ΓÇ£foo-1.0.rbΓÇ¥ instead of ΓÇ£foo.rbΓÇ¥ and
|
130
|
+
that the root sub-directory of ΓÇ£libΓÇ¥ is similarly named ΓÇ£foo-1.0ΓÇ¥ instead
|
131
|
+
of ΓÇ£fooΓÇ¥. The difference is the inclusion of the API version. This must
|
132
|
+
be the major version of the project followed by a constant ΓÇ£.0ΓÇ¥. The
|
105
133
|
reason for this is that it allows concurrent installations of different
|
106
134
|
major versions of the project and means that the wrong version will never
|
107
135
|
accidentally be loaded with require.
|
108
136
|
|
109
|
-
There
|
110
|
-
|
137
|
+
ThereΓÇÖs a bigger difference in the content of the files.
|
138
|
+
‹Lib/foo-1.0/version.rb› will contain our inventory instead of a String:
|
111
139
|
|
112
140
|
require 'inventory-1.0'
|
113
141
|
|
114
142
|
class Foo
|
115
143
|
Version = Foo.new(1, 4, 0){
|
144
|
+
authors{
|
145
|
+
author 'A. U. Thor', 'a.u.thor@example.org'
|
146
|
+
}
|
147
|
+
|
148
|
+
homepage 'http://example.org/'
|
149
|
+
|
150
|
+
licenses{
|
151
|
+
license 'LGPLv3+',
|
152
|
+
'GNU Lesser General Public License, version 3 or later',
|
153
|
+
'http://www.gnu.org/licenses/'
|
154
|
+
}
|
155
|
+
|
116
156
|
def dependencies
|
117
157
|
super + Dependencies.new{
|
118
158
|
development 'baz', 1, 3, 0
|
@@ -127,28 +167,33 @@ description: |2
|
|
127
167
|
}
|
128
168
|
end
|
129
169
|
|
130
|
-
We
|
131
|
-
greater detail, but we begin by setting the
|
170
|
+
WeΓÇÖre introducing quite a few concepts at once, and weΓÇÖll look into each in
|
171
|
+
greater detail, but we begin by setting the ‹Version› constant to a new
|
132
172
|
instance of an Inventory with major, minor, and patch version atoms 1, 4,
|
133
173
|
and 0. Then we add a couple of dependencies and list the library files
|
134
174
|
that are included in this project.
|
135
175
|
|
136
|
-
The version numbers shouldn
|
137
|
-
of the API that we
|
138
|
-
allow the Inventory#to_s method to act as if you
|
139
|
-
|
176
|
+
The version numbers shouldnΓÇÖt come as a surprise. These track the version
|
177
|
+
of the API that weΓÇÖre shipping using {semantic versioning}┬▓. They also
|
178
|
+
allow the Inventory#to_s method to act as if youΓÇÖd defined Version as
|
179
|
+
‹'1.4.0'›.
|
180
|
+
|
181
|
+
Next follows information about the authors of the project, the projectΓÇÖs
|
182
|
+
homepage, and the projectΓÇÖs licenses. Each author has a name and an email
|
183
|
+
address. The homepage is simply a string URL. Licenses have an
|
184
|
+
abbreviation, a name, and a URL where the license text can be found.
|
140
185
|
|
141
|
-
We then extend the definition of
|
142
|
-
dependencies to
|
143
|
-
the inventory project that
|
186
|
+
We then extend the definition of ‹dependencies› by adding another set of
|
187
|
+
dependencies to ‹super›. ‹Super› includes a dependency on the version of
|
188
|
+
the inventory project thatΓÇÖs being used with this project, so youΓÇÖll never
|
144
189
|
have to list that yourself. The other three dependencies are all of
|
145
190
|
different kinds: development, runtime, and optional. A development
|
146
|
-
dependency is one that
|
191
|
+
dependency is one thatΓÇÖs required while developing the project, for
|
147
192
|
example, a unit-testing framework, a documentation generator, and so on.
|
148
193
|
Runtime dependencies are requirements of the project to be able to run,
|
149
194
|
both during development and when installed. Finally, optional dependencies
|
150
195
|
are runtime dependencies that may or may not be required during execution.
|
151
|
-
The difference between runtime and optional is that the inventory won
|
196
|
+
The difference between runtime and optional is that the inventory wonΓÇÖt try
|
152
197
|
to automatically load an optional dependency, instead leaving that up to
|
153
198
|
you to do when and if it becomes necessary. By that logic, runtime
|
154
199
|
dependencies will be automatically loaded, which is a good reason for
|
@@ -160,38 +205,38 @@ description: |2
|
|
160
205
|
|
161
206
|
As mentioned, runtime dependencies will be automatically loaded and the
|
162
207
|
feature they try to load is based on the name of the dependency with a
|
163
|
-
|
164
|
-
Sometimes, this isn
|
208
|
+
ΓÇ£-X.0ΓÇ¥ tacked on the end, where ΓÇÿXΓÇÖ is the major version of the dependency.
|
209
|
+
Sometimes, this isnΓÇÖt correct, in which case the :feature option may be
|
165
210
|
given to specify the name of the feature.
|
166
211
|
|
167
212
|
You may also override other parts of a dependency by passing in a block to
|
168
|
-
the dependency, much like we
|
213
|
+
the dependency, much like weΓÇÖre doing for inventories.
|
169
214
|
|
170
215
|
The rest of an inventory will list the various files included in the
|
171
216
|
project. This project only consists of one additional file to those that
|
172
217
|
an inventory automatically include (Rakefile, README, the main entry point,
|
173
218
|
and the version.rb file that defines the inventory itself), namely the
|
174
|
-
library file
|
175
|
-
main entry point file loads the inventory. Library files that shouldn
|
176
|
-
loaded may be listed under a different heading, namely
|
219
|
+
library file ‹bar.rb›. Library files will be loaded automatically when the
|
220
|
+
main entry point file loads the inventory. Library files that shouldnΓÇÖt be
|
221
|
+
loaded may be listed under a different heading, namely ΓÇ£additional_libsΓÇ¥.
|
177
222
|
Both these sets of files will be used to generate a list of unit test files
|
178
223
|
automatically, so each library file will have a corresponding unit test
|
179
|
-
file in the inventory. We
|
224
|
+
file in the inventory. WeΓÇÖll discuss the different headings of an
|
180
225
|
inventory in more detail later on.
|
181
226
|
|
182
|
-
Now that we
|
227
|
+
Now that weΓÇÖve written our inventory, letΓÇÖs set it up so that itΓÇÖs content
|
183
228
|
gets loaded when our main entry point gets loaded. We add the following
|
184
|
-
piece of code to
|
229
|
+
piece of code to ‹lib/foo-1.0.rb›:
|
185
230
|
|
186
231
|
module Foo
|
187
232
|
load File.expand_path('../foo-1.0/version.rb', __FILE__)
|
188
233
|
Version.load
|
189
234
|
end
|
190
235
|
|
191
|
-
That
|
236
|
+
ThatΓÇÖs all thereΓÇÖs to it.
|
192
237
|
|
193
238
|
The inventory can also be used to great effect from a Rakefile using a
|
194
|
-
separate project called Inventory-Rake
|
239
|
+
separate project called Inventory-Rake┬│. Using itΓÇÖll give us tasks for
|
195
240
|
cleaning up our project, compiling extensions, installing dependencies,
|
196
241
|
installing and uninstalling the project itself, and creating and pushing
|
197
242
|
distribution files to distribution points.
|
@@ -200,28 +245,23 @@ description: |2
|
|
200
245
|
|
201
246
|
load File.expand_path('../lib/foo-1.0/version.rb', __FILE__)
|
202
247
|
|
203
|
-
Inventory::Rake::Tasks.define Foo::Version
|
204
|
-
s.author = 'Your Name'
|
205
|
-
s.email = 'you@example.com'
|
206
|
-
s.homepage = 'https://example.com/'
|
207
|
-
}
|
248
|
+
Inventory::Rake::Tasks.define Foo::Version
|
208
249
|
|
209
250
|
Inventory::Rake::Tasks.unless_installing_dependencies do
|
210
251
|
require 'lookout-rake-3.0'
|
211
252
|
Lookout::Rake::Tasks::Test.new
|
212
253
|
end
|
213
254
|
|
214
|
-
It
|
215
|
-
our inventory and sets up the tasks mentioned above.
|
216
|
-
additional customization of the gem specification.
|
255
|
+
It’s ‹Inventory::Rake::Tasks.define› that does the heavy lifting. It takes
|
256
|
+
our inventory and sets up the tasks mentioned above.
|
217
257
|
|
218
258
|
As we want to be able to use our Rakefile to install our dependencies for
|
219
259
|
us, the rest of the Rakefile is inside the conditional
|
220
260
|
#unless_installing_dependencies, which, as the name certainly implies,
|
221
261
|
executes its block unless the task being run is the one that installs our
|
222
|
-
dependencies. This becomes relevant when we set up Travis
|
262
|
+
dependencies. This becomes relevant when we set up Travis⁴ integration
|
223
263
|
next. The only conditional set-up we do in our Rakefile is creating our
|
224
|
-
test task via Lookout-Rake
|
264
|
+
test task via Lookout-Rake⁵, which also uses our inventory to find the unit
|
225
265
|
tests to run when executed.
|
226
266
|
|
227
267
|
Travis integration is straightforward. Simply put
|
@@ -230,9 +270,9 @@ description: |2
|
|
230
270
|
- gem install inventory-rake -v '~> VERSION' --no-rdoc --no-ri
|
231
271
|
- rake gem:deps:install
|
232
272
|
|
233
|
-
in the project
|
234
|
-
of Inventory-Rake that you require. This
|
235
|
-
all development, runtime, and optional dependencies that you
|
273
|
+
in the project’s ‹.travis.yml› file, replacing ‹VERSION› with the version
|
274
|
+
of Inventory-Rake that you require. ThisΓÇÖll make sure that Travis installs
|
275
|
+
all development, runtime, and optional dependencies that youΓÇÖve listed in
|
236
276
|
your inventory before running any tests.
|
237
277
|
|
238
278
|
You might also need to put
|
@@ -240,22 +280,22 @@ description: |2
|
|
240
280
|
env:
|
241
281
|
- RUBYOPT=rubygems
|
242
282
|
|
243
|
-
in your
|
283
|
+
in your ‹.travis.yml› file, depending on how things are set up.
|
244
284
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
285
|
+
┬╣ Ruby project structure: http://guides.rubygems.org/make-your-own-gem/
|
286
|
+
┬▓ Semantic versioning: http://semver.org/
|
287
|
+
┬│ Inventory-Rake: http://disu.se/software/inventory-rake/
|
288
|
+
⁴ Travis: http://travis-ci.org/
|
289
|
+
⁵ Lookout-Rake: http://disu.se/software/lookout-rake/
|
250
290
|
|
251
|
-
|
291
|
+
§ API
|
252
292
|
|
253
|
-
If the guide above doesn
|
254
|
-
may refer to the API
|
293
|
+
If the guide above doesnΓÇÖt provide you with all the answers you seek, you
|
294
|
+
may refer to the API┬╣ for more answers.
|
255
295
|
|
256
|
-
|
296
|
+
┬╣ See http://disu.se/software/inventory/api/Inventory/
|
257
297
|
|
258
|
-
|
298
|
+
§ Financing
|
259
299
|
|
260
300
|
Currently, most of my time is spent at my day job and in my rather busy
|
261
301
|
private life. Please motivate me to spend time on this piece of software
|
@@ -265,46 +305,56 @@ description: |2
|
|
265
305
|
to have other people give me the things that I need to continue living
|
266
306
|
under the rules of said society. So, if you feel that this piece of
|
267
307
|
software has helped you out enough to warrant a reward, please PayPal a
|
268
|
-
donation to now@disu.se
|
308
|
+
donation to now@disu.se┬╣. Thanks! Your support wonΓÇÖt go unnoticed!
|
269
309
|
|
270
|
-
|
310
|
+
┬╣ Send a donation:
|
271
311
|
https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=Nikolai%20Weibull%20Software%20Services
|
272
312
|
|
273
|
-
|
313
|
+
§ Reporting Bugs
|
274
314
|
|
275
|
-
Please report any bugs that you encounter to the {issue tracker}
|
315
|
+
Please report any bugs that you encounter to the {issue tracker}┬╣.
|
276
316
|
|
277
|
-
|
317
|
+
┬╣ See https://github.com/now/inventory/issues
|
278
318
|
|
279
|
-
|
319
|
+
§ Authors
|
280
320
|
|
281
321
|
Nikolai Weibull wrote the code, the tests, the documentation, and this
|
282
322
|
README.
|
283
|
-
email:
|
323
|
+
email:
|
324
|
+
- now@disu.se
|
284
325
|
executables: []
|
285
326
|
extensions: []
|
286
327
|
extra_rdoc_files: []
|
287
328
|
files:
|
329
|
+
- lib/inventory-1.0/author.rb
|
330
|
+
- lib/inventory-1.0/authors.rb
|
288
331
|
- lib/inventory-1.0/dependency.rb
|
289
332
|
- lib/inventory-1.0/dependencies.rb
|
290
333
|
- lib/inventory-1.0/dependencies/development.rb
|
291
334
|
- lib/inventory-1.0/dependencies/optional.rb
|
292
335
|
- lib/inventory-1.0/dependencies/runtime.rb
|
293
336
|
- lib/inventory-1.0/extension.rb
|
337
|
+
- lib/inventory-1.0/license.rb
|
338
|
+
- lib/inventory-1.0/licenses.rb
|
294
339
|
- lib/inventory-1.0.rb
|
295
340
|
- lib/inventory-1.0/version.rb
|
341
|
+
- test/unit/inventory-1.0/author.rb
|
342
|
+
- test/unit/inventory-1.0/authors.rb
|
296
343
|
- test/unit/inventory-1.0/dependency.rb
|
297
344
|
- test/unit/inventory-1.0/dependencies.rb
|
298
345
|
- test/unit/inventory-1.0/dependencies/development.rb
|
299
346
|
- test/unit/inventory-1.0/dependencies/optional.rb
|
300
347
|
- test/unit/inventory-1.0/dependencies/runtime.rb
|
301
348
|
- test/unit/inventory-1.0/extension.rb
|
349
|
+
- test/unit/inventory-1.0/license.rb
|
350
|
+
- test/unit/inventory-1.0/licenses.rb
|
302
351
|
- test/unit/inventory-1.0.rb
|
303
352
|
- test/unit/inventory-1.0/version.rb
|
304
353
|
- README
|
305
354
|
- Rakefile
|
306
|
-
homepage:
|
307
|
-
licenses:
|
355
|
+
homepage: http://disu.se/software/inventory
|
356
|
+
licenses:
|
357
|
+
- LGPLv3+
|
308
358
|
metadata: {}
|
309
359
|
post_install_message:
|
310
360
|
rdoc_options: []
|
@@ -322,8 +372,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
322
372
|
version: '0'
|
323
373
|
requirements: []
|
324
374
|
rubyforge_project:
|
325
|
-
rubygems_version: 2.0.
|
375
|
+
rubygems_version: 2.0.2
|
326
376
|
signing_key:
|
327
377
|
specification_version: 4
|
328
|
-
summary: Inventory keeps track of the contents of your Ruby
|
378
|
+
summary: Inventory keeps track of the contents of your Ruby┬╣ projects.
|
329
379
|
test_files: []
|