guard-rails 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: badcb2d7fa378fb0f9fc7bc4a4922642f6d1b24b
4
- data.tar.gz: 80d9c099b2b8b7824cf3bfa186f4dd1960f9e9d1
3
+ metadata.gz: 445a62a6bd29148ad6ce3200a020dc60d85a8f1b
4
+ data.tar.gz: 284459605b644a947328ce43fb09431adad8c91e
5
5
  SHA512:
6
- metadata.gz: 364a7e4234fa9efae4af2dcb8319dc2ea712db73d46e0b1492e4486c0b536f04979bb92cc8f2e0a8583bae0640f2a7ce67e64fc69ef36574037c04519a17bc34
7
- data.tar.gz: 84c3dde82a373dd602a5aeead8a8f4f45debbcaf0ae5cbd404e0ea7b3aa13b5632642246856bed09d7ab9ca19a3ac5b178b517ef0bf1d86e57de8b191b2b1436
6
+ metadata.gz: e1766481621fb35a0d698115799188fddfa4430b4fa7757593ee99b62695e349b22ffffce0343947de00c4edadbf4c2fc372b094a30562469249398cca32ddf7
7
+ data.tar.gz: e95d187c66a652c95b231b597afa870f1b196d57958e8a3b90705a9a1e60d1d2df053d115e1abf2949a0310dd3f396c2cd84cba93b6453ae01c7d4890ca78d9e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- guard-rails (0.6.1)
4
+ guard-rails (0.7.0)
5
5
  guard (~> 2.0)
6
6
 
7
7
  GEM
@@ -18,7 +18,7 @@ GEM
18
18
  ffi (1.9.6)
19
19
  ffi (1.9.6-java)
20
20
  formatador (0.2.5)
21
- guard (2.7.0)
21
+ guard (2.8.2)
22
22
  formatador (>= 0.2.4)
23
23
  listen (~> 2.7)
24
24
  lumberjack (~> 1.0)
@@ -75,7 +75,7 @@ GEM
75
75
  slop (3.6.0)
76
76
  spoon (0.0.4)
77
77
  ffi
78
- terminal-notifier-guard (1.6.1)
78
+ terminal-notifier-guard (1.6.4)
79
79
  thor (0.19.1)
80
80
  timers (4.0.1)
81
81
  hitimes
data/README.md CHANGED
@@ -37,6 +37,7 @@ Now I can automatically restart your Rails development server as your files chan
37
37
  * `:environment` is the server environment (**default `development`**)
38
38
  * `:force_run` kills any process that's holding the listen port before attempting to (re)start Rails (**default `false`**)
39
39
  * `:pid_file` specify your pid\_file (**default `tmp/pids/[RAILS_ENV].pid`**)
40
+ * `:host` is where the server is hosted (**default `localhost`**)
40
41
  * `:port` is the server port number (**default `3000`**)
41
42
  * `:root` lets you specify the Rails root, i.e. for using guard-rails to run a dummy app within an engine (try `:root => '/spec/dummy'`).
42
43
  * `:server` the webserver engine to use (**try `:server => :thin`**)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.7.0
data/lib/guard/rails.rb CHANGED
@@ -12,18 +12,19 @@ module Guard
12
12
  attr_reader :options, :runner
13
13
 
14
14
  DEFAULT_OPTIONS = {
15
- :CLI => nil,
16
- :daemon => false,
17
- :debugger => false,
18
- :environment => 'development',
19
- :force_run => false,
20
- :pid_file => nil, # construct the filename based on options[:environment] on runtime
21
- :port => 3000,
22
- :server => nil, # specified by rails
23
- :start_on_start => true,
24
- :timeout => 30,
25
- :zeus_plan => 'server',
26
- :zeus => false,
15
+ CLI: nil,
16
+ daemon: false,
17
+ debugger: false,
18
+ environment: 'development',
19
+ force_run: false,
20
+ pid_file: nil, # construct the filename based on options[:environment] on runtime
21
+ host: "localhost",
22
+ port: 3000,
23
+ server: nil, # specified by rails
24
+ start_on_start: true,
25
+ timeout: 30,
26
+ zeus_plan: 'server',
27
+ zeus: false,
27
28
  }
28
29
 
29
30
  def initialize(options = {})
@@ -41,18 +42,18 @@ module Guard
41
42
  def reload(action = "restart")
42
43
  title = "#{action.capitalize}ing Rails..."
43
44
  UI.info title
