benschwarz-smoke 0.5.2 → 0.5.3

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 3
3
3
  :major: 0
4
4
  :minor: 5
data/dependencies CHANGED
@@ -4,4 +4,4 @@ json 1.1.3
4
4
  fakeweb 1.2.5
5
5
  crack 0.1.1
6
6
  moneta git://github.com/benschwarz/moneta.git
7
- dependencies git://github.com/djanowski/dependencies.git
7
+ dependencies git://github.com/benschwarz/dependencies.git
@@ -58,8 +58,8 @@ protected
58
58
  end
59
59
 
60
60
  def deps
61
- @deps ||= Dep.new(File.read("dependencies"))
62
- rescue Errno::ENOENT
61
+ @deps ||= Dep.new(File.read(Dep.dependencies_file))
62
+ rescue Dep::DependenciesFileNotFound
63
63
  flunk "No dependencies file found."
64
64
  end
65
65
 
@@ -11,5 +11,5 @@ Gem::Specification.new do |s|
11
11
 
12
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
- s.add_dependency("wycats-thor", "~> 0.11")
14
+ s.add_dependency("thor", "~> 0.11")
15
15
  end
@@ -23,5 +23,5 @@ Gem::Specification.new do |s|
23
23
  "test/vendor/baz-1.0/**/*"
24
24
  ].inspect %>
25
25
 
26
- s.add_dependency("wycats-thor", "~> 0.11")
26
+ s.add_dependency("thor", "~> 0.11")
27
27
  end
@@ -1,4 +1,20 @@
1
+ require "pathname"
2
+
1
3
  class Dep
4
+ DependenciesFileNotFound = Class.new(StandardError)
5
+
6
+ def self.dependencies_file
7
+ current = Pathname.new(Dir.pwd)
8
+
9
+ until current.root?
10
+ filename = current.join("dependencies")
11
+ return filename if filename.exist? and filename.file?
12
+ current = current.parent
13
+ end
14
+
15
+ raise DependenciesFileNotFound
16
+ end
17
+
2
18
  class Dependency
3
19
  attr :name
4
20
  attr :version
@@ -62,7 +78,7 @@ class Dep
62
78
  @missing = []
63
79
 
64
80
  dependencies.each_line do |line|
65
- next unless line =~ /^([\w\-_]+) ?([<~=> \d\.]+)?(?: \(([\w, ]+)\))?(?: ([a-z]+:\/\/.+?))?$/
81
+ next unless line =~ /^([\w\-_]+)\s*([<~=>]* ?[\d\.]+)?\s*(?: \(([\w, ]+)\))?\s*(?: ([a-z]+:\/\/.+?))?\s*$/
66
82
  @dependencies << Dependency.new($1, $2, $3, $4)
67
83
  end
68
84
  end
@@ -2,4 +2,5 @@ $:.unshift(File.expand_path(File.dirname(__FILE__)))
2
2
 
3
3
  require "dependencies/dep"
4
4
 
5
- Dep.new(File.read("dependencies")).require(ENV["RACK_ENV"].to_s)
5
+ Dep.new(File.read(Dep.dependencies_file)).require(ENV["RACK_ENV"].to_s)
6
+
@@ -9,6 +9,8 @@ require "fileutils"
9
9
 
10
10
  $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
11
11
 
12
+ DEP_BINARY = File.expand_path(File.join(File.dirname(__FILE__), "..", "bin", "dep"))
13
+
12
14
  class Dep
13
15
  # Override exit to allow the tests to keep running.
14
16
  def exit(*attrs)
@@ -104,7 +106,7 @@ class DependenciesTest < Test::Unit::TestCase
104
106
  def dep(args = nil)
105
107
  out, err = nil
106
108
 
107
- Open3.popen3("#{File.expand_path(File.join("../bin/dep"))} #{args}") do |stdin, stdout, stderr|
109
+ Open3.popen3("#{DEP_BINARY} #{args}") do |stdin, stdout, stderr|
108
110
  out = stdout.read
109
111
  err = stderr.read
110
112
  end
@@ -127,10 +129,29 @@ class DependenciesTest < Test::Unit::TestCase
127
129
  end
128
130
  end
129
131
 
132
+ test "allow for arbitrary spaces in the declarations" do
133
+ with_dependencies "foo 1.0 (test)\nbar >= 3.1 (test)\nbaz 2.0 (development)" do
134
+ out, err = dep "list test"
135
+ assert_equal "foo 1.0 (test)\nbar >= 3.1 (test)\n", out
136
+ end
137
+ end
138
+
130
139
  test "complains when no dependencies file found" do
131
140
  out, err = dep "list"
132
141
  assert_equal "No dependencies file found.\n", err
133
142
  end
143
+
144
+ test "search recursively for the dependencies file" do
145
+ with_dependencies "foo 1.0 (test)\nbar (development)\nbarz 2.0\nbaz 0.1 (test)" do
146
+ FileUtils.rm_rf("dep-test")
147
+ FileUtils.mkdir("dep-test")
148
+ Dir.chdir("dep-test") do
149
+ out, err = dep "list test"
150
+ assert_equal "foo 1.0 (test)\nbarz 2.0\nbaz 0.1 (test)\n", out
151
+ end
152
+ FileUtils.rm_rf("dep-test")
153
+ end
154
+ end
134
155
  end
135
156
 
136
157
  context "vendor" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benschwarz-smoke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Schwarz