spring 0.9.1 → 0.9.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38ac640c7514d41f28205416b110496f5ddb14d2
4
- data.tar.gz: 89b956912fee2b1b75e20c9f06986c33671a4b27
3
+ metadata.gz: fd549dd9f72903f46605eed993f12b7a9be70e71
4
+ data.tar.gz: 32a416243ef3771069b6702ffc65e629c3a79e6f
5
5
  SHA512:
6
- metadata.gz: 1251675f9d073842dc030e0855161594a31807b80ef64b530d2b8a759b9c6bf075a3cb6eb330e108b19483dcb8fb5d50a19a7e0be7a5c777d55326c56577e767
7
- data.tar.gz: a96b76e7742eda3aa9a07ce69f6dc6d6f9de1d6bed809a2b7fc2f165dc49c282214015c229f21e9a157024bc14a4c3a81b2edd596377cee93f7dad70527a0cde
6
+ metadata.gz: ff5ecf5c0af829d76b494a09a7178305c98c2ef0a569937f4043a21d027fd3ce3d22bf0a2e1884a0f738675522abed3eeb0bbb2d52039f106937453bd4ea234a
7
+ data.tar.gz: 945cd6d139c52c09cb6f13bb3edb0f7883bffbe1d40efd95ed63953f724c2ab6b99e4699b0a87651fb1af3f822046d5f97199e3217cc66d0a354878e480b53fa
@@ -1,3 +1,23 @@
1
+ ## 0.9.2
2
+
3
+ * Bugfix: environment variables set by bundler (`BUNDLE_GEMFILE`,
4
+ `RUBYOPT`, etc...) were being removed from the environment.
5
+ * Ensure we only run the code reloader when files have actually changed.
6
+ This issue became more prominent with Rails 4, since Rails 4 will now
7
+ reload routes whenever the code is reloaded (see
8
+ https://github.com/rails/rails/commit/b9b06daa915fdc4d11e8cfe11a7175e5cd8f104f).
9
+ * Allow spring to be used in a descendant directory of the application
10
+ root
11
+ * Use the system tmpdir for our temporary files. Previously we used
12
+ `APP_ROOT/tmp/spring`, which caused problems on filesystems which did
13
+ not support sockets, and also caused problems if `APP_ROOT` was
14
+ sufficiently deep in the filesystem to exhaust the operating system's
15
+ socket name limit. Hence we had a `SPRING_TMP_PATH` environment
16
+ variable for configuration. We now use `/tmp/spring/[md5(APP_ROOT)]`
17
+ for the socket and `/tmp/spring/[md5(APP_ROOT)].pid` for the pid file.
18
+ Thanks @Kriechi for the suggestion. Setting `SPRING_TMP_PATH` no longer
19
+ has any effect.
20
+
1
21
  ## 0.9.1
2
22
 
3
23
  * Environment variables which were created during application startup are no
data/README.md CHANGED
@@ -264,11 +264,6 @@ Spring.watch_method = :listen
264
264
 
265
265
  You may need to add the [`listen` gem](https://github.com/guard/listen) to your `Gemfile`.
266
266
 
267
- ### tmp directory
268
-
269
- Spring needs a tmp directory. This will default to `Rails.root.join('tmp', 'spring')`.
270
- You can set your own configuration directory by setting the `SPRING_TMP_PATH` environment variable.
271
-
272
267
  ## Troubleshooting
273
268
 
274
269
  If you want to get more information about what spring is doing, you can
@@ -15,7 +15,6 @@ module Spring
15
15
  @mutex = Mutex.new
16
16
  @waiting = 0
17
17
  @exiting = false
18
- @env_keys = ENV.keys
19
18
 
20
19
  # Workaround for GC bug in Ruby 2 which causes segfaults if watcher.to_io
21
20
  # instances get dereffed.
@@ -99,8 +98,10 @@ module Spring
99
98
  connect_database
100
99
  setup command
101
100
 
102
- ActionDispatch::Reloader.cleanup!
103
- ActionDispatch::Reloader.prepare!
101
+ if Rails.application.reloaders.any?(&:updated?)
102
+ ActionDispatch::Reloader.cleanup!
103
+ ActionDispatch::Reloader.prepare!
104
+ end
104
105
 
105
106
  pid = fork {
106
107
  Process.setsid
@@ -108,8 +109,12 @@ module Spring
108
109
  IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
109
110
 
110
111
  ARGV.replace(args)
111
- @env_keys.each { |k| ENV.delete k }
112
- ENV.update(env)
112
+
113
+ # Delete all env vars which are unchanged from before spring started
114
+ Spring.original_env.each { |k, v| ENV.delete k if ENV[k] == v }
115
+
116
+ # Load in the current env vars, except those which *were* changed when spring started
117
+ env.each { |k, v| ENV[k] ||= v }
113
118
 
114
119
  connect_database
115
120
  srand
@@ -1,32 +1,43 @@
1
1
  require "pathname"
2
2
  require "fileutils"
3
+ require "digest/md5"
4
+ require "tmpdir"
3
5
 
4
6
  require "spring/version"
5
7
  require "spring/sid"
8
+ require "spring/configuration"
6
9
 
7
10
  module Spring
8
11
  IGNORE_SIGNALS = %w(INT QUIT)
9
12
 
10
13
  class Env
11
- attr_reader :root, :log_file
14
+ attr_reader :log_file
12
15
 
13
16
  def initialize(root = nil)
14
- @root = root || Pathname.new(File.expand_path('.'))
17
+ @root = root
15
18
  @log_file = File.open(ENV["SPRING_LOG"] || "/dev/null", "a")
16
19
  end
17
20
 
21
+ def root
22
+ @root ||= Spring.application_root_path
23
+ end
24
+
18
25
  def version
19
26
  Spring::VERSION
20
27
  end
21
28
 
22
29
  def tmp_path
23
- path = default_tmp_path
30
+ path = Pathname.new(Dir.tmpdir + "/spring")
24
31
  FileUtils.mkdir_p(path) unless path.exist?
25
32
  path
26
33
  end
27
34
 
35
+ def application_id
36
+ Digest::MD5.hexdigest(root.to_s)
37
+ end
38
+
28
39
  def socket_path
29
- tmp_path.join("spring")
40
+ tmp_path.join(application_id)
30
41
  end
31
42
 
32
43
  def socket_name
@@ -34,7 +45,7 @@ module Spring
34
45
  end
35
46
 
36
47
  def pidfile_path
37
- tmp_path.join("spring.pid")
48
+ tmp_path.join("#{application_id}.pid")
38
49
  end
39
50
 
40
51
  def pid
@@ -68,15 +79,5 @@ module Spring
68
79
  log_file.puts "[#{Time.now}] #{message}"
69
80
  log_file.flush
70
81
  end
71
-
72
- private
73
-
74
- def default_tmp_path
75
- if ENV['SPRING_TMP_PATH']
76
- Pathname.new(ENV['SPRING_TMP_PATH'])
77
- else
78
- root.join('tmp/spring')
79
- end
80
- end
81
82
  end
82
83
  end
@@ -15,20 +15,6 @@ module Spring
15
15
  end
16
16
  end
17
17
 
18
- class TmpUnwritable < StandardError
19
- attr_reader :tmp_path
20
-
21
- def initialize(tmp_path)
22
- @tmp_path = tmp_path
23
- end
24
-
25
- def message
26
- "Spring is unable to create a socket file at #{tmp_path}. You may need to " \
27
- "set the SPRING_TMP_PATH environment variable to use a different path. See " \
28
- "the documentation for details."
29
- end
30
- end
31
-
32
18
  class MissingApplication < ClientError
33
19
  attr_reader :project_root
34
20
 
@@ -1,3 +1,10 @@
1
+ module Spring
2
+ class << self
3
+ attr_reader :original_env
4
+ end
5
+ @original_env = ENV.to_hash
6
+ end
7
+
1
8
  require "socket"
2
9
  require "thread"
3
10
 
@@ -48,9 +55,6 @@ module Spring
48
55
  def start_server
49
56
  server = UNIXServer.open(env.socket_name)
50
57
  log "started on #{env.socket_name}"
51
- rescue Errno::EPERM
52
- raise TmpUnwritable.new(env.tmp_path)
53
- else
54
58
  loop { serve server.accept }
55
59
  end
56
60
 
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
@@ -485,9 +485,12 @@ class AppTest < ActiveSupport::TestCase
485
485
 
486
486
  env["OMG"] = "1"
487
487
  env["FOO"] = "1"
488
+ env["RUBYOPT"] = "-rubygems"
488
489
 
489
490
  assert_success %(#{spring} rails runner 'p ENV["OMG"]'), stdout: "1"
490
491
  assert_success %(#{spring} rails runner 'p ENV["BAR"]'), stdout: "bar"
492
+ assert_success %(#{spring} rails runner 'p ENV.key?("BUNDLE_GEMFILE")'), stdout: "true"
493
+ assert_success %(#{spring} rails runner 'p ENV["RUBYOPT"]'), stdout: "bundler"
491
494
 
492
495
  env["OMG"] = "2"
493
496
  env.delete "FOO"
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: 0.9.1
4
+ version: 0.9.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: 2013-11-09 00:00:00.000000000 Z
11
+ date: 2013-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -118,4 +118,3 @@ test_files:
118
118
  - test/unit/commands_test.rb
119
119
  - test/unit/process_title_updater_test.rb
120
120
  - test/unit/watcher_test.rb
121
- has_rdoc: