redis_data_viewer 0.1.10
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +33 -0
- data/app/assets/config/redis_data_viewer_manifest.js +2 -0
- data/app/assets/javascripts/redis_data_viewer/application.js +14 -0
- data/app/assets/javascripts/redis_data_viewer/viewer.js +2 -0
- data/app/assets/stylesheets/redis_data_viewer/application.css +15 -0
- data/app/assets/stylesheets/redis_data_viewer/viewer.css +4 -0
- data/app/controllers/redis_data_viewer/application_controller.rb +5 -0
- data/app/controllers/redis_data_viewer/viewer_controller.rb +42 -0
- data/app/helpers/redis_data_viewer/application_helper.rb +4 -0
- data/app/helpers/redis_data_viewer/viewer_helper.rb +4 -0
- data/app/jobs/redis_data_viewer/application_job.rb +4 -0
- data/app/mailers/redis_data_viewer/application_mailer.rb +6 -0
- data/app/models/redis_data_viewer/application_record.rb +5 -0
- data/app/views/layouts/redis_data_viewer/application.html.erb +14 -0
- data/app/views/redis_data_viewer/viewer/show_data.html.erb +66 -0
- data/config/routes.rb +4 -0
- data/lib/generators/redis_data_viewer/USAGE +5 -0
- data/lib/generators/redis_data_viewer/redis_data_viewer_generator.rb +25 -0
- data/lib/generators/redis_data_viewer/templates/initializer_template.rb +6 -0
- data/lib/redis_data_viewer/configuration.rb +5 -0
- data/lib/redis_data_viewer/engine.rb +5 -0
- data/lib/redis_data_viewer/version.rb +3 -0
- data/lib/redis_data_viewer.rb +27 -0
- data/lib/tasks/redis_data_viewer_tasks.rake +4 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6c75143df0dae336a78e145642e7ab0aa7628761
|
4
|
+
data.tar.gz: 943ed98ebbd28d08edfc1973d7d16a3122ac8374
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f0464eda9a9a60d6a0a66016603eb05c00abcb0e009a570c83194b50e530a0ee88ca3928e84c6220ca81b5ee27f69701bac17763170cf52bd38a917891470345
|
7
|
+
data.tar.gz: 07c7902dc2b641501fbde358cc1a5dfba298359751b5a9c9e4d3875b5a044d558746aa0b9e4dd4c262bf59b4af2725ae30461c69206cb2bb03eb1c5c91775a20
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2021 Manjit
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# RedisDataViewer
|
2
|
+
A gem that lets you see redis data in your rails application. It helps you view the data in your redis in a readonly mode. This prevents accidental changes in your datastore.
|
3
|
+
|
4
|
+
Visit the [Homepage](https://manjitborah2710.github.io/redis_data_viewer/)
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
How to use my plugin.
|
8
|
+
|
9
|
+
- Open you rails app and go to the path /redis. In the UI, enter the db and key to search for and hit fetch.
|
10
|
+
|
11
|
+

|
12
|
+
|
13
|
+
## Installation
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'redis_data_viewer'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
```bash
|
22
|
+
$ bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
```bash
|
27
|
+
$ gem install redis_data_viewer
|
28
|
+
```
|
29
|
+
|
30
|
+
Execute the following in your rails app root directory
|
31
|
+
```bash
|
32
|
+
rails g redis_data_viewer install
|
33
|
+
```
|
34
|
+
|
35
|
+
Visit this to get a sample configuration that needs to be added to config/initializers/redis_data_viewer.rb in your rails application
|
36
|
+
https://gist.github.com/manjitborah2710/80042165479c512c61d21984c25c6bf6
|
37
|
+
## Contributing
|
38
|
+
Contribution directions go here.
|
39
|
+
|
40
|
+
## License
|
41
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
42
|
+
|
43
|
+
|
44
|
+
### Planned for future release
|
45
|
+
- Able to configure multiple redis hosts rather than one
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RedisDataViewer'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
task default: :test
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_dependency "redis_data_viewer/application_controller"
|
2
|
+
|
3
|
+
module RedisDataViewer
|
4
|
+
class ViewerController < ApplicationController
|
5
|
+
extend RedisDataViewer
|
6
|
+
def show_data
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_data
|
11
|
+
result = {
|
12
|
+
"data" => read_only_search(params[:db], params[:key])
|
13
|
+
}
|
14
|
+
render json: result
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def read_only_search(db, key)
|
20
|
+
redis = RedisDataViewer.redis_client
|
21
|
+
redis.select(db.to_i)
|
22
|
+
value = ""
|
23
|
+
case redis.type(key)
|
24
|
+
when "none"
|
25
|
+
value = "No key found"
|
26
|
+
when "set"
|
27
|
+
value = redis.smembers(key)
|
28
|
+
when "hash"
|
29
|
+
value = redis.hgetall(key)
|
30
|
+
when "string"
|
31
|
+
value = redis.get(key)
|
32
|
+
when "list"
|
33
|
+
value = redis.lrange(key, 0, -1)
|
34
|
+
when "zset"
|
35
|
+
value = (redis.zrange(key, 0, -1, with_scores: true) || []).to_h
|
36
|
+
else
|
37
|
+
value = "No key found"
|
38
|
+
end
|
39
|
+
value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Redis data viewer</title>
|
5
|
+
<%= stylesheet_link_tag "redis_data_viewer/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "redis_data_viewer/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Result</title>
|
6
|
+
<style type="text/css">
|
7
|
+
#container-div{
|
8
|
+
margin: 10px auto;
|
9
|
+
padding: 20px;
|
10
|
+
}
|
11
|
+
#f{
|
12
|
+
text-align: center;
|
13
|
+
}
|
14
|
+
#result{
|
15
|
+
display: block;
|
16
|
+
height: 300px;
|
17
|
+
width: 100%;
|
18
|
+
overflow-y: scroll;
|
19
|
+
resize: none;
|
20
|
+
margin-top: 15px;
|
21
|
+
}
|
22
|
+
#title{
|
23
|
+
width: 100%;
|
24
|
+
text-align: center;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<div id="container-div">
|
30
|
+
<h2 id="title">Redis Database</h2>
|
31
|
+
<%= form_tag(get_data_path, method: :get, id: 'f') do %>
|
32
|
+
<%= label_tag :key, "Key to search"%>
|
33
|
+
<%= text_field_tag :key %>
|
34
|
+
|
35
|
+
<%= label_tag :db, "Redis DB index"%>
|
36
|
+
<%= number_field :redis, :db, :min => 0 %>
|
37
|
+
|
38
|
+
<%= submit_tag "Fetch" %>
|
39
|
+
<% end %>
|
40
|
+
<hr>
|
41
|
+
<%= text_area_tag :result, '',:readonly => true %>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<script type="text/javascript">
|
45
|
+
$('#f').on('submit', (e) =>{
|
46
|
+
e.preventDefault();
|
47
|
+
callAction();
|
48
|
+
})
|
49
|
+
|
50
|
+
function callAction(){
|
51
|
+
$.ajax({
|
52
|
+
type: "get",
|
53
|
+
url: "<%= get_data_path %>",
|
54
|
+
contentType: "application/json; charset=utf-8",
|
55
|
+
data: {key: $('#key').val(), db: $('#redis_db').val()},
|
56
|
+
success: function(result){
|
57
|
+
console.log("response received !!")
|
58
|
+
console.log(result)
|
59
|
+
console.log(result.data)
|
60
|
+
$('#result').val(JSON.stringify(result.data))
|
61
|
+
}
|
62
|
+
})
|
63
|
+
}
|
64
|
+
</script>
|
65
|
+
</body>
|
66
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class RedisDataViewerGenerator < Rails::Generators::NamedBase
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def create_route
|
5
|
+
if name == 'install'
|
6
|
+
route "mount RedisDataViewer::Engine, at: '/redis'"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def create_initializer
|
12
|
+
if name == 'install'
|
13
|
+
configs = begin
|
14
|
+
f_loc = File.expand_path('../templates/initializer_template.rb', __FILE__)
|
15
|
+
f = File.open(f_loc)
|
16
|
+
f.read
|
17
|
+
rescue => e
|
18
|
+
print e.message + "#{File.expand_path('../templates', __FILE__)}" + "\n"
|
19
|
+
""
|
20
|
+
end
|
21
|
+
|
22
|
+
initializer 'redis_data_viewer.rb', configs
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'redis_data_viewer/engine'
|
2
|
+
require 'redis_data_viewer/configuration'
|
3
|
+
require 'redis'
|
4
|
+
|
5
|
+
module RedisDataViewer
|
6
|
+
# Your code goes here...
|
7
|
+
# class << self
|
8
|
+
# attr_accessor :config
|
9
|
+
# end
|
10
|
+
|
11
|
+
def self.setup_data
|
12
|
+
@setup_data ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.setup
|
16
|
+
yield(self.setup_data)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.redis_client
|
20
|
+
if setup_data.use_password
|
21
|
+
@client ||= Redis.new(host: setup_data.redis_host, port: setup_data.redis_port, password: setup_data.redis_password || '')
|
22
|
+
else
|
23
|
+
@client ||= Redis.new(host: setup_data.redis_host, port: setup_data.redis_port)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redis_data_viewer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Manjit Borah
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: redis
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jquery-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: ''
|
84
|
+
email:
|
85
|
+
- manjitborah2710@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- MIT-LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- app/assets/config/redis_data_viewer_manifest.js
|
94
|
+
- app/assets/javascripts/redis_data_viewer/application.js
|
95
|
+
- app/assets/javascripts/redis_data_viewer/viewer.js
|
96
|
+
- app/assets/stylesheets/redis_data_viewer/application.css
|
97
|
+
- app/assets/stylesheets/redis_data_viewer/viewer.css
|
98
|
+
- app/controllers/redis_data_viewer/application_controller.rb
|
99
|
+
- app/controllers/redis_data_viewer/viewer_controller.rb
|
100
|
+
- app/helpers/redis_data_viewer/application_helper.rb
|
101
|
+
- app/helpers/redis_data_viewer/viewer_helper.rb
|
102
|
+
- app/jobs/redis_data_viewer/application_job.rb
|
103
|
+
- app/mailers/redis_data_viewer/application_mailer.rb
|
104
|
+
- app/models/redis_data_viewer/application_record.rb
|
105
|
+
- app/views/layouts/redis_data_viewer/application.html.erb
|
106
|
+
- app/views/redis_data_viewer/viewer/show_data.html.erb
|
107
|
+
- config/routes.rb
|
108
|
+
- lib/generators/redis_data_viewer/USAGE
|
109
|
+
- lib/generators/redis_data_viewer/redis_data_viewer_generator.rb
|
110
|
+
- lib/generators/redis_data_viewer/templates/initializer_template.rb
|
111
|
+
- lib/redis_data_viewer.rb
|
112
|
+
- lib/redis_data_viewer/configuration.rb
|
113
|
+
- lib/redis_data_viewer/engine.rb
|
114
|
+
- lib/redis_data_viewer/version.rb
|
115
|
+
- lib/tasks/redis_data_viewer_tasks.rake
|
116
|
+
homepage: https://manjitborah2710.github.io/redis_data_viewer/
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.6.13
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: A gem that lets you see redis data in your rails application. It helps you
|
140
|
+
view the data in your redis in a readonly mode. This prevents accidental changes
|
141
|
+
in your datastore.
|
142
|
+
test_files: []
|