spring 1.4.2 → 1.4.3

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: e18903803d3b81716563a8dcbf07b7d02bf347e3
4
- data.tar.gz: 6a3a2292025ecbe21712d9874ccd4f794f626816
3
+ metadata.gz: f9ab248b060de48656183c39be797c8eb377d1eb
4
+ data.tar.gz: 94bb1ce1cd992afa8930576f76a7c3d6678d9b5e
5
5
  SHA512:
6
- metadata.gz: 3506bd8902272fbc7bfc1a793bda37d56c6e3e5041fc4c26856f6e68c368249f430ed5f822d15cbf47e22677600697b9a79fbb9520a434911a4cbf21e0f0e688
7
- data.tar.gz: 458324cc17f33e8df4945a0e8c67d13996231279233812713a71929cd4a8b8bab3991f8225b83ab8ebaa5521d9550083411aa0450adf00f45514b20923759961
6
+ metadata.gz: 87bbd18c5b6e8370a741472faa21d7933541227307be14306d050244e2cd523d81ffa88afefcd015419c8a2fd54edcfd394192d7ab02af76c3c718826f536f28
7
+ data.tar.gz: 1048881582aa1e47d94602144911752f208e57ae956d225f93b33310851074269f34785ce05dbf8deb19590fe084a617a238a49734de1f5cfba5858d18636251
@@ -48,6 +48,12 @@ CODE
48
48
 
49
49
  OLD_BINSTUB = %{if !Process.respond_to?(:fork) || Gem::Specification.find_all_by_name("spring").empty?}
50
50
 
51
+ BINSTUB_VARIATIONS = Regexp.union [
52
+ %{begin\n load File.expand_path("../spring", __FILE__)\nrescue LoadError\nend\n},
53
+ %{begin\n load File.expand_path('../spring', __FILE__)\nrescue LoadError\nend\n},
54
+ LOADER
55
+ ]
56
+
51
57
  class Item
52
58
  attr_reader :command, :existing
53
59
 
@@ -74,8 +80,12 @@ CODE
74
80
  fallback = nil if fallback.include?("exec")
75
81
  generate(fallback)
76
82
  status "upgraded"
77
- elsif existing =~ /load .*spring/
83
+ elsif existing.include?(LOADER)
78
84
  status "spring already present"
85
+ elsif existing =~ BINSTUB_VARIATIONS
86
+ upgraded = existing.sub(BINSTUB_VARIATIONS, LOADER)
87
+ File.write(command.binstub, upgraded)
88
+ status "upgraded"
79
89
  else
80
90
  head, shebang, tail = existing.partition(SHEBANG)
81
91
 
@@ -110,7 +120,7 @@ CODE
110
120
 
111
121
  def remove
112
122
  if existing
113
- File.write(command.binstub, existing.sub(LOADER, ""))
123
+ File.write(command.binstub, existing.sub(BINSTUB_VARIATIONS, ""))
114
124
  status "spring removed"
115
125
  end
116
126
  end
@@ -119,7 +129,7 @@ CODE
119
129
  attr_reader :bindir, :items
120
130
 
121
131
  def self.description
122
- "Generate spring based binstubs. Use --all to generate a binstub for all known commands."
132
+ "Generate spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert."
123
133
  end
124
134
 
125
135
  def self.rails_command
@@ -208,6 +208,11 @@ module Spring
208
208
  assert_success "bin/rake -T", stdout: "rake db:migrate"
209
209
  end
210
210
 
211
+ test "binstub remove all" do
212
+ assert_success "bin/spring binstub --remove --all"
213
+ refute File.exist?(app.path("bin/spring"))
214
+ end
215
+
211
216
  test "binstub when spring gem is missing" do
212
217
  without_gem "spring-#{Spring::VERSION}" do
213
218
  File.write(app.gemfile, app.gemfile.read.gsub(/gem 'spring.*/, ""))
@@ -224,7 +229,7 @@ module Spring
224
229
  end
225
230
  end
226
231
 
227
- test "binstub upgrade" do
232
+ test "binstub upgrade with old binstub" do
228
233
  File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
229
234
  #!/usr/bin/env ruby
230
235
 
@@ -269,6 +274,93 @@ module Spring
269
274
  assert_equal expected, app.path("bin/rails").read
270
275
  end
271
276
 
277
+ test "binstub upgrade with new binstub variations" do
278
+ # older variation with double quotes
279
+ File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
280
+ #!/usr/bin/env ruby
281
+ begin
282
+ load File.expand_path("../spring", __FILE__)
283
+ rescue LoadError
284
+ end
285
+ require 'bundler/setup'
286
+ load Gem.bin_path('rake', 'rake')
287
+ RUBY
288
+
289
+ # newer variation with single quotes
290
+ File.write(app.path("bin/rails"), <<-RUBY.strip_heredoc)
291
+ #!/usr/bin/env ruby
292
+ begin
293
+ load File.expand_path('../spring', __FILE__)
294
+ rescue LoadError
295
+ end
296
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
297
+ require_relative '../config/boot'
298
+ require 'rails/commands'
299
+ RUBY
300
+
301
+ assert_success "bin/spring binstub --all", stdout: "upgraded"
302
+
303
+ expected = <<-RUBY.gsub(/^ /, "")
304
+ #!/usr/bin/env ruby
305
+ #{Spring::Client::Binstub::LOADER.strip}
306
+ require 'bundler/setup'
307
+ load Gem.bin_path('rake', 'rake')
308
+ RUBY
309
+ assert_equal expected, app.path("bin/rake").read
310
+
311
+ expected = <<-RUBY.gsub(/^ /, "")
312
+ #!/usr/bin/env ruby
313
+ #{Spring::Client::Binstub::LOADER.strip}
314
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
315
+ require_relative '../config/boot'
316
+ require 'rails/commands'
317
+ RUBY
318
+ assert_equal expected, app.path("bin/rails").read
319
+ end
320
+
321
+ test "binstub remove with new binstub variations" do
322
+ # older variation with double quotes
323
+ File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
324
+ #!/usr/bin/env ruby
325
+ begin
326
+ load File.expand_path("../spring", __FILE__)
327
+ rescue LoadError
328
+ end
329
+ require 'bundler/setup'
330
+ load Gem.bin_path('rake', 'rake')
331
+ RUBY
332
+
333
+ # newer variation with single quotes
334
+ File.write(app.path("bin/rails"), <<-RUBY.strip_heredoc)
335
+ #!/usr/bin/env ruby
336
+ begin
337
+ load File.expand_path('../spring', __FILE__)
338
+ rescue LoadError
339
+ end
340
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
341
+ require_relative '../config/boot'
342
+ require 'rails/commands'
343
+ RUBY
344
+
345
+ assert_success "bin/spring binstub --remove rake", stdout: "bin/rake: spring removed"
346
+ assert_success "bin/spring binstub --remove rails", stdout: "bin/rails: spring removed"
347
+
348
+ expected = <<-RUBY.strip_heredoc
349
+ #!/usr/bin/env ruby
350
+ require 'bundler/setup'
351
+ load Gem.bin_path('rake', 'rake')
352
+ RUBY
353
+ assert_equal expected, app.path("bin/rake").read
354
+
355
+ expected = <<-RUBY.strip_heredoc
356
+ #!/usr/bin/env ruby
357
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
358
+ require_relative '../config/boot'
359
+ require 'rails/commands'
360
+ RUBY
361
+ assert_equal expected, app.path("bin/rails").read
362
+ end
363
+
272
364
  test "after fork callback" do
273
365
  File.write(app.spring_config, "Spring.after_fork { puts '!callback!' }")
274
366
  assert_success "bin/rails runner 'puts 2'", stdout: "!callback!\n2"
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.3"
3
3
  end
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.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Leighton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-16 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport