bindi 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -17
- data/lib/bindi.rb +40 -38
- data/lib/bindi/version.rb +2 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -27,11 +27,10 @@ And start Redis:
|
|
27
27
|
```ruby
|
28
28
|
require 'bindi'
|
29
29
|
#=> true
|
30
|
-
|
31
|
-
Bindi.connect
|
32
|
-
#=> nil
|
33
30
|
|
34
|
-
|
31
|
+
bindi = Bindi.new YAML # Works with Marshal, YAML, JSON, etc.
|
32
|
+
|
33
|
+
bindi[:state_gemstones] = { alabama: 'Star Blue Quartz',
|
35
34
|
alaska: 'Nephrite Jade',
|
36
35
|
arizona: 'Turquoise',
|
37
36
|
arkansas: 'Diamond' }
|
@@ -47,50 +46,50 @@ Your Ruby Object is now stored in Redis.
|
|
47
46
|
require 'bindi'
|
48
47
|
#=> true
|
49
48
|
|
50
|
-
|
49
|
+
bindi.keys
|
51
50
|
#=> "state_gemstones"
|
52
51
|
|
53
|
-
|
52
|
+
bindi[:state_gemstones]
|
54
53
|
#=> #=> {:alabama=>"Star Blue Quartz", ...
|
55
54
|
```
|
56
55
|
|
57
56
|
### Ruby Hash Methods
|
58
57
|
|
59
58
|
```ruby
|
60
|
-
|
59
|
+
bindi[:key] = 'value'
|
61
60
|
#=> "value"
|
62
61
|
|
63
|
-
|
62
|
+
bindi[:key]
|
64
63
|
#=> "value"
|
65
64
|
|
66
|
-
|
65
|
+
bindi.clear # Flushes entire DB
|
67
66
|
|
68
|
-
|
67
|
+
bindi.delete :key
|
69
68
|
#=> 1
|
70
69
|
|
71
|
-
|
70
|
+
bindi.each do |key|
|
72
71
|
puts key
|
73
72
|
end
|
74
73
|
|
75
|
-
|
74
|
+
bindi.empty?
|
76
75
|
#=> false
|
77
76
|
|
78
|
-
|
77
|
+
bindi.inspect
|
79
78
|
|
80
|
-
|
79
|
+
bindi.key? :nope
|
81
80
|
#=> false
|
82
81
|
|
83
|
-
|
82
|
+
bindi.keys
|
84
83
|
#=> "key"
|
85
84
|
```
|
86
85
|
|
87
86
|
### Redis Helper Methods
|
88
87
|
|
89
88
|
```ruby
|
90
|
-
|
89
|
+
bindi.info
|
91
90
|
#=> {"redis_version"=>"2.4.15", ...
|
92
91
|
|
93
|
-
|
92
|
+
bindi.inspect_redis
|
94
93
|
#=> "#<Redis client v2.2.2 connected to redis://127.0.0.1:6379 ..."
|
95
94
|
```
|
96
95
|
|
data/lib/bindi.rb
CHANGED
@@ -1,56 +1,58 @@
|
|
1
1
|
require 'ohm'
|
2
2
|
require 'bindi/version'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class Bindi
|
5
|
+
def initialize serializer
|
6
|
+
@serializer = serializer
|
7
|
+
end
|
8
|
+
|
9
|
+
def connect
|
10
|
+
Ohm.connect
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
def [] key
|
14
|
+
@serializer.load(Ohm.redis.get key)
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
def []= key, value
|
18
|
+
Ohm.redis.set key, @serializer.dump(value)
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def clear
|
22
|
+
Ohm.redis.flushdb
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
def delete key
|
26
|
+
Ohm.redis.del key
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
29
|
+
def each
|
30
|
+
Ohm.redis.keys.each do
|
31
|
+
yield
|
30
32
|
end
|
33
|
+
end
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
def empty?
|
36
|
+
Ohm.redis.keys.empty?
|
37
|
+
end
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
def info
|
40
|
+
Ohm.redis.info
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
def inspect
|
44
|
+
Ohm.redis.inspect
|
45
|
+
end
|
43
46
|
|
44
|
-
|
47
|
+
alias to_s inspect
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
def key? key
|
50
|
+
Ohm.redis.exists key
|
51
|
+
end
|
49
52
|
|
50
|
-
|
53
|
+
alias has_key key?
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
+
def keys
|
56
|
+
Ohm.redis.keys.map &:to_sym
|
55
57
|
end
|
56
58
|
end
|
data/lib/bindi/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = '0.0.
|
1
|
+
class Bindi
|
2
|
+
VERSION = '0.0.6'
|
3
3
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bindi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ohm
|