dependencies 0.0.4 → 0.0.5

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.
data/bin/dep CHANGED
@@ -29,12 +29,12 @@ protected
29
29
 
30
30
  def vendor_one(name)
31
31
  dep = dependency(name) || flunk("Dependency #{name} not found in dependencies.")
32
- dep.url || flunk("Don't know where to vendor #{name} from (no URL given...)")
32
+ dep.version || dep.url || flunk("Don't know where to vendor #{name} from (no version or URL given...)")
33
33
 
34
34
  FileUtils.mkdir("vendor") unless File.directory?("vendor")
35
35
 
36
36
  inside "vendor", :verbose => true do
37
- run "git clone #{dep.url} #{dep.name} -q"
37
+ fetch dep
38
38
  remove_file File.join(dep.name, ".git")
39
39
  end
40
40
  end
@@ -47,6 +47,14 @@ protected
47
47
  end
48
48
  end
49
49
 
50
+ def fetch(dep)
51
+ if dep.version
52
+ run "gem unpack #{dep.name} -v #{dep.version}"
53
+ else
54
+ run "git clone #{dep.url} #{dep.name} -q --depth 1"
55
+ end
56
+ end
57
+
50
58
  def deps
51
59
  @deps ||= Dep.new(File.read("dependencies"))
52
60
  rescue Errno::ENOENT
data/dependencies.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "dependencies"
3
- s.version = "0.0.4"
3
+ s.version = "0.0.5"
4
4
  s.summary = "Specify your project's dependencies in one file."
5
5
  s.authors = ["Damian Janowski", "Michel Martens"]
6
6
  s.email = ["djanowski@dimaion.com", "michel@soveran.com"]
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
 
10
10
  s.executables << "dep"
11
11
 
12
- s.files = ["README.markdown", "Rakefile", "bin/dep", "dependencies.gemspec", "lib/dependencies/dep.rb", "lib/dependencies.rb", "test/dependencies_test.rb", "test/vendor/bar/lib", "test/vendor/barz-2.0/lib", "test/vendor/baz-1.0/lib"]
12
+ s.files = ["README.markdown", "Rakefile", "bin/dep", "dependencies.gemspec", "lib/dependencies/dep.rb", "lib/dependencies.rb", "test/dependencies_test.rb", "test/foobaz-0.3.gem", "test/vendor/bar/lib", "test/vendor/barz-2.0/lib", "test/vendor/baz-1.0/lib"]
13
13
 
14
14
  s.add_dependency("wycats-thor", "~> 0.11")
15
15
  end
@@ -25,7 +25,8 @@ class Dep
25
25
  end
26
26
 
27
27
  def vendor_path
28
- Dir[File.join('vendor', "#{vendor_name}*", 'lib')].first
28
+ Dir[File.join("vendor", "#{vendor_name}*", "lib")].first ||
29
+ Dir[File.join("vendor", name, "lib")].first
29
30
  end
30
31
 
31
32
  def require_vendor
@@ -85,6 +86,8 @@ class Dep
85
86
  end
86
87
 
87
88
  $stderr.puts
89
+ $stderr.puts "Run `dep list` to view the missing dependencies or `dep vendor --all` to try to solve them.\n\n"
90
+ exit(1)
88
91
  end
89
92
 
90
93
  $:.unshift File.expand_path("lib")
@@ -11,11 +11,24 @@ require "fileutils"
11
11
 
12
12
  $:.unshift LIB = File.join(File.dirname(__FILE__), "..", "lib")
13
13
 
14
+ class Dep
15
+
16
+ # Override exit to allow the tests to keep running.
17
+ def exit(*attrs)
18
+ end
19
+ end
20
+
14
21
  class DependenciesTest < Test::Unit::TestCase
15
22
  def do_require
16
23
  load "dependencies.rb"
17
24
  end
18
25
 
26
+ def ensure_gem_home
27
+ gem_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "tmp"))
28
+
29
+ flunk "GEM_HOME should be #{gem_path}. Run with env GEM_HOME=#{gem_path}." unless gem_path == ENV["GEM_HOME"]
30
+ end
31
+
19
32
  def with_dependencies(deps)
20
33
  File.open("dependencies", "w") do |f|
21
34
  f.write(deps)
@@ -34,15 +47,25 @@ class DependenciesTest < Test::Unit::TestCase
34
47
  test "loads dependencies from ./vendor" do
35
48
  with_dependencies "bar" do
36
49
  do_require
50
+ assert_equal File.expand_path("vendor/bar/lib"), $:[1]
51
+ end
37
52
 