44
- Notifier.notify("Rails #{action}ing on port #{options[:port]} in #{options[:environment]}...", :title => title, :image => :pending)
45
+ Notifier.notify("Rails #{action}ing on port #{options[:port]} in #{options[:environment]}...", title: title, image: :pending)
45
46
  if runner.restart
46
47
  UI.info "Rails #{action}ed, pid #{runner.pid}"
47
- Notifier.notify("Rails #{action}ed on port #{options[:port]}.", :title => "Rails #{action}ed!", :image => :success)
48
+ Notifier.notify("Rails #{action}ed on port #{options[:port]}.", title: "Rails #{action}ed!", image: :success)
48
49
  else
49
50
  UI.info "Rails NOT #{action}ed, check your log files."
50
- Notifier.notify("Rails NOT #{action}ed, check your log files.", :title => "Rails NOT #{action}ed!", :image => :failed)
51
+ Notifier.notify("Rails NOT #{action}ed, check your log files.", title: "Rails NOT #{action}ed!", image: :failed)
51
52
  end
52
53
  end
53
54
 
54
55
  def stop
55
- Notifier.notify("Until next time...", :title => "Rails shutting down.", :image => :pending)
56
+ Notifier.notify("Until next time...", title: "Rails shutting down.", image: :pending)
56
57
  runner.stop
57
58
  end
58
59
 
@@ -74,6 +74,7 @@ module Guard
74
74
  options[:debugger] ? '-u' : nil,
75
75
  '-e', options[:environment],
76
76
  '--pid', "\"#{pid_file}\"",
77
+ '-b', options[:host],
77
78
  '-p', options[:port],
78
79
  options[:server],
79
80
  ]
@@ -149,7 +150,7 @@ module Guard
149
150
 
150
151
  def remove_pid_file_and_wait_for_no_pid
151
152
  wait_for_pid_loop do
152
- FileUtils.rm pid_file, :force => true
153
+ FileUtils.rm pid_file, force: true
153
154
  !has_pid?
154
155
  end
155
156
  end
@@ -3,12 +3,14 @@ require 'fakefs/spec_helpers'
3
3
 
4
4
  describe Guard::Rails::Runner do
5
5
  let(:runner) { Guard::Rails::Runner.new(options) }
6
- let(:environment) { 'development' }
7
- let(:port) { 3000 }
8
6
 
9
- let(:default_options) { { :environment => environment, :port => port } }
7
+ let(:default_options) { Guard::Rails::DEFAULT_OPTIONS }
10
8
  let(:options) { default_options }
11
9
 
10
+ let(:default_environment) { default_options[:environment] }
11
+ let(:default_host) { default_options[:host] }
12
+ let(:default_port) { default_options[:port] }
13
+
12
14
  describe '#pid' do
13
15
  include FakeFS::SpecHelpers
14
16
 
@@ -32,7 +34,7 @@ describe Guard::Rails::Runner do
32
34
  end
33
35
 
34
36
  context 'when custom rails root given' do
35
- let(:options) { default_options.merge(:root => 'spec/dummy') }
37
+ let(:options) { default_options.merge(root: 'spec/dummy') }
36
38
  let(:pid) { 12345 }
37
39
 
38
40
  before do
@@ -41,7 +43,7 @@ describe Guard::Rails::Runner do
41
43
  end
42
44
 
43
45
  it "points to the right pid file" do
