redis_monitor 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/README.md +11 -3
- data/lib/controllers/base_controller.rb +17 -0
- data/lib/controllers/info_controller.rb +1 -1
- data/lib/errors/errors.rb +1 -0
- data/lib/errors/redis_not_available.rb +7 -0
- data/lib/helpers/base_helper.rb +9 -0
- data/lib/modules/backend.rb +20 -1
- data/lib/modules/helpers.rb +2 -0
- data/lib/modules/router.rb +1 -1
- data/lib/modules/version.rb +1 -1
- data/lib/static/styles/custom.css +5 -0
- data/lib/views/errors/redis_not_available.haml +2 -0
- data/redis_monitor.gemspec +1 -1
- data/spec/controllers/base_controller_spec.rb +25 -0
- data/spec/controllers/info_controller_spec.rb +24 -0
- data/spec/modules/backend_spec.rb +23 -0
- data/spec/spec_helper.rb +19 -0
- metadata +17 -5
- data/lib/views/algo.haml +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bfd5c7207c7570d9c7e902752ccd64f5630c965
|
4
|
+
data.tar.gz: 5292f747d52d970b75b61323bba55975d7cd1410
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7483993062c4a562904bc4f61a52a64b013914657698c0a961781d00b9a6c2600d0dfca4e93b8d8c1dbefcfbff0c7a0e07987050aa01137a98356eb6ef9ae00f
|
7
|
+
data.tar.gz: 03987d561f9a6036afa897f0fed88f92f19ea5b3ddc71cdb9b4775e848c1be79c5691703abee25daff971b4d52c3da9c83dc1dbda750f596412868be446fbc02
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# RedisMonitor
|
2
2
|
|
3
|
-
TODO: Write a gem description
|
4
|
-
|
5
3
|
## Installation
|
6
4
|
|
7
5
|
Add this line to your application's Gemfile:
|
@@ -18,7 +16,13 @@ Or install it yourself as:
|
|
18
16
|
|
19
17
|
## Usage
|
20
18
|
|
21
|
-
|
19
|
+
$ redis_monitor --http-port http_port --host host --port port
|
20
|
+
|
21
|
+
Then browse http://localhost:http_port
|
22
|
+
|
23
|
+
For more information about the parameters:
|
24
|
+
|
25
|
+
$ redis_monitor --help
|
22
26
|
|
23
27
|
## Contributing
|
24
28
|
|
@@ -27,3 +31,7 @@ TODO: Write usage instructions here
|
|
27
31
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
32
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
33
|
5. Create new Pull Request
|
34
|
+
|
35
|
+
Please write meaningful test, ff you need to execute them:
|
36
|
+
|
37
|
+
$ rspec spec
|
@@ -1,14 +1,31 @@
|
|
1
1
|
require 'modules/backend'
|
2
|
+
require 'errors/errors'
|
2
3
|
|
3
4
|
module RedisMonitor
|
4
5
|
module Controllers
|
5
6
|
class BaseController
|
6
7
|
attr_accessor :context, :params
|
7
8
|
|
9
|
+
include RedisMonitor::Helpers::BaseHelper
|
10
|
+
include RedisMonitor::Helpers::LayoutsHelper
|
11
|
+
|
8
12
|
def initialize(opts = {})
|
9
13
|
@context = opts.delete(:context)
|
10
14
|
@params = opts
|
11
15
|
end
|
16
|
+
|
17
|
+
def execute(action)
|
18
|
+
begin
|
19
|
+
send(action)
|
20
|
+
rescue RedisMonitor::Errors::RedisNotAvailable
|
21
|
+
redis_not_available
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def redis_not_available
|
26
|
+
haml 'errors/redis_not_available'.to_sym, layout: main_layout,
|
27
|
+
locals: {host: Backend.host, port: Backend.port}
|
28
|
+
end
|
12
29
|
end
|
13
30
|
end
|
14
31
|
end
|
@@ -5,7 +5,7 @@ module RedisMonitor
|
|
5
5
|
include RedisMonitor::Helpers::LayoutsHelper
|
6
6
|
|
7
7
|
def index
|
8
|
-
|
8
|
+
haml 'info/info'.to_sym, layout: main_layout, locals: {info: Backend.info}
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'errors/redis_not_available'
|
data/lib/modules/backend.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'redis'
|
2
|
+
require 'errors/errors'
|
2
3
|
|
3
4
|
module RedisMonitor
|
4
5
|
class Backend
|
@@ -7,8 +8,26 @@ module RedisMonitor
|
|
7
8
|
@@port = arguments[:redis_port]
|
8
9
|
end
|
9
10
|
|
11
|
+
def self.host
|
12
|
+
@@host
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.port
|
16
|
+
@@port
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.ensure_connected(redis)
|
20
|
+
begin
|
21
|
+
redis.ping
|
22
|
+
rescue Redis::CannotConnectError => e
|
23
|
+
raise RedisMonitor::Errors::RedisNotAvailable
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
10
27
|
def self.redis
|
11
|
-
Redis.new(:host =>
|
28
|
+
redis = Redis.new(:host => host, :port => port)
|
29
|
+
ensure_connected(redis)
|
30
|
+
redis
|
12
31
|
end
|
13
32
|
|
14
33
|
def self.info
|
data/lib/modules/helpers.rb
CHANGED
data/lib/modules/router.rb
CHANGED
data/lib/modules/version.rb
CHANGED
data/redis_monitor.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = %w(javiyu7@gmail.com)
|
11
11
|
spec.description = %q{Get general information of a running redis instance}
|
12
12
|
spec.summary = %q{Get general information of a running redis instance}
|
13
|
-
spec.homepage = ''
|
13
|
+
spec.homepage = 'https://github.com/javiyu/redis_monitor'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BaseController do
|
4
|
+
before :each do
|
5
|
+
@context = double(:context)
|
6
|
+
@controller = BaseController.new(context: @context)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'execute method' do
|
10
|
+
it 'should not raise error if the action executed raised RedisNotAvailable' do
|
11
|
+
@controller.stub(:action) { raise RedisNotAvailable }
|
12
|
+
@controller.should_receive(:redis_not_available)
|
13
|
+
expect{ @controller.execute(:action) }.not_to raise_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'redis_not_available method' do
|
18
|
+
it 'should render redis not available error page' do
|
19
|
+
Backend.stub(:host)
|
20
|
+
Backend.stub(:port)
|
21
|
+
@context.should_receive(:haml).with('errors/redis_not_available'.to_sym, anything)
|
22
|
+
@controller.redis_not_available
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe InfoController do
|
4
|
+
before :each do
|
5
|
+
@context = double(:context)
|
6
|
+
@controller = InfoController.new(context: @context)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'index action' do
|
10
|
+
before :each do
|
11
|
+
Backend.stub(:info){ {} }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should not fail' do
|
15
|
+
@context.stub(:haml)
|
16
|
+
expect{ @controller.index }.not_to raise_error
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should render info page' do
|
20
|
+
@context.should_receive(:haml).with('info/info'.to_sym, anything)
|
21
|
+
@controller.index
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Backend do
|
4
|
+
before :each do
|
5
|
+
Backend.stub(:host)
|
6
|
+
Backend.stub(:port)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'ensure_connected method' do
|
10
|
+
it 'should raise RedisNotAvailable if redis throws an exception' do
|
11
|
+
redis = double(:redis)
|
12
|
+
redis.stub(:ping){ raise Redis::CannotConnectError }
|
13
|
+
expect{ Backend.ensure_connected(redis) }.to raise_error RedisNotAvailable
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'redis method' do
|
18
|
+
it 'should call to ensure_connected' do
|
19
|
+
Backend.should_receive(:ensure_connected)
|
20
|
+
Backend.redis
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.order = 'random'
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'modules/helpers'
|
14
|
+
require 'modules/controllers'
|
15
|
+
require 'modules/backend'
|
16
|
+
|
17
|
+
include RedisMonitor
|
18
|
+
include RedisMonitor::Controllers
|
19
|
+
include RedisMonitor::Errors
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Jimenez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -117,6 +117,7 @@ extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
119
|
- .gitignore
|
120
|
+
- .rspec
|
120
121
|
- Gemfile
|
121
122
|
- LICENSE.txt
|
122
123
|
- README.md
|
@@ -124,6 +125,9 @@ files:
|
|
124
125
|
- bin/redis_monitor
|
125
126
|
- lib/controllers/base_controller.rb
|
126
127
|
- lib/controllers/info_controller.rb
|
128
|
+
- lib/errors/errors.rb
|
129
|
+
- lib/errors/redis_not_available.rb
|
130
|
+
- lib/helpers/base_helper.rb
|
127
131
|
- lib/helpers/layouts_helper.rb
|
128
132
|
- lib/modules/backend.rb
|
129
133
|
- lib/modules/controllers.rb
|
@@ -135,11 +139,15 @@ files:
|
|
135
139
|
- lib/server/server.rb
|
136
140
|
- lib/static/styles/bootstrap.min.css
|
137
141
|
- lib/static/styles/custom.css
|
138
|
-
- lib/views/
|
142
|
+
- lib/views/errors/redis_not_available.haml
|
139
143
|
- lib/views/info/info.haml
|
140
144
|
- lib/views/layouts/main.haml
|
141
145
|
- redis_monitor.gemspec
|
142
|
-
|
146
|
+
- spec/controllers/base_controller_spec.rb
|
147
|
+
- spec/controllers/info_controller_spec.rb
|
148
|
+
- spec/modules/backend_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
homepage: https://github.com/javiyu/redis_monitor
|
143
151
|
licenses:
|
144
152
|
- MIT
|
145
153
|
metadata: {}
|
@@ -163,4 +171,8 @@ rubygems_version: 2.0.6
|
|
163
171
|
signing_key:
|
164
172
|
specification_version: 4
|
165
173
|
summary: Get general information of a running redis instance
|
166
|
-
test_files:
|
174
|
+
test_files:
|
175
|
+
- spec/controllers/base_controller_spec.rb
|
176
|
+
- spec/controllers/info_controller_spec.rb
|
177
|
+
- spec/modules/backend_spec.rb
|
178
|
+
- spec/spec_helper.rb
|
data/lib/views/algo.haml
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
%table.table.table-striped
|
2
|
-
%thead
|
3
|
-
%tr
|
4
|
-
%th
|
5
|
-
Student
|
6
|
-
%th
|
7
|
-
First name
|
8
|
-
%th
|
9
|
-
Last name
|
10
|
-
%th
|
11
|
-
Grade
|
12
|
-
|
13
|
-
%tbody
|
14
|
-
%tr
|
15
|
-
%td
|
16
|
-
Example
|
17
|
-
%td
|
18
|
-
Example
|
19
|
-
%td
|
20
|
-
Example
|
21
|
-
%td
|
22
|
-
Example
|
23
|
-
|
24
|
-
%tr
|
25
|
-
%td
|
26
|
-
Example
|
27
|
-
%td
|
28
|
-
Example
|
29
|
-
%td
|
30
|
-
Example
|
31
|
-
%td
|
32
|
-
Example
|
33
|
-
|
34
|
-
%tr
|
35
|
-
%td
|
36
|
-
Example
|
37
|
-
%td
|
38
|
-
Example
|
39
|
-
%td
|
40
|
-
Example
|
41
|
-
%td
|
42
|
-
Example
|
43
|
-
|
44
|
-
|
45
|
-
= info
|