rails-pulse 0.4.6 → 0.4.7
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/README.textile +21 -0
- data/lib/{pulse_controller.rb → pulse/controller.rb} +0 -0
- data/lib/{pulse_helper.rb → pulse/helper.rb} +0 -0
- data/lib/pulse/routes.rb +17 -0
- data/lib/rails-pulse.rb +3 -0
- data/spec/pulse_spec.rb +49 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +32 -0
- metadata +34 -17
- data/init.rb +0 -1
- data/lib/pulse.rb +0 -3
- data/lib/routes.rb +0 -9
data/README.textile
CHANGED
@@ -14,6 +14,27 @@ h2. Requirements
|
|
14
14
|
|
15
15
|
h2. Installation
|
16
16
|
|
17
|
+
h3. Rails 3.x
|
18
|
+
|
19
|
+
Just add the gem to your @Gemfile@ and then @bundle install@:
|
20
|
+
|
21
|
+
<pre>
|
22
|
+
<code>
|
23
|
+
gem 'rails-pulse'
|
24
|
+
</code>
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
In your @config/routes.rb@:
|
28
|
+
|
29
|
+
<pre>
|
30
|
+
<code>
|
31
|
+
pulse '/my/pulse/url'
|
32
|
+
</code>
|
33
|
+
</pre>
|
34
|
+
|
35
|
+
|
36
|
+
h3. Rails 2.x
|
37
|
+
|
17
38
|
In your @config/environment.rb@:
|
18
39
|
|
19
40
|
<pre>
|
File without changes
|
File without changes
|
data/lib/pulse/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pulse
|
2
|
+
module Routes
|
3
|
+
def pulse(path)
|
4
|
+
if Rails::VERSION::MAJOR == 2
|
5
|
+
connect path, :controller => 'pulse', :action => 'pulse'
|
6
|
+
else
|
7
|
+
match path => "pulse#pulse"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
if Rails::VERSION::MAJOR == 3
|
14
|
+
ActionDispatch::Routing::Mapper.send :include, Pulse::Routes
|
15
|
+
else # fallback to 2.x stuff
|
16
|
+
ActionController::Routing::RouteSet::Mapper.send :include, Pulse::Routes
|
17
|
+
end
|
data/lib/rails-pulse.rb
ADDED
data/spec/pulse_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Pulse" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@controller = PulseController.new
|
7
|
+
@request = ActionController::TestRequest.new
|
8
|
+
@response = ActionController::TestResponse.new
|
9
|
+
ActionController::Routing::Routes.draw do |map|
|
10
|
+
map.pulse 'pulse'
|
11
|
+
end
|
12
|
+
@successful_result_set = mock(:result_set, :num_rows => 1)
|
13
|
+
@unsuccessful_result_set = mock(:result_set, :num_rows => 0)
|
14
|
+
@connection = mock(:connection)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should recognize the pulse route" do
|
18
|
+
params_from(:get, "/pulse").should == {:controller => "pulse", :action => "pulse"}
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "response" do
|
22
|
+
before(:each) do
|
23
|
+
ActiveRecord::Base.should_receive(:connection).and_return(@connection)
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "when in a healthy state" do
|
27
|
+
before(:each) do
|
28
|
+
@connection.should_receive(:execute).with("select 1 from dual").and_return(@successful_result_set)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return a 200" do
|
32
|
+
get 'pulse'
|
33
|
+
@response.should be_success
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "when in an unhealthy state" do
|
38
|
+
before(:each) do
|
39
|
+
@connection.should_receive(:execute).with("select 1 from dual").and_return(@unsuccessful_result_set)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return a 500" do
|
43
|
+
get 'pulse'
|
44
|
+
@response.should_not be_success
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
$LOAD_PATH.unshift 'lib/'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'multi_rails_init'
|
5
|
+
|
6
|
+
#mock out some rails related stuff
|
7
|
+
|
8
|
+
RAILS_ROOT='.'
|
9
|
+
|
10
|
+
def require_dependency(foo)
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
|
14
|
+
class ApplicationController < ActionController::Base
|
15
|
+
helper :all
|
16
|
+
end
|
17
|
+
|
18
|
+
def params_from(method, path)
|
19
|
+
ActionController::Routing::Routes.recognize_path(path, :method => method)
|
20
|
+
end
|
21
|
+
|
22
|
+
begin
|
23
|
+
require 'spec'
|
24
|
+
require 'spec/rails'
|
25
|
+
rescue LoadError
|
26
|
+
gem 'rspec'
|
27
|
+
gem 'rspec-rails'
|
28
|
+
require 'spec'
|
29
|
+
require 'spec/rails'
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'pulse'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-pulse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 7
|
10
|
+
version: 0.4.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Gross
|
@@ -18,28 +18,43 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date:
|
21
|
+
date: 2012-01-10 00:00:00 -05:00
|
22
22
|
default_executable:
|
23
|
-
dependencies:
|
24
|
-
|
23
|
+
dependencies:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: rails
|
26
|
+
prerelease: false
|
27
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
hash: 3
|
33
|
+
segments:
|
34
|
+
- 0
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
25
38
|
description: |-
|
26
39
|
Adds a pulse URL that pings the DB to a Rails app.
|
27
|
-
This is
|
40
|
+
This is the maintained version of the `pulse` gem.
|
28
41
|
email: jnewland@gmail.com
|
29
42
|
executables: []
|
30
43
|
|
31
44
|
extensions: []
|
32
45
|
|
33
|
-
extra_rdoc_files:
|
34
|
-
|
46
|
+
extra_rdoc_files:
|
47
|
+
- README.textile
|
35
48
|
files:
|
36
|
-
- init.rb
|
37
|
-
- lib/pulse.rb
|
38
|
-
- lib/pulse_controller.rb
|
39
|
-
- lib/pulse_helper.rb
|
40
|
-
- lib/routes.rb
|
41
49
|
- README.textile
|
42
|
-
|
50
|
+
- lib/pulse/controller.rb
|
51
|
+
- lib/pulse/helper.rb
|
52
|
+
- lib/pulse/routes.rb
|
53
|
+
- lib/rails-pulse.rb
|
54
|
+
- spec/pulse_spec.rb
|
55
|
+
- spec/spec.opts
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
has_rdoc: false
|
43
58
|
homepage: http://github.com/jnewland/pulse
|
44
59
|
licenses: []
|
45
60
|
|
@@ -73,5 +88,7 @@ rubygems_version: 1.6.2
|
|
73
88
|
signing_key:
|
74
89
|
specification_version: 3
|
75
90
|
summary: Adds a pulse URL that pings the DB to a Rails app.
|
76
|
-
test_files:
|
77
|
-
|
91
|
+
test_files:
|
92
|
+
- spec/pulse_spec.rb
|
93
|
+
- spec/spec.opts
|
94
|
+
- spec/spec_helper.rb
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/lib/pulse"
|
data/lib/pulse.rb
DELETED