bindi 0.0.8 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +25 -25
- data/Rakefile +7 -2
- data/bindi.gemspec +6 -9
- data/lib/bindi.rb +17 -25
- data/lib/bindi/version.rb +1 -1
- data/test/bindi_test.rb +65 -0
- data/test/helper.rb +3 -0
- metadata +24 -55
- data.tar.gz.sig +0 -6
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3919585e02b21afbf784dad9ddcc951a3e507576
|
4
|
+
data.tar.gz: 9d8cf3d10124d0c637cc212d52813f7c31ac1142
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21f5e5a41a62d5f1f42cb09aeb98b628fd761267b911b91314707c31710c3db23626b72f47064023c7ed30818e41f899968e114e1a44e6dbb0492afbd9bef27a
|
7
|
+
data.tar.gz: 40ac89024e1f56582bdaf9f27f278654b544889aa881ecbf0fc5857051e24183fe2c1cb834cf5e73ca80187bb1b39663b515c9e2df4db131d824974e5cf66a18
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Bindi
|
2
2
|
|
3
|
-
[Bindi](https://github.com/
|
3
|
+
[Bindi](https://github.com/havenwood/bindi#readme) makes it very, very simple to store native Ruby object in Redis!
|
4
|
+
|
5
|
+
Bindi provides an easy to use Hash-like syntax for serializing Ruby objects with Marshal, YAML or JSON, and then persisting to [Redis](http://redis.io/) with the [redis gem](https://github.com/redis/redis-rb#readme).
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -26,8 +28,8 @@ And start Redis:
|
|
26
28
|
|
27
29
|
```ruby
|
28
30
|
require 'bindi'
|
29
|
-
|
30
|
-
|
31
|
+
require 'yaml'
|
32
|
+
|
31
33
|
bindi = Bindi.new YAML # Choose between Marshal, YAML, JSON, etcetera for serializing.
|
32
34
|
#=> #<Redis client v3.0.2 for redis://127.0.0.1:6379/0>
|
33
35
|
|
@@ -45,7 +47,6 @@ Your Ruby Object is now stored in Redis.
|
|
45
47
|
|
46
48
|
```ruby
|
47
49
|
require 'bindi'
|
48
|
-
#=> true
|
49
50
|
|
50
51
|
bindi = Bindi.new YAML
|
51
52
|
#=> #<Redis client v3.0.2 for redis://127.0.0.1:6379/0>
|
@@ -65,36 +66,35 @@ bindi[:key] = 'value'
|
|
65
66
|
|
66
67
|
bindi[:key]
|
67
68
|
#=> "value"
|
68
|
-
|
69
|
-
bindi.clear # Flushes entire DB
|
70
|
-
|
71
|
-
bindi.delete :key
|
72
|
-
#=> 1
|
73
|
-
|
74
|
-
bindi.each do |key|
|
75
|
-
puts key
|
76
|
-
end
|
77
|
-
|
78
|
-
bindi.empty?
|
79
|
-
#=> false
|
80
|
-
|
81
|
-
bindi.inspect
|
82
69
|
|
83
70
|
bindi.key? :nope
|
84
71
|
#=> false
|
85
|
-
|
72
|
+
|
86
73
|
bindi.keys
|
87
|
-
#=>
|
74
|
+
#=> [:key]
|
75
|
+
|
76
|
+
bindi.delete :key
|
77
|
+
#=> "value"
|
78
|
+
|
79
|
+
bindi.clear # Flushes entire DB
|
80
|
+
#=> []
|
81
|
+
|
82
|
+
bindi.empty?
|
83
|
+
#=> true
|
88
84
|
```
|
89
85
|
|
90
|
-
### Redis
|
86
|
+
### Redis Info
|
91
87
|
|
92
88
|
```ruby
|
93
|
-
bindi
|
94
|
-
#=>
|
89
|
+
bindi
|
90
|
+
#=> #<Redis client v3.0.4 for redis://127.0.0.1:6379/0>
|
95
91
|
|
96
|
-
bindi.
|
97
|
-
#=> "
|
92
|
+
bindi.info
|
93
|
+
#=> {"redis_version"=>"2.6.14",
|
94
|
+
"redis_git_sha1"=>"00000000",
|
95
|
+
"redis_git_dirty"=>"0",
|
96
|
+
"redis_mode"=>"standalone",
|
97
|
+
...}
|
98
98
|
```
|
99
99
|
|
100
100
|
## Contributing
|
data/Rakefile
CHANGED
data/bindi.gemspec
CHANGED
@@ -4,10 +4,10 @@ require File.expand_path('../lib/bindi/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ['Shannon Skipper']
|
6
6
|
gem.email = ['shannonskipper@gmail.com']
|
7
|
-
gem.description = %q{
|
8
|
-
gem.summary = %q{
|
9
|
-
gem.homepage = 'https://github.com/
|
10
|
-
|
7
|
+
gem.description = %q{Persist your Ruby objects in Redis.}
|
8
|
+
gem.summary = %q{Serialize and store Ruby object in Redis.}
|
9
|
+
gem.homepage = 'https://github.com/havenwood/bindi#readme'
|
10
|
+
gem.license = 'MIT'
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
@@ -15,9 +15,6 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ['lib']
|
16
16
|
gem.version = Bindi::VERSION
|
17
17
|
|
18
|
-
gem.add_development_dependency '
|
19
|
-
gem.add_runtime_dependency '
|
20
|
-
|
21
|
-
gem.signing_key = '/Users/shannonskipper/.gem/private/gem-private_key.pem'
|
22
|
-
gem.cert_chain = ['/Users/shannonskipper/.gem/private/gem-public_cert.pem']
|
18
|
+
gem.add_development_dependency 'redis'
|
19
|
+
gem.add_runtime_dependency 'redis'
|
23
20
|
end
|
data/lib/bindi.rb
CHANGED
@@ -1,58 +1,50 @@
|
|
1
|
-
require '
|
2
|
-
require 'bindi/version'
|
1
|
+
require 'redis'
|
3
2
|
|
4
3
|
class Bindi
|
5
|
-
def initialize serializer
|
4
|
+
def initialize serializer = Marshal
|
6
5
|
@serializer = serializer
|
7
|
-
|
8
|
-
|
9
|
-
def connect
|
10
|
-
Ohm.connect
|
6
|
+
@redis = Redis.new
|
11
7
|
end
|
12
8
|
|
13
9
|
def [] key
|
14
|
-
@serializer.load(
|
10
|
+
@serializer.load(@redis.get key) if @redis.exists key
|
15
11
|
end
|
16
12
|
|
17
13
|
def []= key, value
|
18
|
-
|
14
|
+
@redis.set key, @serializer.dump(value)
|
19
15
|
end
|
20
16
|
|
21
17
|
def clear
|
22
|
-
|
18
|
+
[] if @redis.flushdb == "OK"
|
23
19
|
end
|
24
20
|
|
25
21
|
def delete key
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
Ohm.redis.keys.each do
|
31
|
-
yield
|
22
|
+
if key? key
|
23
|
+
value = @serializer.load(@redis.get key)
|
24
|
+
@redis.del key
|
25
|
+
value
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
35
29
|
def empty?
|
36
|
-
|
30
|
+
@redis.keys.empty?
|
37
31
|
end
|
38
32
|
|
39
33
|
def info
|
40
|
-
|
34
|
+
@redis.info
|
41
35
|
end
|
42
|
-
|
36
|
+
|
43
37
|
def inspect
|
44
|
-
|
38
|
+
@redis.inspect
|
45
39
|
end
|
46
|
-
|
47
40
|
alias to_s inspect
|
48
41
|
|
49
42
|
def key? key
|
50
|
-
|
43
|
+
@redis.exists key
|
51
44
|
end
|
52
|
-
|
53
45
|
alias has_key key?
|
54
46
|
|
55
47
|
def keys
|
56
|
-
|
48
|
+
@redis.keys.map &:to_sym
|
57
49
|
end
|
58
|
-
end
|
50
|
+
end
|
data/lib/bindi/version.rb
CHANGED
data/test/bindi_test.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
describe Bindi do
|
4
|
+
before do
|
5
|
+
@bindi = Bindi.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "getting a list of keys with @bindi.keys" do
|
9
|
+
it "returns an Array" do
|
10
|
+
assert_kind_of Array, @bindi.keys
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "getting true or false if key exists with @bindi.key?" do
|
15
|
+
before do
|
16
|
+
@bindi[:cake] = 'yummy'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns true if key exists" do
|
20
|
+
assert @bindi.key?(:cake)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns false if the key doesn't exist" do
|
24
|
+
refute @bindi.key?(:this_does_not_exist)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "getting a particular key's value with @bindi.[]" do
|
29
|
+
before do
|
30
|
+
@bindi[:cake] = 'yummy'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns a value if the key exists" do
|
34
|
+
assert_equal 'yummy', @bindi[:cake]
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns nil if the key doesn't exist" do
|
38
|
+
assert_nil @bindi[:this_does_not_exist]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "setting a particular key's value with @bindi.[]=" do
|
43
|
+
before do
|
44
|
+
@bindi[:trees] = ['oak', 'pine', 'cedar']
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should add the key to the persistent store" do
|
48
|
+
assert @bindi.key?(:trees)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be set to the expected value" do
|
52
|
+
assert_equal ["oak", "pine", "cedar"], @bindi[:trees]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "deleting a root key with @bindi.delete" do
|
57
|
+
before do
|
58
|
+
@bindi[:cake] = 'yummy'
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns the value of the deleted key" do
|
62
|
+
assert_equal "yummy", @bindi.delete(:cake)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/test/helper.rb
ADDED
metadata
CHANGED
@@ -1,79 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bindi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Shannon Skipper
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
-
|
13
|
-
LS0tLS1CRUdJTiBDRVJUSUZ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QmhEQ0JnVEFKQmdOVkhS
|
29
|
-
TUVBakFBTUFzR0ExVWREd1FFQXdJRQpzREFkQmdOVkhRNEVGZ1FVK2NvaEhy
|
30
|
-
dXI3S3FScFYvakZzYXRFRmY5cjJzd0l3WURWUjBSQkJ3d0dvRVljMmhoCmJt
|
31
|
-
NXZibk5yYVhCd1pYSkFaMjFoYVd3dVkyOXRNQ01HQTFVZEVnUWNNQnFCR0hO
|
32
|
-
b1lXNXViMjV6YTJsd2NHVnkKUUdkdFlXbHNMbU52YlRBTkJna3Foa2lHOXcw
|
33
|
-
QkFRVUZBQU9DQVFFQUNHODRxc0d3NGYrRGorZHlka1laSzVvMgp3VUh1YjNV
|
34
|
-
U1YwRlo1Rnd1cVhaclcxQitjY3JqNzZWVzdsalpkNnJyYTkxMjBmSC9KOUN0
|
35
|
-
R0ZYSExOYmJGYnFyCk03Tkd4N0p4eVBVbFdTQ0VDYUVIeDF3UkFzc3Y2aU9p
|
36
|
-
TzlpZWozU1pGS2VrQWZDVDNWUG1Kb2s1OXR2dGtHL1MKWGRsYkZGekQwclMw
|
37
|
-
MEdaZEEyaHBzSmJ2ck1IcmNlclJsSTNXRnR1dk9RT2VGN01ndDNmMnNJQjVl
|
38
|
-
RkZQR2huZgp6MjJXUXliTStmbGpBek1FcE1qYkdUaFdtdy9nS3FIV09NT1Ey
|
39
|
-
WjlTOWpjR2pFZUVzK3EzTFJhdlJDelJCQnptCnVZSWIwbWtUcGg0M3lxOVp4
|
40
|
-
T3h3VDNmYld0RkorUDAwNEl2ZnFwUmpqelgvRXFTRTVBUi94RjFwYTUyRjd3
|
41
|
-
PT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
|
42
|
-
date: 2013-02-08 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-06 00:00:00.000000000 Z
|
43
12
|
dependencies:
|
44
13
|
- !ruby/object:Gem::Dependency
|
45
|
-
name:
|
14
|
+
name: redis
|
46
15
|
requirement: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
16
|
requirements:
|
49
|
-
- -
|
17
|
+
- - '>='
|
50
18
|
- !ruby/object:Gem::Version
|
51
19
|
version: '0'
|
52
20
|
type: :development
|
53
21
|
prerelease: false
|
54
22
|
version_requirements: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
23
|
requirements:
|
57
|
-
- -
|
24
|
+
- - '>='
|
58
25
|
- !ruby/object:Gem::Version
|
59
26
|
version: '0'
|
60
27
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
28
|
+
name: redis
|
62
29
|
requirement: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
30
|
requirements:
|
65
|
-
- -
|
31
|
+
- - '>='
|
66
32
|
- !ruby/object:Gem::Version
|
67
33
|
version: '0'
|
68
34
|
type: :runtime
|
69
35
|
prerelease: false
|
70
36
|
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
37
|
requirements:
|
73
|
-
- -
|
38
|
+
- - '>='
|
74
39
|
- !ruby/object:Gem::Version
|
75
40
|
version: '0'
|
76
|
-
description:
|
41
|
+
description: Persist your Ruby objects in Redis.
|
77
42
|
email:
|
78
43
|
- shannonskipper@gmail.com
|
79
44
|
executables: []
|
@@ -88,29 +53,33 @@ files:
|
|
88
53
|
- bindi.gemspec
|
89
54
|
- lib/bindi.rb
|
90
55
|
- lib/bindi/version.rb
|
91
|
-
|
92
|
-
|
56
|
+
- test/bindi_test.rb
|
57
|
+
- test/helper.rb
|
58
|
+
homepage: https://github.com/havenwood/bindi#readme
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
93
62
|
post_install_message:
|
94
63
|
rdoc_options: []
|
95
64
|
require_paths:
|
96
65
|
- lib
|
97
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
67
|
requirements:
|
100
|
-
- -
|
68
|
+
- - '>='
|
101
69
|
- !ruby/object:Gem::Version
|
102
70
|
version: '0'
|
103
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
72
|
requirements:
|
106
|
-
- -
|
73
|
+
- - '>='
|
107
74
|
- !ruby/object:Gem::Version
|
108
75
|
version: '0'
|
109
76
|
requirements: []
|
110
77
|
rubyforge_project:
|
111
|
-
rubygems_version:
|
78
|
+
rubygems_version: 2.0.3
|
112
79
|
signing_key:
|
113
|
-
specification_version:
|
114
|
-
summary:
|
115
|
-
test_files:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Serialize and store Ruby object in Redis.
|
82
|
+
test_files:
|
83
|
+
- test/bindi_test.rb
|
84
|
+
- test/helper.rb
|
116
85
|
has_rdoc:
|
data.tar.gz.sig
DELETED
metadata.gz.sig
DELETED
Binary file
|