dep 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dep +30 -28
  3. data/test/dep.rb +1 -31
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c048afaa8e1434021fa0d47b0620610d19277582
4
- data.tar.gz: 3b01932b6467a81334fc2a024eb9783ed555d362
3
+ metadata.gz: e524ea44c406b91aee8bd1dd52818bc1cbd9a4d9
4
+ data.tar.gz: 95272d72184f135265f22263f1eb773b72431fd8
5
5
  SHA512:
6
- metadata.gz: b29865a7f0e6591c579d13a99ce1307795f72032e8196e4971472c983cdb4412d73c871fca26af560624927afa633b4a2a9bf1aea0fff579d5c10a6266aef03e
7
- data.tar.gz: 03b29aa4ef6f61ce4ddf5dc191bfede0d51ca33671139e1a4cd95893946a7c939af6ec9aa7a2392391ea530c31c1fbc4c8d82903bd56a592bc93b7221e8f1b99
6
+ metadata.gz: 188c63e82626083d79b8e230141cc6a80813009e3b3fe06eab692dd69fc579d73f21677f88098e1d707b53b39c48b4f08eda761b3c23f7932c0dc08fa94bc9ea
7
+ data.tar.gz: 65e035c49b90bc187f3a4b8cac9b711d94971b90828f56d58d95543faca01843c9fbdc9bcb339aad139764f6bdc2b3ae0b835b38c56f1c1b13396fe3b902d244
data/bin/dep CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  require "fileutils"
4
4
 
5
- def die
6
- abort("error: dep --help for more info")
7
- end
8
-
9
5
  module Dep
10
6
  class List
11
7
  attr :path
@@ -42,7 +38,7 @@ module Dep
42
38
 
43
39
  class Lib < Struct.new(:name, :version)
44
40
  def self.[](line)
45
- if line.strip =~ /^(\S+):(\S+)$/
41
+ if line.strip =~ /^(\S+) -v (\S+)$/
46
42
  return new($1, $2)
47
43
  else
48
44
  abort("Invalid requirement found: #{line}")
@@ -56,7 +52,7 @@ module Dep
56
52
  end
57
53
 
58
54
  def to_s
59
- "#{name}:#{version}"
55
+ "#{name} -v #{version}"
60
56
  end
61
57
 
62
58
  def ==(other)
@@ -64,10 +60,12 @@ module Dep
64
60
  end
65
61
  end
66
62
 
67
- class CLI
68
- attr_accessor :prerelease, :list, :file
63
+ module CLI
64
+ class << self
65
+ attr_accessor :prerelease, :list, :file
66
+ end
69
67
 
70
- def add(name)
68
+ def self.add(name)
71
69
  dependency = Gem::Dependency.new(name)
72
70
  fetcher = Gem::SpecFetcher.fetcher
73
71
 
@@ -89,14 +87,14 @@ module Dep
89
87
  puts "dep: added #{lib}"
90
88
  end
91
89
 
92
- def rm(name)
90
+ def self.rm(name)
93
91
  @list.remove(Dep::Lib.new(name))
94
92
  @list.save
95
93
 
96
94
  puts "dep: removed #{name}"
97
95
  end
98
96
 
99
- def check
97
+ def self.check
100
98
  if @list.missing_libraries.empty?
101
99
  puts "dep: all cool"
102
100
  else
@@ -110,19 +108,25 @@ module Dep
110
108
  end
111
109
  end
112
110
 
113
- def install
111
+ def self.install
114
112
  if @list.missing_libraries.empty?
115
113
  puts "dep: nothing to install"
116
114
  exit
117
115
  end
118
116
 
119
- run "gem install #{@list.missing_libraries.join(" ")}"
117
+ @list.missing_libraries.each do |lib|
118
+ run "gem install #{lib}"
119
+ end
120
120
  end
121
121
 
122
- def run(cmd)
122
+ def self.run(cmd)
123
123
  puts " #{cmd}"
124
124
  `#{cmd}`
125
125
  end
126
+
127
+ def self.abort
128
+ abort("error: dep --help for more info")
129
+ end
126
130
  end
127
131
  end
128
132
 
@@ -136,7 +140,7 @@ private
136
140
  when 1 then block.call(ARGV.delete_at(index))
137
141
  when 0 then block.call
138
142
  else
139
- die
143
+ Dep::CLI.abort
140
144
  end
141
145
  end
142
146
  end
@@ -147,17 +151,15 @@ end
147
151
  # script, we have to instead rely on a different condition.
148
152
  if File.basename($0) == "dep"
149
153
 
150
- cli = Dep::CLI.new
151
-
152
- cli.file = File.join(Dir.pwd, ".gems")
153
- cli.prerelease = false
154
+ Dep::CLI.file = File.join(Dir.pwd, ".gems")
155
+ Dep::CLI.prerelease = false
154
156
 
155
157
  on("-f") do |file|
156
- cli.file = file
158
+ Dep::CLI.file = file
157
159
  end
158
160
 
159
161
  on("--pre") do
160
- cli.prerelease = true
162
+ Dep::CLI.prerelease = true
161
163
  end
162
164
 
163
165
  on("--help") do
@@ -169,21 +171,21 @@ if File.basename($0) == "dep"
169
171
  exit
170
172
  end
171
173
 
172
- cli.list = Dep::List.new(cli.file)
174
+ Dep::CLI.list = Dep::List.new(Dep::CLI.file)
173
175
 
174
- FileUtils.touch(cli.list.path) unless File.exist?(cli.list.path)
176
+ FileUtils.touch(Dep::CLI.list.path) unless File.exist?(Dep::CLI.list.path)
175
177
 
176
178
  case ARGV[0]
177
179
  when "add"
178
- cli.add(ARGV[1])
180
+ Dep::CLI.add(ARGV[1])
179
181
  when "rm"
180
- cli.rm(ARGV[1])
182
+ Dep::CLI.rm(ARGV[1])
181
183
  when "install", "i"
182
- cli.install
184
+ Dep::CLI.install
183
185
  when nil
184
- cli.check
186
+ Dep::CLI.check
185
187
  else
186
- die
188
+ Dep::CLI.abort
187
189
  end
188
190
 
189
191
  end
@@ -1,12 +1,7 @@
1
1
  require "cutest"
2
- require "override"
3
2
 
4
3
  load File.expand_path("../../bin/dep", __FILE__)
5
4
 
6
- class Cutest::Scope
7
- include Override
8
- end
9
-
10
5
  # Dep::Lib
11
6
  scope do
12
7
  test "parsing" do
@@ -28,7 +23,7 @@ scope do
28
23
 
29
24
  test "to_s" do
30
25
  lib = Dep::Lib.new("cutest", "1.1.3")
31
- assert_equal "cutest:1.1.3", lib.to_s
26
+ assert_equal "cutest -v 1.1.3", lib.to_s
32
27
  end
33
28
  end
34
29
 
@@ -56,28 +51,3 @@ scope do
56
51
  assert list.libraries.include?(Dep::Lib.new("cutest", "2.0"))
57
52
  end
58
53
  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
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.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril David