isolate 1.7.1 → 1.8.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.
- data/CHANGELOG.rdoc +7 -0
- data/README.rdoc +1 -22
- data/lib/isolate.rb +10 -28
- data/test/test_isolate.rb +0 -15
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
=== 1.8.0 / 2010-01-05
|
|
2
|
+
|
|
3
|
+
* Make build args forgive non-Array input.
|
|
4
|
+
* OMG, heaven forbid I use math.
|
|
5
|
+
* Remove deprecated Isolate.activate method.
|
|
6
|
+
* Remove passthrough, that's what conditionals are for.
|
|
7
|
+
|
|
1
8
|
=== 1.7.1 / 2009-12-08
|
|
2
9
|
|
|
3
10
|
* Move to 1-phase activation. Deprecate Isolate.activate.
|
data/README.rdoc
CHANGED
|
@@ -64,27 +64,6 @@ Unsurprisingly, the <tt>mocha</tt> gem will only be activated in the
|
|
|
64
64
|
example below for an example of how to use <tt>RAILS_ENV</tt> to set
|
|
65
65
|
your environment.
|
|
66
66
|
|
|
67
|
-
=== Passthrough
|
|
68
|
-
|
|
69
|
-
Sometimes (especially on systems with alternative Gem management like
|
|
70
|
-
Heroku) you want Isolate to sit in a corner, be very, very quiet, and
|
|
71
|
-
let all calls pass right through.
|
|
72
|
-
|
|
73
|
-
If you want to make Isolate a complete no-op in production, and your
|
|
74
|
-
environment sets <tt>RACK_ENV</tt>, you could do something like this:
|
|
75
|
-
|
|
76
|
-
Isolate.gems "vendor/isolated" do
|
|
77
|
-
passthrough { %w(beta production).include? ENV["RACK_ENV"] }
|
|
78
|
-
|
|
79
|
-
# the rest of your gems...
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
...and nothing will get isolated. The block should evaluate to
|
|
83
|
-
<tt>true</tt> if that's what you want, and it's only evaluated
|
|
84
|
-
once. This is run really early, so don't blindly assume things like
|
|
85
|
-
the <tt>RAILS_ENV</tt> constant are set. Check your environment for
|
|
86
|
-
details.
|
|
87
|
-
|
|
88
67
|
=== Options
|
|
89
68
|
|
|
90
69
|
Any trailing hash args to <tt>gem</tt> are passed to
|
|
@@ -95,7 +74,7 @@ exceptions, <tt>:source</tt> and <tt>:args</tt>.
|
|
|
95
74
|
gem "jbarnette-johnson", :source => "http://gems.github.com"
|
|
96
75
|
|
|
97
76
|
# pass gem install args (the part after the '--')
|
|
98
|
-
gem "
|
|
77
|
+
gem "agem", :args => "--no-blah"
|
|
99
78
|
|
|
100
79
|
=== Installing Isolated Gems
|
|
101
80
|
|
data/lib/isolate.rb
CHANGED
|
@@ -21,18 +21,11 @@ class Isolate
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
VERSION = "1.
|
|
24
|
+
VERSION = "1.8.0" # :nodoc:
|
|
25
25
|
|
|
26
26
|
attr_reader :entries # :nodoc:
|
|
27
27
|
attr_reader :path # :nodoc:
|
|
28
28
|
|
|
29
|
-
# Deprecated. This is no a no-op, and will be removed shortly.
|
|
30
|
-
|
|
31
|
-
def self.activate environment
|
|
32
|
-
puts "DEPRECATED: Isolate.activate is a no-op now. " +
|
|
33
|
-
"It'll be removed in v1.8. See the README for details."
|
|
34
|
-
end
|
|
35
|
-
|
|
36
29
|
# Declare an isolated RubyGems environment, installed in +path+. The
|
|
37
30
|
# block given will be <tt>instance_eval</tt>ed, see Isolate#gem and
|
|
38
31
|
# Isolate#environment for the sort of stuff you can do.
|
|
@@ -68,7 +61,6 @@ class Isolate
|
|
|
68
61
|
@enabled = false
|
|
69
62
|
@entries = []
|
|
70
63
|
@environments = []
|
|
71
|
-
@passthrough = false
|
|
72
64
|
@path = File.expand_path path
|
|
73
65
|
|
|
74
66
|
@install = options.fetch :install, true
|
|
@@ -107,18 +99,17 @@ class Isolate
|
|
|
107
99
|
end
|
|
108
100
|
|
|
109
101
|
def cleanup # :nodoc:
|
|
110
|
-
return self if passthrough?
|
|
111
|
-
|
|
112
102
|
activated = Gem.loaded_specs.values.map { |s| s.full_name }
|
|
113
103
|
extra = Gem.source_index.gems.values.sort.reject { |spec|
|
|
114
104
|
activated.include? spec.full_name or
|
|
115
105
|
entries.any? { |e| e.matches_spec? spec }
|
|
116
106
|
}
|
|
117
107
|
|
|
118
|
-
|
|
108
|
+
return if extra.empty?
|
|
119
109
|
|
|
120
|
-
padding = extra.size.
|
|
110
|
+
padding = Math.log10(extra.size).to_i + 1
|
|
121
111
|
format = "[%0#{padding}d/%s] Nuking %s."
|
|
112
|
+
|
|
122
113
|
extra.each_with_index do |e, i|
|
|
123
114
|
log format % [i + 1, extra.size, e.full_name]
|
|
124
115
|
|
|
@@ -137,7 +128,7 @@ class Isolate
|
|
|
137
128
|
end
|
|
138
129
|
|
|
139
130
|
def disable # :nodoc:
|
|
140
|
-
return self if
|
|
131
|
+
return self if not enabled?
|
|
141
132
|
|
|
142
133
|
ENV["GEM_PATH"] = @old_gem_path
|
|
143
134
|
ENV["GEM_HOME"] = @old_gem_home
|
|
@@ -154,7 +145,7 @@ class Isolate
|
|
|
154
145
|
end
|
|
155
146
|
|
|
156
147
|
def enable # :nodoc:
|
|
157
|
-
return self if
|
|
148
|
+
return self if enabled?
|
|
158
149
|
|
|
159
150
|
@old_gem_path = ENV["GEM_PATH"]
|
|
160
151
|
@old_gem_home = ENV["GEM_HOME"]
|
|
@@ -220,16 +211,15 @@ class Isolate
|
|
|
220
211
|
end
|
|
221
212
|
|
|
222
213
|
def install environment # :nodoc:
|
|
223
|
-
return self if passthrough?
|
|
224
|
-
|
|
225
214
|
installable = entries.select do |e|
|
|
226
215
|
!Gem.available?(e.name, *e.requirement.as_list) && e.matches?(environment)
|
|
227
216
|
end
|
|
228
217
|
|
|
229
|
-
|
|
218
|
+
return self if installable.empty?
|
|
230
219
|
|
|
231
|
-
padding = installable.size.
|
|
220
|
+
padding = Math.log10(installable.size).to_i + 1
|
|
232
221
|
format = "[%0#{padding}d/%s] Isolating %s (%s)."
|
|
222
|
+
|
|
233
223
|
installable.each_with_index do |e, i|
|
|
234
224
|
log format % [i + 1, installable.size, e.name, e.requirement]
|
|
235
225
|
|
|
@@ -242,7 +232,7 @@ class Isolate
|
|
|
242
232
|
Gem.sources = Array(source) if source
|
|
243
233
|
installer = Gem::DependencyInstaller.new options
|
|
244
234
|
|
|
245
|
-
Gem::Command.build_args = args if args
|
|
235
|
+
Gem::Command.build_args = Array(args) if args
|
|
246
236
|
installer.install e.name, e.requirement
|
|
247
237
|
|
|
248
238
|
Gem.sources = old
|
|
@@ -262,14 +252,6 @@ class Isolate
|
|
|
262
252
|
$stderr.puts s if verbose?
|
|
263
253
|
end
|
|
264
254
|
|
|
265
|
-
def passthrough &block # :nodoc:
|
|
266
|
-
@passthrough = yield
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
def passthrough? # :nodoc:
|
|
270
|
-
@passthrough
|
|
271
|
-
end
|
|
272
|
-
|
|
273
255
|
def verbose? # :nodoc:
|
|
274
256
|
@verbose
|
|
275
257
|
end
|
data/test/test_isolate.rb
CHANGED
|
@@ -209,21 +209,6 @@ class TestIsolate < MiniTest::Unit::TestCase
|
|
|
209
209
|
i = Isolate.new "foo/gems", :install => false
|
|
210
210
|
refute i.cleanup?, "no install, no cleanup"
|
|
211
211
|
end
|
|
212
|
-
|
|
213
|
-
def test_passthrough
|
|
214
|
-
refute @isolate.passthrough?
|
|
215
|
-
|
|
216
|
-
@isolate.passthrough { true }
|
|
217
|
-
assert @isolate.passthrough?
|
|
218
|
-
|
|
219
|
-
idx = Gem.source_index.dup
|
|
220
|
-
@isolate.activate
|
|
221
|
-
assert_equal idx, Gem.source_index
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
@isolate.passthrough { false }
|
|
225
|
-
refute @isolate.passthrough?
|
|
226
|
-
end
|
|
227
212
|
end
|
|
228
213
|
|
|
229
214
|
module BrutalStub
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: isolate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Barnette
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date:
|
|
13
|
+
date: 2010-01-05 00:00:00 -08:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
@@ -31,7 +31,7 @@ dependencies:
|
|
|
31
31
|
requirements:
|
|
32
32
|
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: 2.
|
|
34
|
+
version: 2.4.0
|
|
35
35
|
version:
|
|
36
36
|
description: |-
|
|
37
37
|
Isolate is a very simple RubyGems sandbox. It provides a way to
|