guard-spin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Andrew Assarattanakul
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ Guard::Spin
2
+ ===========
3
+
4
+ Install
5
+ -------
6
+
7
+ Please be sure to have [Guard](https://github.com/guard/guard) installed before continue.
8
+
9
+ Install the gem:
10
+
11
+ $ gem install guard-spin
12
+
13
+ Add it to your Gemfile (inside development group):
14
+
15
+ ``` ruby
16
+ gem 'guard-spin'
17
+ ```
18
+
19
+ Add guard definition to your Guardfile by running this command:
20
+
21
+ $ guard init spin
22
+
23
+ Usage
24
+ -----
25
+
26
+ Please read [Guard usage doc](https://github.com/guard/guard#readme)
27
+
28
+ Guardfile
29
+ ---------
30
+
31
+ Please read [Guard doc](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.
32
+
33
+ Development
34
+ -----------
35
+
36
+ * Source hosted at [GitHub](https://github.com/vizjerai/guard-spin)
37
+ * Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/vizjerai/guard-spin/issues)
38
+
39
+ Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
40
+ you make.
41
+
42
+ Authors
43
+ ------
44
+
45
+ * [Jonathan](https://github.com/jonsgreen)
46
+ * [Andrew Assarattanakul](https://github.com/vizjerai)
47
+
48
+ Many Thanks To
49
+ --------------
50
+
51
+ * [Jesse Storimer](https://github.com/jstorimer)
@@ -0,0 +1,69 @@
1
+ # Needed for socket_file
2
+ require 'socket'
3
+ require 'tempfile'
4
+ require 'digest/md5'
5
+
6
+ module Guard
7
+ class Spin
8
+ class Runner
9
+ attr_reader :options
10
+
11
+ def initialize(options = {})
12
+ @options = options
13
+ UI.info "Guard::Spin Initialized"
14
+ end
15
+
16
+ def launch_spin(action)
17
+ UI.info "#{action}ing Spin", :reset => true
18
+ spawn_spin
19
+ end
20
+
21
+ def kill_spin
22
+ stop_spin
23
+ end
24
+
25
+ def run(paths)
26
+ system "spin push #{paths.join(" ")}"
27
+ end
28
+
29
+ def run_all
30
+ run(['spec'])
31
+ end
32
+
33
+ private
34
+
35
+ def spawn_spin
36
+ @spin_pid = fork do
37
+ exec spin_serve_command
38
+ end
39
+ end
40
+
41
+ def stop_spin
42
+ return unless @spin_pid
43
+
44
+ Process.kill(:INT, @spin_pid)
45
+ sleep 0.5
46
+
47
+ begin
48
+ unless Process.waitpid(@spin_pid, Process::WNOHANG)
49
+ Process.kill(:KILL, @spin_pid)
50
+ end
51
+ rescue Errno::ECHILD
52
+ end
53
+ UI.info "Spin Stopped", :reset => true
54
+ end
55
+
56
+ def spin_serve_command
57
+ cmd_parts = []
58
+ cmd_parts << "bundle exec" if bundler?
59
+ cmd_parts << "spin serve"
60
+
61
+ cmd_parts.join(' ')
62
+ end
63
+
64
+ def bundler?
65
+ @bundler ||= File.exist?("#{Dir.pwd}/Gemfile") && options[:bundler] != false
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,9 @@
1
+ guard 'spin' do
2
+ # uses the .rspec file
3
+ # --colour --fail-fast --format documentation --tag ~slow
4
+ watch(%r{^spec/.+_spec\.rb})
5
+ watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
6
+ watch(%r{^app/(.+)\.haml}) { |m| "spec/#{m[1]}.haml_spec.rb" }
7
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
8
+ 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"] }
9
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module SpinVersion
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/lib/guard/spin.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Guard
5
+ class Spin < Guard
6
+
7
+ autoload :Runner, 'guard/spin/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.kill_spin
17
+ runner.launch_spin("Start")
18
+ end
19
+
20
+ def reload
21
+ runner.kill_spin
22
+ runner.launch_spin("Reload")
23
+ end
24
+
25
+ def run_all
26
+ runner.run_all
27
+ end
28
+
29
+ def run_on_change(paths)
30
+ runner.run(paths)
31
+ end
32
+
33
+ def stop
34
+ runner.kill_spin
35
+ end
36
+
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-spin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - jonathangreenberg
9
+ - Andrew Assarattanakul
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-11-08 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: guard
17
+ requirement: &17190048100 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *17190048100
26
+ - !ruby/object:Gem::Dependency
27
+ name: spin
28
+ requirement: &17190047580 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *17190047580
37
+ description: Guard gem for Spin
38
+ email:
39
+ - greenberg@entryway.net
40
+ - assarata@gmail.com
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - lib/guard/spin.rb
46
+ - lib/guard/spin/runner.rb
47
+ - lib/guard/spin/templates/Guardfile
48
+ - lib/guard/spin/version.rb
49
+ - LICENSE
50
+ - README.md
51
+ homepage: http://github.com/vizjerai/guard-spin
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 1.8.11
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Pushes watched files to Spin
75
+ test_files: []