guard-spork 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,7 +7,7 @@ Spork guard allows to automatically & intelligently start/reload your RSpec/Cucu
7
7
 
8
8
  == Install
9
9
 
10
- Please be sure to have {guard}[http://github.com/guard/guard] installed before continue.
10
+ Please be sure to have {Guard}[http://github.com/guard/guard] installed before continue.
11
11
 
12
12
  Install the gem:
13
13
 
@@ -23,28 +23,28 @@ Add guard definition to your Guardfile with:
23
23
 
24
24
  == Usage
25
25
 
26
- Please read {guard usage doc}[http://github.com/guard/guard#readme]
26
+ Please read {Guard usage doc}[http://github.com/guard/guard#readme]
27
27
 
28
28
  == Guardfile
29
29
 
30
30
  Spork guard can be really be adapated to all kind of projects.
31
- Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
31
+ Please read {Guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
32
32
 
33
- !!! Attention place Spork guard before rspec/cucumber guards !!!
33
+ !!! IMPORTANT: place Spork guard before rspec/cucumber guards !!!
34
34
 
35
35
  === Rails app
36
36
 
37
37
  guard 'spork' do
38
- watch('^config/application.rb$')
39
- watch('^config/environment.rb$')
40
- watch('^config/environments/.*\.rb$')
41
- watch('^config/initializers/.*\.rb$')
42
- watch('^spec/spec_helper.rb')
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
43
  end
44
44
 
45
45
  == Options
46
46
 
47
- Spork guard automatically detect RSpec/Cucumber/Bundler presence but you can disabled them via:
47
+ Spork guard automatically detect RSpec/Cucumber/Bundler presence but you can disable any of them with the corresponding options:
48
48
 
49
49
  guard 'spork', :cucumber => false, :bundler => false do
50
50
  ...
@@ -52,13 +52,21 @@ Spork guard automatically detect RSpec/Cucumber/Bundler presence but you can dis
52
52
 
53
53
  Available options:
54
54
 
55
- :wait => 30 # Seconds to wait server launch, default 20
55
+ :wait => 30 # Seconds to wait server launch, default 20
56
56
  :cucumber => false
57
57
  :rspec => false
58
- :bundler => false # don't use "bundle exec"
59
- :rspec_port => xxxx # default 8989
58
+ :bundler => false # don't use "bundle exec"
59
+ :rspec_port => xxxx # default 8989
60
60
  :cucumber_port => xxxx # default 8990
61
61
 
62
+ == Common troubleshooting
63
+
64
+ If you can start Spork manually but get the following error message when using Spork guard:
65
+
66
+ Starting Spork for RSpec ERROR: Could not start Spork for RSpec. Make sure you can use it manually first.
67
+
68
+ Try to increase the value of the :wait option before any further investigation.
69
+
62
70
  == Development
63
71
 
64
72
  - Source hosted at {GitHub}[http://github.com/guard/guard-spork]
@@ -69,4 +77,4 @@ you make.
69
77
 
70
78
  == Authors
71
79
 
72
- {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg]
80
+ {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg]
data/lib/guard/spork.rb CHANGED
@@ -3,34 +3,34 @@ require 'guard/guard'
3
3
 
4
4
  module Guard
5
5
  class Spork < Guard
6
-
6
+
7
7
  autoload :Runner, 'guard/spork/runner'
8
8
  attr_accessor :runner
9
-
9
+
10
10
  def initialize(watchers = [], options = {})
11
11
  super
12
12
  @runner = Runner.new(options)
13
-
13
+
14
14
  end
15
-
15
+
16
16
  def start
17
17
  runner.kill_sporks
18
18
  runner.launch_sporks("start")
19
19
  end
20
-
20
+
21
21
  def reload
22
22
  runner.kill_sporks
23
23
  runner.launch_sporks("reload")
24
24
  end
25
-
25
+
26
26
  def run_on_change(paths)
27
27
  runner.kill_sporks
28
28
  runner.launch_sporks("reload")
29
29
  end
30
-
30
+
31
31
  def stop
32
32
  runner.kill_sporks
33
33
  end
34
-
34
+
35
35
  end
36
36
  end
@@ -4,32 +4,32 @@ module Guard
4
4
  class Spork
5
5
  class Runner
6
6
  attr_accessor :options
7
-
7
+
8
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 = options
13
13
  end
14
-
14
+
15
15
  def launch_sporks(action)
16
16
  UI.info "#{action.capitalize}ing Spork for #{sporked_gems} ", :reset => true
17
17
  system(spork_command("rspec")) if rspec?
18
18
  system(spork_command("cucumber")) if cucumber?
19
19
  verify_launches(action)
20
20
  end
21
-
21
+
22
22
  def kill_sporks
23
23
  spork_pids.each { |pid| Process.kill("KILL", pid) }
24
24
  end
25
-
25
+
26
26
  private
27
-
27
+
28
28
  def spork_command(type)
29
29
  cmd_parts = []
30
30
  cmd_parts << "bundle exec" if bundler?
31
31
  cmd_parts << "spork"
32
-
32
+
33
33
  case type
34
34
  when "rspec"
35
35
  cmd_parts << "-p #{options[:rspec_port]}"
@@ -37,11 +37,11 @@ module Guard
37
37
  cmd_parts << "cu"
38
38
  cmd_parts << "-p #{options[:cucumber_port]}"
39
39
  end
40
-
40
+
41
41
  cmd_parts << ">/dev/null 2>&1 < /dev/null &"
42
42
  cmd_parts.join(" ")
43
43
  end
44
-
44
+
45
45
  def verify_launches(action)
46
46
  options[:wait].times do
47
47
  sleep 1
@@ -60,30 +60,30 @@ module Guard
60
60
  UI.error "Could not #{action} Spork for #{sporked_gems}. Make sure you can use it manually first."
61
61
  Notifier.notify "#{sporked_gems} NOT #{action}ed", :title => "Spork", :image => :failed
62
62
  end
63
-
63
+
64
64
  def spork_pids
65
65
  `ps aux | awk '/spork/&&!/awk/{print $2;}'`.split("\n").map { |pid| pid.to_i }
66
66
  end
67
-
67
+
68
68
  def sporked_gems
69
69
  gems = []
70
70
  gems << "RSpec" if rspec?
71
71
  gems << "Cucumber" if cucumber?
72
72
  gems.join(' & ')
73
73
  end
74
-
74
+
75
75
  def bundler?
76
76
  @bundler ||= File.exist?("#{Dir.pwd}/Gemfile") && options[:bundler] != false
77
77
  end
78
-
78
+
79
79
  def rspec?
80
80
  @rspec ||= File.exist?("#{Dir.pwd}/spec") && options[:rspec] != false
81
81
  end
82
-
82
+
83
83
  def cucumber?
84
84
  @cucumber ||= File.exist?("#{Dir.pwd}/features") && options[:cucumber] != false
85
85
  end
86
-
86
+
87
87
  end
88
88
  end
89
89
  end
@@ -1,7 +1,7 @@
1
1
  guard 'spork' do
2
- watch('^config/application.rb$')
3
- watch('^config/environment.rb$')
4
- watch('^config/environments/.*\.rb$')
5
- watch('^config/initializers/.*\.rb$')
6
- watch('^spec/spec_helper.rb')
7
- end
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,5 +1,5 @@
1
1
  module Guard
2
2
  module SporkVersion
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
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: 29
5
- prerelease: false
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
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: 2010-11-18 00:00:00 +01:00
18
+ date: 2011-02-08 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 23
29
+ hash: 19
30
30
  segments:
31
31
  - 0
32
32
  - 2
33
- - 0
34
- version: 0.2.0
33
+ - 2
34
+ version: 0.2.2
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -74,11 +74,12 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- hash: 1
77
+ hash: 7
78
78
  segments:
79
79
  - 2
80
- - 1
81
- version: "2.1"
80
+ - 2
81
+ - 0
82
+ version: 2.2.0
82
83
  type: :development
83
84
  version_requirements: *id004
84
85
  - !ruby/object:Gem::Dependency
@@ -89,12 +90,12 @@ dependencies:
89
90
  requirements:
90
91
  - - ~>
91
92
  - !ruby/object:Gem::Version
92
- hash: 11
93
+ hash: 9
93
94
  segments:
94
95
  - 0
95
96
  - 1
96
- - 8
97
- version: 0.1.8
97
+ - 9
98
+ version: 0.1.9
98
99
  type: :development
99
100
  version_requirements: *id005
100
101
  description: Guard::Spork automatically manage Spork DRb servers
@@ -145,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
146
  requirements: []
146
147
 
147
148
  rubyforge_project: guard-spork
148
- rubygems_version: 1.3.7
149
+ rubygems_version: 1.5.0
149
150
  signing_key:
150
151
  specification_version: 3
151
152
  summary: Guard gem for Spork