guard-rails 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .rvmrc
data/Gemfile CHANGED
@@ -8,11 +8,11 @@ gem 'guard'
8
8
  gem 'guard-rspec'
9
9
 
10
10
  require 'rbconfig'
11
- if Config::CONFIG['target_os'] =~ /darwin/i
11
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
12
12
  gem 'rb-fsevent', '>= 0.3.9'
13
13
  gem 'growl', '~> 1.0.3'
14
14
  end
15
- if Config::CONFIG['target_os'] =~ /linux/i
15
+ if RbConfig::CONFIG['target_os'] =~ /linux/i
16
16
  gem 'rb-inotify', '>= 0.5.1'
17
17
  gem 'libnotify', '~> 0.1.3'
18
18
  end
data/README.md CHANGED
@@ -14,7 +14,9 @@ Lots of fun options!
14
14
  * `:start_on_start` will start the server when starting Guard (default `true`)
15
15
  * `:force_run` kills any process that's holding open the listen port before attempting to (re)start Rails (default `false`).
16
16
  * `:daemon` runs the server as a daemon, without any output to the terminal that ran `guard` (default `false`).
17
+ * `:debugger` runs the server with the debugger enabled (default `false`). Required ruby-debug gem.
17
18
  * `:timeout` waits this number of seconds when restarting the Rails server before reporting there's a problem (default `20`).
19
+ * `:server` lets you specify the webserver engine to use (try `:server => :thin`).
18
20
 
19
21
  This is super-alpha, but it works for me! Only really hand-tested in Mac OS X. Feel free to fork'n'fix for other
20
22
  OSes, and to add some more real tests.
data/Rakefile CHANGED
@@ -15,10 +15,10 @@ RSpec::Core::RakeTask.new(:spec)
15
15
  namespace :spec do
16
16
  desc "Run on three Rubies"
17
17
  task :platforms do
18
- prefix = "rvm 1.8.7,1.9.2,ree ruby"
18
+ prefix = "rvm 1.8.7,1.9.2,ree,1.9.3 do"
19
19
  system %{#{prefix} bundle}
20
20
  system %{#{prefix} bundle exec rake spec}
21
- exit $?.exitstatus
21
+ exit $?.exitstatus if $?.exitstatus != 0
22
22
  end
23
23
  end
24
24
 
data/lib/guard/rails.rb CHANGED
@@ -12,8 +12,9 @@ module Guard
12
12
  :environment => 'development',
13
13
  :start_on_start => true,
14
14
  :force_run => false,
15
- :timeout => 20,
16
- :server => nil
15
+ :timeout => 30,
16
+ :server => nil,
17
+ :debugger => false
17
18
  }
18
19
 
19
20
  def initialize(watchers = [], options = {})
@@ -26,18 +27,19 @@ module Guard
26
27
  def start
27
28
  server = options[:server] ? "#{options[:server]} and " : ""
28
29
  UI.info "Guard::Rails will now restart your app on port #{options[:port]} using #{server}#{options[:environment]} environment."
29
- run_all if options[:start_on_start]
30
+ reload("start") if options[:start_on_start]
30
31
  end
31
32
 
32
- def run_all
33
- UI.info "Restarting Rails..."
34
- Notifier.notify("Rails restarting on port #{options[:port]} in #{options[:environment]} environment...", :title => "Restarting Rails...", :image => :pending)
33
+ def reload(action = "restart")
34
+ action_cap = action.capitalize
35
+ UI.info "#{action_cap}ing Rails..."
36
+ Notifier.notify("Rails #{action}ing on port #{options[:port]} in #{options[:environment]} environment...", :title => "#{action_cap}ing Rails...", :image => :pending)
35
37
  if runner.restart
36
- UI.info "Rails restarted, pid #{runner.pid}"
37
- Notifier.notify("Rails restarted on port #{options[:port]}.", :title => "Rails restarted!", :image => :success)
38
+ UI.info "Rails #{action}ed, pid #{runner.pid}"
39
+ Notifier.notify("Rails #{action}ed on port #{options[:port]}.", :title => "Rails #{action}ed!", :image => :success)
38
40
  else
39
- UI.info "Rails NOT restarted, check your log files."
40
- Notifier.notify("Rails NOT restarted, check your log files.", :title => "Rails NOT restarted!", :image => :failed)
41
+ UI.info "Rails NOT #{action}ed, check your log files."
42
+ Notifier.notify("Rails NOT #{action}ed, check your log files.", :title => "Rails NOT #{action}ed!", :image => :failed)
41
43
  end
42
44
  end
43
45
 
@@ -47,7 +49,7 @@ module Guard
47
49
  end
48
50
 
49
51
  def run_on_change(paths)
50
- run_all
52
+ reload
51
53
  end
52
54
  end
53
55
  end
@@ -23,7 +23,7 @@ module Guard
23
23
  FileUtils.rm pid_file
24
24
  end
25
25
  end
26
-
26
+
27
27
  def restart
28
28
  stop
29
29
  start
@@ -37,6 +37,7 @@ module Guard
37
37
  ]
