polyamory 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/polyamory.rb +26 -13
  2. metadata +22 -39
data/lib/polyamory.rb CHANGED
@@ -137,7 +137,7 @@ class Polyamory
137
137
  'spec'
138
138
  elsif file_exists? '.rspec'
139
139
  'rspec'
140
- elsif helper.exist?
140
+ elsif file_exists? helper
141
141
  File.open(helper) do |file|
142
142
  while file.gets
143
143
  return $&.downcase if $_ =~ /\bR?Spec\b/
@@ -167,7 +167,7 @@ class Polyamory
167
167
 
168
168
  def prepare_cmdline(args)
169
169
  args = args.map { |p| p.to_s }
170
- args = %w[bundle exec] + args if args.first != 'polyamory' and bundler?
170
+ args = %w[bundle exec] + args if bundler?
171
171
  args
172
172
  end
173
173
 
@@ -175,25 +175,38 @@ class Polyamory
175
175
  args = prepare_cmdline(args)
176
176
  puts args.join(' ')
177
177
 
178
- # TODO: hack; make this configurable, use bundler
179
- with_rubyopt(args.first == 'polyamory' ? '-rubygems' : nil) do
180
- if many
181
- system(*args)
182
- exit $?.exitstatus unless $?.success?
183
- else
184
- exec(*args)
178
+ unless noop?
179
+ # TODO: hack; make this configurable, use bundler
180
+ with_rubyopt(!bundler? ? '-rubygems' : nil) do
181
+ with_rubylib('lib', args.include?('polyamory') ? 'test' : nil) do
182
+ if many
183
+ system(*args)
184
+ exit $?.exitstatus unless $?.success?
185
+ else
186
+ exec(*args)
187
+ end
188
+ end
185
189
  end
186
- end unless noop?
190
+ end
187
191
  end
188
192
 
189
193
  def with_rubyopt(value)
190
- old_value = ENV['RUBYOPT']
191
- ENV['RUBYOPT'] = "#{value} #{old_value}"
194
+ with_env('RUBYOPT', "#{value} %s") { yield }
195
+ end
196
+
197
+ def with_rubylib(*values)
198
+ value = values.flatten.compact.join(':')
199
+ with_env('RUBYLIB', "#{value}:%s") { yield }
200
+ end
201
+
202
+ def with_env(key, value)
203
+ old_value = ENV[key]
204
+ ENV[key] = value % old_value
192
205
 
193
206
  begin
194
207
  yield
195
208
  ensure
196
- ENV['RUBYOPT'] = old_value
209
+ ENV[key] = old_value
197
210
  end
198
211
  end
199
212
 
metadata CHANGED
@@ -1,66 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: polyamory
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 2
9
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
12
- - "Mislav Marohni\xC4\x87"
7
+ authors:
8
+ - Mislav Marohnić
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-12-30 00:00:00 +01:00
18
- default_executable:
12
+ date: 2011-04-25 00:00:00.000000000Z
19
13
  dependencies: []
20
-
21
14
  description: A tool that knows how to run your tests regardless of framework
22
15
  email: mislav.marohnic@gmail.com
23
- executables:
16
+ executables:
24
17
  - polyamory
25
18
  extensions: []
26
-
27
19
  extra_rdoc_files: []
28
-
29
- files:
20
+ files:
30
21
  - bin/polyamory
31
22
  - lib/polyamory.rb
32
23
  - README.md
33
- has_rdoc: true
34
24
  homepage: http://github.com/mislav/polyamory
35
25
  licenses: []
36
-
37
26
  post_install_message:
38
27
  rdoc_options: []
39
-
40
- require_paths:
28
+ require_paths:
41
29
  - lib
42
- required_ruby_version: !ruby/object:Gem::Requirement
30
+ required_ruby_version: !ruby/object:Gem::Requirement
43
31
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- segments:
48
- - 0
49
- version: "0"
50
- required_rubygems_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
37
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- version: "0"
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
58
42
  requirements: []
59
-
60
43
  rubyforge_project:
61
- rubygems_version: 1.3.7
44
+ rubygems_version: 1.7.2
62
45
  signing_key:
63
46
  specification_version: 3
64
47
  summary: Runs your tests
65
48
  test_files: []
66
-
49
+ has_rdoc: false