guard-rails 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README.md +4 -6
- data/guard-rails.gemspec +5 -6
- data/lib/guard/rails.rb +3 -1
- data/lib/guard/rails/runner.rb +12 -7
- data/lib/guard/rails/version.rb +1 -1
- data/spec/lib/guard/rails/runner_spec.rb +20 -3
- data/spec/spec_helper.rb +1 -1
- metadata +22 -26
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
[![Build Status](http://travis-ci.org/johnbintz/guard-rails.png)](http://travis-ci.org/johnbintz/guard-rails)
|
1
|
+
[![Build Status](https://travis-ci.org/ranmocy/guard-rails.png)](https://travis-ci.org/ranmocy/guard-rails)
|
4
2
|
|
5
3
|
Want to restart your Rails development server whilst you work? Now you can!
|
6
4
|
|
@@ -19,7 +17,7 @@ Lots of fun options!
|
|
19
17
|
* `:debugger` runs the server with the debugger enabled (default `false`). Required ruby-debug gem.
|
20
18
|
* `:timeout` waits this number of seconds when restarting the Rails server before reporting there's a problem (default `20`).
|
21
19
|
* `:server` lets you specify the webserver engine to use (try `:server => :thin`).
|
20
|
+
* `:pid_file` specify your pid_file, so that maybe you can run multiple instances with same rails_env (default `tmp/pids/[RAILS_ENV].pid`).
|
21
|
+
* `:zeus` support [zeus](https://github.com/burke/zeus) to boost rails init speed (default `false`).
|
22
22
|
|
23
|
-
|
24
|
-
OSes, and to add some more real tests.
|
25
|
-
|
23
|
+
Feel free to fork'n'fix for any willing.
|
data/guard-rails.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
$:.push File.expand_path("../lib", __FILE__)
|
3
2
|
require "guard/rails/version"
|
4
3
|
|
@@ -6,10 +5,10 @@ Gem::Specification.new do |s|
|
|
6
5
|
s.name = "guard-rails"
|
7
6
|
s.version = GuardRails::VERSION
|
8
7
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["John Bintz"]
|
10
|
-
s.email = ["john@coswellproductions.com"]
|
11
|
-
s.homepage = ""
|
12
|
-
s.summary = %q{
|
8
|
+
s.authors = ["John Bintz", "Wanzhang Sheng"]
|
9
|
+
s.email = ["john@coswellproductions.com", "Ranmocy@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/ranmocy/guard-rails"
|
11
|
+
s.summary = %q{Guard your Rails to always be there.}
|
13
12
|
s.description = %q{Restart Rails when things change in your app}
|
14
13
|
|
15
14
|
s.rubyforge_project = "guard-rails"
|
@@ -22,5 +21,5 @@ Gem::Specification.new do |s|
|
|
22
21
|
s.add_dependency 'guard', '>= 0.2.2'
|
23
22
|
|
24
23
|
s.add_development_dependency 'rspec', '~> 2.6.0'
|
25
|
-
s.add_development_dependency 'mocha'
|
24
|
+
s.add_development_dependency 'mocha', '~> 0.12.3'
|
26
25
|
end
|
data/lib/guard/rails.rb
CHANGED
data/lib/guard/rails/runner.rb
CHANGED
@@ -18,8 +18,12 @@ module Guard
|
|
18
18
|
|
19
19
|
def stop
|
20
20
|
if File.file?(pid_file)
|
21
|
-
|
21
|
+
pid = File.read(pid_file).strip
|
22
|
+
system %{kill -SIGINT #{pid}}
|
22
23
|
wait_for_no_pid if $?.exitstatus == 0
|
24
|
+
|
25
|
+
# If you lost your pid_file, you are already died.
|
26
|
+
system %{kill -KILL #{pid} > /dev/null 2>&1}
|
23
27
|
FileUtils.rm pid_file, :force => true
|
24
28
|
end
|
25
29
|
end
|
@@ -33,18 +37,19 @@ module Guard
|
|
33
37
|
rails_options = [
|
34
38
|
'-e', options[:environment],
|
35
39
|
'-p', options[:port],
|
36
|
-
'--pid', pid_file
|
40
|
+
'--pid', pid_file,
|
41
|
+
options[:daemon] ? '-d' : '',
|
42
|
+
options[:debugger] ? '-u' : '',
|
43
|
+
options[:server].nil? ? '' : options[:server],
|
37
44
|
]
|
38
45
|
|
39
|
-
|
40
|
-
rails_options << '-u' if options[:debugger]
|
41
|
-
rails_options << options[:server] if options[:server]
|
46
|
+
rails_runner = options[:zeus] ? 'zeus' : 'rails'
|
42
47
|
|
43
|
-
%{sh -c 'cd #{Dir.pwd} && RAILS_ENV=#{options[:environment]}
|
48
|
+
%{sh -c 'cd #{Dir.pwd} && RAILS_ENV=#{options[:environment]} #{rails_runner} s #{rails_options.join(' ')} &'}
|
44
49
|
end
|
45
50
|
|
46
51
|
def pid_file
|
47
|
-
File.expand_path("tmp/pids/#{options[:environment]}.pid")
|
52
|
+
File.expand_path(options[:pid_file] || "tmp/pids/#{options[:environment]}.pid")
|
48
53
|
end
|
49
54
|
|
50
55
|
def pid
|
data/lib/guard/rails/version.rb
CHANGED
@@ -6,10 +6,10 @@ describe Guard::RailsRunner do
|
|
6
6
|
let(:runner) { Guard::RailsRunner.new(options) }
|
7
7
|
let(:environment) { 'development' }
|
8
8
|
let(:port) { 3000 }
|
9
|
-
|
9
|
+
|
10
10
|
let(:default_options) { { :environment => environment, :port => port } }
|
11
11
|
let(:options) { default_options }
|
12
|
-
|
12
|
+
|
13
13
|
describe '#pid' do
|
14
14
|
include FakeFS::SpecHelpers
|
15
15
|
|
@@ -47,7 +47,7 @@ describe Guard::RailsRunner do
|
|
47
47
|
runner.build_rails_command.should match(%r{ -d})
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
context 'debugger' do
|
52
52
|
let(:options) { default_options.merge(:debugger => true) }
|
53
53
|
|
@@ -63,6 +63,23 @@ describe Guard::RailsRunner do
|
|
63
63
|
runner.build_rails_command.should match(%r{thin})
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
context "no pid_file" do
|
68
|
+
it "should use default pid_file" do
|
69
|
+
pid_file_path = File.expand_path "tmp/pids/development.pid"
|
70
|
+
runner.build_rails_command.should match(%r{ --pid #{pid_file_path}})
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "custom pid_file" do
|
75
|
+
let(:custom_pid_file) { "tmp/pids/rails_dev.pid" }
|
76
|
+
let(:options) { default_options.merge(:pid_file => custom_pid_file) }
|
77
|
+
|
78
|
+
it "should use custom pid_file" do
|
79
|
+
pid_file_path = File.expand_path custom_pid_file
|
80
|
+
runner.build_rails_command.should match(%r{ --pid #{pid_file_path}})
|
81
|
+
end
|
82
|
+
end
|
66
83
|
end
|
67
84
|
|
68
85
|
describe '#start' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,67 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Bintz
|
9
|
+
- Wanzhang Sheng
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2013-01-23 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: guard
|
17
|
+
prerelease: false
|
16
18
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 0.2.2
|
23
|
+
none: false
|
22
24
|
type: :runtime
|
23
|
-
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.2.2
|
30
|
+
none: false
|
30
31
|
- !ruby/object:Gem::Dependency
|
31
32
|
name: rspec
|
33
|
+
prerelease: false
|
32
34
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
35
|
requirements:
|
35
36
|
- - ~>
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: 2.6.0
|
39
|
+
none: false
|
38
40
|
type: :development
|
39
|
-
prerelease: false
|
40
41
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 2.6.0
|
46
|
+
none: false
|
46
47
|
- !ruby/object:Gem::Dependency
|
47
48
|
name: mocha
|
49
|
+
prerelease: false
|
48
50
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
51
|
requirements:
|
51
|
-
- -
|
52
|
+
- - ~>
|
52
53
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
54
|
+
version: 0.12.3
|
55
|
+
none: false
|
54
56
|
type: :development
|
55
|
-
prerelease: false
|
56
57
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.12.3
|
62
|
+
none: false
|
62
63
|
description: Restart Rails when things change in your app
|
63
64
|
email:
|
64
65
|
- john@coswellproductions.com
|
66
|
+
- Ranmocy@gmail.com
|
65
67
|
executables: []
|
66
68
|
extensions: []
|
67
69
|
extra_rdoc_files: []
|
@@ -81,36 +83,30 @@ files:
|
|
81
83
|
- spec/lib/guard/rails/runner_spec.rb
|
82
84
|
- spec/lib/guard/rails_spec.rb
|
83
85
|
- spec/spec_helper.rb
|
84
|
-
homepage:
|
86
|
+
homepage: https://github.com/ranmocy/guard-rails
|
85
87
|
licenses: []
|
86
88
|
post_install_message:
|
87
89
|
rdoc_options: []
|
88
90
|
require_paths:
|
89
91
|
- lib
|
90
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
93
|
requirements:
|
93
94
|
- - ! '>='
|
94
95
|
- !ruby/object:Gem::Version
|
95
96
|
version: '0'
|
96
|
-
segments:
|
97
|
-
- 0
|
98
|
-
hash: -1845982293298969643
|
99
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
97
|
none: false
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
99
|
requirements:
|
102
100
|
- - ! '>='
|
103
101
|
- !ruby/object:Gem::Version
|
104
102
|
version: '0'
|
105
|
-
|
106
|
-
- 0
|
107
|
-
hash: -1845982293298969643
|
103
|
+
none: false
|
108
104
|
requirements: []
|
109
105
|
rubyforge_project: guard-rails
|
110
|
-
rubygems_version: 1.8.
|
106
|
+
rubygems_version: 1.8.24
|
111
107
|
signing_key:
|
112
108
|
specification_version: 3
|
113
|
-
summary:
|
109
|
+
summary: Guard your Rails to always be there.
|
114
110
|
test_files:
|
115
111
|
- spec/lib/guard/rails/runner_spec.rb
|
116
112
|
- spec/lib/guard/rails_spec.rb
|