38
38
 
39
39
  rails_options << '-d' if options[:daemon]
40
+ rails_options << '-u' if options[:debugger]
40
41
  rails_options << options[:server] if options[:server]
41
42
 
42
43
  %{sh -c 'cd #{Dir.pwd} && rails s #{rails_options.join(' ')} &'}
@@ -1,4 +1,4 @@
1
1
  module GuardRails
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
4
4
 
@@ -17,6 +17,7 @@ describe Guard::RailsRunner do
17
17
  let(:pid) { 12345 }
18
18
 
19
19
  before do
20
+ FileUtils.mkdir_p File.split(runner.pid_file).first
20
21
  File.open(runner.pid_file, 'w') { |fh| fh.print pid }
21
22
  end
22
23
 
@@ -46,6 +47,14 @@ describe Guard::RailsRunner do
46
47
  runner.build_rails_command.should match(%r{ -d})
47
48
  end
48
49
  end
50
+
51
+ context 'debugger' do
52
+ let(:options) { default_options.merge(:debugger => true) }
53
+
54
+ it "should have a debugger switch" do
55
+ runner.build_rails_command.should match(%r{ -u})
56
+ end
57
+ end
49
58
 
50
59
  context 'custom server' do
51
60
  let(:options) { default_options.merge(:server => 'thin') }
@@ -19,7 +19,7 @@ describe Guard::Rails do
19
19
 
20
20
  context 'start on start' do
21
21
  it "should show the right message and run startup" do
22
- guard.expects(:run_all).once
22
+ guard.expects(:reload).once
23
23
  ui_expectation
24
24
  guard.start
25
25
  end
@@ -29,52 +29,73 @@ describe Guard::Rails do
29
29
  let(:options) { { :start_on_start => false } }
30
30
 
31
31
  it "should show the right message and not run startup" do
32
- guard.expects(:run_all).never
32
+ guard.expects(:reload).never
33
33
  ui_expectation
34
34
  guard.start
35
35
  end
36
36
  end
37
37
  end
38
38
 
39
- describe '#run_all' do
39
+ describe '#reload' do
40
40
  let(:pid) { '12345' }
41
41
 
42
42
  before do
43
- Guard::UI.expects(:info).with('Restarting Rails...')
44
- Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarting/), has_entry(:image => :pending))
45
43
  Guard::RailsRunner.any_instance.stubs(:pid).returns(pid)
46
44
  end
47
45
 
48
46
  let(:runner_stub) { Guard::RailsRunner.any_instance.stubs(:restart) }
49
47
 
50
- context 'with pid file' do
48
+ context 'at start' do
51
49
  before do
50
+ Guard::UI.expects(:info).with('Starting Rails...')
51
+ Guard::Notifier.expects(:notify).with(regexp_matches(/Rails starting/), has_entry(:image => :pending))
52
52
  runner_stub.returns(true)
53
53
  end
54
54
 
55
- it "should restart and show the pid file" do
55
+ it "should start and show the pid file" do
56
56
  Guard::UI.expects(:info).with(regexp_matches(/#{pid}/))
57
- Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarted/), has_entry(:image => :success))
57
+ Guard::Notifier.expects(:notify).with(regexp_matches(/Rails started/), has_entry(:image => :success))
58
58
 
59
- guard.run_all
59
+ guard.reload("start")
60
60
  end
61
61
  end
62
62
 
63
- context 'no pid file' do
63
+ context 'after start' do
64
64
  before do
65
- runner_stub.returns(false)
65
+ Guard::RailsRunner.any_instance.stubs(:pid).returns(pid)
66
+ Guard::UI.expects(:info).with('Restarting Rails...')
67
+ Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarting/), has_entry(:image => :pending))
66
68
  end
67
69
 
