guard-spork 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -0
- data/lib/guard/spork.rb +2 -3
- data/lib/guard/spork/runner.rb +23 -12
- data/lib/guard/spork/templates/Guardfile +3 -3
- data/lib/guard/spork/version.rb +2 -2
- metadata +15 -16
data/README.rdoc
CHANGED
@@ -61,6 +61,14 @@ Guard::Spork automatically detect RSpec/Cucumber/Bundler presence but you can di
|
|
61
61
|
...
|
62
62
|
end
|
63
63
|
|
64
|
+
To append additional environment variables for rspec and cucumber you can provided a hash to rspec_env/cucumber_env:
|
65
|
+
|
66
|
+
guard 'spork', :cucumber_env => {'RAILS_ENV' => 'cucumber'}, :rspec_env => {'RAILS_ENV' => 'test'} do
|
67
|
+
...
|
68
|
+
end
|
69
|
+
|
70
|
+
<b>IMPORTANT: when using ruby 1.8.x please set the env for both rspec and cucumber as they will overwrite each other and the system env's</b>
|
71
|
+
|
64
72
|
Available options:
|
65
73
|
|
66
74
|
:wait => 30 # Seconds to wait for the server to starts, default: 20
|
@@ -69,6 +77,8 @@ Available options:
|
|
69
77
|
:bundler => false # Don't use "bundle exec"
|
70
78
|
:rspec_port => 1234 # Default: 8989
|
71
79
|
:cucumber_port => 4321 # Default: 8990
|
80
|
+
:rspec_env
|
81
|
+
:cucumber_env
|
72
82
|
|
73
83
|
== Common troubleshooting
|
74
84
|
|
data/lib/guard/spork.rb
CHANGED
@@ -7,10 +7,9 @@ module Guard
|
|
7
7
|
autoload :Runner, 'guard/spork/runner'
|
8
8
|
attr_accessor :runner
|
9
9
|
|
10
|
-
def initialize(watchers
|
10
|
+
def initialize(watchers=[], options={})
|
11
11
|
super
|
12
12
|
@runner = Runner.new(options)
|
13
|
-
|
14
13
|
end
|
15
14
|
|
16
15
|
def start
|
@@ -33,4 +32,4 @@ module Guard
|
|
33
32
|
end
|
34
33
|
|
35
34
|
end
|
36
|
-
end
|
35
|
+
end
|
data/lib/guard/spork/runner.rb
CHANGED
@@ -5,11 +5,13 @@ module Guard
|
|
5
5
|
class Runner
|
6
6
|
attr_accessor :options
|
7
7
|
|
8
|
-
def initialize(options
|
8
|
+
def initialize(options={})
|
9
9
|
options[:wait] ||= 20 # seconds
|
10
10
|
options[:rspec_port] ||= 8989
|
11
11
|
options[:cucumber_port] ||= 8990
|
12
|
-
|
12
|
+
options[:rspec_env] ||= nil
|
13
|
+
options[:cucumber_env] ||= nil
|
14
|
+
@options = options
|
13
15
|
@children = {}
|
14
16
|
|
15
17
|
Signal.trap('CHLD', self.method(:reap_children))
|
@@ -17,27 +19,37 @@ module Guard
|
|
17
19
|
|
18
20
|
def launch_sporks(action)
|
19
21
|
UI.info "#{action.capitalize}ing Spork for #{sporked_gems} ", :reset => true
|
20
|
-
spawn_child(spork_command("rspec")) if rspec?
|
21
|
-
spawn_child(spork_command("cucumber")) if cucumber?
|
22
|
+
spawn_child(options[:rspec_env], spork_command("rspec")) if rspec?
|
23
|
+
spawn_child(options[:cucumber_env], spork_command("cucumber")) if cucumber?
|
22
24
|
verify_launches(action)
|
23
25
|
end
|
24
26
|
|
25
27
|
def kill_sporks
|
26
|
-
UI.debug "Killing
|
28
|
+
UI.debug "Killing Spork servers with PID: #{spork_pids.join(', ')}"
|
27
29
|
spork_pids.each { |pid| Process.kill("KILL", pid) }
|
28
30
|
end
|
29
31
|
|
30
32
|
private
|
31
|
-
|
33
|
+
|
34
|
+
def spawn_child(env, cmd)
|
32
35
|
pid = fork
|
33
36
|
raise "Fork failed." if pid == -1
|
34
37
|
|
35
38
|
unless pid
|
36
39
|
ignore_control_signals
|
37
|
-
|
40
|
+
if env
|
41
|
+
if RUBY_VERSION > "1.9"
|
42
|
+
exec(env, cmd)
|
43
|
+
else
|
44
|
+
env.each { |key, value| ENV[key] = value }
|
45
|
+
exec(cmd)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
exec(cmd)
|
49
|
+
end
|
38
50
|
end
|
39
51
|
|
40
|
-
UI.debug "Spawned
|
52
|
+
UI.debug "Spawned Spork server #{pid} ('#{cmd}')"
|
41
53
|
@children[pid] = cmd
|
42
54
|
pid
|
43
55
|
end
|
@@ -80,8 +92,7 @@ module Guard
|
|
80
92
|
when "rspec"
|
81
93
|
cmd_parts << "-p #{options[:rspec_port]}"
|
82
94
|
when "cucumber"
|
83
|
-
cmd_parts << "cu"
|
84
|
-
cmd_parts << "-p #{options[:cucumber_port]}"
|
95
|
+
cmd_parts << "cu -p #{options[:cucumber_port]}"
|
85
96
|
end
|
86
97
|
|
87
98
|
cmd_parts.join(" ")
|
@@ -96,12 +107,12 @@ module Guard
|
|
96
107
|
rescue Errno::ECONNREFUSED
|
97
108
|
next
|
98
109
|
end
|
99
|
-
UI.info "Spork for #{sporked_gems} successfully #{action}ed", :reset => true
|
110
|
+
UI.info "Spork server for #{sporked_gems} successfully #{action}ed", :reset => true
|
100
111
|
Notifier.notify "#{sporked_gems} successfully #{action}ed", :title => "Spork", :image => :success
|
101
112
|
return true
|
102
113
|
end
|
103
114
|
UI.reset_line # workaround before Guard::UI update
|
104
|
-
UI.error "Could not #{action} Spork for #{sporked_gems}. Make sure you can use it manually first."
|
115
|
+
UI.error "Could not #{action} Spork server for #{sporked_gems}. Make sure you can use it manually first."
|
105
116
|
Notifier.notify "#{sporked_gems} NOT #{action}ed", :title => "Spork", :image => :failed
|
106
117
|
end
|
107
118
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
guard 'spork' do
|
1
|
+
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
|
2
2
|
watch('config/application.rb')
|
3
3
|
watch('config/environment.rb')
|
4
|
-
watch(%r{^config/environments
|
5
|
-
watch(%r{^config/initializers
|
4
|
+
watch(%r{^config/environments/.+\.rb$})
|
5
|
+
watch(%r{^config/initializers/.+\.rb$})
|
6
6
|
watch('spec/spec_helper.rb')
|
7
7
|
end
|
data/lib/guard/spork/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Thibaud Guillaume-Gentil
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-17 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -62,8 +62,7 @@ dependencies:
|
|
62
62
|
segments:
|
63
63
|
- 1
|
64
64
|
- 0
|
65
|
-
|
66
|
-
version: 1.0.12
|
65
|
+
version: "1.0"
|
67
66
|
type: :development
|
68
67
|
version_requirements: *id003
|
69
68
|
- !ruby/object:Gem::Dependency
|
@@ -74,12 +73,11 @@ dependencies:
|
|
74
73
|
requirements:
|
75
74
|
- - ~>
|
76
75
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
76
|
+
hash: 9
|
78
77
|
segments:
|
79
78
|
- 2
|
80
79
|
- 5
|
81
|
-
|
82
|
-
version: 2.5.0
|
80
|
+
version: "2.5"
|
83
81
|
type: :development
|
84
82
|
version_requirements: *id004
|
85
83
|
- !ruby/object:Gem::Dependency
|
@@ -90,15 +88,14 @@ dependencies:
|
|
90
88
|
requirements:
|
91
89
|
- - ~>
|
92
90
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
91
|
+
hash: 15
|
94
92
|
segments:
|
95
93
|
- 0
|
96
94
|
- 2
|
97
|
-
|
98
|
-
version: 0.2.0
|
95
|
+
version: "0.2"
|
99
96
|
type: :development
|
100
97
|
version_requirements: *id005
|
101
|
-
description: Guard::Spork automatically manage Spork DRb servers
|
98
|
+
description: Guard::Spork automatically manage Spork DRb servers.
|
102
99
|
email:
|
103
100
|
- thibaud@thibaud.me
|
104
101
|
executables: []
|
@@ -128,10 +125,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
125
|
requirements:
|
129
126
|
- - ">="
|
130
127
|
- !ruby/object:Gem::Version
|
131
|
-
hash:
|
128
|
+
hash: 57
|
132
129
|
segments:
|
133
|
-
-
|
134
|
-
|
130
|
+
- 1
|
131
|
+
- 8
|
132
|
+
- 7
|
133
|
+
version: 1.8.7
|
135
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
135
|
none: false
|
137
136
|
requirements:
|