ops_routes 0.5.0 → 0.6.0
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/VERSION +1 -1
- data/config/routes.rb +13 -5
- data/lib/ops_routes.rb +6 -3
- data/lib/views/config.html.haml +3 -3
- data/spec/ops_routes/middleware_spec.rb +0 -7
- data/spec/ops_routes_spec.rb +51 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
if Rails::VERSION::MAJOR == 3
|
2
|
+
Rails.application.routes.draw do |map|
|
3
|
+
match '/ops/version', :to => 'ops#version'
|
4
|
+
match '/ops/heartbeat(/:name)', :to => 'ops#heartbeat'
|
5
|
+
match '/ops/configuration', :to => 'ops#configuration'
|
6
|
+
end
|
7
|
+
else
|
8
|
+
ActionController::Routing::Routes.draw do |map|
|
9
|
+
map.connect '/ops/version', :controller => 'ops', :action => 'version'
|
10
|
+
map.connect '/ops/heartbeat', :controller => 'ops', :action => 'heartbeat'
|
11
|
+
map.connect '/ops/heartbeat/:name', :controller => 'ops', :action => 'heartbeat'
|
12
|
+
map.connect '/ops/configuration', :controller => 'ops', :action => 'configuration'
|
13
|
+
end
|
6
14
|
end
|
data/lib/ops_routes.rb
CHANGED
@@ -132,13 +132,16 @@ module OpsRoutes
|
|
132
132
|
|
133
133
|
# Configuration page
|
134
134
|
|
135
|
-
def
|
135
|
+
def configuration
|
136
136
|
@configuration ||= {}
|
137
|
-
|
137
|
+
end
|
138
|
+
|
139
|
+
def add_configuration_section(name, &block)
|
140
|
+
configuration[name] = block
|
138
141
|
end
|
139
142
|
|
140
143
|
def current_config
|
141
|
-
|
144
|
+
configuration.inject({}) do |current, (section, block)|
|
142
145
|
current[section] = block.call
|
143
146
|
current
|
144
147
|
end
|
data/lib/views/config.html.haml
CHANGED
@@ -11,11 +11,11 @@
|
|
11
11
|
-# %pre&= current_config.inspect
|
12
12
|
- current_config.each do |section, settings|
|
13
13
|
%h2= section
|
14
|
-
%table
|
14
|
+
%table.settings
|
15
15
|
- settings.each_with_index do |(setting, value), i|
|
16
16
|
%tr{ :class => i%2==0 ? 'even' : nil }
|
17
|
-
%td= setting
|
18
|
-
%td
|
17
|
+
%td.key= setting
|
18
|
+
%td.value
|
19
19
|
%pre&= print_detail(value)
|
20
20
|
|
21
21
|
|
@@ -74,13 +74,6 @@ describe OpsRoutes::Middleware do
|
|
74
74
|
OpsRoutes.should_receive(:check_configuration).and_return('The configuration page')
|
75
75
|
get '/ops/configuration'
|
76
76
|
end
|
77
|
-
|
78
|
-
it 'should call the configuration block' do
|
79
|
-
config_block = lambda{}
|
80
|
-
OpsRoutes.add_configuration_section(:test, &config_block)
|
81
|
-
config_block.should_receive(:call).and_return( :key => 'value' )
|
82
|
-
get '/ops/configuration'
|
83
|
-
end
|
84
77
|
end
|
85
78
|
|
86
79
|
end
|
data/spec/ops_routes_spec.rb
CHANGED
@@ -97,6 +97,57 @@ describe OpsRoutes do
|
|
97
97
|
|
98
98
|
end
|
99
99
|
|
100
|
+
describe ".check_configuration" do
|
101
|
+
it "should call current_config" do
|
102
|
+
OpsRoutes.should_receive(:current_config).and_return({})
|
103
|
+
OpsRoutes.check_configuration
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should render a valid html page" do
|
107
|
+
config_page = OpsRoutes.check_configuration
|
108
|
+
config_page.should have_tag('html')
|
109
|
+
config_page.should have_tag('head')
|
110
|
+
config_page.should have_tag('body')
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should have h2 for section" do
|
114
|
+
OpsRoutes.add_configuration_section(:test){{}}
|
115
|
+
config_page = OpsRoutes.check_configuration
|
116
|
+
config_page.should have_tag('h2', 'test')
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should have config section key and value in table" do
|
120
|
+
OpsRoutes.add_configuration_section(:test){ { :some_key => 'the value' } }
|
121
|
+
config_page = OpsRoutes.check_configuration
|
122
|
+
config_page.should have_tag('.settings td.key', 'some_key')
|
123
|
+
config_page.should have_tag('.settings td.value pre', '"the value"')
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '.add_configuration_section' do
|
129
|
+
it "should add provided block to configuration hash" do
|
130
|
+
config_block = lambda{}
|
131
|
+
OpsRoutes.add_configuration_section(:test, &config_block)
|
132
|
+
OpsRoutes.configuration.should have_key(:test)
|
133
|
+
OpsRoutes.configuration[:test].should == config_block
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '.current_config' do
|
139
|
+
it 'should call the configuration block' do
|
140
|
+
config_block = lambda{}
|
141
|
+
OpsRoutes.add_configuration_section(:test, &config_block)
|
142
|
+
config_block.should_receive(:call).and_return( :key => 'value' )
|
143
|
+
OpsRoutes.current_config
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should return empty hash if no config provided' do
|
147
|
+
OpsRoutes.current_config.should == {}
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
100
151
|
describe '.app_name' do
|
101
152
|
|
102
153
|
it "should return config option if given" do
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 6
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Primedia Team
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-12 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|