isolate 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG.rdoc +4 -0
  2. data/README.rdoc +4 -9
  3. data/lib/isolate.rb +26 -16
  4. metadata +2 -2
@@ -1,3 +1,7 @@
1
+ === 1.7.1 / 2009-12-08
2
+
3
+ * Move to 1-phase activation. Deprecate Isolate.activate.
4
+
1
5
  === 1.7.0 / 2009-12-07
2
6
 
3
7
  * Activate gems even in passthrough mode.
@@ -193,15 +193,10 @@ the preinitializer:
193
193
  end
194
194
 
195
195
  Since this is in the preinitializer, Isolate will install and activate
196
- the fundamental gems before Rails loads.
197
-
198
- This is early enough in Rails' lifecycle that <tt>RAILS_ENV</tt> isn't
199
- set, so we need a way to activate gems for the current
200
- environment. Let's add one line to <tt>config/environment.rb</tt>,
201
- right below where <tt>boot.rb</tt> is required:
202
-
203
- require File.join(File.dirname(__FILE__), 'boot')
204
- Isolate.activate RAILS_ENV
196
+ the all gems before Rails loads. The current environment is determined
197
+ by looking at the <tt>ISOLATE_ENV</tt>, <tt>RAILS_ENV</tt>, or
198
+ <tt>RACK_ENV</tt> environment variable. If none are set,
199
+ <tt>"development"</tt> is the default.
205
200
 
206
201
  Pow. Isolated!
207
202
 
@@ -17,21 +17,20 @@ class Isolate
17
17
  end
18
18
 
19
19
  def matches_spec? spec
20
- self.name == spec.name and self.requirement.satisfied_by? spec.version
20
+ name == spec.name and requirement.satisfied_by? spec.version
21
21
  end
22
22
  end
23
23
 
24
- VERSION = "1.7.0" # :nodoc:
24
+ VERSION = "1.7.1" # :nodoc:
25
25
 
26
26
  attr_reader :entries # :nodoc:
27
27
  attr_reader :path # :nodoc:
28
28
 
29
- # Activate (and possibly install) gems for a specific
30
- # +environment+. This allows two-stage isolation, which is necessary
31
- # for stuff like Rails. See README.rdoc for a detailed example.
29
+ # Deprecated. This is no a no-op, and will be removed shortly.
32
30
 
33
31
  def self.activate environment
34
- instance.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."
35
34
  end
36
35
 
37
36
  # Declare an isolated RubyGems environment, installed in +path+. The
@@ -63,7 +62,7 @@ class Isolate
63
62
  end
64
63
 
65
64
  # Create a new Isolate instance. See Isolate.gems for the public
66
- # API. Don't use this constructor directly.
65
+ # API. You probably don't want to use this constructor directly.
67
66
 
68
67
  def initialize path, options = {}, &block
69
68
  @enabled = false
@@ -79,11 +78,24 @@ class Isolate
79
78
  instance_eval(&block) if block_given?
80
79
  end
81
80
 
82
- def activate environment = nil # :nodoc:
81
+ # Activate this set of isolated entries, respecting an optional
82
+ # +environment+. Points RubyGems to a separate repository, messes
83
+ # with paths, auto-installs gems (if necessary), activates
84
+ # everything, and removes any superfluous gem (again, if
85
+ # necessary). If +environment+ isn't specified, +ISOLATE_ENV+,
86
+ # +RAILS_ENV+, and +RACK_ENV+ are checked before falling back to
87
+ # <tt>"development"</tt>.
88
+
89
+ def activate environment = nil
83
90
  enable unless enabled?
84
91
 
85
- env = environment.to_s if environment
86
- install environment if install?
92
+ env = (environment ||
93
+ ENV["ISOLATE_ENV"] ||
94
+ ENV["RAILS_ENV"] ||
95
+ ENV["RACK_ENV"] ||
96
+ "development").to_s
97
+
98
+ install env if install?
87
99
 
88
100
  entries.each do |e|
89
101
  Gem.activate e.name, *e.requirement.as_list if e.matches? env
@@ -94,7 +106,7 @@ class Isolate
94
106
  self
95
107
  end
96
108
 
97
- def cleanup
109
+ def cleanup # :nodoc:
98
110
  return self if passthrough?
99
111
 
100
112
  activated = Gem.loaded_specs.values.map { |s| s.full_name }
@@ -115,7 +127,7 @@ class Isolate
115
127
  :version => e.version,
116
128
  :ignore => true,
117
129
  :executables => true,
118
- :install_dir => self.path).uninstall
130
+ :install_dir => path).uninstall
119
131
  end
120
132
  end
121
133
  end
@@ -207,13 +219,11 @@ class Isolate
207
219
  entry
208
220
  end
209
221
 
210
- def install environment = nil # :nodoc:
222
+ def install environment # :nodoc:
211
223
  return self if passthrough?
212
224
 
213
- env = environment.to_s if environment
214
-
215
225
  installable = entries.select do |e|
216
- !Gem.available?(e.name, *e.requirement.as_list) && e.matches?(env)
226
+ !Gem.available?(e.name, *e.requirement.as_list) && e.matches?(environment)
217
227
  end
218
228
 
219
229
  log "Isolating #{environment}..." unless installable.empty?
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.7.0
4
+ version: 1.7.1
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: 2009-12-07 00:00:00 -08:00
13
+ date: 2009-12-08 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency