spring 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8e020e7dc1eb3f27faa79634ad8c9ff4e9c1ddb
4
- data.tar.gz: 5bd55b0c1e659701f4cd61afaba2b854070bc482
3
+ metadata.gz: d4095a71b95759b8a4ed6a71b5ddcb5048aad506
4
+ data.tar.gz: 360837121b6655c0abc8fb88f28ce6b62f46a88e
5
5
  SHA512:
6
- metadata.gz: ebecedcb2e4a616615dc33a752e54a380f685e9d43227f67a5c3a0f29ae8c500df20ab75705778e13f2efa5c52d51f4ed682472eda7b12006e3720a762232dd9
7
- data.tar.gz: 349a6b90ba96409a80e90a14e5bc39d7057970d3a6a81eb8fe7e6c6b7cd48aebc7465d687ffd08b704a3977cc0c3405a72cc93521b022fd54ef7a13a154ba3e8
6
+ metadata.gz: 255ec2bc4edd38b0c1d609e16b8cc6d7d9f8bccdddff14e482f98202260e1dae3f7d766a56b47cb846973c443e45b67bac0ae1c8c3c830c9c9c0ed64486c6025
7
+ data.tar.gz: 3181e4b656a12b4094742647f6b7fe260d6f3f5acb0642bc39bfbfb83389a174a7434fa6ab355723a169cb2a2441793f02f46aa618a9ec87d7f9eccb9611ee71
@@ -6,4 +6,6 @@ rvm:
6
6
  env:
7
7
  - RAILS_VERSION="~> 3.2.0"
8
8
  - RAILS_VERSION="~> 4.0.0"
9
- - RAILS_VERSION="~> 4.1.0.beta1"
9
+ - RAILS_VERSION="~> 4.1.0.rc1"
10
+ before_script:
11
+ - travis_retry gem install rails --version "$RAILS_VERSION"
@@ -1,3 +1,15 @@
1
+ ## 1.1.2
2
+
3
+ * Detect old binstubs generated with Spring 1.0 and exit with an error.
4
+ This prevents a situation where you can get stuck in an infinite loop
5
+ of spring invocations.
6
+ * Avoid `warning: already initialized constant APP_PATH` when running
7
+ rails commands that do not use spring (e.g. `bin/rails server` would
8
+ emit this when you ^C to exit)
9
+ * Fix `reload!` in rails console
10
+ * Don't connect/disconnect the database if there are no connections
11
+ configured. Issue #256.
12
+
1
13
  ## 1.1.1
2
14
 
3
15
  * Fix `$0` so that it is no longer prefixed with "spring ", as doing
data/README.md CHANGED
@@ -209,6 +209,7 @@ to pick up the changes):
209
209
 
210
210
  * [spring-commands-rspec](https://github.com/jonleighton/spring-commands-rspec)
211
211
  * [spring-commands-cucumber](https://github.com/jonleighton/spring-commands-cucumber)
212
+ * [spring-commands-spinach](https://github.com/jvanbaarsen/spring-commands-spinach)
212
213
  * [spring-commands-testunit](https://github.com/jonleighton/spring-commands-testunit) - useful for
213
214
  running `Test::Unit` tests on Rails 3, since only Rails 4 allows you
214
215
  to use `rake test path/to/test` to run a particular test/directory.
data/bin/spring CHANGED
@@ -1,5 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ if defined?(Spring)
4
+ $stderr.puts "You've tried to invoke Spring when it's already loaded (i.e. the Spring " \
5
+ "constant is defined)."
6
+ $stderr.puts
7
+ $stderr.puts "This is probably because you generated binstubs with " \
8
+ "Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve " \
9
+ "this, upgrade your bundle to the latest Spring version and then run " \
10
+ "`bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time " \
11
+ "step necessary to upgrade from 1.0 to 1.1."
12
+ $stderr.puts
13
+ $stderr.puts "Here's the backtrace:"
14
+ $stderr.puts
15
+ $stderr.puts caller
16
+ exit 1
17
+ end
18
+
3
19
  if defined?(Gem)
4
20
  if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.1.0")
5
21
  warn "Warning: You're using Rubygems #{Gem::VERSION} with Spring. " \
@@ -91,7 +91,9 @@ module Spring
91
91
 
92
92
  require Spring.application_root_path.join("config", "environment")
93
93
 
94
+ @original_cache_classes = Rails.application.config.cache_classes
94
95
  Rails.application.config.cache_classes = false
96
+
95
97
  disconnect_database
96
98
 
97
99
  @preloaded = :success
@@ -161,9 +163,13 @@ module Spring
161
163
  # Load in the current env vars, except those which *were* changed when spring started
162
164
  env.each { |k, v| ENV[k] ||= v }
163
165
 
164
- # requiring is faster, and we don't need constant reloading in this process
165
- ActiveSupport::Dependencies.mechanism = :require
166
- Rails.application.config.cache_classes = true
166
+ # requiring is faster, so if config.cache_classes was true in
167
+ # the environment's config file, then we can respect that from
168
+ # here on as we no longer need constant reloading.
169
+ if @original_cache_classes
170
+ ActiveSupport::Dependencies.mechanism = :require
171
+ Rails.application.config.cache_classes = true
172
+ end
167
173
 
168
174
  connect_database
169
175
  srand
@@ -246,11 +252,11 @@ module Spring
246
252
  end
247
253
 
248
254
  def disconnect_database
249
- ActiveRecord::Base.remove_connection if defined?(ActiveRecord::Base)
255
+ ActiveRecord::Base.remove_connection if active_record_configured?
250
256
  end
251
257
 
252
258
  def connect_database
253
- ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
259
+ ActiveRecord::Base.establish_connection if active_record_configured?
254
260
  end
255
261
 
256
262
  # This feels very naughty
@@ -289,5 +295,11 @@ module Spring
289
295
  [STDOUT, STDERR].each { |stream| stream.reopen(spring_env.log_file) }
290
296
  STDIN.reopen("/dev/null")
291
297
  end
298
+
299
+ private
300
+
301
+ def active_record_configured?
302
+ defined?(ActiveRecord::Base) && ActiveRecord::Base.configurations.any?
303
+ end
292
304
  end
293
305
  end
@@ -82,6 +82,8 @@ module Spring
82
82
  Process.kill('TERM', pid)
83
83
  Process.wait(pid)
84
84
  end
85
+ rescue Errno::ESRCH, Errno::ECHILD
86
+ # Don't care
85
87
  end
86
88
 
87
89
  private
@@ -25,6 +25,7 @@ module Spring
25
25
  require "spring/configuration"
26
26
  ARGV.shift
27
27
  load Dir.glob(Spring.application_root_path.join("{bin,script}/rails")).first
28
+ exit
28
29
  end
29
30
  end
30
31
  end
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -263,13 +263,13 @@ CODE
263
263
  end
264
264
 
265
265
  test "runner command sets Rails environment from command-line options" do
266
- assert_success "bin/rails runner -e production 'puts Rails.env'", stdout: "production"
267
- assert_success "bin/rails runner --environment=production 'puts Rails.env'", stdout: "production"
266
+ assert_success "bin/rails runner -e test 'puts Rails.env'", stdout: "test"
267
+ assert_success "bin/rails runner --environment=test 'puts Rails.env'", stdout: "test"
268
268
  end
269
269
 
270
270
  test "forcing rails env via environment variable" do
271
- app.env['RAILS_ENV'] = 'production'
272
- assert_success "bin/rake -p 'Rails.env'", stdout: "production"
271
+ app.env['RAILS_ENV'] = 'test'
272
+ assert_success "bin/rake -p 'Rails.env'", stdout: "test"
273
273
  end
274
274
 
275
275
  test "setting env vars with rake" do
@@ -23,7 +23,7 @@ module Spring
23
23
  end
24
24
 
25
25
  def bundles_spring?
26
- version >= Gem::Version.new("4.1.0.beta1")
26
+ version.segments.take(2) == [4, 1] || version > Gem::Version.new("4.1")
27
27
  end
28
28
 
29
29
  def major
@@ -33,6 +33,10 @@ module Spring
33
33
  def minor
34
34
  version.segments[1]
35
35
  end
36
+
37
+ def to_s
38
+ version.to_s
39
+ end
36
40
  end
37
41
 
38
42
  class Application
@@ -216,17 +220,25 @@ module Spring
216
220
  end
217
221
  end
218
222
 
219
- def run!(*args)
220
- artifacts = run(*args)
221
- unless artifacts[:status].success?
223
+ def run!(command, options = {})
224
+ attempts = (options.delete(:retry) || 0) + 1
225
+ artifacts = nil
226
+
227
+ until attempts == 0 || artifacts && artifacts[:status].success?
228
+ artifacts = run(command, options)
229
+ attempts -= 1
230
+ end
231
+
232
+ if artifacts[:status].success?
233
+ artifacts
234
+ else
222
235
  raise "command failed\n\n#{debug(artifacts)}"
223
236
  end
224
- artifacts
225
237
  end
226
238
 
227
239
  def bundle
228
- run! "(gem list bundler | grep bundler) || gem install bundler", timeout: nil
229
- run! "bundle update", timeout: nil
240
+ run! "(gem list bundler | grep bundler) || gem install bundler", timeout: nil, retry: 2
241
+ run! "bundle update --retry=2", timeout: nil
230
242
  end
231
243
 
232
244
  private
@@ -270,10 +282,13 @@ module Spring
270
282
  system("gem list rails --installed --version '#{version_constraint}' || " \
271
283
  "gem install rails --clear-sources --source http://rubygems.org --version '#{version_constraint}'")
272
284
 
285
+ @version = RailsVersion.new(`ruby -e 'puts Gem::Specification.find_by_name("rails", "#{version_constraint}").version'`.chomp)
286
+
273
287
  skips = %w(--skip-bundle --skip-javascript --skip-sprockets)
274
288
  skips << "--skip-spring" if version.bundles_spring?
275
289
 
276
- system("rails '_#{version_constraint}_' new #{application.root} #{skips.join(' ')}")
290
+ system("rails _#{version}_ new #{application.root} #{skips.join(' ')}")
291
+ raise "application generation failed" unless application.exists?
277
292
 
278
293
  FileUtils.mkdir_p(application.gem_home)
279
294
  FileUtils.mkdir_p(application.user_home)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spring
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Leighton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-09 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport