bindi 0.0.5 → 0.0.6

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