guard-spinoff 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/guard-spinoff.gemspec +20 -0
- data/lib/guard/spinoff.rb +36 -0
- data/lib/guard/spinoff/runner.rb +68 -0
- data/lib/guard/spinoff/templates/Guardfile +17 -0
- data/lib/guard/spinoff/version.rb +5 -0
- metadata +77 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (C) 2011 by Andrew Assarattanakul
|
2
|
+
Copyright (C) 2011 by Bernd Ahlers
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Guard::Spinoff
|
2
|
+
|
3
|
+
Guard::Spinoff is used to integrate the [Spinoff](http://github.com/bernd/spinoff)
|
4
|
+
server with [Guard](https://github.com/guard/guard).
|
5
|
+
|
6
|
+
# Installation
|
7
|
+
|
8
|
+
Install the gem.
|
9
|
+
|
10
|
+
$ gem install guard-spinoff
|
11
|
+
|
12
|
+
You can also add it to your Gemfile.
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'guard-spinoff'
|
16
|
+
```
|
17
|
+
|
18
|
+
Initialize or modify a Guardfile by running the following command.
|
19
|
+
|
20
|
+
$ guard init spinoff
|
21
|
+
|
22
|
+
# Configuration
|
23
|
+
|
24
|
+
Make sure you set the `:runner` and `:init` options in your Guardfile.
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
guard 'spinoff', :runner => :rspec, :init => 'config/spinoff.rb' do
|
28
|
+
# ...
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
Available runner options: `:rspec`, `:test\_unit`
|
33
|
+
|
34
|
+
The `:init` option takes the path to the Spinoff initialization file.
|
35
|
+
|
36
|
+
# Caveats
|
37
|
+
|
38
|
+
* No test suite yet!
|
39
|
+
|
40
|
+
# Credits
|
41
|
+
|
42
|
+
Thanks to [Jonathan](https://github.com/jonsgreen) and
|
43
|
+
[Andrew Assarattanakul](https://github.com/vizjerai) for writing
|
44
|
+
[guard-spin](https://github.com/vizjerai/guard-spin) which is the base
|
45
|
+
for this gem.
|
46
|
+
|
47
|
+
# Author
|
48
|
+
|
49
|
+
* [Bernd Ahlers](https://github.com/bernd)
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/guard/spinoff/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Bernd Ahlers"]
|
6
|
+
gem.email = ["bernd@tuneafish.de"]
|
7
|
+
gem.description = %q{Guard module for spinoff}
|
8
|
+
gem.summary = %q{Guard module for spinoff}
|
9
|
+
gem.homepage = "https://github.com/bernd/guard-spinoff"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "guard-spinoff"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Guard::Spinoff::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'guard'
|
19
|
+
gem.add_dependency 'spinoff'
|
20
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'guard/spinoff/runner'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class Spinoff < Guard
|
7
|
+
attr_reader :runner
|
8
|
+
|
9
|
+
def initialize(watchers = [], options = {})
|
10
|
+
super
|
11
|
+
@runner = Runner.new(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
runner.kill
|
16
|
+
runner.launch('Start')
|
17
|
+
end
|
18
|
+
|
19
|
+
def stop
|
20
|
+
runner.kill
|
21
|
+
end
|
22
|
+
|
23
|
+
def reload
|
24
|
+
runner.kill
|
25
|
+
runner.launch('Reload')
|
26
|
+
end
|
27
|
+
|
28
|
+
def run_all
|
29
|
+
runner.run_all
|
30
|
+
end
|
31
|
+
|
32
|
+
def run_on_change(paths)
|
33
|
+
runner.run(paths)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'thread'
|
2
|
+
require 'guard'
|
3
|
+
require 'guard/guard'
|
4
|
+
require 'spinoff/client'
|
5
|
+
require 'spinoff/server'
|
6
|
+
|
7
|
+
module Guard
|
8
|
+
class Spinoff < Guard
|
9
|
+
class Runner
|
10
|
+
attr_reader :options
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
Thread.abort_on_exception = true
|
14
|
+
@options = options
|
15
|
+
@config = init_config(@options)
|
16
|
+
UI.info 'Guard::Spinoff Initialized'
|
17
|
+
end
|
18
|
+
|
19
|
+
def launch(action)
|
20
|
+
UI.info "#{action}ing Spinoff", :reset => true
|
21
|
+
start_server
|
22
|
+
end
|
23
|
+
|
24
|
+
def kill
|
25
|
+
@server.kill if @server
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(paths)
|
29
|
+
::Spinoff::Client.start(Array(paths))
|
30
|
+
end
|
31
|
+
|
32
|
+
def run_all
|
33
|
+
if rspec?
|
34
|
+
run('spec')
|
35
|
+
elsif test_unit?
|
36
|
+
run('test')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def init_config(options)
|
42
|
+
{}.tap do |config|
|
43
|
+
config[:init_script] = options[:init]
|
44
|
+
config[:test_framework] = :rspec if rspec?
|
45
|
+
config[:test_framework] = :testunit if test_unit?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def start_server
|
50
|
+
unless @config[:test_framework]
|
51
|
+
raise "No :runner guard option set!"
|
52
|
+
end
|
53
|
+
|
54
|
+
@server ||= Thread.new do
|
55
|
+
::Spinoff::Server.start(@config)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def rspec?
|
60
|
+
options[:runner] == :rspec
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_unit?
|
64
|
+
options[:runner] == :test_unit
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Available runner: :rspec, :test_unit
|
2
|
+
guard 'spinoff', :runner => :rspec do
|
3
|
+
# uses the .rspec file
|
4
|
+
# --colour --fail-fast --format documentation --tag ~slow
|
5
|
+
watch(%r{^spec/.+_spec\.rb})
|
6
|
+
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
|
+
watch(%r{^app/(.+)\.haml}) { |m| "spec/#{m[1]}.haml_spec.rb" }
|
8
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
9
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
|
10
|
+
|
11
|
+
# TestUnit
|
12
|
+
# watch(%r|^test/(.*)_test\.rb|)
|
13
|
+
# watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
14
|
+
# watch(%r|^test/test_helper\.rb|) { "test" }
|
15
|
+
# watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
|
16
|
+
# watch(%r|^app/models/(.*)\.rb|) { |m| "test/unit/#{m[1]}_test.rb" }
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-spinoff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bernd Ahlers
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: guard
|
16
|
+
requirement: &72365190 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *72365190
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: spinoff
|
27
|
+
requirement: &72364980 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *72364980
|
36
|
+
description: Guard module for spinoff
|
37
|
+
email:
|
38
|
+
- bernd@tuneafish.de
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- guard-spinoff.gemspec
|
49
|
+
- lib/guard/spinoff.rb
|
50
|
+
- lib/guard/spinoff/runner.rb
|
51
|
+
- lib/guard/spinoff/templates/Guardfile
|
52
|
+
- lib/guard/spinoff/version.rb
|
53
|
+
homepage: https://github.com/bernd/guard-spinoff
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.8.11
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Guard module for spinoff
|
77
|
+
test_files: []
|