bindi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in namaste.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Havenwood
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # Bindi
2
+
3
+ [Bindi](https://github.com/Havenwood/bindi) is a DSL for storing marshallable Ruby Objects in [Redis](http://redis.io/) using [Ohm](http://ohm.keyvalue.org/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bindi'
10
+
11
+ Or install it yourself:
12
+
13
+ $ gem install bindi
14
+
15
+ Then install Redis:
16
+
17
+ $ brew install redis
18
+
19
+ And start Redis:
20
+
21
+ $ redis-server
22
+
23
+ ## Usage
24
+
25
+ ### The Basics
26
+
27
+ ```ruby
28
+ require 'bindi'
29
+ #=> true
30
+
31
+ Bindi.connect
32
+ #=> nil
33
+
34
+ Bindi[:state_gemstones] = { alabama: 'Star Blue Quartz',
35
+ alaska: 'Nephrite Jade',
36
+ arizona: 'Turquoise',
37
+ arkansas: 'Diamond' }
38
+
39
+ #=> {:alabama=>"Star Blue Quartz", ...
40
+
41
+ exit
42
+ ```
43
+
44
+ Your Ruby Object is now stored in Redis.
45
+
46
+ ```ruby
47
+ require 'bindi'
48
+ #=> true
49
+
50
+ Bindi.keys
51
+ #=> "state_gemstones"
52
+
53
+ Bindi[:state_gemstones]
54
+ #=> #=> {:alabama=>"Star Blue Quartz", ...
55
+ ```
56
+
57
+ ### Ruby Hash Methods
58
+
59
+ ```ruby
60
+ Bindi[:key] = 'value'
61
+ #=> "value"
62
+
63
+ Bindi[:key]
64
+ #=> "value"
65
+
66
+ Bindi.clear # Flushes entire DB
67
+
68
+ Bindi.delete :key
69
+ #=> 1
70
+
71
+ Bindi.each do |key|
72
+ puts key
73
+ end
74
+
75
+ Bindi.empty?
76
+ #=> false
77
+
78
+ Bindi.inspect
79
+
80
+ Bindi.key? :nope
81
+ #=> false
82
+
83
+ Bindi.keys
84
+ #=> "key"
85
+ ```
86
+
87
+ ### Redis Helper Methods
88
+
89
+ ```ruby
90
+ Bindi.info
91
+ #=> {"redis_version"=>"2.4.15", ...
92
+
93
+ Bindi.inspect_redis
94
+ #=> "#<Redis client v2.2.2 connected to redis://127.0.0.1:6379 ..."
95
+ ```
96
+
97
+ ## Contributing
98
+
99
+ 1. Fork it
100
+ 2. Commit your changes
101
+ 3. Pull request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bindi.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/namaste/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Havenwood']
6
+ gem.email = ['shannonskipper@gmail.com']
7
+ gem.description = %q{A DSL for saving Ruby Objects to Redis.}
8
+ gem.summary = %q{Bindi is a DSL that marshals Ruby Objects and saves them to Redis using Ohm.}
9
+ gem.homepage = 'https://github.com/Havenwood/bindi'
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = 'bindi'
15
+ gem.require_paths = ['lib']
16
+ gem.version = Namaste::VERSION
17
+
18
+ gem.add_development_dependency 'ohm'
19
+ gem.add_runtime_dependency 'ohm'
20
+ end
@@ -0,0 +1,3 @@
1
+ module Namaste
2
+ VERSION = "0.0.1"
3
+ end
data/lib/namaste.rb ADDED
@@ -0,0 +1,60 @@
1
+ require 'ohm'
2
+ require 'namaste/version'
3
+
4
+ module Namaste
5
+ class << self
6
+ def connect
7
+ Ohm.connect
8
+ end
9
+
10
+ def [] key
11
+ Marshal.load(Ohm.redis.get key)
12
+ end
13
+
14
+ def []= key, value
15
+ Ohm.redis.set key, Marshal.dump(value)
16
+ end
17
+
18
+ def clear
19
+ Ohm.redis.flushdb
20
+ end
21
+
22
+ def delete key
23
+ Ohm.redis.del key
24
+ end
25
+
26
+ def each
27
+ Ohm.redis.keys.each do
28
+ yield
29
+ end
30
+ end
31
+
32
+ def empty?
33
+ Ohm.redis.keys.empty?
34
+ end
35
+
36
+ def info
37
+ Ohm.redis.info
38
+ end
39
+
40
+ def inspect
41
+ Ohm.redis.all
42
+ end
43
+
44
+ alias to_s inspect
45
+
46
+ def inspect_redis
47
+ Ohm.redis.inspect
48
+ end
49
+
50
+ def key? key
51
+ Ohm.redis.exists key
52
+ end
53
+
54
+ alias has_key key?
55
+
56
+ def keys
57
+ Ohm.redis.keys
58
+ end
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bindi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Havenwood
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ none: false
21
+ prerelease: false
22
+ type: :development
23
+ name: ohm
24
+ requirement: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ none: false
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ none: false
37
+ prerelease: false
38
+ type: :runtime
39
+ name: ohm
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ none: false
46
+ description: A DSL for saving Ruby Objects to Redis.
47
+ email:
48
+ - shannonskipper@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE
56
+ - README.md
57
+ - Rakefile
58
+ - bindi.gemspec
59
+ - lib/namaste.rb
60
+ - lib/namaste/version.rb
61
+ homepage: https://github.com/Havenwood/bindi
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ none: false
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ none: false
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.24
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Bindi is a DSL that marshals Ruby Objects and saves them to Redis using Ohm.
85
+ test_files: []
86
+ has_rdoc: