dep 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dep +248 -58
- data/test/dep.rb +1 -1
- metadata +4 -21
- data/README.1 +0 -115
- data/lib/dep.rb +0 -58
- data/man/dep.1 +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d20ad871272540cfc045dc91e3dc95cb58735bc0
|
4
|
+
data.tar.gz: 954088f85ffa02926ad843283461472c34e97a72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fb8289270e143aa36ce2f5407abb4c4d16647f511c1dfdec1fe5ba272fe3486384dd58db7861bebe93dac87fce3ccf8718484c83119c73e7579384874ba0af8
|
7
|
+
data.tar.gz: 3e28c39c0b0e73a2320ad09037068240f04b61a9b0dadebf05b508c2c919b37f7e49c1981367c1f48b919fe3f0e7f9ab588548d2b65897d3e40b9a946f7c3232
|
data/bin/dep
CHANGED
@@ -1,90 +1,280 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative "../lib/dep"
|
4
|
-
|
5
3
|
require "fileutils"
|
6
|
-
require "clap"
|
7
4
|
|
8
|
-
|
9
|
-
|
5
|
+
module Dep
|
6
|
+
class List
|
7
|
+
attr :path
|
10
8
|
|
11
|
-
|
12
|
-
|
9
|
+
def initialize(path)
|
10
|
+
@path = path
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
def add(lib)
|
14
|
+
remove(lib)
|
15
|
+
libraries.push(lib)
|
16
|
+
end
|
17
|
+
|
18
|
+
def remove(lib)
|
19
|
+
libraries.delete_if { |e| e.name == lib.name }
|
20
|
+
end
|
16
21
|
|
17
|
-
|
22
|
+
def libraries
|
23
|
+
@libraries ||= File.readlines(path).map { |line| Lib[line] }
|
24
|
+
end
|
18
25
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
26
|
+
def missing_libraries
|
27
|
+
libraries.reject(&:available?)
|
28
|
+
end
|
22
29
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
def save
|
31
|
+
File.open(path, "w") do |file|
|
32
|
+
libraries.each do |lib|
|
33
|
+
file.puts lib.to_s
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
28
37
|
end
|
29
38
|
|
30
|
-
|
39
|
+
class Lib < Struct.new(:name, :version)
|
40
|
+
def self.[](line)
|
41
|
+
if line.strip =~ /^(\S+) -v (\S+)$/
|
42
|
+
return new($1, $2)
|
43
|
+
else
|
44
|
+
abort("Invalid requirement found: #{line}")
|
45
|
+
end
|
46
|
+
end
|
31
47
|
|
32
|
-
|
33
|
-
|
48
|
+
def available?
|
49
|
+
Gem::Specification.find_by_name(name, version)
|
50
|
+
rescue Gem::LoadError
|
51
|
+
return false
|
52
|
+
end
|
34
53
|
|
35
|
-
|
36
|
-
|
54
|
+
def to_s
|
55
|
+
"#{name} -v #{version}"
|
56
|
+
end
|
37
57
|
|
38
|
-
|
39
|
-
|
58
|
+
def ==(other)
|
59
|
+
to_s == other.to_s
|
60
|
+
end
|
61
|
+
end
|
40
62
|
|
41
|
-
|
42
|
-
|
43
|
-
|
63
|
+
module CLI
|
64
|
+
class << self
|
65
|
+
attr_accessor :prerelease, :list, :file
|
66
|
+
end
|
44
67
|
|
45
|
-
|
46
|
-
|
68
|
+
def self.add(name)
|
69
|
+
dependency = Gem::Dependency.new(name)
|
70
|
+
fetcher = Gem::SpecFetcher.fetcher
|
47
71
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
72
|
+
if fetcher.respond_to?(:spec_for_dependency)
|
73
|
+
dependency.prerelease = @prerelease
|
74
|
+
res, _ = fetcher.spec_for_dependency(dependency)
|
75
|
+
else
|
76
|
+
res = fetcher.fetch(dependency, false, true, @prerelease)
|
77
|
+
end
|
78
|
+
|
79
|
+
abort("Unable to find #{name}") if res.empty?
|
53
80
|
|
54
|
-
|
55
|
-
|
81
|
+
spec = res[-1][0]
|
82
|
+
lib = Dep::Lib.new(spec.name, spec.version)
|
83
|
+
|
84
|
+
@list.add(lib)
|
85
|
+
@list.save
|
86
|
+
|
87
|
+
puts "dep: added #{lib}"
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.rm(name)
|
91
|
+
@list.remove(Dep::Lib.new(name))
|
92
|
+
@list.save
|
93
|
+
|
94
|
+
puts "dep: removed #{name}"
|
56
95
|
end
|
57
96
|
|
58
|
-
|
97
|
+
def self.check
|
98
|
+
if @list.missing_libraries.empty?
|
99
|
+
puts "dep: all cool"
|
100
|
+
else
|
101
|
+
puts "dep: the following libraries are missing"
|
102
|
+
|
103
|
+
@list.missing_libraries.each do |lib|
|
104
|
+
puts " %s" % lib
|
105
|
+
end
|
106
|
+
|
107
|
+
exit(1)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.install
|
112
|
+
if @list.missing_libraries.empty?
|
113
|
+
puts "dep: nothing to install"
|
114
|
+
exit
|
115
|
+
end
|
116
|
+
|
117
|
+
@list.missing_libraries.each do |lib|
|
118
|
+
run "gem install #{lib}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.run(cmd)
|
123
|
+
puts " #{cmd}"
|
124
|
+
`#{cmd}`
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.abort
|
128
|
+
abort("error: dep --help for more info")
|
129
|
+
end
|
59
130
|
end
|
60
131
|
end
|
61
132
|
|
62
|
-
|
63
|
-
|
64
|
-
|
133
|
+
module Kernel
|
134
|
+
private
|
135
|
+
def on(flag, &block)
|
136
|
+
if index = ARGV.index(flag)
|
137
|
+
_ = ARGV.delete_at(index)
|
138
|
+
|
139
|
+
case block.arity
|
140
|
+
when 1 then block.call(ARGV.delete_at(index))
|
141
|
+
when 0 then block.call
|
142
|
+
else
|
143
|
+
Dep::CLI.abort
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
if __FILE__ == $0
|
150
|
+
|
151
|
+
Dep::CLI.file = File.join(Dir.pwd, ".gems")
|
152
|
+
Dep::CLI.prerelease = false
|
153
|
+
|
154
|
+
on("-f") do |file|
|
155
|
+
Dep::CLI.file = file
|
156
|
+
end
|
157
|
+
|
158
|
+
on("--pre") do
|
159
|
+
Dep::CLI.prerelease = true
|
160
|
+
end
|
161
|
+
|
162
|
+
on("--help") do
|
163
|
+
IO.popen("less", "w") { |f| f.write(DATA.read) }
|
65
164
|
exit
|
66
165
|
end
|
67
166
|
|
68
|
-
|
69
|
-
|
167
|
+
Dep::CLI.list = Dep::List.new(Dep::CLI.file)
|
168
|
+
|
169
|
+
FileUtils.touch(Dep::CLI.list.path) unless File.exist?(Dep::CLI.list.path)
|
170
|
+
|
171
|
+
case ARGV[0]
|
172
|
+
when "add"
|
173
|
+
Dep::CLI.add(ARGV[1])
|
174
|
+
when "rm"
|
175
|
+
Dep::CLI.rm(ARGV[1])
|
176
|
+
when "install", "i"
|
177
|
+
Dep::CLI.install
|
178
|
+
when nil
|
179
|
+
Dep::CLI.check
|
180
|
+
else
|
181
|
+
Dep::CLI.abort
|
70
182
|
end
|
71
|
-
end
|
72
183
|
|
73
|
-
def run(cmd)
|
74
|
-
puts " #{cmd}"
|
75
|
-
`#{cmd}`
|
76
184
|
end
|
77
185
|
|
78
|
-
|
79
|
-
|
80
|
-
|
186
|
+
__END__
|
187
|
+
|
188
|
+
DEP(1)
|
189
|
+
|
190
|
+
NAME
|
191
|
+
dep -- Basic dependency tracking
|
192
|
+
|
193
|
+
SYNOPSIS
|
194
|
+
dep
|
195
|
+
dep add libname [--pre]
|
196
|
+
dep rm libname
|
197
|
+
dep install
|
198
|
+
|
199
|
+
DESCRIPTION
|
200
|
+
dep
|
201
|
+
Checks that all dependencies are met.
|
202
|
+
|
203
|
+
dep add [gemname]
|
204
|
+
Fetches the latest version of `gemname`
|
205
|
+
and automatically adds it to your .gems file.
|
206
|
+
|
207
|
+
rm
|
208
|
+
Removes the corresponding entry in your .gems file.
|
209
|
+
|
210
|
+
install
|
211
|
+
Installs all the missing dependencies for you. An important
|
212
|
+
point here is that it simply does a `gem install` for each
|
213
|
+
dependency you have. Dep assumes that you use some form of
|
214
|
+
sandboxing like gs, rbenv-gemset or RVM gemsets.
|
215
|
+
|
216
|
+
|
217
|
+
INSTALLATION
|
218
|
+
$ wget -qO- http://amakawa.org/sh/install.sh | sh
|
219
|
+
|
220
|
+
# or
|
221
|
+
|
222
|
+
$ gem install dep
|
223
|
+
|
224
|
+
HISTORY
|
225
|
+
dep is actually more of a workflow than a tool. If you think about
|
226
|
+
package managers and the problem of dependencies, you can summarize
|
227
|
+
what you absolutely need from them in just two points:
|
228
|
+
|
229
|
+
1. When you build an application which relies on 3rd party libraries,
|
230
|
+
it's best to explicitly declare the version numbers of these
|
231
|
+
libraries.
|
232
|
+
|
233
|
+
2. You can either bundle the specific library version together with
|
234
|
+
your application, or you can have a list of versions.
|
235
|
+
|
236
|
+
The first approach is handled by vendoring the library. The second
|
237
|
+
approach typically is done using Bundler. But why do you need such
|
238
|
+
a complicated tool when all you need is simply listing version numbers?
|
239
|
+
|
240
|
+
We dissected what we were doing and eventually reached the following
|
241
|
+
workflow:
|
242
|
+
|
243
|
+
1. We maintain a .gems file for every application which lists the
|
244
|
+
libraries and the version numbers.
|
245
|
+
2. We omit dependencies of dependencies in that file, the reason being
|
246
|
+
is that that should already be handled by the package manager
|
247
|
+
(typically rubygems).
|
248
|
+
3. Whenever we add a new library, we add the latest version.
|
249
|
+
4. When we pull the latest changes, we want to be able to rapidly
|
250
|
+
check if the dependencies we have is up to date and matches what
|
251
|
+
we just pulled.
|
252
|
+
|
253
|
+
So after doing this workflow manually for a while, we decided to
|
254
|
+
build the simplest tool to aid us with our workflow.
|
255
|
+
|
256
|
+
The first point is handled implicitly by dep. You can also specify
|
257
|
+
a different file by doing dep -f.
|
258
|
+
|
259
|
+
The second point is more of an implementation detail. We thought about
|
260
|
+
doing dependencies, but then, why re-implement something that's already
|
261
|
+
done for you by rubygems?
|
262
|
+
|
263
|
+
The third point (and also the one which is most inconvenient), is
|
264
|
+
handled by dep add.
|
265
|
+
|
266
|
+
The manual workflow for that would be:
|
267
|
+
|
268
|
+
gem search -r "^ohm$" [--pre] # check and remember the version number
|
269
|
+
echo "ohm -v X.x.x" >> .gems
|
270
|
+
|
271
|
+
If you try doing that repeatedly, it will quickly become cumbersome.
|
272
|
+
|
273
|
+
The fourth and final point is handled by typing dep check or simply dep.
|
274
|
+
Practically speaking it's just:
|
81
275
|
|
82
|
-
|
83
|
-
|
84
|
-
"--help" => lambda { exec "man #{help}" }
|
276
|
+
git pull
|
277
|
+
dep
|
85
278
|
|
86
|
-
|
87
|
-
|
88
|
-
"rm" => method(:rm),
|
89
|
-
"install" => method(:install),
|
90
|
-
"check" => method(:check)
|
279
|
+
And that's it. The dep command typically happens in 0.2 seconds which
|
280
|
+
is something we LOVE.
|
data/test/dep.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril David
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: clap
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - ~>
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 1.0.0
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 1.0.0
|
12
|
+
date: 2013-03-16 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
28
14
|
description: Specify your project's dependencies in one file.
|
29
15
|
email:
|
30
16
|
- cyx.ucron@gmail.com
|
@@ -34,12 +20,9 @@ executables:
|
|
34
20
|
extensions: []
|
35
21
|
extra_rdoc_files: []
|
36
22
|
files:
|
37
|
-
- README.1
|
38
23
|
- bin/dep
|
39
|
-
- lib/dep.rb
|
40
24
|
- test/dep.rb
|
41
|
-
|
42
|
-
homepage: http://twpil.github.com/dep
|
25
|
+
homepage: http://cyx.github.com/dep
|
43
26
|
licenses: []
|
44
27
|
metadata: {}
|
45
28
|
post_install_message:
|
data/README.1
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
.\" generated with Ronn/v0.7.3
|
2
|
-
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
-
.
|
4
|
-
.TH "DEP" "1" "April 2012" "" ""
|
5
|
-
.
|
6
|
-
.SH "NAME"
|
7
|
-
\fBDEP\fR \- basic dependency tracking
|
8
|
-
.
|
9
|
-
.SH "SYNOPSIS"
|
10
|
-
.
|
11
|
-
.nf
|
12
|
-
|
13
|
-
dep check
|
14
|
-
dep add libname [\-\-pre]
|
15
|
-
dep rm libname
|
16
|
-
dep install
|
17
|
-
.
|
18
|
-
.fi
|
19
|
-
.
|
20
|
-
.SH "DESCRIPTION"
|
21
|
-
.
|
22
|
-
.TP
|
23
|
-
check
|
24
|
-
Checks that all dependencies are met\.
|
25
|
-
.
|
26
|
-
.TP
|
27
|
-
add
|
28
|
-
Fetches the latest version of the library in question and automatically adds it to your \.gems file\.
|
29
|
-
.
|
30
|
-
.TP
|
31
|
-
rm
|
32
|
-
Simply removes the corresponding entry in your \.gems file\.
|
33
|
-
.
|
34
|
-
.TP
|
35
|
-
install
|
36
|
-
Installs all the missing dependencies for you\. An important point here is that it simply does a \fBgem install\fR for each dependency you have\. Dep assumes that you use some form of sandboxing like gs, RVM or rbenv\-gemset\.
|
37
|
-
.
|
38
|
-
.SH "INSTALLATION"
|
39
|
-
.
|
40
|
-
.nf
|
41
|
-
|
42
|
-
$ gem install dep
|
43
|
-
.
|
44
|
-
.fi
|
45
|
-
.
|
46
|
-
.SH "HISTORY"
|
47
|
-
dep is actually more of a workflow than a tool\. If you think about package managers and the problem of dependencies, you can summarize what you absolutely need from them in just two points:
|
48
|
-
.
|
49
|
-
.IP "1." 4
|
50
|
-
When you build an application which relies on 3rd party libraries, it\'s best to explicitly declare the version numbers of these libraries\.
|
51
|
-
.
|
52
|
-
.IP "2." 4
|
53
|
-
You can either bundle the specific library version together with your application, or you can have a list of versions\.
|
54
|
-
.
|
55
|
-
.IP "" 0
|
56
|
-
.
|
57
|
-
.P
|
58
|
-
The first approach is handled by vendoring the library\. The second approach typically is done using Bundler\. But why do you need such a complicated tool when all you need is simply listing version numbers?
|
59
|
-
.
|
60
|
-
.P
|
61
|
-
We dissected what we were doing and eventually reached the following workflow:
|
62
|
-
.
|
63
|
-
.IP "1." 4
|
64
|
-
We maintain a \.gems file for every application which lists the libraries and the version numbers\.
|
65
|
-
.
|
66
|
-
.IP "2." 4
|
67
|
-
We omit dependencies of dependencies in that file, the reason being is that that should already be handled by the package manager (typically rubygems)\.
|
68
|
-
.
|
69
|
-
.IP "3." 4
|
70
|
-
Whenever we add a new library, we add the latest version\.
|
71
|
-
.
|
72
|
-
.IP "4." 4
|
73
|
-
When we pull the latest changes, we want to be able to rapidly check if the dependencies we have is up to date and matches what we just pulled\.
|
74
|
-
.
|
75
|
-
.IP "" 0
|
76
|
-
.
|
77
|
-
.P
|
78
|
-
So after doing this workflow manually for a while, we decided to build the simplest tool to aid us with our workflow\.
|
79
|
-
.
|
80
|
-
.IP "\(bu" 4
|
81
|
-
The first point is handled implicitly by dep\. You can also specify a different file by doing dep \-f\.
|
82
|
-
.
|
83
|
-
.IP "\(bu" 4
|
84
|
-
The second point is more of an implementation detail\. We thought about doing dependencies, but then, why re\-implement something that\'s already done for you by rubygems?
|
85
|
-
.
|
86
|
-
.IP "\(bu" 4
|
87
|
-
The third point (and also the one which is most inconvenient), is handled by dep add\.
|
88
|
-
.
|
89
|
-
.IP "" 0
|
90
|
-
.
|
91
|
-
.P
|
92
|
-
The manual workflow for \fBdep add\fR would be:
|
93
|
-
.
|
94
|
-
.IP "" 4
|
95
|
-
.
|
96
|
-
.nf
|
97
|
-
|
98
|
-
gem search \-r "^ohm$" [\-\-pre] # check and remember the version number
|
99
|
-
echo "ohm \-v X\.x\.x" >> \.gems
|
100
|
-
.
|
101
|
-
.fi
|
102
|
-
.
|
103
|
-
.IP "" 0
|
104
|
-
.
|
105
|
-
.P
|
106
|
-
If you try doing that repeatedly, it will quickly become cumbersome\.
|
107
|
-
.
|
108
|
-
.P
|
109
|
-
The fourth and final point is handled by typing dep check or simply dep\. Practically speaking it\'s just:
|
110
|
-
.
|
111
|
-
.P
|
112
|
-
\fBgit pull dep\fR
|
113
|
-
.
|
114
|
-
.P
|
115
|
-
And that\'s it\. The dep command typically happens in 0\.2 seconds which is something we LOVE\.
|
data/lib/dep.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
module Dep
|
2
|
-
class List
|
3
|
-
attr :path
|
4
|
-
|
5
|
-
def initialize(path = File.join(Dir.pwd, ".gems"))
|
6
|
-
@path = path
|
7
|
-
end
|
8
|
-
|
9
|
-
def add(lib)
|
10
|
-
remove(lib)
|
11
|
-
libraries.push(lib)
|
12
|
-
end
|
13
|
-
|
14
|
-
def remove(lib)
|
15
|
-
libraries.delete_if { |e| e.name == lib.name }
|
16
|
-
end
|
17
|
-
|
18
|
-
def libraries
|
19
|
-
@libraries ||= File.readlines(path).map { |line| Lib[line] }
|
20
|
-
end
|
21
|
-
|
22
|
-
def missing_libraries
|
23
|
-
libraries.reject(&:available?)
|
24
|
-
end
|
25
|
-
|
26
|
-
def save
|
27
|
-
File.open(path, "w") do |file|
|
28
|
-
libraries.each do |lib|
|
29
|
-
file.puts lib.to_s
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Lib < Struct.new(:name, :version)
|
36
|
-
def self.[](line)
|
37
|
-
if line.strip =~ /^(\S+) -v (\S+)$/
|
38
|
-
return new($1, $2)
|
39
|
-
else
|
40
|
-
abort("Invalid requirement found: #{line}")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def available?
|
45
|
-
Gem::Specification.find_by_name(name, version)
|
46
|
-
rescue Gem::LoadError
|
47
|
-
return false
|
48
|
-
end
|
49
|
-
|
50
|
-
def to_s
|
51
|
-
"#{name} -v #{version}"
|
52
|
-
end
|
53
|
-
|
54
|
-
def ==(other)
|
55
|
-
to_s == other.to_s
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/man/dep.1
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
.\" generated with Ronn/v0.7.3
|
2
|
-
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
-
.
|
4
|
-
.TH "DEP" "1" "April 2012" "" ""
|
5
|
-
.
|
6
|
-
.SH "NAME"
|
7
|
-
\fBDEP\fR \- basic dependency tracking
|
8
|
-
.
|
9
|
-
.SH "SYNOPSIS"
|
10
|
-
.
|
11
|
-
.nf
|
12
|
-
|
13
|
-
dep check
|
14
|
-
dep add libname [\-\-pre]
|
15
|
-
dep rm libname
|
16
|
-
dep install
|
17
|
-
.
|
18
|
-
.fi
|
19
|
-
.
|
20
|
-
.SH "DESCRIPTION"
|
21
|
-
.
|
22
|
-
.TP
|
23
|
-
check
|
24
|
-
Checks that all dependencies are met\.
|
25
|
-
.
|
26
|
-
.TP
|
27
|
-
add
|
28
|
-
Fetches the latest version of the library in question and automatically adds it to your \.gems file\.
|
29
|
-
.
|
30
|
-
.TP
|
31
|
-
rm
|
32
|
-
Simply removes the corresponding entry in your \.gems file\.
|
33
|
-
.
|
34
|
-
.TP
|
35
|
-
install
|
36
|
-
Installs all the missing dependencies for you\. An important point here is that it simply does a \fBgem install\fR for each dependency you have\. Dep assumes that you use some form of sandboxing like gs, RVM or rbenv\-gemset\.
|
37
|
-
.
|
38
|
-
.SH "INSTALLATION"
|
39
|
-
.
|
40
|
-
.nf
|
41
|
-
|
42
|
-
$ gem install dep
|
43
|
-
.
|
44
|
-
.fi
|
45
|
-
.
|
46
|
-
.SH "HISTORY"
|
47
|
-
dep is actually more of a workflow than a tool\. If you think about package managers and the problem of dependencies, you can summarize what you absolutely need from them in just two points:
|
48
|
-
.
|
49
|
-
.IP "1." 4
|
50
|
-
When you build an application which relies on 3rd party libraries, it\'s best to explicitly declare the version numbers of these libraries\.
|
51
|
-
.
|
52
|
-
.IP "2." 4
|
53
|
-
You can either bundle the specific library version together with your application, or you can have a list of versions\.
|
54
|
-
.
|
55
|
-
.IP "" 0
|
56
|
-
.
|
57
|
-
.P
|
58
|
-
The first approach is handled by vendoring the library\. The second approach typically is done using Bundler\. But why do you need such a complicated tool when all you need is simply listing version numbers?
|
59
|
-
.
|
60
|
-
.P
|
61
|
-
We dissected what we were doing and eventually reached the following workflow:
|
62
|
-
.
|
63
|
-
.IP "1." 4
|
64
|
-
We maintain a \.gems file for every application which lists the libraries and the version numbers\.
|
65
|
-
.
|
66
|
-
.IP "2." 4
|
67
|
-
We omit dependencies of dependencies in that file, the reason being is that that should already be handled by the package manager (typically rubygems)\.
|
68
|
-
.
|
69
|
-
.IP "3." 4
|
70
|
-
Whenever we add a new library, we add the latest version\.
|
71
|
-
.
|
72
|
-
.IP "4." 4
|
73
|
-
When we pull the latest changes, we want to be able to rapidly check if the dependencies we have is up to date and matches what we just pulled\.
|
74
|
-
.
|
75
|
-
.IP "" 0
|
76
|
-
.
|
77
|
-
.P
|
78
|
-
So after doing this workflow manually for a while, we decided to build the simplest tool to aid us with our workflow\.
|
79
|
-
.
|
80
|
-
.IP "\(bu" 4
|
81
|
-
The first point is handled implicitly by dep\. You can also specify a different file by doing dep \-f\.
|
82
|
-
.
|
83
|
-
.IP "\(bu" 4
|
84
|
-
The second point is more of an implementation detail\. We thought about doing dependencies, but then, why re\-implement something that\'s already done for you by rubygems?
|
85
|
-
.
|
86
|
-
.IP "\(bu" 4
|
87
|
-
The third point (and also the one which is most inconvenient), is handled by dep add\.
|
88
|
-
.
|
89
|
-
.IP "" 0
|
90
|
-
.
|
91
|
-
.P
|
92
|
-
The manual workflow for \fBdep add\fR would be:
|
93
|
-
.
|
94
|
-
.IP "" 4
|
95
|
-
.
|
96
|
-
.nf
|
97
|
-
|
98
|
-
gem search \-r "^ohm$" [\-\-pre] # check and remember the version number
|
99
|
-
echo "ohm \-v X\.x\.x" >> \.gems
|
100
|
-
.
|
101
|
-
.fi
|
102
|
-
.
|
103
|
-
.IP "" 0
|
104
|
-
.
|
105
|
-
.P
|
106
|
-
If you try doing that repeatedly, it will quickly become cumbersome\.
|
107
|
-
.
|
108
|
-
.P
|
109
|
-
The fourth and final point is handled by typing dep check or simply dep\. Practically speaking it\'s just:
|
110
|
-
.
|
111
|
-
.P
|
112
|
-
\fBgit pull dep\fR
|
113
|
-
.
|
114
|
-
.P
|
115
|
-
And that\'s it\. The dep command typically happens in 0\.2 seconds which is something we LOVE\.
|