68
- it "should restart and show the pid file" do
69
- Guard::UI.expects(:info).with(regexp_matches(/#{pid}/)).never
70
- Guard::UI.expects(:info).with(regexp_matches(/Rails NOT restarted/))
71
- Guard::Notifier.expects(:notify).with(regexp_matches(/Rails NOT restarted/), has_entry(:image => :failed))
70
+ context 'with pid file' do
71
+ before do
72
+ runner_stub.returns(true)
73
+ end
72
74
 
73
- guard.run_all
75
+ it "should restart and show the pid file" do
76
+ Guard::UI.expects(:info).with(regexp_matches(/#{pid}/))
77
+ Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarted/), has_entry(:image => :success))
78
+
79
+ guard.reload
80
+ end
81
+ end
82
+
83
+ context 'no pid file' do
84
+ before do
85
+ runner_stub.returns(false)
86
+ end
87
+
88
+ it "should restart and show the pid file" do
89
+ Guard::UI.expects(:info).with(regexp_matches(/#{pid}/)).never
90
+ Guard::UI.expects(:info).with(regexp_matches(/Rails NOT restarted/))
91
+ Guard::Notifier.expects(:notify).with(regexp_matches(/Rails NOT restarted/), has_entry(:image => :failed))
92
+
93
+ guard.reload
94
+ end
74
95
  end
75
96
  end
76
97
  end
77
-
98
+
78
99
  describe '#stop' do
79
100
  it "should stop correctly" do
80
101
  Guard::Notifier.expects(:notify).with('Until next time...', anything)
@@ -83,8 +104,8 @@ describe Guard::Rails do
83
104
  end
84
105
 
85
106
  describe '#run_on_change' do
86
- it "should run on change" do
87
- guard.expects(:run_all).once
107
+ it "should reload on change" do
108
+ guard.expects(:reload).once
88
109
  guard.run_on_change([])
89
110
  end
90
111
  end
metadata CHANGED
@@ -1,79 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: guard-rails
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - John Bintz
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-04 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: guard
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2155769020 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 19
30
- segments:
31
- - 0
32
- - 2
33
- - 2
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 0.2.2
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rspec
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2155769020
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &2155768300 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
29
+ requirements:
43
30
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 2
48
- - 6
49
- - 0
31
+ - !ruby/object:Gem::Version
50
32
  version: 2.6.0
51
33
  type: :development
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: mocha
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2155768300
36
+ - !ruby/object:Gem::Dependency
37
+ name: mocha
38
+ requirement: &2155767740 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
65
44
  type: :development
66
- version_requirements: *id003
45
+ prerelease: false
46
+ version_requirements: *2155767740
67
47
  description: Restart Rails when things change in your app
68
- email:
48
+ email:
69
49
  - john@coswellproductions.com
70
50
  executables: []
71
-
72
51
  extensions: []
73
-
74
52
  extra_rdoc_files: []
75
-
76
- files:
53
+ files:
77
54
  - .gitignore
78
55
  - .travis.yml
79
56
  - Gemfile
@@ -89,41 +66,37 @@ files:
89
66
  - spec/lib/guard/rails/runner_spec.rb
90
67
  - spec/lib/guard/rails_spec.rb
91
68
  - spec/spec_helper.rb
92
- has_rdoc: true
93
- homepage: ""
69
+ homepage: ''
94
70
  licenses: []
95
-
96
71
  post_install_message:
97
72
  rdoc_options: []
98
-
99
- require_paths:
73
+ require_paths:
100
74
  - lib
101
- required_ruby_version: !ruby/object:Gem::Requirement
75
+ required_ruby_version: !ruby/object:Gem::Requirement
102
76
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ segments:
108
82
  - 0
109
- version: "0"
110
- required_rubygems_version: !ruby/object:Gem::Requirement
83
+ hash: -954311980352509128
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
85
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ segments:
117
91
  - 0
118
- version: "0"
92
+ hash: -954311980352509128
119
93
  requirements: []
120
-
121
94
  rubyforge_project: guard-rails
122
- rubygems_version: 1.6.2
95
+ rubygems_version: 1.8.11
123
96
  signing_key:
124
97
  specification_version: 3
125
98
  summary: Restart Rails when things change in your app
126
- test_files:
99
+ test_files:
127
100
  - spec/lib/guard/rails/runner_spec.rb
128
101
  - spec/lib/guard/rails_spec.rb
129
102
  - spec/spec_helper.rb