guard-puma 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  .rbx/
19
+ .rvmrc
@@ -3,3 +3,5 @@ rvm:
3
3
  - 1.9.3
4
4
  - rbx-19mode
5
5
  - rbx-18mode
6
+ - jruby-19mode
7
+ - jruby-18mode
data/README.md CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
25
25
  ```ruby
26
26
  guard 'puma', :port => 4000 do
27
27
  watch('Gemfile.lock')
28
- watch(%r{^config|lib|app/.*})
28
+ watch(%r{^config|lib/.*})
29
29
  end
30
30
  ```
31
31
 
@@ -38,11 +38,18 @@ end
38
38
  * `:daemon` runs the server as a daemon, without any output to the terminal that ran `guard` (default `false`).
39
39
  * `:debugger` runs the server with the debugger enabled (default `false`). Required ruby-debug gem.
40
40
  * `:timeout` waits this number of seconds when restarting the Puma server before reporting there's a problem (default `20`).
41
+ * `:config` is the path to Puma config file (optional)
42
+ * `:bind` is URI to bind to (tcp:// and unix:// only) (optional)
43
+ * `:state` is the path to store the state details (optional)
44
+ * `:control` is the bind URL to use for the control server. Use 'auto' to use temp unix server (optional)
45
+ * `:control_token` is the token to use as authentication for the control server(optional)
46
+ * `:threads` is the min:max number of threads to use. Defaults to 0:16 (optional)
41
47
 
42
48
  ## Contributing
43
49
 
44
50
  1. Fork it
45
- 2. Create your feature branch (`git checkout -b my-new-feature`)
46
- 3. Commit your changes (`git commit -am 'Added some feature'`)
47
- 4. Push to the branch (`git push origin my-new-feature`)
48
- 5. Create new Pull Request
51
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 1. Leave the version alone!
53
+ 1. Commit your changes (`git commit -am 'Added some feature'`)
54
+ 1. Push to the branch (`git push origin my-new-feature`)
55
+ 1. Create new Pull Request
@@ -13,7 +13,7 @@ module Guard
13
13
 
14
14
  def start
15
15
  kill_unmanaged_pid! if options[:force_run]
16
- run_rack_command!
16
+ run_puma_command!
17
17
  wait_for_pid
18
18
  end
19
19
 
@@ -30,14 +30,18 @@ module Guard
30
30
  start
31
31
  end
32
32
 
33
- def build_rack_command
34
- rack_options = [
35
- '--port', options[:port],
36
- '--pid', pid_file,
37
- '-s', 'puma'
38
- ]
33
+ def build_puma_command
34
+ puma_options = {
35
+ '--port' => options[:port],
36
+ '--pidfile' => pid_file,
37
+ }
38
+ [:config, :bind, :state, :control, :threads].each do |opt|
39
+ puma_options["--#{opt}"] = options[opt] if options[opt]
40
+ end
41
+ puma_options["--control-token"] = options[:control_token] if options[:control_token]
42
+ opts = puma_options.to_a.flatten << '-q'
39
43
 
40
- %{sh -c 'cd #{Dir.pwd} && rackup #{rack_options.join(' ')} &'}
44
+ %{sh -c 'cd #{Dir.pwd} && puma #{opts.join(' ')} &'}
41
45
  end
42
46
 
43
47
  def pid_file
@@ -54,8 +58,8 @@ module Guard
54
58
 
55
59
  private
56
60
 
57
- def run_rack_command!
58
- system build_rack_command
61
+ def run_puma_command!
62
+ system build_puma_command
59
63
  end
60
64
 
61
65
  def has_pid?
@@ -1,4 +1,4 @@
1
1
  guard 'puma' do
2
2
  watch('Gemfile.lock')
3
- watch(%r{^config|lib|app/.*})
3
+ watch(%r{^config|lib/.*})
4
4
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module PumaVersion
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ require 'fakefs/spec_helpers'
5
5
  describe Guard::PumaRunner do
6
6
  let(:runner) { Guard::PumaRunner.new(options) }
7
7
  let(:environment) { 'development' }
8
- let(:port) { 3000 }
8
+ let(:port) { 4000 }
9
9
 
10
10
  let(:default_options) { { :environment => environment, :port => port } }
11
11
  let(:options) { default_options }
@@ -42,7 +42,7 @@ describe Guard::PumaRunner do
42
42
  let(:pid_stub) { runner.stubs(:has_pid?) }
43
43
 
44
44
  before do
45
- runner.expects(:run_rack_command!).once
45
+ runner.expects(:run_puma_command!).once
46
46
  end
47
47
 
48
48
  context 'do not force run' do
@@ -92,4 +92,57 @@ describe Guard::PumaRunner do
92
92
  runner.sleep_time.should == (timeout.to_f / Guard::PumaRunner::MAX_WAIT_COUNT.to_f)
93
93
  end
94
94
  end
95
+
96
+ describe "#build_puma_command" do
97
+ let(:command) {
98
+ Guard::PumaRunner.new(options).build_puma_command
99
+ }
100
+ context "with config" do
101
+ let(:options) {{ :config => path }}
102
+ let(:path) { "/tmp/elephants" }
103
+ it "adds path to command" do
104
+ command.should match("--config #{path}")
105
+ end
106
+ end
107
+
108
+ context "with bind" do
109
+ let(:options) {{ :bind => uri }}
110
+ let(:uri) { "tcp://foo" }
111
+ it "adds uri option to command" do
112
+ command.should match("--bind #{uri}")
113
+ end
114
+ end
115
+
116
+ context "with state" do
117
+ let(:options) {{ :state => path }}
118
+ let(:path) { "/tmp/zebras" }
119
+ it "adds path to command" do
120
+ command.should match("--state #{path}")
121
+ end
122
+ end
123
+
124
+ context "with control" do
125
+ let(:options) {{ :control => uri }}
126
+ let(:uri) { "http://foo" }
127
+ it "adds path to command" do
128
+ command.should match("--control #{uri}")
129
+ end
130
+ end
131
+
132
+ context "with control_token" do
133
+ let(:options) {{ :control_token => token }}
134
+ let(:token) { "IMMA_TOKEN" }
135
+ it "adds path to command" do
136
+ command.should match("--control-token #{token}")
137
+ end
138
+ end
139
+
140
+ context "with threads" do
141
+ let(:options) {{ :threads => threads }}
142
+ let(:threads) { "13:42" }
143
+ it "adds path to command" do
144
+ command.should match("--threads #{threads}")
145
+ end
146
+ end
147
+ end
95
148
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,116 +9,116 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-21 00:00:00.000000000 Z
12
+ date: 2012-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime
16
- requirement: &5800 !ruby/object:Gem::Requirement
16
+ requirement: &6060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 1.0.1
22
- version_requirements: *5800
22
+ version_requirements: *6060
23
23
  name: guard
24
24
  prerelease: false
25
25
  - !ruby/object:Gem::Dependency
26
26
  type: :runtime
27
- requirement: &5856 !ruby/object:Gem::Requirement
27
+ requirement: &6116 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
- version_requirements: *5856
33
+ version_requirements: *6116
34
34
  name: rb-inotify
35
35
  prerelease: false
36
36
  - !ruby/object:Gem::Dependency
37
37
  type: :runtime
38
- requirement: &5900 !ruby/object:Gem::Requirement
38
+ requirement: &6160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
- version_requirements: *5900
44
+ version_requirements: *6160
45
45
  name: libnotify
46
46
  prerelease: false
47
47
  - !ruby/object:Gem::Dependency
48
48
  type: :runtime
49
- requirement: &5944 !ruby/object:Gem::Requirement
49
+ requirement: &6204 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- version_requirements: *5944
55
+ version_requirements: *6204
56
56
  name: puma
57
57
  prerelease: false
58
58
  - !ruby/object:Gem::Dependency
59
59
  type: :development
60
- requirement: &5988 !ruby/object:Gem::Requirement
60
+ requirement: &6248 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
64
64
  - !ruby/object:Gem::Version
65
65
  version: 0.9.2.2
66
- version_requirements: *5988
66
+ version_requirements: *6248
67
67
  name: rake
68
68
  prerelease: false
69
69
  - !ruby/object:Gem::Dependency
70
70
  type: :development
71
- requirement: &6032 !ruby/object:Gem::Requirement
71
+ requirement: &6292 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
75
75
  - !ruby/object:Gem::Version
76
76
  version: 2.9.0
77
- version_requirements: *6032
77
+ version_requirements: *6292
78
78
  name: rspec
79
79
  prerelease: false
80
80
  - !ruby/object:Gem::Dependency
81
81
  type: :development
82
- requirement: &6076 !ruby/object:Gem::Requirement
82
+ requirement: &6336 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
86
86
  - !ruby/object:Gem::Version
87
87
  version: 0.6.0
88
- version_requirements: *6076
88
+ version_requirements: *6336
89
89
  name: guard-rspec
90
90
  prerelease: false
91
91
  - !ruby/object:Gem::Dependency
92
92
  type: :development
93
- requirement: &6120 !ruby/object:Gem::Requirement
93
+ requirement: &6380 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
97
97
  - !ruby/object:Gem::Version
98
98
  version: 1.1.0
99
- version_requirements: *6120
99
+ version_requirements: *6380
100
100
  name: bundler
101
101
  prerelease: false
102
102
  - !ruby/object:Gem::Dependency
103
103
  type: :development
104
- requirement: &6164 !ruby/object:Gem::Requirement
104
+ requirement: &6424 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
- version_requirements: *6164
110
+ version_requirements: *6424
111
111
  name: fakefs
112
112
  prerelease: false
113
113
  - !ruby/object:Gem::Dependency
114
114
  type: :development
115
- requirement: &6208 !ruby/object:Gem::Requirement
115
+ requirement: &6468 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
- version_requirements: *6208
121
+ version_requirements: *6468
122
122
  name: mocha
123
123
  prerelease: false
124
124
  description: