redis_web_manager 0.2.0 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -5
- data/app/controllers/redis_web_manager/application_controller.rb +24 -4
- data/app/views/redis_web_manager/shared/_header.html.erb +15 -2
- data/config/routes.rb +22 -16
- data/lib/redis_web_manager.rb +10 -5
- data/lib/redis_web_manager/base.rb +11 -1
- data/lib/redis_web_manager/data.rb +2 -2
- data/lib/redis_web_manager/info.rb +1 -1
- data/lib/redis_web_manager/version.rb +1 -1
- data/redis_web_manager.gemspec +2 -2
- data/spec/controllers/redis_web_manager/actions_controller_spec.rb +7 -3
- data/spec/controllers/redis_web_manager/clients_controller_spec.rb +5 -1
- data/spec/controllers/redis_web_manager/configuration_controller_spec.rb +5 -1
- data/spec/controllers/redis_web_manager/dashboard_controller_spec.rb +5 -1
- data/spec/controllers/redis_web_manager/information_controller_spec.rb +5 -1
- data/spec/controllers/redis_web_manager/keys_controller_spec.rb +14 -10
- data/spec/redis_web_manager_action_spec.rb +1 -1
- data/spec/redis_web_manager_connection_spec.rb +1 -1
- data/spec/redis_web_manager_data_spec.rb +1 -1
- data/spec/redis_web_manager_info_spec.rb +1 -1
- data/spec/redis_web_manager_spec.rb +15 -10
- data/spec/routing/actions_controller_spec.rb +10 -6
- data/spec/routing/clients_controller_spec.rb +6 -2
- data/spec/routing/configuration_controller_spec.rb +6 -2
- data/spec/routing/dashboard_controller_spec.rb +6 -2
- data/spec/routing/keys_controller_spec.rb +14 -10
- data/spec/spec_helper.rb +1 -1
- metadata +8 -9
- data/Gemfile.lock +0 -184
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87282a19ada15764441008d37f194bff06f282a71b8d2e62760ec03af4aeb071
|
4
|
+
data.tar.gz: 728d6078be9216f01b53d4cf8dfeb3eb6ab4ef82dfd9f2f3bee9a47e666a688a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2daea2f01fa82df07a3830d346222df004f9150f02b1ef92988537dd63242000c1093be2d4b4150093c1f32331fec2d6c688eb65660296b60c4b93b8d44d65a1
|
7
|
+
data.tar.gz: 8a599b60c3324e1d5ce01c7fb2fc183d144c436ca9aa509ffb38ba4b83a5ff73da5dd3d41bd4113b5da06716e743a9a32eeb08a10eaf75f28f400730a2e861be
|
data/README.md
CHANGED
@@ -56,7 +56,10 @@ You can configure RedisWebManager:
|
|
56
56
|
# initializers/redis_web_manager.rb
|
57
57
|
|
58
58
|
RedisWebManager.configure do |config|
|
59
|
-
config.
|
59
|
+
config.redises = {
|
60
|
+
default: Redis.new(db: 1),
|
61
|
+
production: Redis.new(url: 'XXX')
|
62
|
+
} # Default { default: Redis.new } (Hash with instance(s) of Redis)
|
60
63
|
config.lifespan = 2.days # Default 15.days (Lifespan of each keys for dashboard)
|
61
64
|
config.authenticate = proc {
|
62
65
|
authenticate_or_request_with_http_basic do |username, password|
|
@@ -70,10 +73,19 @@ end
|
|
70
73
|
|
71
74
|
In order to have data on your dashboard you must collect the data like this:
|
72
75
|
```ruby
|
73
|
-
data = RedisWebManager::Data.new
|
76
|
+
data = RedisWebManager::Data.new(:default)
|
74
77
|
data.perform
|
75
78
|
```
|
76
79
|
|
80
|
+
or
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
RedisWebManager.redises.keys.each do |instance|
|
84
|
+
data = RedisWebManager::Data.new(instance)
|
85
|
+
data.perform
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
77
89
|
If you are using a system to run background tasks in your application (like Sidekiq, Sucker Punch or ActiveJob), you can write your own background task to update the dashboard statistics.
|
78
90
|
|
79
91
|
Sidekiq exemple:
|
@@ -82,29 +94,59 @@ class DashboardWorker
|
|
82
94
|
include Sidekiq::Worker
|
83
95
|
|
84
96
|
def perform
|
85
|
-
data = RedisWebManager::Data.new
|
97
|
+
data = RedisWebManager::Data.new(:default)
|
86
98
|
data.perform
|
87
99
|
end
|
88
100
|
end
|
89
101
|
```
|
90
102
|
|
103
|
+
or
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
class DashboardWorker
|
107
|
+
include Sidekiq::Worker
|
108
|
+
|
109
|
+
def perform
|
110
|
+
RedisWebManager.redises.keys.each do |instance|
|
111
|
+
data = RedisWebManager::Data.new(instance)
|
112
|
+
data.perform
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
91
118
|
Sucker Punch exemple:
|
92
119
|
```ruby
|
93
120
|
class DashboardJob
|
94
121
|
include SuckerPunch::Job
|
95
122
|
|
96
123
|
def perform
|
97
|
-
data = RedisWebManager::Data.new
|
124
|
+
data = RedisWebManager::Data.new(:default)
|
98
125
|
data.perform
|
99
126
|
end
|
100
127
|
end
|
101
128
|
```
|
102
129
|
|
130
|
+
or
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
class DashboardJob
|
134
|
+
include SuckerPunch::Job
|
135
|
+
|
136
|
+
def perform
|
137
|
+
RedisWebManager.redises.keys.each do |instance|
|
138
|
+
data = RedisWebManager::Data.new(instance)
|
139
|
+
data.perform
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
```
|
144
|
+
|
145
|
+
|
103
146
|
|
104
147
|
|
105
148
|
## Todo
|
106
149
|
* [ ] Add graph for most used commands
|
107
|
-
* [ ] Manage multiple redis instances
|
108
150
|
* [ ] Real time chart update
|
109
151
|
* [ ] Alert system (ex: triggered when memory is peaking)
|
110
152
|
* [ ] Command line interface to manage your redis database
|
@@ -5,6 +5,9 @@ module RedisWebManager
|
|
5
5
|
protect_from_forgery with: :exception
|
6
6
|
|
7
7
|
before_action :authenticated?, if: :authenticate
|
8
|
+
before_action :valid_instance?
|
9
|
+
helper_method :redises
|
10
|
+
helper_method :instance
|
8
11
|
|
9
12
|
private
|
10
13
|
|
@@ -17,19 +20,36 @@ module RedisWebManager
|
|
17
20
|
end
|
18
21
|
|
19
22
|
def info
|
20
|
-
@info ||= RedisWebManager::Info.new
|
23
|
+
@info ||= RedisWebManager::Info.new(instance)
|
21
24
|
end
|
22
25
|
|
23
26
|
def connection
|
24
|
-
@connection ||= RedisWebManager::Connection.new
|
27
|
+
@connection ||= RedisWebManager::Connection.new(instance)
|
25
28
|
end
|
26
29
|
|
27
30
|
def action
|
28
|
-
@action ||= RedisWebManager::Action.new
|
31
|
+
@action ||= RedisWebManager::Action.new(instance)
|
29
32
|
end
|
30
33
|
|
31
34
|
def data
|
32
|
-
@data ||= RedisWebManager::Data.new
|
35
|
+
@data ||= RedisWebManager::Data.new(instance)
|
36
|
+
end
|
37
|
+
|
38
|
+
def default_url_options(options = {})
|
39
|
+
options.merge(instance: instance)
|
40
|
+
end
|
41
|
+
|
42
|
+
def valid_instance?
|
43
|
+
default_instance = redises.keys[0]
|
44
|
+
redirect_to dashboard_url(instance: default_instance) if instance.nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
def instance
|
48
|
+
@instance ||= params[:instance].presence
|
49
|
+
end
|
50
|
+
|
51
|
+
def redises
|
52
|
+
@redises ||= RedisWebManager.redises
|
33
53
|
end
|
34
54
|
end
|
35
55
|
end
|
@@ -1,13 +1,26 @@
|
|
1
1
|
<nav class="navbar navbar-expand-lg navbar-light bg-light shadow-sm">
|
2
2
|
<div class="container">
|
3
|
-
<%= link_to 'Redis Web Manager',
|
3
|
+
<%= link_to 'Redis Web Manager', dashboard_path, title: 'Redis Web Manager', class: 'navbar-brand' %>
|
4
4
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Redis Web Manager">
|
5
5
|
<span class="navbar-toggler-icon"></span>
|
6
6
|
</button>
|
7
7
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
8
8
|
<ul class="navbar-nav mr-auto">
|
9
|
+
<li class="nav-item dropdown mr-3">
|
10
|
+
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
11
|
+
<%= instance.humanize.capitalize %>
|
12
|
+
</a>
|
13
|
+
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
14
|
+
<% redises.each do |k, v| %>
|
15
|
+
<%= link_to v.connection[:id],
|
16
|
+
dashboard_path(instance: k),
|
17
|
+
title: k,
|
18
|
+
class: instance == k.to_s ? 'dropdown-item active' : 'dropdown-item' %>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
</li>
|
9
22
|
<li class="nav-item">
|
10
|
-
<%= link_to 'Dashboard',
|
23
|
+
<%= link_to 'Dashboard', dashboard_path, title: 'Dashboard', class: 'nav-link' %>
|
11
24
|
</li>
|
12
25
|
<li class="nav-item">
|
13
26
|
<%= link_to 'Clients', clients_path, title: 'Clients', class: 'nav-link' %>
|
data/config/routes.rb
CHANGED
@@ -1,26 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RedisWebManager::Engine.routes.draw do
|
4
|
-
|
5
|
-
|
4
|
+
redises_keys = RedisWebManager.redises.keys
|
5
|
+
scope ':instance', instance: /#{redises_keys.join('|')}/ do
|
6
|
+
# Configuration
|
7
|
+
get :configuration, to: 'configuration#index'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
# Information
|
10
|
+
get :information, to: 'information#index'
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
get 'key' => 'keys#show'
|
13
|
-
get 'key/edit' => 'keys#edit', as: :edit_key
|
14
|
-
put 'keys' => 'keys#update', as: :update_key
|
15
|
-
delete 'keys' => 'keys#destroy', as: :destroy_key
|
12
|
+
# Dashboard
|
13
|
+
get :dashboard, to: 'dashboard#index'
|
16
14
|
|
17
|
-
|
18
|
-
|
15
|
+
# Keys
|
16
|
+
get 'keys' => 'keys#index'
|
17
|
+
get 'key' => 'keys#show'
|
18
|
+
get 'key/edit' => 'keys#edit', as: :edit_key
|
19
|
+
put 'keys' => 'keys#update', as: :update_key
|
20
|
+
delete 'keys' => 'keys#destroy', as: :destroy_key
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
# Clients
|
23
|
+
get :clients, to: 'clients#index'
|
24
|
+
|
25
|
+
# Actions
|
26
|
+
delete :reset, to: 'actions#reset'
|
27
|
+
delete :flushdb, to: 'actions#flushdb'
|
28
|
+
delete :flushall, to: 'actions#flushall'
|
29
|
+
end
|
24
30
|
|
25
31
|
# Root
|
26
32
|
root 'dashboard#index'
|
data/lib/redis_web_manager.rb
CHANGED
@@ -9,7 +9,7 @@ require 'redis_web_manager/data'
|
|
9
9
|
require 'redis'
|
10
10
|
|
11
11
|
module RedisWebManager
|
12
|
-
mattr_accessor :
|
12
|
+
mattr_accessor :redises, default: { default: ::Redis.new }
|
13
13
|
mattr_accessor :lifespan, default: 15.days
|
14
14
|
mattr_accessor :authenticate, default: nil
|
15
15
|
|
@@ -22,14 +22,19 @@ module RedisWebManager
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def check_attrs
|
25
|
-
unless
|
26
|
-
raise
|
25
|
+
unless redises.is_a?(::Hash)
|
26
|
+
raise(ArgumentError, 'Invalid redises hash, use like that { test: Redis.new }')
|
27
|
+
end
|
28
|
+
redises.each do |k, v|
|
29
|
+
unless v.is_a?(::Redis)
|
30
|
+
raise(ArgumentError, "Invalid Redis instance for #{k}, use like that Redis.new")
|
31
|
+
end
|
27
32
|
end
|
28
33
|
unless lifespan.is_a?(::ActiveSupport::Duration)
|
29
|
-
raise
|
34
|
+
raise(ArgumentError, 'Invalid lifespan, use like that 15.days, 15.minutes etc')
|
30
35
|
end
|
31
36
|
valid = lifespan.to_i.positive?
|
32
|
-
raise
|
37
|
+
raise(ArgumentError, 'Invalid lifespan, value must be greater than 0') unless valid
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -2,10 +2,20 @@
|
|
2
2
|
|
3
3
|
module RedisWebManager
|
4
4
|
class Base
|
5
|
+
attr_accessor :instance
|
6
|
+
|
7
|
+
def initialize(instance)
|
8
|
+
@instance = instance || redises.keys[0]
|
9
|
+
end
|
10
|
+
|
5
11
|
private
|
6
12
|
|
7
13
|
def redis
|
8
|
-
@redis ||=
|
14
|
+
@redis ||= redises[instance.to_sym]
|
15
|
+
end
|
16
|
+
|
17
|
+
def redises
|
18
|
+
@redises ||= RedisWebManager.redises
|
9
19
|
end
|
10
20
|
end
|
11
21
|
end
|
@@ -11,7 +11,7 @@ module RedisWebManager
|
|
11
11
|
def perform
|
12
12
|
now = Time.now.to_i
|
13
13
|
seconds = (now + lifespan.to_i) - now
|
14
|
-
redis.setex("#{BASE}_#{now}", seconds, serialize.to_json)
|
14
|
+
redis.setex("#{BASE}_#{instance}_#{now}", seconds, serialize.to_json)
|
15
15
|
end
|
16
16
|
|
17
17
|
def flush
|
@@ -21,7 +21,7 @@ module RedisWebManager
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def data
|
24
|
-
@data ||= redis.scan_each(match: "#{BASE}_*").to_a
|
24
|
+
@data ||= redis.scan_each(match: "#{BASE}_#{instance}_*").to_a
|
25
25
|
end
|
26
26
|
|
27
27
|
def lifespan
|
data/redis_web_manager.gemspec
CHANGED
@@ -35,10 +35,10 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.test_files = Dir['spec/**/*']
|
36
36
|
|
37
37
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
38
|
-
spec.add_development_dependency 'rspec-rails', '
|
38
|
+
spec.add_development_dependency 'rspec-rails', '~> 4.0.0'
|
39
39
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
40
40
|
|
41
|
-
spec.add_dependency 'pagy', '~> 3.
|
41
|
+
spec.add_dependency 'pagy', '~> 3.8'
|
42
42
|
spec.add_dependency 'rails', '>= 5.2', '< 7'
|
43
43
|
spec.add_dependency 'redis', '~> 4.1.0'
|
44
44
|
end
|
@@ -5,23 +5,27 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::ActionsController, type: :controller do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'DELETE #reset' do
|
9
13
|
it 'returns a success response' do
|
10
|
-
delete :reset
|
14
|
+
delete :reset, params: { instance: default.to_s }
|
11
15
|
expect(response).to be_redirect
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
15
19
|
describe 'DELETE #flushdb' do
|
16
20
|
it 'returns a success response' do
|
17
|
-
delete :flushdb
|
21
|
+
delete :flushdb, params: { instance: default.to_s }
|
18
22
|
expect(response).to be_redirect
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
22
26
|
describe 'DELETE #flushall' do
|
23
27
|
it 'returns a success response' do
|
24
|
-
delete :flushall
|
28
|
+
delete :flushall, params: { instance: default.to_s }
|
25
29
|
expect(response).to be_redirect
|
26
30
|
end
|
27
31
|
end
|
@@ -5,9 +5,13 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::ClientsController, type: :controller do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'GET #index' do
|
9
13
|
it 'returns a success response' do
|
10
|
-
get :index
|
14
|
+
get :index, params: { instance: default.to_s }
|
11
15
|
expect(response).to be_successful
|
12
16
|
end
|
13
17
|
end
|
@@ -5,9 +5,13 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::ConfigurationController, type: :controller do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'GET #index' do
|
9
13
|
it 'returns a success response' do
|
10
|
-
get :index
|
14
|
+
get :index, params: { instance: default.to_s }
|
11
15
|
expect(response).to be_successful
|
12
16
|
end
|
13
17
|
end
|
@@ -5,9 +5,13 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::DashboardController, type: :controller do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'GET #index' do
|
9
13
|
it 'returns a success response' do
|
10
|
-
get :index
|
14
|
+
get :index, params: { instance: default.to_s }
|
11
15
|
expect(response).to be_successful
|
12
16
|
end
|
13
17
|
end
|
@@ -5,9 +5,13 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::InformationController, type: :controller do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'GET #index' do
|
9
13
|
it 'returns a success response' do
|
10
|
-
get :index
|
14
|
+
get :index, params: { instance: default.to_s }
|
11
15
|
expect(response).to be_successful
|
12
16
|
end
|
13
17
|
end
|
@@ -8,19 +8,23 @@ RSpec.describe RedisWebManager::KeysController, type: :controller do
|
|
8
8
|
::Redis.new
|
9
9
|
end
|
10
10
|
|
11
|
+
let(:default) do
|
12
|
+
RedisWebManager.redises.keys[0]
|
13
|
+
end
|
14
|
+
|
11
15
|
describe 'GET #index' do
|
12
16
|
it 'returns a success response' do
|
13
|
-
get :index
|
17
|
+
get :index, params: { instance: default.to_s }
|
14
18
|
expect(response).to be_successful
|
15
|
-
get :index, params: { query: 'test' }
|
19
|
+
get :index, params: { query: 'test', instance: default.to_s }
|
16
20
|
expect(response).to be_successful
|
17
|
-
get :index, params: { type: 'string' }
|
21
|
+
get :index, params: { type: 'string', instance: default.to_s }
|
18
22
|
expect(response).to be_successful
|
19
|
-
get :index, params: { expiry: '-1' }
|
23
|
+
get :index, params: { expiry: '-1', instance: default.to_s }
|
20
24
|
expect(response).to be_successful
|
21
|
-
get :index, params: { expiry: '3600' }
|
25
|
+
get :index, params: { expiry: '3600', instance: default.to_s }
|
22
26
|
expect(response).to be_successful
|
23
|
-
get :index, params: { memory: '1000' }
|
27
|
+
get :index, params: { memory: '1000', instance: default.to_s }
|
24
28
|
expect(response).to be_successful
|
25
29
|
end
|
26
30
|
end
|
@@ -28,7 +32,7 @@ RSpec.describe RedisWebManager::KeysController, type: :controller do
|
|
28
32
|
describe 'GET #show' do
|
29
33
|
it 'returns a success response' do
|
30
34
|
redis.set('test', 'test')
|
31
|
-
get :show, params: { key: 'test' }
|
35
|
+
get :show, params: { key: 'test', instance: default.to_s }
|
32
36
|
expect(response).to be_successful
|
33
37
|
end
|
34
38
|
end
|
@@ -36,7 +40,7 @@ RSpec.describe RedisWebManager::KeysController, type: :controller do
|
|
36
40
|
describe 'GET #edit' do
|
37
41
|
it 'returns a success response' do
|
38
42
|
redis.set('test', 'test')
|
39
|
-
get :edit, params: { key: 'test' }
|
43
|
+
get :edit, params: { key: 'test', instance: default.to_s }
|
40
44
|
expect(response).to be_successful
|
41
45
|
end
|
42
46
|
end
|
@@ -44,7 +48,7 @@ RSpec.describe RedisWebManager::KeysController, type: :controller do
|
|
44
48
|
describe 'GET #update' do
|
45
49
|
it 'returns a success response' do
|
46
50
|
redis.set('test', 'test')
|
47
|
-
put :update, params: { old_name: 'test', new_name: 'testtest' }
|
51
|
+
put :update, params: { old_name: 'test', new_name: 'testtest', instance: default.to_s }
|
48
52
|
expect(response).to be_redirect
|
49
53
|
end
|
50
54
|
end
|
@@ -52,7 +56,7 @@ RSpec.describe RedisWebManager::KeysController, type: :controller do
|
|
52
56
|
describe 'GET #destroy' do
|
53
57
|
it 'returns a success response' do
|
54
58
|
redis.set('test', 'test')
|
55
|
-
delete :destroy, params: { key: 'test' }
|
59
|
+
delete :destroy, params: { key: 'test', instance: default.to_s }
|
56
60
|
expect(response).to be_redirect
|
57
61
|
end
|
58
62
|
end
|
@@ -5,7 +5,7 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager do
|
6
6
|
describe 'Test default configuration' do
|
7
7
|
it 'returns a Redis class' do
|
8
|
-
expect(RedisWebManager.
|
8
|
+
expect(RedisWebManager.redises).to be_a_kind_of(Hash)
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'returns a nil class' do
|
@@ -18,27 +18,30 @@ RSpec.describe RedisWebManager do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe 'Test configuration' do
|
21
|
-
it 'returns a raise error' do
|
21
|
+
it 'returns a raise error (redises)' do
|
22
22
|
expect do
|
23
23
|
RedisWebManager.configure do |c|
|
24
|
-
c.
|
25
|
-
c.lifespan = 1
|
24
|
+
c.redises = 1
|
26
25
|
end
|
27
|
-
end.to raise_error(ArgumentError, 'Invalid
|
26
|
+
end.to raise_error(ArgumentError, 'Invalid redises hash, use like that { test: Redis.new }')
|
28
27
|
end
|
29
28
|
|
30
|
-
it 'returns a raise error (
|
29
|
+
it 'returns a raise error (value of redises)' do
|
31
30
|
expect do
|
32
31
|
RedisWebManager.configure do |c|
|
33
|
-
c.
|
32
|
+
c.redises = {
|
33
|
+
default: 1
|
34
|
+
}
|
34
35
|
end
|
35
|
-
end.to raise_error(ArgumentError, 'Invalid Redis instance, use like that Redis.new')
|
36
|
+
end.to raise_error(ArgumentError, 'Invalid Redis instance for default, use like that Redis.new')
|
36
37
|
end
|
37
38
|
|
38
39
|
it 'returns a raise error (lifespan)' do
|
39
40
|
expect do
|
40
41
|
RedisWebManager.configure do |c|
|
41
|
-
c.
|
42
|
+
c.redises = {
|
43
|
+
default: ::Redis.new
|
44
|
+
}
|
42
45
|
c.lifespan = 1
|
43
46
|
end
|
44
47
|
end.to raise_error(ArgumentError, 'Invalid lifespan, use like that 15.days, 15.minutes etc')
|
@@ -47,7 +50,9 @@ RSpec.describe RedisWebManager do
|
|
47
50
|
it 'returns a raise error (lifespan)' do
|
48
51
|
expect do
|
49
52
|
RedisWebManager.configure do |c|
|
50
|
-
c.
|
53
|
+
c.redises = {
|
54
|
+
default: ::Redis.new
|
55
|
+
}
|
51
56
|
c.lifespan = -1.days
|
52
57
|
end
|
53
58
|
end.to raise_error(ArgumentError, 'Invalid lifespan, value must be greater than 0')
|
@@ -5,22 +5,26 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::ActionsController, type: :routing do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'routing' do
|
9
13
|
it 'routes to #reset' do
|
10
|
-
expect(delete:
|
11
|
-
route_to('redis_web_manager/actions#reset')
|
14
|
+
expect(delete: "/#{default}/reset").to(
|
15
|
+
route_to('redis_web_manager/actions#reset', instance: default.to_s)
|
12
16
|
)
|
13
17
|
end
|
14
18
|
|
15
19
|
it 'routes to #flushdb' do
|
16
|
-
expect(delete:
|
17
|
-
route_to('redis_web_manager/actions#flushdb')
|
20
|
+
expect(delete: "/#{default}/flushdb").to(
|
21
|
+
route_to('redis_web_manager/actions#flushdb', instance: default.to_s)
|
18
22
|
)
|
19
23
|
end
|
20
24
|
|
21
25
|
it 'routes to #flushall' do
|
22
|
-
expect(delete:
|
23
|
-
route_to('redis_web_manager/actions#flushall')
|
26
|
+
expect(delete: "/#{default}/flushall").to(
|
27
|
+
route_to('redis_web_manager/actions#flushall', instance: default.to_s)
|
24
28
|
)
|
25
29
|
end
|
26
30
|
end
|
@@ -5,10 +5,14 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::ClientsController, type: :routing do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'routing' do
|
9
13
|
it 'routes to #index' do
|
10
|
-
expect(get:
|
11
|
-
route_to('redis_web_manager/clients#index')
|
14
|
+
expect(get: "/#{default}/clients").to(
|
15
|
+
route_to('redis_web_manager/clients#index', instance: default.to_s)
|
12
16
|
)
|
13
17
|
end
|
14
18
|
end
|
@@ -5,10 +5,14 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::ConfigurationController, type: :routing do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'routing' do
|
9
13
|
it 'routes to #index' do
|
10
|
-
expect(get:
|
11
|
-
route_to('redis_web_manager/configuration#index')
|
14
|
+
expect(get: "/#{default}/configuration").to(
|
15
|
+
route_to('redis_web_manager/configuration#index', instance: default.to_s)
|
12
16
|
)
|
13
17
|
end
|
14
18
|
end
|
@@ -5,10 +5,14 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::DashboardController, type: :routing do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'routing' do
|
9
13
|
it 'routes to #index' do
|
10
|
-
expect(get:
|
11
|
-
route_to('redis_web_manager/dashboard#index')
|
14
|
+
expect(get: "/#{default}/dashboard").to(
|
15
|
+
route_to('redis_web_manager/dashboard#index', instance: default.to_s)
|
12
16
|
)
|
13
17
|
end
|
14
18
|
end
|
@@ -5,34 +5,38 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe RedisWebManager::KeysController, type: :routing do
|
6
6
|
routes { RedisWebManager::Engine.routes }
|
7
7
|
|
8
|
+
let(:default) do
|
9
|
+
RedisWebManager.redises.keys[0]
|
10
|
+
end
|
11
|
+
|
8
12
|
describe 'routing' do
|
9
13
|
it 'routes to #index' do
|
10
|
-
expect(get:
|
11
|
-
route_to('redis_web_manager/keys#index')
|
14
|
+
expect(get: "/#{default}/keys").to(
|
15
|
+
route_to('redis_web_manager/keys#index', instance: default.to_s)
|
12
16
|
)
|
13
17
|
end
|
14
18
|
|
15
19
|
it 'routes to #show' do
|
16
|
-
expect(get:
|
17
|
-
route_to('redis_web_manager/keys#show')
|
20
|
+
expect(get: "/#{default}/key").to(
|
21
|
+
route_to('redis_web_manager/keys#show', instance: default.to_s)
|
18
22
|
)
|
19
23
|
end
|
20
24
|
|
21
25
|
it 'routes to #edit' do
|
22
|
-
expect(get:
|
23
|
-
route_to('redis_web_manager/keys#edit')
|
26
|
+
expect(get: "/#{default}/key/edit").to(
|
27
|
+
route_to('redis_web_manager/keys#edit', instance: default.to_s)
|
24
28
|
)
|
25
29
|
end
|
26
30
|
|
27
31
|
it 'routes to #update' do
|
28
|
-
expect(put:
|
29
|
-
route_to('redis_web_manager/keys#update')
|
32
|
+
expect(put: "/#{default}/keys").to(
|
33
|
+
route_to('redis_web_manager/keys#update', instance: default.to_s)
|
30
34
|
)
|
31
35
|
end
|
32
36
|
|
33
37
|
it 'routes to #destroy' do
|
34
|
-
expect(delete:
|
35
|
-
route_to('redis_web_manager/keys#destroy')
|
38
|
+
expect(delete: "/#{default}/keys").to(
|
39
|
+
route_to('redis_web_manager/keys#destroy', instance: default.to_s)
|
36
40
|
)
|
37
41
|
end
|
38
42
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -10,7 +10,7 @@ require 'simplecov'
|
|
10
10
|
require 'coveralls'
|
11
11
|
|
12
12
|
SimpleCov.start
|
13
|
-
Coveralls.wear!
|
13
|
+
#Coveralls.wear!
|
14
14
|
|
15
15
|
# Given that it is always loaded, you are encouraged to keep this file as
|
16
16
|
# light-weight as possible. Requiring heavyweight dependencies from this file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_web_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris BRESCIANI
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-05-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: coveralls
|
@@ -30,16 +30,16 @@ dependencies:
|
|
30
30
|
name: rspec-rails
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 4.0.0
|
35
|
+
version: 4.0.0
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 4.0.0
|
42
|
+
version: 4.0.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: simplecov
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,14 +60,14 @@ dependencies:
|
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '3.
|
63
|
+
version: '3.8'
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '3.
|
70
|
+
version: '3.8'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rails
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +118,6 @@ files:
|
|
118
118
|
- ".rubocop.yml"
|
119
119
|
- ".travis.yml"
|
120
120
|
- Gemfile
|
121
|
-
- Gemfile.lock
|
122
121
|
- MIT-LICENSE
|
123
122
|
- README.md
|
124
123
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
redis_web_manager (0.1.9)
|
5
|
-
pagy (~> 3.7)
|
6
|
-
rails (>= 5.2, < 7)
|
7
|
-
redis (~> 4.1.0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
actioncable (6.0.2.1)
|
13
|
-
actionpack (= 6.0.2.1)
|
14
|
-
nio4r (~> 2.0)
|
15
|
-
websocket-driver (>= 0.6.1)
|
16
|
-
actionmailbox (6.0.2.1)
|
17
|
-
actionpack (= 6.0.2.1)
|
18
|
-
activejob (= 6.0.2.1)
|
19
|
-
activerecord (= 6.0.2.1)
|
20
|
-
activestorage (= 6.0.2.1)
|
21
|
-
activesupport (= 6.0.2.1)
|
22
|
-
mail (>= 2.7.1)
|
23
|
-
actionmailer (6.0.2.1)
|
24
|
-
actionpack (= 6.0.2.1)
|
25
|
-
actionview (= 6.0.2.1)
|
26
|
-
activejob (= 6.0.2.1)
|
27
|
-
mail (~> 2.5, >= 2.5.4)
|
28
|
-
rails-dom-testing (~> 2.0)
|
29
|
-
actionpack (6.0.2.1)
|
30
|
-
actionview (= 6.0.2.1)
|
31
|
-
activesupport (= 6.0.2.1)
|
32
|
-
rack (~> 2.0, >= 2.0.8)
|
33
|
-
rack-test (>= 0.6.3)
|
34
|
-
rails-dom-testing (~> 2.0)
|
35
|
-
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
-
actiontext (6.0.2.1)
|
37
|
-
actionpack (= 6.0.2.1)
|
38
|
-
activerecord (= 6.0.2.1)
|
39
|
-
activestorage (= 6.0.2.1)
|
40
|
-
activesupport (= 6.0.2.1)
|
41
|
-
nokogiri (>= 1.8.5)
|
42
|
-
actionview (6.0.2.1)
|
43
|
-
activesupport (= 6.0.2.1)
|
44
|
-
builder (~> 3.1)
|
45
|
-
erubi (~> 1.4)
|
46
|
-
rails-dom-testing (~> 2.0)
|
47
|
-
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
-
activejob (6.0.2.1)
|
49
|
-
activesupport (= 6.0.2.1)
|
50
|
-
globalid (>= 0.3.6)
|
51
|
-
activemodel (6.0.2.1)
|
52
|
-
activesupport (= 6.0.2.1)
|
53
|
-
activerecord (6.0.2.1)
|
54
|
-
activemodel (= 6.0.2.1)
|
55
|
-
activesupport (= 6.0.2.1)
|
56
|
-
activestorage (6.0.2.1)
|
57
|
-
actionpack (= 6.0.2.1)
|
58
|
-
activejob (= 6.0.2.1)
|
59
|
-
activerecord (= 6.0.2.1)
|
60
|
-
marcel (~> 0.3.1)
|
61
|
-
activesupport (6.0.2.1)
|
62
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
63
|
-
i18n (>= 0.7, < 2)
|
64
|
-
minitest (~> 5.1)
|
65
|
-
tzinfo (~> 1.1)
|
66
|
-
zeitwerk (~> 2.2)
|
67
|
-
builder (3.2.4)
|
68
|
-
concurrent-ruby (1.1.6)
|
69
|
-
coveralls (0.8.23)
|
70
|
-
json (>= 1.8, < 3)
|
71
|
-
simplecov (~> 0.16.1)
|
72
|
-
term-ansicolor (~> 1.3)
|
73
|
-
thor (>= 0.19.4, < 2.0)
|
74
|
-
tins (~> 1.6)
|
75
|
-
crass (1.0.6)
|
76
|
-
diff-lcs (1.3)
|
77
|
-
docile (1.3.2)
|
78
|
-
erubi (1.9.0)
|
79
|
-
globalid (0.4.2)
|
80
|
-
activesupport (>= 4.2.0)
|
81
|
-
i18n (1.8.2)
|
82
|
-
concurrent-ruby (~> 1.0)
|
83
|
-
json (2.3.0)
|
84
|
-
loofah (2.4.0)
|
85
|
-
crass (~> 1.0.2)
|
86
|
-
nokogiri (>= 1.5.9)
|
87
|
-
mail (2.7.1)
|
88
|
-
mini_mime (>= 0.1.1)
|
89
|
-
marcel (0.3.3)
|
90
|
-
mimemagic (~> 0.3.2)
|
91
|
-
method_source (0.9.2)
|
92
|
-
mimemagic (0.3.4)
|
93
|
-
mini_mime (1.0.2)
|
94
|
-
mini_portile2 (2.4.0)
|
95
|
-
minitest (5.14.0)
|
96
|
-
nio4r (2.5.2)
|
97
|
-
nokogiri (1.10.8)
|
98
|
-
mini_portile2 (~> 2.4.0)
|
99
|
-
pagy (3.7.3)
|
100
|
-
rack (2.2.2)
|
101
|
-
rack-test (1.1.0)
|
102
|
-
rack (>= 1.0, < 3)
|
103
|
-
rails (6.0.2.1)
|
104
|
-
actioncable (= 6.0.2.1)
|
105
|
-
actionmailbox (= 6.0.2.1)
|
106
|
-
actionmailer (= 6.0.2.1)
|
107
|
-
actionpack (= 6.0.2.1)
|
108
|
-
actiontext (= 6.0.2.1)
|
109
|
-
actionview (= 6.0.2.1)
|
110
|
-
activejob (= 6.0.2.1)
|
111
|
-
activemodel (= 6.0.2.1)
|
112
|
-
activerecord (= 6.0.2.1)
|
113
|
-
activestorage (= 6.0.2.1)
|
114
|
-
activesupport (= 6.0.2.1)
|
115
|
-
bundler (>= 1.3.0)
|
116
|
-
railties (= 6.0.2.1)
|
117
|
-
sprockets-rails (>= 2.0.0)
|
118
|
-
rails-dom-testing (2.0.3)
|
119
|
-
activesupport (>= 4.2.0)
|
120
|
-
nokogiri (>= 1.6)
|
121
|
-
rails-html-sanitizer (1.3.0)
|
122
|
-
loofah (~> 2.3)
|
123
|
-
railties (6.0.2.1)
|
124
|
-
actionpack (= 6.0.2.1)
|
125
|
-
activesupport (= 6.0.2.1)
|
126
|
-
method_source
|
127
|
-
rake (>= 0.8.7)
|
128
|
-
thor (>= 0.20.3, < 2.0)
|
129
|
-
rake (13.0.1)
|
130
|
-
redis (4.1.3)
|
131
|
-
rspec-core (3.9.1)
|
132
|
-
rspec-support (~> 3.9.1)
|
133
|
-
rspec-expectations (3.9.0)
|
134
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
135
|
-
rspec-support (~> 3.9.0)
|
136
|
-
rspec-mocks (3.9.1)
|
137
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
138
|
-
rspec-support (~> 3.9.0)
|
139
|
-
rspec-rails (4.0.0.beta3)
|
140
|
-
actionpack (>= 4.2)
|
141
|
-
activesupport (>= 4.2)
|
142
|
-
railties (>= 4.2)
|
143
|
-
rspec-core (~> 3.8)
|
144
|
-
rspec-expectations (~> 3.8)
|
145
|
-
rspec-mocks (~> 3.8)
|
146
|
-
rspec-support (~> 3.8)
|
147
|
-
rspec-support (3.9.2)
|
148
|
-
simplecov (0.16.1)
|
149
|
-
docile (~> 1.1)
|
150
|
-
json (>= 1.8, < 3)
|
151
|
-
simplecov-html (~> 0.10.0)
|
152
|
-
simplecov-html (0.10.2)
|
153
|
-
sprockets (4.0.0)
|
154
|
-
concurrent-ruby (~> 1.0)
|
155
|
-
rack (> 1, < 3)
|
156
|
-
sprockets-rails (3.2.1)
|
157
|
-
actionpack (>= 4.0)
|
158
|
-
activesupport (>= 4.0)
|
159
|
-
sprockets (>= 3.0.0)
|
160
|
-
sync (0.5.0)
|
161
|
-
term-ansicolor (1.7.1)
|
162
|
-
tins (~> 1.0)
|
163
|
-
thor (1.0.1)
|
164
|
-
thread_safe (0.3.6)
|
165
|
-
tins (1.24.1)
|
166
|
-
sync
|
167
|
-
tzinfo (1.2.6)
|
168
|
-
thread_safe (~> 0.1)
|
169
|
-
websocket-driver (0.7.1)
|
170
|
-
websocket-extensions (>= 0.1.0)
|
171
|
-
websocket-extensions (0.1.4)
|
172
|
-
zeitwerk (2.2.2)
|
173
|
-
|
174
|
-
PLATFORMS
|
175
|
-
ruby
|
176
|
-
|
177
|
-
DEPENDENCIES
|
178
|
-
coveralls (~> 0.8)
|
179
|
-
redis_web_manager!
|
180
|
-
rspec-rails (= 4.0.0.beta3)
|
181
|
-
simplecov (~> 0.16)
|
182
|
-
|
183
|
-
BUNDLED WITH
|
184
|
-
2.1.4
|