guard-spork 0.0.1
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.
- data/LICENSE +20 -0
- data/README.rdoc +71 -0
- data/lib/guard/spork.rb +30 -0
- data/lib/guard/spork/runner.rb +81 -0
- data/lib/guard/spork/templates/Guardfile +7 -0
- data/lib/guard/spork/version.rb +5 -0
- metadata +138 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Thibaud Guillaume-Gentil
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
= Guard::Spork
|
2
|
+
|
3
|
+
Spork guard allows to automatically & intelligently start/reload your RSpec/Cucumber Spork server(s).
|
4
|
+
|
5
|
+
- Compatible with Spork 0.8.4 & 0.9.0.rc2
|
6
|
+
- Tested on Ruby 1.8.6, 1.8.7 & 1.9.2.
|
7
|
+
|
8
|
+
== Install
|
9
|
+
|
10
|
+
Please be sure to have {guard}[http://github.com/guard/guard] installed before continue.
|
11
|
+
|
12
|
+
Install the gem:
|
13
|
+
|
14
|
+
gem install guard-spork
|
15
|
+
|
16
|
+
Add it to your Gemfile (inside test group):
|
17
|
+
|
18
|
+
gem 'guard-spork'
|
19
|
+
|
20
|
+
Add guard definition to your Guardfile with:
|
21
|
+
|
22
|
+
guard init spork
|
23
|
+
|
24
|
+
== Usage
|
25
|
+
|
26
|
+
Please read {guard usage doc}[http://github.com/guard/guard#readme]
|
27
|
+
|
28
|
+
== Guardfile
|
29
|
+
|
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.
|
32
|
+
|
33
|
+
!!! Attention place Spork guard before rspec/cucumber guards !!!
|
34
|
+
|
35
|
+
=== Rails app
|
36
|
+
|
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')
|
43
|
+
end
|
44
|
+
|
45
|
+
== Options
|
46
|
+
|
47
|
+
Spork guard automatically detect RSpec/Cucumber/Bundler presence but you can disabled them via:
|
48
|
+
|
49
|
+
guard 'spork', :cucumber => false, :bundler => false do
|
50
|
+
...
|
51
|
+
end
|
52
|
+
|
53
|
+
Available options:
|
54
|
+
|
55
|
+
:cucumber => false
|
56
|
+
:rspec => false
|
57
|
+
:bundler => false # don't use "bundle exec"
|
58
|
+
:rspec_port => xxxx # default 8989
|
59
|
+
:cucumber_port => xxxx # default 8990
|
60
|
+
|
61
|
+
== Development
|
62
|
+
|
63
|
+
- Source hosted at {GitHub}[http://github.com/guard/guard-spork]
|
64
|
+
- Report issues/Questions/Feature requests on {GitHub Issues}[http://github.com/guard/guard-spork/issues]
|
65
|
+
|
66
|
+
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
|
67
|
+
you make.
|
68
|
+
|
69
|
+
== Authors
|
70
|
+
|
71
|
+
{Thibaud Guillaume-Gentil}[http://github.com/thibaudgg]
|
data/lib/guard/spork.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
|
4
|
+
module Guard
|
5
|
+
class Spork < Guard
|
6
|
+
|
7
|
+
autoload :Runner, 'guard/spork/runner'
|
8
|
+
attr_accessor :runner
|
9
|
+
|
10
|
+
def initialize(watchers = [], options = {})
|
11
|
+
super
|
12
|
+
@runner = Runner.new(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def start
|
16
|
+
runner.launch_sporks("start")
|
17
|
+
end
|
18
|
+
|
19
|
+
def reload
|
20
|
+
runner.kill_sporks
|
21
|
+
runner.launch_sporks("reload")
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_on_change(paths)
|
25
|
+
runner.kill_sporks
|
26
|
+
runner.launch_sporks("reload")
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Guard
|
2
|
+
class Spork
|
3
|
+
class Runner
|
4
|
+
attr_accessor :options
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
options[:rspec_port] ||= 8989
|
8
|
+
options[:cucumber_port] ||= 8990
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def launch_sporks(action)
|
13
|
+
UI.info "#{action.capitalize}ing Spork for #{sporked_gems} ", :reset => true
|
14
|
+
system(spork_command("rspec")) if rspec?
|
15
|
+
system(spork_command("cucumber")) if cucumber?
|
16
|
+
verify_launches(action)
|
17
|
+
end
|
18
|
+
|
19
|
+
def kill_sporks
|
20
|
+
system("kill $(ps aux | awk '/spork/&&!/awk/{print $2;}') >/dev/null 2>&1")
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def spork_command(type)
|
26
|
+
cmd_parts = []
|
27
|
+
cmd_parts << "bundle exec" if bundler?
|
28
|
+
cmd_parts << "spork"
|
29
|
+
|
30
|
+
case type
|
31
|
+
when "rspec"
|
32
|
+
cmd_parts << "-p #{options[:rspec_port]}"
|
33
|
+
when "cucumber"
|
34
|
+
cmd_parts << "cu"
|
35
|
+
cmd_parts << "-p #{options[:cucumber_port]}"
|
36
|
+
end
|
37
|
+
|
38
|
+
cmd_parts << ">/dev/null 2>&1 < /dev/null &"
|
39
|
+
cmd_parts.join(" ")
|
40
|
+
end
|
41
|
+
|
42
|
+
def verify_launches(action)
|
43
|
+
30.times do
|
44
|
+
sleep 1
|
45
|
+
begin
|
46
|
+
TCPSocket.new('localhost', options[:rspec_port]).close if rspec?
|
47
|
+
TCPSocket.new('localhost', options[:cucumber_port]).close if cucumber?
|
48
|
+
rescue Errno::ECONNREFUSED
|
49
|
+
print '.'
|
50
|
+
next
|
51
|
+
end
|
52
|
+
UI.info "Spork for #{sporked_gems} successufly #{action}ed", :reset => true
|
53
|
+
Notifier.notify "#{sporked_gems} successufly #{action}ed", :title => "Spork", :image => :success
|
54
|
+
return true
|
55
|
+
end
|
56
|
+
UI.error "Could not #{action} Spork for #{sporked_gems}. Make sure you can use it manually first.", :reset => true
|
57
|
+
Notifier.notify "#{sporked_gems} NOT #{action}ed", :title => "Spork", :image => :failed
|
58
|
+
end
|
59
|
+
|
60
|
+
def sporked_gems
|
61
|
+
gems = []
|
62
|
+
gems << "RSpec" if rspec?
|
63
|
+
gems << "Cucumber" if cucumber?
|
64
|
+
gems.join(' & ')
|
65
|
+
end
|
66
|
+
|
67
|
+
def bundler?
|
68
|
+
@bundler ||= File.exist?("#{Dir.pwd}/Gemfile") && options[:bundler] != false
|
69
|
+
end
|
70
|
+
|
71
|
+
def rspec?
|
72
|
+
@rspec ||= File.exist?("#{Dir.pwd}/spec") && options[:rspec] != false
|
73
|
+
end
|
74
|
+
|
75
|
+
def cucumber?
|
76
|
+
@cucumber ||= File.exist?("#{Dir.pwd}/features") && options[:cucumber] != false
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-spork
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Thibaud Guillaume-Gentil
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-10 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: guard
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 2
|
33
|
+
- 0
|
34
|
+
version: 0.2.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: spork
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 977940487
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 9
|
49
|
+
- 0
|
50
|
+
- rc2
|
51
|
+
version: 0.9.0.rc2
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: bundler
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 17
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 0
|
66
|
+
- 3
|
67
|
+
version: 1.0.3
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 1
|
79
|
+
segments:
|
80
|
+
- 2
|
81
|
+
- 1
|
82
|
+
version: "2.1"
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
description: Guard::Spork automatically manage Spork DRb servers
|
86
|
+
email:
|
87
|
+
- thibaud@thibaud.me
|
88
|
+
executables: []
|
89
|
+
|
90
|
+
extensions: []
|
91
|
+
|
92
|
+
extra_rdoc_files: []
|
93
|
+
|
94
|
+
files:
|
95
|
+
- lib/guard/spork/runner.rb
|
96
|
+
- lib/guard/spork/templates/Guardfile
|
97
|
+
- lib/guard/spork/version.rb
|
98
|
+
- lib/guard/spork.rb
|
99
|
+
- LICENSE
|
100
|
+
- README.rdoc
|
101
|
+
has_rdoc: true
|
102
|
+
homepage: http://rubygems.org/gems/guard-spork
|
103
|
+
licenses: []
|
104
|
+
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
hash: 23
|
125
|
+
segments:
|
126
|
+
- 1
|
127
|
+
- 3
|
128
|
+
- 6
|
129
|
+
version: 1.3.6
|
130
|
+
requirements: []
|
131
|
+
|
132
|
+
rubyforge_project: guard-spork
|
133
|
+
rubygems_version: 1.3.7
|
134
|
+
signing_key:
|
135
|
+
specification_version: 3
|
136
|
+
summary: Guard gem for Spork
|
137
|
+
test_files: []
|
138
|
+
|