guard 2.12.9 → 2.13.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/guard +106 -23
  3. data/lib/guard/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 405dd41ca5e1687db6ca44dbafd373d8f25a5f8b
4
- data.tar.gz: 7a4551f85bf89de5387332ac326e5b0c6443d8b6
3
+ metadata.gz: 0c6b3428b071bd5e34a0b9a05235d5814f7fe190
4
+ data.tar.gz: 19dae3ff061b4d697789e01dcfd3a4558047672e
5
5
  SHA512:
6
- metadata.gz: 57305dd135f3abe025f1062c274079ec31430d9c544d8dee92064f22798721d73a86d947f01b7df35ca98593d2a62a63b29ecc556ed34e4a79563b82aa0049dd
7
- data.tar.gz: e2d5aa2c3c0ff95b72e8382872dd53da7e72057709189ec0629f1a86935aeb9a546857063274bb2bf12e8bf377036c77043b6fcdf8a6117d542f187f1fa929d1
6
+ metadata.gz: f539620c78fa10c40df9b8fb11bab2519772b6f2ad1c3839c964f1e2efda97e0ab10397baa591dc036552b30c77ef91e05e1901912db83a55527a01798070eb9
7
+ data.tar.gz: f234c272662f566f641a3fb684d010291c809630e5b4fc6ee6fc7bb8b0a0e1c2a859e64c5d6b892b8ed1d447287bc71fe3488d1846f3874bd498599ab6a6ea59
data/bin/guard CHANGED
@@ -2,31 +2,114 @@
2
2
 
3
3
  require "pathname"
4
4
 
5
- default = Pathname(ENV.fetch("BUNDLE_GEMFILE", "Gemfile"))
6
- relative_to_binstub = Pathname(__FILE__).realpath + "../../Gemfile"
7
- gemfile = [default, relative_to_binstub].detect(&:exist?)
8
-
9
- if gemfile && !ENV["RUBYGEMS_GEMDEPS"]
10
- ENV["BUNDLE_GEMFILE"] = gemfile.to_s
11
- require "rubygems"
12
- require "bundler/setup"
13
- else
14
- require "rubygems"
15
- end
5
+ class GuardReloader
6
+ class Config
7
+ def using_rubygems?
8
+ ENV["RUBYGEMS_GEMDEPS"]
9
+ end
10
+
11
+ def setup_rubygems_for_deps
12
+ require "rubygems"
13
+ end
14
+
15
+ def current_bundler_gemfile
16
+ ENV["BUNDLE_GEMFILE"]
17
+ end
18
+
19
+ def using_bundler?
20
+ ENV["BUNDLE_GEMFILE"]
21
+ end
22
+
23
+ def setup_bundler_env(gemfile)
24
+ ENV["BUNDLE_GEMFILE"] = gemfile
25
+ end
26
+
27
+ def setup_bundler
28
+ require "rubygems"
29
+ require "bundler/setup"
30
+ end
31
+
32
+ def program_path
33
+ Pathname(__FILE__)
34
+ end
35
+
36
+ def program_arguments
37
+ ARGV
38
+ end
39
+
40
+ def windows?
41
+ Gem.win_platform?
42
+ end
43
+
44
+ def default_system_ruby
45
+ RbConfig.ruby
46
+ end
47
+
48
+ def exit_with(code)
49
+ exit(code)
50
+ end
51
+
52
+ def spawn_with(*args)
53
+ spawn(*args)
54
+ end
55
+
56
+ def wait_ignoring_interrupts(pid)
57
+ Process.wait2(pid)[1].exitstatus
58
+ rescue Interrupt
59
+ retry
60
+ rescue Errno::ECHILD
61
+ 1
62
+ end
63
+
64
+ def exist?(path)
65
+ path.exist?
66
+ end
67
+
68
+ def guard_core_path
69
+ Gem.bin_path("guard", "_guard-core")
70
+ end
71
+ end
72
+
73
+ attr_reader :config
74
+ def initialize(config)
75
+ @config = config
76
+ end
77
+
78
+ def setup
79
+ return config.setup_bundler if config.using_bundler?
80
+ return config.setup_rubygems_for_deps if config.using_rubygems?
81
+
82
+ # No dependency management detected - check if binstubbed by bundler
83
+ relative_to_binstub = config.program_path + "../../Gemfile"
84
+ if config.exist?(relative_to_binstub)
85
+ config.setup_bundler_env(relative_to_binstub.to_s)
86
+ config.setup_bundler
87
+ return
88
+ end
89
+
90
+ unless config.exist?(Pathname("Gemfile"))
91
+ # Running guard with bare ruby here - it's up to the user
92
+ # to setup/install missing deps
93
+ return
94
+ end
95
+
96
+ STDERR.puts "Warning: you have a Gemfile, but you're not using"\
97
+ " bundler or RUBYGEMS_GEMDEPS"
98
+ end
16
99
 
17
- def ignore_interrupts(*args)
18
- args.unshift(RbConfig.ruby) if Gem.win_platform?
19
- pid = spawn(*args)
20
- begin
21
- Process.wait(pid)
22
- rescue Interrupt
23
- retry
100
+ def auto_restart
101
+ args = [config.guard_core_path] + config.program_arguments
102
+ args.unshift(config.default_system_ruby) if config.windows?
103
+ loop do
104
+ exitcode = config.wait_ignoring_interrupts(config.spawn_with(*args))
105
+ config.exit_with(exitcode) if exitcode != 2
106
+ end
24
107
  end
25
- $? == 0
26
108
  end
27
109
 
28
- guard_core_path = Gem.bin_path("guard", "_guard-core")
29
- while !ignore_interrupts(guard_core_path, *ARGV) && $?.exitstatus == 2
30
- puts("Restarting guard...")
110
+ unless ENV["GUARD_SPECS_RUNNING"]
111
+ config = GuardReloader::Config.new
112
+ reloader = GuardReloader.new(config)
113
+ reloader.setup
114
+ reloader.auto_restart
31
115
  end
32
- exit($?.exitstatus)
@@ -1,3 +1,3 @@
1
1
  module Guard
2
- VERSION = "2.12.9"
2
+ VERSION = "2.13.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.9
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-22 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor