dep 1.0.6 → 1.0.7

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dep +29 -31
  3. data/test/dep.rb +31 -1
  4. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e53e9ac04f81fb3af567a9b5db05cd8fad2f8e4
4
- data.tar.gz: cec73d8932a8996485ee8c24a811aa57af50c2f9
3
+ metadata.gz: 17dd7631845fb1eb16af43d99d96f1810f1eaf70
4
+ data.tar.gz: 9ab140c32d7bd7d61192935a20342ed032c98d8e
5
5
  SHA512:
6
- metadata.gz: bdb92137ee6edd38b3b12f6e8997d053075b5da9cf027ecb13eb83e70b51925bbff4a0e49984518f6a6bfb230cf079656972bcafe5537ed47409dbe548c6e8af
7
- data.tar.gz: 5bdc7dc4662f18258d63fecf1c1a985b64070c82df037da259e736faaf19debe09009e53bca568ff6e55e46accdc37b3ece9dbcc69211657843d18b6788631db
6
+ metadata.gz: e25a239fab4ebd9a18e0eeb60095a08b99dd3064195674416bbb8b419b9424d1237e96ee54d1ebbffac458026343b18810b479b327f0dcf4597ac130356ba7a6
7
+ data.tar.gz: 159bae56a23174e18fd696083306d2ee7b5d13e04cf712f7621e5c6a8b78e670dfd0cb60724b5a307d41d4ed78cd0efd31d20a15692c882f58f114204915cc62
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
@@ -52,7 +56,7 @@ module Dep
52
56
  end
53
57
 
54
58
  def to_s
55
- "#{name} -v #{version}"
59
+ "#{name}:#{version}"
56
60
  end
57
61
 
58
62
  def ==(other)
@@ -60,12 +64,10 @@ module Dep
60
64
  end
61
65
  end
62
66
 
63
- module CLI
64
- class << self
65
- attr_accessor :prerelease, :list, :file
66
- end
67
+ class CLI
68
+ attr_accessor :prerelease, :list, :file
67
69
 
68
- def self.add(name)
70
+ def add(name)
69
71
  dependency = Gem::Dependency.new(name)
70
72
  fetcher = Gem::SpecFetcher.fetcher
71
73
 
@@ -87,14 +89,14 @@ module Dep
87
89
  puts "dep: added #{lib}"
88
90
  end
89
91
 
90
- def self.rm(name)
92
+ def rm(name)
91
93
  @list.remove(Dep::Lib.new(name))
92
94
  @list.save
93
95
 
94
96
  puts "dep: removed #{name}"
95
97
  end
96
98
 
97
- def self.check
99
+ def check
98
100
  if @list.missing_libraries.empty?
99
101
  puts "dep: all cool"
100
102
  else
@@ -108,25 +110,19 @@ module Dep
108
110
  end
109
111
  end
110
112
 
111
- def self.install
113
+ def install
112
114
  if @list.missing_libraries.empty?
113
115
  puts "dep: nothing to install"
114
116
  exit
115
117
  end
116
118
 
117
- @list.missing_libraries.each do |lib|
118
- run "gem install #{lib}"
119
- end
119
+ run "gem install #{@list.missing_libraries.join(" ")}"
120
120
  end
121
121
 
122
- def self.run(cmd)
122
+ def 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
130
126
  end
131
127
  end
132
128
 
@@ -140,7 +136,7 @@ private
140
136
  when 1 then block.call(ARGV.delete_at(index))
141
137
  when 0 then block.call
142
138
  else
143
- Dep::CLI.abort
139
+ die
144
140
  end
145
141
  end
146
142
  end
@@ -151,41 +147,43 @@ end
151
147
  # script, we have to instead rely on a different condition.
152
148
  if File.basename($0) == "dep"
153
149
 
154
- Dep::CLI.file = File.join(Dir.pwd, ".gems")
155
- Dep::CLI.prerelease = false
150
+ cli = Dep::CLI.new
151
+
152
+ cli.file = File.join(Dir.pwd, ".gems")
153
+ cli.prerelease = false
156
154
 
157
155
  on("-f") do |file|
158
- Dep::CLI.file = file
156
+ cli.file = file
159
157
  end
160
158
 
161
159
  on("--pre") do
162
- Dep::CLI.prerelease = true
160
+ cli.prerelease = true
163
161
  end
164
162
 
165
163
  on("--help") do
166
- # I hate this, but since rubygems does a wrapper
167
- # script, we can't use the elegance of DATA.read :(
164
+
165
+ # We can't use DATA.read because rubygems does a wrapper script.
168
166
  help = File.read(__FILE__).split(/^__END__/)[1]
169
167
 
170
168
  IO.popen("less", "w") { |f| f.write(help) }
171
169
  exit
172
170
  end
173
171
 
174
- Dep::CLI.list = Dep::List.new(Dep::CLI.file)
172
+ cli.list = Dep::List.new(cli.file)
175
173
 
176
- FileUtils.touch(Dep::CLI.list.path) unless File.exist?(Dep::CLI.list.path)
174
+ FileUtils.touch(cli.list.path) unless File.exist?(cli.list.path)
177
175
 
178
176
  case ARGV[0]
179
177
  when "add"
180
- Dep::CLI.add(ARGV[1])
178
+ cli.add(ARGV[1])
181
179
  when "rm"
182
- Dep::CLI.rm(ARGV[1])
180
+ cli.rm(ARGV[1])
183
181
  when "install", "i"
184
- Dep::CLI.install
182
+ cli.install
185
183
  when nil
186
- Dep::CLI.check
184
+ cli.check
187
185
  else
188
- Dep::CLI.abort
186
+ die
189
187
  end
190
188
 
191
189
  end
@@ -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
@@ -23,7 +28,7 @@ scope do
23
28
 
24
29
  test "to_s" do
25
30
  lib = Dep::Lib.new("cutest", "1.1.3")
26
- assert_equal "cutest -v 1.1.3", lib.to_s
31
+ assert_equal "cutest:1.1.3", lib.to_s
27
32
  end
28
33
  end
29
34
 
@@ -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
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.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril David
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-22 00:00:00.000000000 Z
12
+ date: 2014-06-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Specify your project's dependencies in one file.
15
15
  email:
@@ -31,17 +31,17 @@ require_paths:
31
31
  - lib
32
32
  required_ruby_version: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
37
  required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  requirements: []
43
43
  rubyforge_project:
44
- rubygems_version: 2.0.0
44
+ rubygems_version: 2.2.2
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: Dependencies manager