dep 1.0.9 → 1.1.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/bin/dep +30 -28
- data/test/dep.rb +30 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76ef3eef686b0b32799b211eb23c2db50914be15
|
4
|
+
data.tar.gz: 16636d764be0bccd03082d56daa57ed7d6cebc74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1284025521df66b6024f5d87b205fc43bc9376c2f364ee83b91ed9990098c98a7ece86168a998fa8f263407be0c5a31b74138095ffcc2964cf9ce27d4b249720
|
7
|
+
data.tar.gz: 382c097dd64b1ffe800590c46b46c6030f89f2fd905d808d917bac2c83f82e72494eff287a058ebf56a28ec91bf0d21301532354bc3d03e03a75e07b9e32fb62
|
data/bin/dep
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
require "fileutils"
|
4
4
|
|
5
|
+
def die
|
6
|
+
abort("error: dep --help for more info")
|
7
|
+
end
|
8
|
+
|
5
9
|
module Dep
|
6
10
|
class List
|
7
11
|
attr :path
|
@@ -55,17 +59,19 @@ module Dep
|
|
55
59
|
"#{name} -v #{version}"
|
56
60
|
end
|
57
61
|
|
62
|
+
def csv
|
63
|
+
"#{name}:#{version}"
|
64
|
+
end
|
65
|
+
|
58
66
|
def ==(other)
|
59
67
|
to_s == other.to_s
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
63
|
-
|
64
|
-
|
65
|
-
attr_accessor :prerelease, :list, :file
|
66
|
-
end
|
71
|
+
class CLI
|
72
|
+
attr_accessor :prerelease, :list, :file
|
67
73
|
|
68
|
-
def
|
74
|
+
def add(name)
|
69
75
|
dependency = Gem::Dependency.new(name)
|
70
76
|
fetcher = Gem::SpecFetcher.fetcher
|
71
77
|
|
@@ -87,14 +93,14 @@ module Dep
|
|
87
93
|
puts "dep: added #{lib}"
|
88
94
|
end
|
89
95
|
|
90
|
-
def
|
96
|
+
def rm(name)
|
91
97
|
@list.remove(Dep::Lib.new(name))
|
92
98
|
@list.save
|
93
99
|
|
94
100
|
puts "dep: removed #{name}"
|
95
101
|
end
|
96
102
|
|
97
|
-
def
|
103
|
+
def check
|
98
104
|
if @list.missing_libraries.empty?
|
99
105
|
puts "dep: all cool"
|
100
106
|
else
|
@@ -108,25 +114,19 @@ module Dep
|
|
108
114
|
end
|
109
115
|
end
|
110
116
|
|
111
|
-
def
|
117
|
+
def install
|
112
118
|
if @list.missing_libraries.empty?
|
113
119
|
puts "dep: nothing to install"
|
114
120
|
exit
|
115
121
|
end
|
116
122
|
|
117
|
-
@list.missing_libraries.
|
118
|
-
run "gem install #{lib}"
|
119
|
-
end
|
123
|
+
run "gem install #{@list.missing_libraries.map(&:csv).join(" ")}"
|
120
124
|
end
|
121
125
|
|
122
|
-
def
|
126
|
+
def run(cmd)
|
123
127
|
puts " #{cmd}"
|
124
128
|
`#{cmd}`
|
125
129
|
end
|
126
|
-
|
127
|
-
def self.abort
|
128
|
-
abort("error: dep --help for more info")
|
129
|
-
end
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -140,7 +140,7 @@ private
|
|
140
140
|
when 1 then block.call(ARGV.delete_at(index))
|
141
141
|
when 0 then block.call
|
142
142
|
else
|
143
|
-
|
143
|
+
die
|
144
144
|
end
|
145
145
|
end
|
146
146
|
end
|
@@ -151,15 +151,17 @@ end
|
|
151
151
|
# script, we have to instead rely on a different condition.
|
152
152
|
if File.basename($0) == "dep"
|
153
153
|
|
154
|
-
Dep::CLI.
|
155
|
-
|
154
|
+
cli = Dep::CLI.new
|
155
|
+
|
156
|
+
cli.file = File.join(Dir.pwd, ".gems")
|
157
|
+
cli.prerelease = false
|
156
158
|
|
157
159
|
on("-f") do |file|
|
158
|
-
|
160
|
+
cli.file = file
|
159
161
|
end
|
160
162
|
|
161
163
|
on("--pre") do
|
162
|
-
|
164
|
+
cli.prerelease = true
|
163
165
|
end
|
164
166
|
|
165
167
|
on("--help") do
|
@@ -171,21 +173,21 @@ if File.basename($0) == "dep"
|
|
171
173
|
exit
|
172
174
|
end
|
173
175
|
|
174
|
-
|
176
|
+
cli.list = Dep::List.new(cli.file)
|
175
177
|
|
176
|
-
FileUtils.touch(
|
178
|
+
FileUtils.touch(cli.list.path) unless File.exist?(cli.list.path)
|
177
179
|
|
178
180
|
case ARGV[0]
|
179
181
|
when "add"
|
180
|
-
|
182
|
+
cli.add(ARGV[1])
|
181
183
|
when "rm"
|
182
|
-
|
184
|
+
cli.rm(ARGV[1])
|
183
185
|
when "install", "i"
|
184
|
-
|
186
|
+
cli.install
|
185
187
|
when nil
|
186
|
-
|
188
|
+
cli.check
|
187
189
|
else
|
188
|
-
|
190
|
+
die
|
189
191
|
end
|
190
192
|
|
191
193
|
end
|
data/test/dep.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
require "cutest"
|
2
|
+
require "override"
|
2
3
|
|
3
4
|
load File.expand_path("../../bin/dep", __FILE__)
|
4
5
|
|
6
|
+
class Cutest::Scope
|
7
|
+
include Override
|
8
|
+
end
|
9
|
+
|
5
10
|
# Dep::Lib
|
6
11
|
scope do
|
7
12
|
test "parsing" do
|
@@ -51,3 +56,28 @@ scope do
|
|
51
56
|
assert list.libraries.include?(Dep::Lib.new("cutest", "2.0"))
|
52
57
|
end
|
53
58
|
end
|
59
|
+
|
60
|
+
# Dep::CLI
|
61
|
+
scope do
|
62
|
+
setup do
|
63
|
+
list = Dep::List.new("/dev/null")
|
64
|
+
|
65
|
+
list.add(Dep::Lib.new("foo", "2.0"))
|
66
|
+
list.add(Dep::Lib.new("bar", "1.1"))
|
67
|
+
|
68
|
+
commands = []
|
69
|
+
|
70
|
+
cli = Dep::CLI.new
|
71
|
+
cli.list = list
|
72
|
+
|
73
|
+
override(cli, run: -> args { commands << args })
|
74
|
+
|
75
|
+
[cli, commands]
|
76
|
+
end
|
77
|
+
|
78
|
+
test "install" do |cli, commands|
|
79
|
+
cli.install
|
80
|
+
|
81
|
+
assert_equal ["gem install foo:2.0 bar:1.1"], commands
|
82
|
+
end
|
83
|
+
end
|