isolate 1.9.3 → 1.10.0

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 (3) hide show
  1. data/CHANGELOG.rdoc +4 -0
  2. data/lib/isolate.rb +35 -14
  3. metadata +4 -4
@@ -1,3 +1,7 @@
1
+ === 1.10.0 / 2010-03-15
2
+
3
+ * Speculative now! shortcut.
4
+
1
5
  === 1.9.3 / 2010-02-24
2
6
 
3
7
  * Passing <tt>:file => true</tt> to Isolate.gems will try +Isolate+
@@ -8,7 +8,7 @@ require "rubygems/requirement"
8
8
 
9
9
  class Isolate
10
10
 
11
- VERSION = "1.9.3" # :nodoc:
11
+ VERSION = "1.10.0" # :nodoc:
12
12
 
13
13
  # An isolated Gem, with requirement, environment restrictions, and
14
14
  # installation options. Internal use only.
@@ -46,7 +46,12 @@ class Isolate
46
46
  #
47
47
  # Option defaults:
48
48
  #
49
- # { :cleanup => true, :install => true, :verbose => true }
49
+ # {
50
+ # :cleanup => true,
51
+ # :install => true,
52
+ # :system => false,
53
+ # :verbose => true
54
+ # }
50
55
 
51
56
  def self.gems path, options = {}, &block
52
57
  @@instance = new path, options, &block
@@ -59,6 +64,10 @@ class Isolate
59
64
  @@instance
60
65
  end
61
66
 
67
+ def self.now! #:nodoc:
68
+ gems "tmp/gems", :file => true, :system => true
69
+ end
70
+
62
71
  # Poke RubyGems, we've probably monkeyed with a bunch of paths and
63
72
  # suchlike. Clears paths, loaded specs, and source indexes.
64
73
 
@@ -78,6 +87,7 @@ class Isolate
78
87
  @path = File.expand_path path
79
88
 
80
89
  @install = options.fetch :install, true
90
+ @system = options.fetch :system, false
81
91
  @verbose = options.fetch :verbose, true
82
92
  @cleanup = @install && options.fetch(:cleanup, true)
83
93
 
@@ -114,9 +124,11 @@ class Isolate
114
124
 
115
125
  def cleanup # :nodoc:
116
126
  activated = Gem.loaded_specs.values.map { |s| s.full_name }
117
- extra = Gem.source_index.gems.values.sort.reject { |spec|
118
- activated.include? spec.full_name or
119
- entries.any? { |e| e.matches_spec? spec }
127
+
128
+ extra = Gem.source_index.gems.values.sort.reject { |spec|
129
+ !spec.loaded_from.include?(path) or
130
+ activated.include? spec.full_name or
131
+ entries.any? { |e| e.matches? spec }
120
132
  }
121
133
 
122
134
  return if extra.empty?
@@ -168,22 +180,27 @@ class Isolate
168
180
  @old_ruby_opt = ENV["RUBYOPT"]
169
181
  @old_load_path = $LOAD_PATH.dup
170
182
 
171
- $LOAD_PATH.reject! do |p|
172
- p != File.dirname(__FILE__) &&
173
- Gem.path.any? { |gp| p.include?(gp) }
174
- end
183
+ ENV["GEM_HOME"] = path
175
184
 
176
- # HACK: Gotta keep isolate explicitly in the LOAD_PATH in
177
- # subshells, and the only way I can think of to do that is by
178
- # abusing RUBYOPT.
185
+ unless system?
186
+ $LOAD_PATH.reject! do |p|
187
+ p != File.dirname(__FILE__) &&
188
+ Gem.path.any? { |gp| p.include?(gp) }
189
+ end
179
190
 
180
- ENV["RUBYOPT"] = "#{ENV['RUBYOPT']} -I#{File.dirname(__FILE__)}"
181
- ENV["GEM_PATH"] = ENV["GEM_HOME"] = path
191
+ # HACK: Gotta keep isolate explicitly in the LOAD_PATH in
192
+ # subshells, and the only way I can think of to do that is by
193
+ # abusing RUBYOPT.
194
+
195
+ ENV["RUBYOPT"] = "#{ENV['RUBYOPT']} -I#{File.dirname(__FILE__)}"
196
+ ENV["GEM_PATH"] = path
197
+ end
182
198
 
183
199
  bin = File.join path, "bin"
184
200
  ENV["PATH"] = [bin, ENV["PATH"]].join File::PATH_SEPARATOR
185
201
 
186
202
  self.class.refresh
203
+ Gem.path.unshift path if system?
187
204
 
188
205
  @enabled = true
189
206
 
@@ -268,6 +285,10 @@ class Isolate
268
285
  $stderr.puts s if verbose?
269
286
  end
270
287
 
288
+ def system? # :nodoc:
289
+ @system
290
+ end
291
+
271
292
  def verbose? # :nodoc:
272
293
  @verbose
273
294
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 9
8
- - 3
9
- version: 1.9.3
7
+ - 10
8
+ - 0
9
+ version: 1.10.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Barnette
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-02-24 00:00:00 -08:00
18
+ date: 2010-03-15 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency