guard-spork 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,103 +1,112 @@
1
- = Guard::Spork
2
- http://travis-ci.org/guard/guard-spork.png
3
-
4
- Guard::Spork allows to automatically & intelligently start/reload your RSpec/Cucumber/Test::Unit {Spork}[https://github.com/timcharper/spork] server(s).
5
-
6
- - Compatible with Spork 0.8.4 & 0.9.0.rcXX.
7
- - Tested on Ruby 1.8.7, REE, 1.9.2, JRuby & Rubinius.
8
-
9
- == Install
10
-
11
- Please be sure to have {Guard}[https://github.com/guard/guard] installed before continue.
12
-
13
- Install the gem:
14
-
15
- gem install guard-spork
16
-
17
- Add it to your Gemfile (inside test group):
18
-
19
- gem 'guard-spork'
20
-
21
- Add guard definition to your Guardfile with:
22
-
23
- guard init spork
24
-
25
- == Usage
26
-
27
- Please read {Guard usage doc}[https://github.com/guard/guard#readme].
28
-
29
- == Guardfile
30
-
31
- Please read {Guard doc}[https://github.com/guard/guard#readme] for more info about the Guardfile DSL.
32
-
33
- <b>IMPORTANT: place Spork guard before RSpec/Cucumber/Test::Unit guards!</b>
34
-
35
- === Rails app
36
-
37
- guard 'spork' do
38
- watch('config/application.rb')
39
- watch('config/environment.rb')
40
- watch(%r{^config/environments/.*\.rb$})
41
- watch(%r{^config/initializers/.*\.rb$})
42
- watch('spec/spec_helper.rb')
43
- end
44
-
45
- === Running specs over Spork
46
-
47
- Pass the <tt>:cli => "--drb"</tt> option to {Guard::RSpec}[https://github.com/guard/guard-rspec] and/or {Guard::Cucumber}[https://github.com/guard/guard-cucumber] to run them over the Spork DRb server:
48
-
49
- guard 'rspec', :cli => "--drb" do
50
- ...
51
- end
52
-
53
- guard 'cucumber', :cli => "--drb" do
54
- ...
55
- end
56
-
57
- == Options
58
-
59
- Guard::Spork automatically detect RSpec/Cucumber/Test::Unit/Bundler presence but you can disable any of them with the corresponding options:
60
-
61
- guard 'spork', :cucumber => false, :bundler => false do
62
- ...
63
- end
64
-
65
- You can provide additional environment variables for RSpec, Cucumber, and Test::Unit with the <tt>:rspec_env</tt>, <tt>:cucumber_env</tt>, and <tt>:test_unit_env</tt> options:
66
-
67
- guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' }, :test_unit_env => { 'RAILS_ENV' => 'test' } do
68
- ...
69
- end
70
-
71
- Available options:
72
-
73
- :wait => 30 # Seconds to wait for the server to starts, default: 20
74
- :cucumber => false
75
- :rspec => false
76
- :test_unit => false
77
- :bundler => false # Don't use "bundle exec"
78
- :test_unit_port => 1233 # Default: 8988
79
- :rspec_port => 1234 # Default: 8989
80
- :cucumber_port => 4321 # Default: 8990
81
- :test_unit_env => { 'RAILS_ENV' => 'baz' } # Default: nil
82
- :rspec_env => { 'RAILS_ENV' => 'foo' } # Default: nil
83
- :cucumber_env => { 'RAILS_ENV' => 'bar' } # Default: nil
84
-
85
- == Common troubleshooting
86
-
87
- If you can start Spork manually but get the following error message when using Guard::Spork:
88
-
89
- Starting Spork for RSpec ERROR: Could not start Spork for RSpec/Cucumber. Make sure you can use it manually first.
90
-
91
- Try to increase the value of the <tt>:wait</tt> option before any further investigation.
92
-
93
- == Development
94
-
95
- - Source hosted at {GitHub}[https://github.com/guard/guard-spork]
96
- - Report issues/Questions/Feature requests on {GitHub Issues}[https://github.com/guard/guard-spork/issues]
97
-
98
- Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
99
- you make.
100
-
101
- == Authors
102
-
103
- {Thibaud Guillaume-Gentil}[https://github.com/thibaudgg]
1
+ = Guard::Spork
2
+ http://travis-ci.org/guard/guard-spork.png
3
+
4
+ Guard::Spork allows to automatically & intelligently start/reload your RSpec/Cucumber/Test::Unit {Spork}[https://github.com/timcharper/spork] server(s).
5
+
6
+ - Compatible with Spork 0.8.4 & 0.9.0.rcXX.
7
+ - Tested on Ruby 1.8.7, REE, 1.9.2 & Rubinius.
8
+
9
+ == Install
10
+
11
+ Please be sure to have {Guard}[https://github.com/guard/guard] installed before continue.
12
+
13
+ Install the gem:
14
+
15
+ gem install guard-spork
16
+
17
+ Add it to your Gemfile (inside test group):
18
+
19
+ gem 'guard-spork'
20
+
21
+ Add guard definition to your Guardfile with:
22
+
23
+ guard init spork
24
+
25
+ == Usage
26
+
27
+ Please read {Guard usage doc}[https://github.com/guard/guard#readme].
28
+
29
+ == Guardfile
30
+
31
+ Please read {Guard doc}[https://github.com/guard/guard#readme] for more info about the Guardfile DSL.
32
+
33
+ <b>IMPORTANT: place Spork guard before RSpec/Cucumber/Test::Unit guards!</b>
34
+
35
+ === Rails app
36
+
37
+ guard 'spork' do
38
+ watch('config/application.rb')
39
+ watch('config/environment.rb')
40
+ watch(%r{^config/environments/.*\.rb$})
41
+ watch(%r{^config/initializers/.*\.rb$})
42
+ watch('Gemfile')
43
+ watch('Gemfile.lock')
44
+ watch('spec/spec_helper.rb')
45
+ watch('test/test_helper.rb')
46
+ end
47
+
48
+ === Running specs over Spork
49
+
50
+ Pass the <tt>:cli => "--drb"</tt> option to {Guard::RSpec}[https://github.com/guard/guard-rspec] and/or {Guard::Cucumber}[https://github.com/guard/guard-cucumber] to run them over the Spork DRb server:
51
+
52
+ guard 'rspec', :cli => "--drb" do
53
+ ...
54
+ end
55
+
56
+ guard 'cucumber', :cli => "--drb" do
57
+ ...
58
+ end
59
+
60
+ For MiniTest Guard you should pass the `:drb => true` option:
61
+
62
+ guard 'minitest', :drb => true do
63
+ ...
64
+ end
65
+
66
+ == Options
67
+
68
+ Guard::Spork automatically detect RSpec/Cucumber/Test::Unit/Bundler presence but you can disable any of them with the corresponding options:
69
+
70
+ guard 'spork', :cucumber => false, :bundler => false do
71
+ ...
72
+ end
73
+
74
+ You can provide additional environment variables for RSpec, Cucumber, and Test::Unit with the <tt>:rspec_env</tt>, <tt>:cucumber_env</tt>, and <tt>:test_unit_env</tt> options:
75
+
76
+ guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' }, :test_unit_env => { 'RAILS_ENV' => 'test' } do
77
+ ...
78
+ end
79
+
80
+ Available options:
81
+
82
+ :wait => 30 # Seconds to wait for the server to starts, default: 20
83
+ :cucumber => false
84
+ :rspec => false
85
+ :test_unit => false
86
+ :bundler => false # Don't use "bundle exec"
87
+ :test_unit_port => 1233 # Default: 8988
88
+ :rspec_port => 1234 # Default: 8989
89
+ :cucumber_port => 4321 # Default: 8990
90
+ :test_unit_env => { 'RAILS_ENV' => 'baz' } # Default: nil
91
+ :rspec_env => { 'RAILS_ENV' => 'foo' } # Default: nil
92
+ :cucumber_env => { 'RAILS_ENV' => 'bar' } # Default: nil
93
+
94
+ == Common troubleshooting
95
+
96
+ If you can start Spork manually but get the following error message when using Guard::Spork:
97
+
98
+ Starting Spork for RSpec ERROR: Could not start Spork for RSpec/Cucumber. Make sure you can use it manually first.
99
+
100
+ Try to increase the value of the <tt>:wait</tt> option before any further investigation.
101
+
102
+ == Development
103
+
104
+ - Source hosted at {GitHub}[https://github.com/guard/guard-spork]
105
+ - Report issues/Questions/Feature requests on {GitHub Issues}[https://github.com/guard/guard-spork/issues]
106
+
107
+ Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
108
+ you make.
109
+
110
+ == Authors
111
+
112
+ {Thibaud Guillaume-Gentil}[https://github.com/thibaudgg]
@@ -14,7 +14,7 @@ module Guard
14
14
  options[:rspec_env] ||= {}
15
15
  options[:cucumber_env] ||= {}
16
16
  @options = options
17
- @children = {}
17
+ ENV['SPORK_PIDS'] ||= ''
18
18
 
19
19
  Signal.trap('CHLD', self.method(:reap_children))
20
20
  end
@@ -48,7 +48,7 @@ module Guard
48
48
  end
49
49
 
50
50
  UI.debug "Spawned Spork server #{pid} ('#{cmd}')"
51
- @children[pid] = cmd
51
+ add_children(pid)
52
52
  pid
53
53
  end
54
54
 
@@ -75,7 +75,7 @@ module Guard
75
75
  def reap_children(sig)
76
76
  terminated_children.each do |stat|
77
77
  pid = stat.pid
78
- if cmd = @children.delete(pid)
78
+ if remove_children(pid)
79
79
  UI.debug "Reaping spork #{pid}"
80
80
  end
81
81
  end
@@ -131,8 +131,20 @@ module Guard
131
131
  Notifier.notify "#{sporked_gems} NOT #{action}ed", :title => "Spork", :image => :failed
132
132
  end
133
133
 
134
+ def add_children(pid)
135
+ pids = spork_pids << pid
136
+ ENV['SPORK_PIDS'] = pids.join(',')
137
+ end
138
+
139
+ def remove_children(pid)
140
+ pids = spork_pids
141
+ deleted_pid = pids.delete(pid)
142
+ ENV['SPORK_PIDS'] = pids.join(',')
143
+ deleted_pid
144
+ end
145
+
134
146
  def spork_pids
135
- @children.keys
147
+ ENV['SPORK_PIDS'].split(',').map { |pid| pid.to_i }
136
148
  end
137
149
 
138
150
  def sporked_gems
@@ -1,7 +1,10 @@
1
- guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
2
- watch('config/application.rb')
3
- watch('config/environment.rb')
4
- watch(%r{^config/environments/.+\.rb$})
5
- watch(%r{^config/initializers/.+\.rb$})
6
- watch('spec/spec_helper.rb')
7
- end
1
+ guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
2
+ watch('config/application.rb')
3
+ watch('config/environment.rb')
4
+ watch(%r{^config/environments/.+\.rb$})
5
+ watch(%r{^config/initializers/.+\.rb$})
6
+ watch('Gemfile')
7
+ watch('Gemfile.lock')
8
+ watch('spec/spec_helper.rb')
9
+ watch('test/test_helper.rb')
10
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module SporkVersion
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-spork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,23 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-06 00:00:00.000000000 +02:00
13
- default_executable:
12
+ date: 2011-09-30 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: guard
17
- requirement: &2153014920 !ruby/object:Gem::Requirement
16
+ requirement: &70177655971420 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
21
20
  - !ruby/object:Gem::Version
22
- version: 0.2.2
21
+ version: 0.8.2
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2153014920
24
+ version_requirements: *70177655971420
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: spork
28
- requirement: &2153014000 !ruby/object:Gem::Requirement
27
+ requirement: &70177655959080 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: 0.8.4
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *2153014000
35
+ version_requirements: *70177655959080
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: bundler
39
- requirement: &2153013440 !ruby/object:Gem::Requirement
38
+ requirement: &70177655957840 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: '1.0'
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *2153013440
46
+ version_requirements: *70177655957840
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: rspec
50
- requirement: &2153012860 !ruby/object:Gem::Requirement
49
+ requirement: &70177655956940 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ~>
@@ -55,10 +54,10 @@ dependencies:
55
54
  version: '2.6'
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *2153012860
57
+ version_requirements: *70177655956940
59
58
  - !ruby/object:Gem::Dependency
60
59
  name: guard-rspec
61
- requirement: &2153012240 !ruby/object:Gem::Requirement
60
+ requirement: &70177655955740 !ruby/object:Gem::Requirement
62
61
  none: false
63
62
  requirements:
64
63
  - - ~>
@@ -66,7 +65,7 @@ dependencies:
66
65
  version: '0.4'
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *2153012240
68
+ version_requirements: *70177655955740
70
69
  description: Guard::Spork automatically manage Spork DRb servers.
71
70
  email:
72
71
  - thibaud@thibaud.me
@@ -80,7 +79,6 @@ files:
80
79
  - lib/guard/spork.rb
81
80
  - LICENSE
82
81
  - README.rdoc
83
- has_rdoc: true
84
82
  homepage: http://rubygems.org/gems/guard-spork
85
83
  licenses: []
86
84
  post_install_message:
@@ -101,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
99
  version: 1.3.6
102
100
  requirements: []
103
101
  rubyforge_project: guard-spork
104
- rubygems_version: 1.6.2
102
+ rubygems_version: 1.8.9
105
103
  signing_key:
106
104
  specification_version: 3
107
105
  summary: Guard gem for Spork