memcached-manager 0.2.2 → 0.2.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.
- data/config.ru +3 -1
- metadata +5 -77
- data/.rspec +0 -2
- data/.travis.yml +0 -19
- data/CONTRIBUTING.md +0 -28
- data/Gemfile +0 -26
- data/Gemfile.lock +0 -143
- data/Rakefile +0 -59
- data/VERSION +0 -1
- data/features/api/create_memcached_key.feature +0 -6
- data/features/api/delete_memcached_key.feature +0 -6
- data/features/api/list_memcached_keys.feature +0 -6
- data/features/api/set_memcached_info.feature +0 -5
- data/features/api/show_memcached_key.feature +0 -10
- data/features/api/show_memcached_stats.feature +0 -5
- data/features/api/update_memcached_key.feature +0 -7
- data/features/step_definitions/api/create_memcached_key.rb +0 -21
- data/features/step_definitions/api/delete_memcached_key.rb +0 -7
- data/features/step_definitions/api/list_memcached_keys.rb +0 -16
- data/features/step_definitions/api/show_memcached_key.rb +0 -18
- data/features/step_definitions/api/show_memcached_stats.rb +0 -3
- data/features/step_definitions/api/update_memcached_key.rb +0 -18
- data/features/step_definitions/set_memcached_info.rb +0 -25
- data/features/step_definitions/webapp/create_memcached_key.rb +0 -10
- data/features/step_definitions/webapp/delete_memcached_key.rb +0 -16
- data/features/step_definitions/webapp/edit_memcached_key.rb +0 -3
- data/features/step_definitions/webapp/list_memcached_keys.rb +0 -4
- data/features/step_definitions/webapp/show_memcached_key.rb +0 -4
- data/features/step_definitions/webapp/show_memcached_stats.rb +0 -5
- data/features/support/env.rb +0 -28
- data/features/support/hooks.rb +0 -3
- data/features/webapp/create_memcached_key.feature +0 -9
- data/features/webapp/delete_memcached_key.feature +0 -8
- data/features/webapp/edit_memcached_key.feature +0 -9
- data/features/webapp/list_memcached_keys.feature +0 -8
- data/features/webapp/show_memcached_key.feature +0 -7
- data/features/webapp/show_memcached_stats.feature +0 -6
- data/lib/api.rb +0 -85
- data/lib/extensions.rb +0 -14
- data/lib/extensions/api_response.rb +0 -15
- data/lib/extensions/errors.rb +0 -19
- data/lib/extensions/memcached_connection.rb +0 -15
- data/lib/extensions/memcached_inspector.rb +0 -49
- data/lib/extensions/memcached_settings.rb +0 -18
- data/lib/public/images/glyphicons-halflings-white.png +0 -0
- data/lib/public/images/glyphicons-halflings.png +0 -0
- data/lib/public/javascripts/angular-resource.min.js +0 -10
- data/lib/public/javascripts/angular-ui-states.min.js +0 -7
- data/lib/public/javascripts/angular.min.js +0 -161
- data/lib/public/javascripts/angular/controllers.js +0 -89
- data/lib/public/javascripts/angular/routes.js +0 -66
- data/lib/public/javascripts/angular/services/notification.js +0 -16
- data/lib/public/javascripts/angular/services/resources.js +0 -20
- data/lib/public/javascripts/angular/services/response.js +0 -10
- data/lib/public/javascripts/application.js +0 -18
- data/lib/public/javascripts/jquery-1.9.1.min.js +0 -5
- data/lib/public/javascripts/noty/jquery.noty.js +0 -547
- data/lib/public/javascripts/noty/layouts/top.js +0 -34
- data/lib/public/javascripts/noty/themes/default.js +0 -156
- data/lib/public/javascripts/noty_config.js +0 -25
- data/lib/public/stylesheets/app.css +0 -50
- data/lib/public/stylesheets/base.css +0 -269
- data/lib/public/stylesheets/icons.css +0 -492
- data/lib/public/stylesheets/layout.css +0 -58
- data/lib/public/stylesheets/skeleton.css +0 -242
- data/lib/public/templates/edit.html.erb +0 -6
- data/lib/public/templates/keys.html.erb +0 -36
- data/lib/public/templates/new.html.erb +0 -6
- data/lib/public/templates/show.html.erb +0 -2
- data/lib/public/templates/stats.html.erb +0 -8
- data/lib/views/index.erb +0 -13
- data/lib/views/layout.erb +0 -52
- data/lib/webapp.rb +0 -14
- data/memcached-manager.gemspec +0 -152
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
@api
|
|
2
|
-
Feature: Show memcached keys
|
|
3
|
-
Scenario: Success
|
|
4
|
-
Given there's the "username" memcached key avaiable
|
|
5
|
-
When I visit "/keys/username.json" in the API
|
|
6
|
-
Then I should receive a json response with this key
|
|
7
|
-
|
|
8
|
-
Scenario: Key doesn't exist
|
|
9
|
-
When I visit "/keys/username.json" in the API
|
|
10
|
-
Then I should receive a json telling me that the key doesn't exist
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
@api
|
|
2
|
-
Feature: Update memcached pair
|
|
3
|
-
Scenario: Success
|
|
4
|
-
Given there's the "username" memcached key avaiable
|
|
5
|
-
When I put some data to "/keys.json" in the API
|
|
6
|
-
Then I should receive a json response that it was edited successfully
|
|
7
|
-
And it should be updated in memcached
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
When /^I post some data to "(.*?)" in the API$/ do |route|
|
|
2
|
-
@data = { key: 'all.i.want.to.do', value: 'is.bang.bang.bang' }
|
|
3
|
-
@response = API.post do |req|
|
|
4
|
-
req.url "api/#{route}"
|
|
5
|
-
req.params = @data
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
Then /^I should receive a json response that it was saved successfully$/ do
|
|
10
|
-
@response.status.should be 200
|
|
11
|
-
response_json = JSON.parse(@response.body)
|
|
12
|
-
response_json.class.should eql Hash
|
|
13
|
-
response_json.keys.should_not include 'errors'
|
|
14
|
-
response_json.values.should include 'all.i.want.to.do'
|
|
15
|
-
response_json.keys.should include 'expired'
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
Then /^it should be saved in memcached$/ do
|
|
19
|
-
key = Memcached.get(@data[:key])
|
|
20
|
-
key.should == @data[:value]
|
|
21
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
Given /^there's some memcached keys avaiable$/ do
|
|
4
|
-
Memcached.set('foo', 'bar')
|
|
5
|
-
Memcached.set('ineed', 'togetalife')
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
When /^I visit "(.*?)" in the API$/ do |route|
|
|
9
|
-
@response = JSON.parse(API.get("api/#{route}").body)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
Then /^I should receive a json response with those keys$/ do
|
|
13
|
-
@response.should_not equal nil
|
|
14
|
-
@response.last.values.should include 'foo'
|
|
15
|
-
@response.first.values.should include 'ineed'
|
|
16
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# Scenario: Success
|
|
2
|
-
Given /^there's the "(.*?)" memcached key avaiable$/ do |key|
|
|
3
|
-
@key = key
|
|
4
|
-
Memcached.set(@key, 'John Doe')
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
Then /^I should receive a json response with this key$/ do
|
|
8
|
-
@response.class.should eql Hash
|
|
9
|
-
@response["key"].should include 'name'
|
|
10
|
-
@response["value"].should include 'John Doe'
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Scenario: Key doesn't exist
|
|
14
|
-
Then /^I should receive a json telling me that the key doesn't exist$/ do
|
|
15
|
-
@response.class.should eql Hash
|
|
16
|
-
@response.keys.should include 'errors'
|
|
17
|
-
@response["errors"].should include 'Key not found.'
|
|
18
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
When /^I put some data to "(.*?)" in the API$/ do |route|
|
|
2
|
-
@data = { key: 'username', value: 'thiagofm' }
|
|
3
|
-
@response = API.put do |req|
|
|
4
|
-
req.url "api/#{route}"
|
|
5
|
-
req.params = @data
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
Then /^I should receive a json response that it was edited successfully$/ do
|
|
10
|
-
@response.status.should be 200
|
|
11
|
-
response_json = JSON.parse(@response.body)
|
|
12
|
-
response_json.class.should eql Hash
|
|
13
|
-
response_json.keys.should include 'key'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
Then /^it should be updated in memcached$/ do
|
|
17
|
-
Memcached.get(@key).should eql 'thiagofm'
|
|
18
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
When /^I post configs to "(.*?)" in the API$/ do |route|
|
|
2
|
-
@data = { 'host' => 'i.am', 'port' => '1337' }
|
|
3
|
-
@route = route
|
|
4
|
-
|
|
5
|
-
API.post do |req|
|
|
6
|
-
req.url "api/#{@route}"
|
|
7
|
-
req.params = @data
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
Then /^the memcached config should be set$/ do
|
|
12
|
-
response = API.get("api/#{@route}")
|
|
13
|
-
response_json = JSON.parse(response.body)
|
|
14
|
-
|
|
15
|
-
response.status.should be 200
|
|
16
|
-
response_json['host'].should eql @data['host']
|
|
17
|
-
response_json['port'].should eql @data['port']
|
|
18
|
-
|
|
19
|
-
# Workaround so the next feature don't use the current memcached configs
|
|
20
|
-
@data = { 'host' => MemcachedConfigs[:host], 'port' => MemcachedConfigs[:port] }
|
|
21
|
-
API.post do |req|
|
|
22
|
-
req.url "api/#{@route}"
|
|
23
|
-
req.params = @data
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
When /^I visit "(.*?)"$/ do |route|
|
|
2
|
-
visit route
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
When /^fill in "(.*?)" with "(.*?)"$/ do |field, value|
|
|
6
|
-
fill_in(field, :with => value)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
When /^click "(.*?)"$/ do |button|
|
|
10
|
-
click_button button
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Then /^"(.*?)" key should have the "(.*?)" value in memcached$/ do |key, value|
|
|
14
|
-
sleep 1
|
|
15
|
-
Memcached.get(key).should == value
|
|
16
|
-
end
|
data/features/support/env.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require 'cucumber'
|
|
2
|
-
require 'capybara/cucumber'
|
|
3
|
-
require 'faraday'
|
|
4
|
-
require 'dalli'
|
|
5
|
-
require 'rspec'
|
|
6
|
-
require 'rspec/expectations'
|
|
7
|
-
require 'capybara/poltergeist'
|
|
8
|
-
require 'sinatra'
|
|
9
|
-
|
|
10
|
-
Capybara.javascript_driver = :poltergeist
|
|
11
|
-
|
|
12
|
-
World(RSpec::Matchers)
|
|
13
|
-
|
|
14
|
-
# Files
|
|
15
|
-
Dir.glob("lib/**/*.rb").each do |file|
|
|
16
|
-
require_relative "../../#{file}"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
Capybara.app = Rack::Builder.parse_file(File.expand_path('../../../config.ru', __FILE__)).first
|
|
20
|
-
|
|
21
|
-
API = Faraday.new do |conn| conn.adapter :rack, Rack::URLMap.new({
|
|
22
|
-
"/api" => MemcachedManager::API.new,
|
|
23
|
-
"/" => MemcachedManager::Webapp.new
|
|
24
|
-
})
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
MemcachedConfigs = { host: 'localhost', port: '11211' }
|
|
28
|
-
Memcached = Dalli::Client.new("#{MemcachedConfigs[:host]}:#{MemcachedConfigs[:port]}")
|
data/features/support/hooks.rb
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
@webapp
|
|
2
|
-
@javascript
|
|
3
|
-
Feature: Edit memcached pair
|
|
4
|
-
Scenario: Success
|
|
5
|
-
Given a key named "foo" with the content "bar" exists
|
|
6
|
-
When I visit "#/edit/foo"
|
|
7
|
-
And fill in "Value" with "baz"
|
|
8
|
-
And click "Edit"
|
|
9
|
-
Then "foo" key should have the "baz" value in memcached
|
data/lib/api.rb
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# Sinatra
|
|
2
|
-
require 'sinatra/base'
|
|
3
|
-
require 'sinatra/contrib'
|
|
4
|
-
require 'json'
|
|
5
|
-
|
|
6
|
-
# Libs
|
|
7
|
-
require 'dalli'
|
|
8
|
-
require 'net/telnet'
|
|
9
|
-
|
|
10
|
-
# Project files
|
|
11
|
-
require_relative './extensions'
|
|
12
|
-
|
|
13
|
-
module MemcachedManager
|
|
14
|
-
class API < Sinatra::Base
|
|
15
|
-
enable :inline_templates
|
|
16
|
-
enable :sessions
|
|
17
|
-
|
|
18
|
-
set :public_folder, 'public'
|
|
19
|
-
|
|
20
|
-
helpers Sinatra::MemcachedSettings
|
|
21
|
-
helpers Sinatra::MemcachedConnection
|
|
22
|
-
helpers Sinatra::MemcachedInspector
|
|
23
|
-
helpers Sinatra::Errors
|
|
24
|
-
helpers Sinatra::APIResponse
|
|
25
|
-
|
|
26
|
-
before do
|
|
27
|
-
content_type :json
|
|
28
|
-
|
|
29
|
-
setup_errors
|
|
30
|
-
|
|
31
|
-
try { setup_memcached(memcached_host(session), memcached_port(session)) }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
after do
|
|
35
|
-
close_memcached
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
get '/config.json' do
|
|
39
|
-
api_response { { host: memcached_host(session), port: memcached_port(session) } }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
post '/config.json' do
|
|
43
|
-
session['host'] = params['host']
|
|
44
|
-
session['port'] = params['port']
|
|
45
|
-
|
|
46
|
-
api_response { { host: memcached_host(session), port: memcached_port(session) } }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
post '/keys.json' do
|
|
50
|
-
try { memcached_connection.set(params[:key], params[:value]) }
|
|
51
|
-
|
|
52
|
-
api_response { memcached_inspect(host: memcached_host(session), port: memcached_port(session), key: params[:key]) }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
put '/keys.json' do
|
|
56
|
-
try { memcached_connection.replace(params[:key], params[:value]) }
|
|
57
|
-
|
|
58
|
-
api_response { memcached_inspect(host: memcached_host(session), port: memcached_port(session), key: params[:key]) }
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
get '/keys.json' do
|
|
62
|
-
api_response do
|
|
63
|
-
memcached_inspect(host: memcached_host(session), port: memcached_port(session))
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
get '/keys/:key.json' do
|
|
68
|
-
value = memcached_connection.get(params[:key])
|
|
69
|
-
|
|
70
|
-
try { raise 'Key not found.' if value.nil? }
|
|
71
|
-
|
|
72
|
-
api_response { { key: params[:key], value: value } }
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
delete '/keys/:key.json' do
|
|
76
|
-
try { memcached_connection.delete(params[:key]) }
|
|
77
|
-
|
|
78
|
-
api_response { { key: params[:key] } }
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
get '/stats.json' do
|
|
82
|
-
api_response { memcached_connection.stats }
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
data/lib/extensions.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#TODO: autoload extensions
|
|
2
|
-
require_relative 'extensions/errors'
|
|
3
|
-
require_relative 'extensions/memcached_settings'
|
|
4
|
-
require_relative 'extensions/memcached_connection'
|
|
5
|
-
require_relative 'extensions/memcached_inspector'
|
|
6
|
-
require_relative 'extensions/api_response'
|
|
7
|
-
|
|
8
|
-
module Sinatra
|
|
9
|
-
helpers Errors
|
|
10
|
-
helpers MemcachedSettings
|
|
11
|
-
helpers MemcachedConnection
|
|
12
|
-
helpers MemcachedInspector
|
|
13
|
-
helpers APIResponse
|
|
14
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module Sinatra
|
|
2
|
-
module APIResponse
|
|
3
|
-
# This makes the api very DRY by taking care of API errors and converting the object
|
|
4
|
-
# or value passed by the block to json.
|
|
5
|
-
def api_response(&block)
|
|
6
|
-
raise 'No block given' unless block_given?
|
|
7
|
-
|
|
8
|
-
if errors.any?
|
|
9
|
-
return { errors: errors }.to_json
|
|
10
|
-
else
|
|
11
|
-
block.call.tap {|response| return response.to_json }
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
data/lib/extensions/errors.rb
DELETED