53
+ with_dependencies "bar 1.0" do
54
+ do_require
38
55
  assert_equal File.expand_path("vendor/bar/lib"), $:[1]
39
56
  end
40
57
  end
41
58
 
59
+ test "honors the version number for the vendor directory" do
60
+ with_dependencies "foo 2.0" do
61
+ do_require
62
+ assert_equal File.expand_path("vendor/foo-2.0/lib"), $:[1]
63
+ end
64
+ end
65
+
42
66
  test "add ./lib to the load path" do
43
67
  with_dependencies "" do
44
68
  do_require
45
-
46
69
  assert_equal File.expand_path("lib"), $:.first
47
70
  end
48
71
  end
@@ -54,6 +77,7 @@ class DependenciesTest < Test::Unit::TestCase
54
77
  end
55
78
 
56
79
  assert err.include?("Missing dependencies:\n\n foo 1.0")
80
+ assert err.include?("Run `dep list` to view the missing dependencies or `dep vendor --all` to try to solve them")
57
81
  end
58
82
  end
59
83
 
@@ -95,7 +119,6 @@ class DependenciesTest < Test::Unit::TestCase
95
119
  test "prints all dependencies" do
96
120
  with_dependencies "foo ~> 1.0\nbar" do
97
121
  out, err = dep "list"
98
-
99
122
  assert_equal "foo ~> 1.0\nbar\n", out
100
123
  end
101
124
  end
@@ -103,14 +126,12 @@ class DependenciesTest < Test::Unit::TestCase
103
126
  test "prints dependencies based on given environment" do
104
127
  with_dependencies "foo 1.0 (test)\nbar (development)\nbarz 2.0\nbaz 0.1 (test)" do
105
128
  out, err = dep "list test"
106
-
107
129
  assert_equal "foo 1.0 (test)\nbarz 2.0\nbaz 0.1 (test)\n", out
108
130
  end
109
131
  end
110
132
 
111
133
  test "complains when no dependencies file found" do
112
134
  out, err = dep "list"
113
-
114
135
  assert_equal "No dependencies file found.\n", err
115
136
  end
116
137
  end
@@ -121,7 +142,7 @@ class DependenciesTest < Test::Unit::TestCase
121
142
  end
122
143
 
123
144
  test "vendors dependencies" do
124
- with_dependencies "foobar 1.0 file://#{@dir}" do
145
+ with_dependencies "foobar file://#{@dir}" do
125
146
  out, err = dep "vendor foobar"
126
147
 
127
148
  assert File.exist?("vendor/foobar/lib/foobar.rb")
@@ -129,11 +150,24 @@ class DependenciesTest < Test::Unit::TestCase
129
150
  end
130
151
  end
131
152
 
153
+ test "vendors using RubyGems when given a version" do
154
+ ensure_gem_home
155
+
156
+ system "gem install foobaz-0.3.gem > /dev/null"
157
+
158
+ with_dependencies "foobaz 0.3" do
159
+ out, err = dep "vendor foobaz"
160
+
161
+ assert File.exist?("vendor/foobaz-0.3/lib/foobaz.rb")
162
+ assert !File.exist?("vendor/foobaz-0.3/.git")
163
+ end
164
+ end
165
+
132
166
  test "complains when no URL given" do
133
- with_dependencies "foobar 1.0" do
167
+ with_dependencies "foobar" do
134
168
  out, err = dep "vendor foobar"
135
169
 
136
- assert_match %r{Don't know where to vendor foobar from \(no URL given...\)}, err
170
+ assert_match %r{Don't know where to vendor foobar from \(no version or URL given...\)}, err
137
171
  end
138
172
  end
139
173
 
@@ -146,7 +180,7 @@ class DependenciesTest < Test::Unit::TestCase
146
180
  end
147
181
 
148
182
  test "vendors everything with --all" do
149
- with_dependencies "foobar 1.0 file://#{@dir}\nbarbar file://#{create_repo "barbar"}" do
183
+ with_dependencies "foobar file://#{@dir}\nbarbar file://#{create_repo "barbar"}" do
150
184
  out, err = dep "vendor --all"
151
185
 
152
186
  assert File.exist?("vendor/foobar/lib/foobar.rb")
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Janowski
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-07-21 00:00:00 -03:00
13
+ date: 2009-07-22 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,7 @@ files:
41
41
  - lib/dependencies/dep.rb
42
42
  - lib/dependencies.rb
43
43
  - test/dependencies_test.rb
44
+ - test/foobaz-0.3.gem
44
45
  has_rdoc: true
45
46
  homepage:
46
47
  licenses: []