44
- expect(runner.pid_file).to match %r{spec/dummy/tmp/pids/development.pid}
46
+ expect(runner.pid_file).to match %r{spec/dummy/tmp/pids/#{default_environment}.pid}
45
47
  end
46
48
  end
47
49
 
@@ -50,13 +52,13 @@ describe Guard::Rails::Runner do
50
52
  describe '#build_command' do
51
53
  context "with options[:CLI]" do
52
54
  let(:custom_cli) { 'custom_CLI_command' }
53
- let(:options) { default_options.merge(:CLI => custom_cli) }
55
+ let(:options) { default_options.merge(CLI: custom_cli) }
54
56
  it "has customized CLI" do
55
57
  expect(runner.build_command).to match(%r{#{custom_cli} --pid })
56
58
  end
57
59
 
58
60
  let(:custom_pid_file) { "tmp/pids/rails_dev.pid" }
59
- let(:options) { default_options.merge(:CLI => custom_cli, :pid_file => custom_pid_file) }
61
+ let(:options) { default_options.merge(CLI: custom_cli, pid_file: custom_pid_file) }
60
62
  it "uses customized pid_file" do
61
63
  pid_file_path = File.expand_path custom_pid_file
62
64
  expect(runner.build_command).to match(%r{#{custom_cli} --pid \"#{pid_file_path}\"})
@@ -70,27 +72,27 @@ describe Guard::Rails::Runner do
70
72
  end
71
73
 
72
74
  context "with options[:daemon]" do
73
- let(:options) { default_options.merge(:daemon => true) }
75
+ let(:options) { default_options.merge(daemon: true) }
74
76
  it "has a daemon switch" do
75
77
  expect(runner.build_command).to match(%r{ -d})
76
78
  end
77
79
  end
78
80
 
79
81
  context "without options[:env]" do
80
- it "has environment switch to development" do
81
- expect(runner.build_command).to match(%r{ -e development})
82
+ it "has environment switch to default" do
83
+ expect(runner.build_command).to match(%r{ -e #{default_environment}})
82
84
  end
83
85
  end
84
86
 
85
87
  context "with options[:environment] as test" do
86
- let(:options) { default_options.merge(:environment => 'test') }
88
+ let(:options) { default_options.merge(environment: 'test') }
87
89
  it "has environment switch to test" do
88
90
  expect(runner.build_command).to match(%r{ -e test})
89
91
  end
90
92
  end
91
93
 
92
94
  context 'with options[:debugger]' do
93
- let(:options) { default_options.merge(:debugger => true) }
95
+ let(:options) { default_options.merge(debugger: true) }
94
96
 
95
97
  it "has a debugger switch" do
96
98
  expect(runner.build_command).to match(%r{ -u})
@@ -98,7 +100,7 @@ describe Guard::Rails::Runner do
98
100
  end
99
101
 
100
102
  context 'with options[:server] as thin' do
101
- let(:options) { default_options.merge(:server => 'thin') }
103
+ let(:options) { default_options.merge(server: 'thin') }
102
104
 
103
105
  it "has the server name thin" do
104
106
  expect(runner.build_command).to match(%r{thin})
@@ -107,14 +109,14 @@ describe Guard::Rails::Runner do
107
109
 
108
110
  context "without options[:pid_file]" do
109
111
  it "uses default pid_file" do
110
- pid_file_path = File.expand_path "tmp/pids/development.pid"
112
+ pid_file_path = File.expand_path "tmp/pids/#{default_environment}.pid"
111
113
  expect(runner.build_command).to match(%r{ --pid \"#{pid_file_path}\"})
112
114
  end
113
115
  end
114
116
 
115
117
  context "with options[:pid_file]" do
116
118
  let(:custom_pid_file) { "tmp/pids/rails_dev.pid" }
117
- let(:options) { default_options.merge(:pid_file => custom_pid_file) }
119
+ let(:options) { default_options.merge(pid_file: custom_pid_file) }
118
120
 
119
121
  it "uses customized pid_file" do
120
122
  pid_file_path = File.expand_path custom_pid_file
@@ -122,20 +124,50 @@ describe Guard::Rails::Runner do
122
124
  end
123
125
  end
124
126
 
127
+ context 'with options[:host]' do
128
+ let(:host) { "1.2.3.4" }
129
+ let(:options) { default_options.merge(host: host) }
130
+
131
+ it 'use customized host' do
132
+ expect(runner.build_command).to match(/ -b #{host}/)
133
+ end
134
+ end
135
+
136
+ context 'without options[:host]' do
137
+ it 'use deafult host' do
138
+ expect(runner.build_command).to match(/ -b #{default_host}/)
139
+ end
140
+ end
141
+
142
+ context 'with options[:port]' do
143
+ let(:port) { 3456 }
144
+ let(:options) { default_options.merge(port: port) }
145
+
146
+ it 'use customized port' do
147
+ expect(runner.build_command).to match(/ -p #{port}/)
148
+ end
149
+ end
150
+
151
+ context 'without options[:port]' do
152
+ it 'use default port' do
153
+ expect(runner.build_command).to match(/ -p #{default_port}/)
154
+ end
155
+ end
156
+
125
157
  context "with options[:zeus]" do
126
- let(:options) { default_options.merge(:zeus => true) }
158
+ let(:options) { default_options.merge(zeus: true) }
127
159
  it "has zeus" do
128
160
  expect(runner.build_command).to match(%r{zeus server })
129
161
  end
130
162
 
131
163
  context "with options[:zeus_plan]" do
132
- let(:options) { default_options.merge(:zeus => true, :zeus_plan => 'test_server') }
164
+ let(:options) { default_options.merge(zeus: true, zeus_plan: 'test_server') }
133
165
  it "uses customized zeus plan" do
134
166
  expect(runner.build_command).to match(%r{zeus test_server})
135
167
  end
136
168
 
137
169
  context "with options[:server]" do
138
- let(:options) { default_options.merge(:zeus => true, :zeus_plan => 'test_server', :server => 'thin') }
170
+ let(:options) { default_options.merge(zeus: true, zeus_plan: 'test_server', server: 'thin') }
139
171
  it "uses customized server" do
140
172
  expect(runner.build_command).to match(%r{zeus test_server .* thin})
141
173
  end
@@ -148,14 +180,14 @@ describe Guard::Rails::Runner do
148
180
  expect(runner.build_command).to_not match(%r{zeus server })
149
181
  end
150
182
 
151
- let(:options) { default_options.merge(:zeus_plan => 'test_server') }
183
+ let(:options) { default_options.merge(zeus_plan: 'test_server') }
152
184
  it "doesnt' have test_server" do
153
185
  expect(runner.build_command).to_not match(%r{test_server})
154
186
  end
155
187
  end
156
188
 
157
189
  context 'with options[:root]' do
158
- let(:options) { default_options.merge(:root => 'spec/dummy') }
190
+ let(:options) { default_options.merge(root: 'spec/dummy') }
159
191
 
160
192
  it "has `cd` command with customized rails root" do
161
193
  expect(runner.build_command).to match(%r{cd .*/spec/dummy\" &&})
@@ -164,19 +196,19 @@ describe Guard::Rails::Runner do
164
196
  end
165
197
 
166
198
  describe '#environment' do
167
- it "sets RAILS_ENV to development" do
168
- expect(runner.environment["RAILS_ENV"]).to eq "development"
199
+ it "sets RAILS_ENV to default" do
200
+ expect(runner.environment["RAILS_ENV"]).to eq default_environment
169
201
  end
170
202
 
171
203
  context "with options[:environment] as test" do
172
- let(:options) { default_options.merge(:environment => 'test') }
204
+ let(:options) { default_options.merge(environment: 'test') }
173
205
 
174
206
  it "sets RAILS_ENV to test" do
175
207
  expect(runner.environment["RAILS_ENV"]).to eq "test"
176
208
  end
177
209
 
178
210
  context "with options[:zeus]" do
179
- let(:options) { default_options.merge(:zeus => true) }
211
+ let(:options) { default_options.merge(zeus: true) }
180
212
 
181
213
  it "sets RAILS_ENV to nil" do
182
214
  expect(runner.environment["RAILS_ENV"]).to be nil
@@ -216,13 +248,13 @@ describe Guard::Rails::Runner do
216
248
  end
217
249
 
218
250
  context 'with zeus' do
219
- let(:options) { default_options.merge(:zeus => true) }
251
+ let(:options) { default_options.merge(zeus: true) }
220
252
  it_behaves_like "outside of bundler"
221
253
  end
222
254
 
223
255
  context 'with CLI' do
224
256
  let(:custom_cli) { 'custom_CLI_command' }
225
- let(:options) { default_options.merge(:CLI => custom_cli) }
257
+ let(:options) { default_options.merge(CLI: custom_cli) }
226
258
  it_behaves_like "outside of bundler"
227
259
  end
228
260
  end
@@ -243,13 +275,13 @@ describe Guard::Rails::Runner do
243
275
  end
244
276
 
245
277
  context 'with zeus' do
246
- let(:options) { default_options.merge(:zeus => true) }
278
+ let(:options) { default_options.merge(zeus: true) }
247
279
  it_behaves_like "outside of bundler"
248
280
  end
249
281
 
250
282
  context 'with CLI' do
251
283
  let(:custom_cli) { 'custom_CLI_command' }
252
- let(:options) { default_options.merge(:CLI => custom_cli) }
284
+ let(:options) { default_options.merge(CLI: custom_cli) }
253
285
  it_behaves_like "outside of bundler"
254
286
  end
255
287
  end
@@ -276,7 +308,7 @@ describe Guard::Rails::Runner do
276
308
  end
277
309
 
278
310
  context 'with options[:force_run]' do
279
- let(:options) { default_options.merge(:force_run => true) }
311
+ let(:options) { default_options.merge(force_run: true) }
280
312
 
281
313
  before do
282
314
  pid_stub.returns(true)
@@ -324,6 +356,7 @@ describe Guard::Rails::Runner do
324
356
 
325
357
  it 'kills the process with INT' do
326
358
  mock(runner).kill_process.with("INT", pid).returns { true }
359
+ stub(runner).sleep
327
360
  mock(runner).kill_process.with("KILL", pid).once
328
361
  runner.stop
329
362
  end
@@ -390,7 +423,7 @@ describe Guard::Rails::Runner do
390
423
 
391
424
  it 'returns pid if any' do
392
425
  mock(runner, :'`').with(anything).returns {
393
- "ruby #{pid} ranmocy 12u IPv4 0x9c30720e04d31a0f 0t0 TCP *:#{port} (LISTEN)"
426
+ "ruby #{pid} ranmocy 12u IPv4 0x9c30720e04d31a0f 0t0 TCP *:#{default_port} (LISTEN)"
394
427
  }
395
428
  expect(runner.send(:unmanaged_pid)).to eq pid
396
429
  end
@@ -424,7 +457,7 @@ describe Guard::Rails::Runner do
424
457
 
425
458
  describe '#sleep_time' do
426
459
  let(:timeout) { 30 }
427
- let(:options) { default_options.merge(:timeout => timeout) }
460
+ let(:options) { default_options.merge(timeout: timeout) }
428
461
 
429
462
  it "adjusts the sleep time as necessary" do
430
463
  expect(runner.sleep_time).to eq (timeout.to_f / Guard::Rails::Runner::MAX_WAIT_COUNT.to_f)
@@ -5,9 +5,10 @@ describe Guard::Rails do
5
5
  let(:options) { {} }
6
6
 
7
7
  describe "#initialize" do
8
- it "initializes with options" do
8
+ it "initializes with default options" do
9
9
  guard
10
10
 
11
+ expect(guard.runner.options[:host]).to eq "localhost"
11
12
  expect(guard.runner.options[:port]).to eq 3000
12
13
  end
13
14
  end
@@ -24,7 +25,7 @@ describe Guard::Rails do
24
25
  end
25
26
 
26
27
  context "doesn't start when Guard starts" do
27
- let(:options) { { :start_on_start => false } }
28
+ let(:options) { { start_on_start: false } }
28
29
 
29
30
  it "shows the right message and doesn't run startup" do
30
31
  mock(guard).reload.never
@@ -44,13 +45,13 @@ describe Guard::Rails do
44
45
  context 'at start' do
45
46
  before do
46
47
  mock(Guard::UI).info.with('Starting Rails...')
47
- mock(Guard::Notifier).notify.with(/Rails starting/, hash_including(:image => :pending))
48
+ mock(Guard::Notifier).notify.with(/Rails starting/, hash_including(image: :pending))
48
49
  any_instance_of(Guard::Rails::Runner, restart: true)
49
50
  end
50
51
 
51
52
  it "starts and shows the pid file" do
52
53
  mock(Guard::UI).info.with(/#{pid}/)
53
- mock(Guard::Notifier).notify.with(/Rails started/, hash_including(:image => :success))
54
+ mock(Guard::Notifier).notify.with(/Rails started/, hash_including(image: :success))
54
55
 
55
56
  guard.reload("start")
56
57
  end
@@ -60,7 +61,7 @@ describe Guard::Rails do
60
61
  before do
61
62
  any_instance_of(Guard::Rails::Runner, pid: pid)
62
63
  mock(Guard::UI).info.with('Restarting Rails...')
63
- mock(Guard::Notifier).notify.with(/Rails restarting/, hash_including(:image => :pending))
64
+ mock(Guard::Notifier).notify.with(/Rails restarting/, hash_including(image: :pending))
64
65
  end
65
66
 
66
67
  context "with pid file" do
@@ -70,7 +71,7 @@ describe Guard::Rails do
70
71
 
71
72
  it "restarts and shows the pid file" do
72
73
  mock(Guard::UI).info.with(/#{pid}/)
73
- mock(Guard::Notifier).notify.with(/Rails restarted/, hash_including(:image => :success))
74
+ mock(Guard::Notifier).notify.with(/Rails restarted/, hash_including(image: :success))
74
75
 
75
76
  guard.reload
76
77
  end
@@ -84,7 +85,7 @@ describe Guard::Rails do
84
85
  it "restarts and shows the pid file" do
85
86
  mock(Guard::UI).info.with(/#{pid}/).never
86
87
  mock(Guard::UI).info.with(/Rails NOT restarted/)
87
- mock(Guard::Notifier).notify.with(/Rails NOT restarted/, hash_including(:image => :failed))
88
+ mock(Guard::Notifier).notify.with(/Rails NOT restarted/, hash_including(image: :failed))
88
89
 
89
90
  guard.reload
90
91
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Bintz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-02 00:00:00.000000000 Z
12
+ date: 2014-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard