guard-delayed 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.1 (2012-12-10)
2
+
3
+ * Fixed script/delayed\_job call when passing RAILS_ENV in dash shell (not sure if it happens with other ones)
4
+
1
5
  ## 0.2.0 (2012-07-04)
2
6
 
3
7
  * Merged pull request from @drewda to support guard 1.1
data/README.markdown CHANGED
@@ -36,8 +36,8 @@ being active.
36
36
  * Source hosted at [GitHub](http://github.com/suranyami/guard-delayed)
37
37
  * Report issues/Questions/Feature requests on [GitHub Issues](http://github.com/suranyami/guard-delayed/issues)
38
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.
39
+ Pull requests are very welcome! Make sure your patches are well tested.
40
+ Please create a topic branch for every separate change you make.
41
41
 
42
42
  ## Building and deploying gem
43
43
 
@@ -49,11 +49,11 @@ you make.
49
49
 
50
50
  * Push to rubygems.org:
51
51
 
52
- gem push guard-delayed-0.2.0.gem
53
-
52
+ gem push guard-delayed-0.2.1.gem
53
+
54
54
  ## Testing the gem locally
55
55
 
56
- gem install guard-delayed-0.2.0.gem
56
+ gem install guard-delayed-0.2.1.gem
57
57
 
58
58
 
59
59
  ## Authors
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module DelayedVersion
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
data/lib/guard/delayed.rb CHANGED
@@ -21,25 +21,24 @@ module Guard
21
21
  end
22
22
 
23
23
  def start
24
- system("#{cmd} stop")
24
+ run_cmd("stop")
25
25
  UI.info "Starting up delayed_job..."
26
- command = cmd
27
- command << " start"
28
- command << " --min-priority #{@options[:min_priority]}" if @options[:min_priority]
29
- command << " --max-priority #{@options[:max_priority]}" if @options[:max_priority]
30
- command << " --number_of_workers=#{@options[:number_of_workers]}" if @options[:number_of_workers]
31
- command << " --pid-dir=#{@options[:pid_dir]}" if @options[:pid_dir]
32
- command << " --identifier=#{@options[:identifier]}" if @options[:identifier]
33
- command << " --monitor" if @options[:monitor]
34
- command << " --sleep-delay #{@options[:sleep_delay]}" if @options[:sleep_delay]
35
- command << " --prefix #{@options[:prefix]} " if @options[:prefix]
36
- system(command)
26
+ parameters = "start"
27
+ parameters << " --min-priority #{@options[:min_priority]}" if @options[:min_priority]
28
+ parameters << " --max-priority #{@options[:max_priority]}" if @options[:max_priority]
29
+ parameters << " --number_of_workers=#{@options[:number_of_workers]}" if @options[:number_of_workers]
30
+ parameters << " --pid-dir=#{@options[:pid_dir]}" if @options[:pid_dir]
31
+ parameters << " --identifier=#{@options[:identifier]}" if @options[:identifier]
32
+ parameters << " --monitor" if @options[:monitor]
33
+ parameters << " --sleep-delay #{@options[:sleep_delay]}" if @options[:sleep_delay]
34
+ parameters << " --prefix #{@options[:prefix]} " if @options[:prefix]
35
+ run_cmd(parameters)
37
36
  end
38
37
 
39
38
  # Called on Ctrl-C signal (when Guard quits)
40
39
  def stop
41
40
  UI.info "Stopping delayed_job..."
42
- system(cmd, 'stop')
41
+ run_cmd("stop")
43
42
  end
44
43
 
45
44
  # Called on Ctrl-Z signal
@@ -63,7 +62,7 @@ module Guard
63
62
  private
64
63
 
65
64
  def restart
66
- system(cmd, 'restart')
65
+ run_cmd('restart')
67
66
  end
68
67
 
69
68
  def cmd
@@ -71,5 +70,11 @@ module Guard
71
70
  command = "export RAILS_ENV=#{@options[:environment]}; #{command}" if @options[:environment]
72
71
  command
73
72
  end
73
+
74
+ def run_cmd(parameters)
75
+ sys_response = system("#{cmd} #{parameters}")
76
+ raise StandardError, "Bad command: #{cmd} #{parameters}" if sys_response.nil? || !sys_response
77
+ sys_response
78
+ end
74
79
  end
75
80
  end
@@ -2,11 +2,27 @@ require 'spec_helper'
2
2
 
3
3
  describe Guard::Delayed do
4
4
  describe "when passing an environment option" do
5
+ subject { Guard::Delayed.new([], {:environment => 'test'}) }
6
+
5
7
  it "calls system with 'export RAILS_ENV=test;' call first" do
6
- @delayed = Guard::Delayed.new([], {:environment => 'test'})
7
- @delayed.should_receive(:system).with("export RAILS_ENV=test; script/delayed_job stop").and_return(true)
8
- @delayed.should_receive(:system).with("export RAILS_ENV=test; script/delayed_job start").and_return(true)
9
- @delayed.start
8
+ subject.should_receive(:system).with("export RAILS_ENV=test; script/delayed_job stop").and_return(true)
9
+ subject.should_receive(:system).with("export RAILS_ENV=test; script/delayed_job start").and_return(true)
10
+ subject.start
11
+ end
12
+
13
+ it "calls system with 'export RAILS_ENV=test;' after changes" do
14
+ subject.should_receive(:system).with("export RAILS_ENV=test; script/delayed_job restart").and_return(true)
15
+ subject.run_on_changes([])
16
+ end
17
+
18
+ it "should raise an exception when system call fails" do
19
+ subject.should_receive(:system).and_return(nil)
20
+ lambda { subject.run_on_changes([]) }.should raise_error
21
+ end
22
+
23
+ it "should raise an exception when system command fails " do
24
+ subject.should_receive(:system).and_return(false)
25
+ lambda { subject.run_on_changes([]) }.should raise_error
10
26
  end
11
27
  end
12
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-delayed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-04 00:00:00.000000000 Z
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -163,11 +163,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: 1.3.6
164
164
  requirements: []
165
165
  rubyforge_project: guard-delayed
166
- rubygems_version: 1.8.23
166
+ rubygems_version: 1.8.24
167
167
  signing_key:
168
168
  specification_version: 3
169
169
  summary: guard gem for delayed_job
170
170
  test_files:
171
171
  - spec/guard/delayed_spec.rb
172
172
  - spec/spec_helper.rb
173
- has_rdoc: