datastore_redis 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/javascripts/datastore_redis/application.js +9 -0
  5. data/app/assets/javascripts/datastore_redis/redis_strings.js +2 -0
  6. data/app/assets/stylesheets/datastore_redis/application.css +7 -0
  7. data/app/assets/stylesheets/datastore_redis/redis_strings.css +4 -0
  8. data/app/assets/stylesheets/scaffold.css +56 -0
  9. data/app/controllers/datastore_redis/application_controller.rb +4 -0
  10. data/app/controllers/datastore_redis/redis_strings_controller.rb +81 -0
  11. data/app/helpers/datastore_redis/application_helper.rb +4 -0
  12. data/app/helpers/datastore_redis/redis_strings_helper.rb +4 -0
  13. data/app/models/datastore_redis/redis_connection.rb +21 -0
  14. data/app/models/datastore_redis/redis_string.rb +29 -0
  15. data/app/views/datastore_redis/redis_strings/_form.html.erb +10 -0
  16. data/app/views/datastore_redis/redis_strings/edit.html.erb +6 -0
  17. data/app/views/datastore_redis/redis_strings/index.html.erb +23 -0
  18. data/app/views/datastore_redis/redis_strings/new.html.erb +5 -0
  19. data/app/views/datastore_redis/redis_strings/show.html.erb +15 -0
  20. data/app/views/layouts/datastore_redis/application.html.erb +14 -0
  21. data/config/routes.rb +3 -0
  22. data/lib/datastore_redis.rb +4 -0
  23. data/lib/datastore_redis/engine.rb +5 -0
  24. data/lib/datastore_redis/version.rb +3 -0
  25. data/lib/tasks/datastore_redis_tasks.rake +4 -0
  26. data/lib/tasks/routes.rake +7 -0
  27. data/test/datastore_redis_test.rb +7 -0
  28. data/test/dummy/Rakefile +7 -0
  29. data/test/dummy/app/assets/javascripts/application.js +9 -0
  30. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  31. data/test/dummy/app/controllers/application_controller.rb +3 -0
  32. data/test/dummy/app/helpers/application_helper.rb +2 -0
  33. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  34. data/test/dummy/config.ru +4 -0
  35. data/test/dummy/config/application.rb +45 -0
  36. data/test/dummy/config/boot.rb +10 -0
  37. data/test/dummy/config/database.yml +25 -0
  38. data/test/dummy/config/environment.rb +5 -0
  39. data/test/dummy/config/environments/development.rb +30 -0
  40. data/test/dummy/config/environments/production.rb +60 -0
  41. data/test/dummy/config/environments/test.rb +39 -0
  42. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  43. data/test/dummy/config/initializers/inflections.rb +10 -0
  44. data/test/dummy/config/initializers/mime_types.rb +5 -0
  45. data/test/dummy/config/initializers/secret_token.rb +7 -0
  46. data/test/dummy/config/initializers/session_store.rb +8 -0
  47. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/test/dummy/config/locales/en.yml +5 -0
  49. data/test/dummy/config/routes.rb +4 -0
  50. data/test/dummy/db/development.sqlite3 +0 -0
  51. data/test/dummy/lib/tasks/datastore_redis_tasks.rake +4 -0
  52. data/test/dummy/lib/tasks/routes.rake +7 -0
  53. data/test/dummy/log/development.log +989 -0
  54. data/test/dummy/public/404.html +26 -0
  55. data/test/dummy/public/422.html +26 -0
  56. data/test/dummy/public/500.html +26 -0
  57. data/test/dummy/public/favicon.ico +0 -0
  58. data/test/dummy/script/rails +6 -0
  59. data/test/dummy/tmp/cache/assets/CAE/810/sprockets%2F6e17affb146108a554244e494ed83351 +0 -0
  60. data/test/dummy/tmp/cache/assets/CBB/050/sprockets%2F385671e24d82c400d04f38f6e9287c4f +0 -0
  61. data/test/dummy/tmp/cache/assets/D3C/550/sprockets%2F085759d3bb472fea26d0d3bf2a8813e3 +0 -0
  62. data/test/dummy/tmp/cache/assets/D45/0B0/sprockets%2Fb6fb348130590989cecd0f7bcf3c8621 +0 -0
  63. data/test/dummy/tmp/cache/assets/D46/5C0/sprockets%2F63820178fa5358b3e9206aadfc66e5fe +0 -0
  64. data/test/dummy/tmp/cache/assets/D48/5D0/sprockets%2Fb5b9698ca26593ccfc1001cc88d0d788 +0 -0
  65. data/test/dummy/tmp/cache/assets/D5F/DB0/sprockets%2F797375835dc5b5494eb88ccd66abc98e +0 -0
  66. data/test/dummy/tmp/cache/assets/D76/B90/sprockets%2F3d5585be95ebd0989b7100db3ff820ed +0 -0
  67. data/test/dummy/tmp/cache/assets/D98/0C0/sprockets%2F122a68de8c1c103dca5f83da769f5e1b +0 -0
  68. data/test/dummy/tmp/cache/assets/DB1/CF0/sprockets%2Fb2c2c9f24470bc59162f01ac1daeac1b +0 -0
  69. data/test/dummy/tmp/cache/assets/DCC/E80/sprockets%2F2a7ec065ceafb5054a729df9390fec2b +0 -0
  70. data/test/dummy/tmp/cache/assets/E94/610/sprockets%2F884cdccdc1ce3ee3df9c60e4ed2fa6d6 +0 -0
  71. data/test/fixtures/datastore_redis/redis_strings.yml +11 -0
  72. data/test/functional/datastore_redis/redis_strings_controller_test.rb +51 -0
  73. data/test/integration/navigation_test.rb +10 -0
  74. data/test/test_helper.rb +10 -0
  75. data/test/unit/datastore_redis/redis_string_test.rb +9 -0
  76. data/test/unit/helpers/datastore_redis/redis_strings_helper_test.rb +6 -0
  77. metadata +199 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 YOURNAME
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.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = DatastoreRedis
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'DatastoreRedis'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |t|
32
+ t.libs << 'lib'
33
+ t.libs << 'test'
34
+ t.pattern = 'test/**/*_test.rb'
35
+ t.verbose = false
36
+ end
37
+
38
+
39
+ task :default => :test
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,4 @@
1
+ module DatastoreRedis
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,81 @@
1
+ module DatastoreRedis
2
+ class RedisStringsController < ApplicationController
3
+ # GET /redis_strings
4
+ # GET /redis_strings.json
5
+ def index
6
+ @redis_strings = RedisString.all
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @redis_strings }
11
+ end
12
+ end
13
+
14
+ # GET /redis_strings/1
15
+ # GET /redis_strings/1.json
16
+ def show
17
+ @redis_key = params[:id]
18
+ @redis_value = RedisString.find(@redis_key)
19
+
20
+ respond_to do |format|
21
+ format.html # show.html.erb
22
+ format.json { render json: @redis_value }
23
+ end
24
+ end
25
+
26
+ # GET /redis_strings/new
27
+ # GET /redis_strings/new.json
28
+ def new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.json { render json: ''}
33
+ end
34
+ end
35
+
36
+ # GET /redis_strings/1/edit
37
+ def edit
38
+ @redis_key = params[:id]
39
+ @redis_value = RedisString.find(@redis_key)
40
+ end
41
+
42
+ # POST /redis_strings
43
+ # POST /redis_strings.json
44
+ def create
45
+ RedisString.create(params['redis_key'], params['redis_value'])
46
+
47
+ respond_to do |format|
48
+ format.html { redirect_to redis_string_path(params['redis_key']), notice: 'Redis string was successfully created.' }
49
+ format.json { render json: params['redis_value'], status: :created, location: @redis_string }
50
+ end
51
+ end
52
+
53
+ # PUT /redis_strings/1
54
+ # PUT /redis_strings/1.json
55
+ def update
56
+ @redis_string = RedisString.find(params[:id])
57
+
58
+ respond_to do |format|
59
+ if @redis_string.update_attributes(params[:redis_string])
60
+ format.html { redirect_to redis_string_path(@redis_string), notice: 'Redis string was successfully updated.' }
61
+ format.json { head :ok }
62
+ else
63
+ format.html { render action: "edit" }
64
+ format.json { render json: @redis_string.errors, status: :unprocessable_entity }
65
+ end
66
+ end
67
+ end
68
+
69
+ # DELETE /redis_strings/1
70
+ # DELETE /redis_strings/1.json
71
+ def destroy
72
+ @redis_key = params[:id]
73
+ RedisString.destroy(@redis_key)
74
+
75
+ respond_to do |format|
76
+ format.html { redirect_to redis_strings_url }
77
+ format.json { head :ok }
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,4 @@
1
+ module DatastoreRedis
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module DatastoreRedis
2
+ module RedisStringsHelper
3
+ end
4
+ end
@@ -0,0 +1,21 @@
1
+ module DatastoreRedis
2
+ class RedisConnection
3
+ def connection_string
4
+ conn_string = ENV["REDISTOGO_URL"]
5
+ conn_string ||= "localhost:6379"
6
+ conn_string
7
+ end
8
+
9
+ def get_new_connection
10
+ uri = URI.parse(connection_string)
11
+ args = {:host => uri.host, :port => uri.port}
12
+ args[:password] = uri.password if uri.password
13
+ Redis.new(args)
14
+ end
15
+
16
+ def self.connection
17
+ @@redis ||= RedisConnection.new.get_new_connection
18
+ @@redis
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ module DatastoreRedis
2
+ class RedisString
3
+ class << self
4
+ def all
5
+ DatastoreRedis::RedisConnection.connection.keys
6
+ end
7
+
8
+ def find(key)
9
+ DatastoreRedis::RedisConnection.connection[key]
10
+ end
11
+
12
+ def create(key, value)
13
+ DatastoreRedis::RedisConnection.connection[key] = value
14
+ end
15
+
16
+ def update(key, value)
17
+ DatastoreRedis::RedisConnection.connection[key] = value
18
+ end
19
+
20
+ def destroy(key)
21
+ DatastoreRedis::RedisConnection.connection.del(key)
22
+ end
23
+
24
+ def destroy_all
25
+ DatastoreRedis::RedisConnection.connection.flushall
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ <%= form_tag({:controller => "redis_strings", :action => "create"}, :method => "post") do %>
2
+ <%= label_tag :redis_key %>
3
+ <%= text_field_tag :redis_key, @redis_key %>
4
+ <%= label_tag :redis_value %>
5
+ <%= text_field_tag :redis_value, @redis_value %>
6
+
7
+ <div class="actions">
8
+ <%= submit_tag %>
9
+ </div>
10
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing redis_string</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @redis_string %> |
6
+ <%= link_to 'Back', redis_strings_path %>
@@ -0,0 +1,23 @@
1
+ <h1>Listing redis_strings</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Key</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+
11
+ <% @redis_strings.each do |redis_key| %>
12
+ <tr>
13
+ <td><%= redis_key %></td>
14
+ <td><%= link_to 'Show', redis_string_path(redis_key) %></td>
15
+ <td><%= link_to 'Edit', edit_redis_string_path(redis_key) %></td>
16
+ <td><%= link_to 'Destroy', redis_string_path(redis_key), confirm: 'Are you sure?', method: :delete %></td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+
21
+ <br />
22
+
23
+ <%= link_to 'New Redis string', new_redis_string_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New redis_string</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', redis_strings_path %>
@@ -0,0 +1,15 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Key:</th>
6
+ <td><%= @redis_key %></td>
7
+ </tr>
8
+ <tr>
9
+ <th>Value:</th>
10
+ <td><%= @redis_value %></td>
11
+ </tr>
12
+ </table>
13
+
14
+ <%= link_to 'Edit', edit_redis_string_path(@redis_key) %> |
15
+ <%= link_to 'Back', redis_strings_path %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>DatastoreRedis</title>
5
+ <%= stylesheet_link_tag "datastore_redis/application" %>
6
+ <%= javascript_include_tag "datastore_redis/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ DatastoreRedis::Engine.routes.draw do
2
+ resources :redis_strings
3
+ end
@@ -0,0 +1,4 @@
1
+ require "datastore_redis/engine"
2
+
3
+ module DatastoreRedis
4
+ end
@@ -0,0 +1,5 @@
1
+ module DatastoreRedis
2
+ class Engine < Rails::Engine
3
+ isolate_namespace DatastoreRedis
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module DatastoreRedis
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :datastore_redis do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ task :routes => 'app:environment' do
2
+ Rails.application.reload_routes!
3
+ all_routes = DatastoreRedis::Engine.routes.routes
4
+ require 'rails/application/route_inspector'
5
+ inspector = Rails::Application::RouteInspector.new
6
+ puts inspector.format(all_routes, ENV['CONTROLLER']).join "\n"
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class DatastoreRedisTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, DatastoreRedis
6
+ end
7
+ end