bindi 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3919585e02b21afbf784dad9ddcc951a3e507576
4
- data.tar.gz: 9d8cf3d10124d0c637cc212d52813f7c31ac1142
3
+ metadata.gz: 95a53ade2cb5e9748468fe43c4b23023202b6012
4
+ data.tar.gz: 1a2d77ff97563e5880fec8c4b0f0aafe191150b5
5
5
  SHA512:
6
- metadata.gz: 21f5e5a41a62d5f1f42cb09aeb98b628fd761267b911b91314707c31710c3db23626b72f47064023c7ed30818e41f899968e114e1a44e6dbb0492afbd9bef27a
7
- data.tar.gz: 40ac89024e1f56582bdaf9f27f278654b544889aa881ecbf0fc5857051e24183fe2c1cb834cf5e73ca80187bb1b39663b515c9e2df4db131d824974e5cf66a18
6
+ metadata.gz: 0db0612def5b52f23883933ece7c1875fd4af6f1198f199bfb3004ac16e94fa9013b34a5abdbb70971f8e2a5557d338940c611d5a856b73061c22e50fe8b887f
7
+ data.tar.gz: f34831006245cb6b17348a7e6418f22a9871e1e45b02ee31a80e5a915a2f2a5b4615d646fa3e38a1a369a2883f629d648279dc29e7ae49d2bffc3e037e729b4a
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Havenwood
1
+ Copyright (c) 2014 Shannon Skipper
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,104 +1,102 @@
1
1
  # Bindi
2
+ Persist your Ruby objects to [Redis](http://redis.io/)!
2
3
 
3
- [Bindi](https://github.com/havenwood/bindi#readme) makes it very, very simple to store native Ruby object in Redis!
4
+ Bindi provides a simple Hash-like syntax for serializing and storing Ruby objects using the [redis](https://github.com/redis/redis-rb#readme) gem. Serialize with Marshal, YAML, JSON or your serializer of choice (as long as it supports #dump and #load methods).
4
5
 
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).
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- gem 'bindi'
12
-
13
- Or install it yourself:
14
-
15
- $ gem install bindi
16
-
17
- Then install Redis:
18
-
19
- $ brew install redis
20
-
21
- And start Redis:
22
-
23
- $ redis-server
24
-
25
6
  ## Usage
26
-
27
- ### The Basics
28
-
29
7
  ```ruby
30
8
  require 'bindi'
31
- require 'yaml'
32
9
 
33
- bindi = Bindi.new YAML # Choose between Marshal, YAML, JSON, etcetera for serializing.
10
+ bindi = Bindi.new # Marshal is the default serializer.
34
11
  #=> #<Redis client v3.0.2 for redis://127.0.0.1:6379/0>
35
12
 
36
- bindi[:state_gemstones] = { alabama: 'Star Blue Quartz',
37
- alaska: 'Nephrite Jade',
38
- arizona: 'Turquoise',
39
- arkansas: 'Diamond' }
40
-
41
- #=> {:alabama=>"Star Blue Quartz", ...
42
-
13
+ bindi[:state_gemstones] = {alabama: 'Star Blue Quartz',
14
+ alaska: 'Nephrite Jade'}
43
15
  exit
44
16
  ```
45
17
 
46
- Your Ruby Object is now stored in Redis.
47
-
18
+ Your Ruby Object is now stored in Redis:
48
19
  ```ruby
49
20
  require 'bindi'
50
21
 
51
- bindi = Bindi.new YAML
22
+ bindi = Bindi.new
52
23
  #=> #<Redis client v3.0.2 for redis://127.0.0.1:6379/0>
53
24
 
54
- bindi.keys
55
- #=> "state_gemstones"
56
-
57
25
  bindi[:state_gemstones]
58
- #=> #=> {:alabama=>"Star Blue Quartz", ...
26
+ #=> {:alabama=>"Star Blue Quartz", :alaska=>"Nephrite Jade"}
59
27
  ```
60
28
 
61
- ### Ruby Hash Methods
62
-
29
+ ### Additional Hash-like methods:
63
30
  ```ruby
64
- bindi[:key] = 'value'
65
- #=> "value"
66
-
67
- bindi[:key]
68
- #=> "value"
31
+ bindi.keys
32
+ #=> [:state_gemstones]
69
33
 
70
34
  bindi.key? :nope
71
35
  #=> false
72
36
 
73
- bindi.keys
74
- #=> [:key]
75
-
76
- bindi.delete :key
77
- #=> "value"
78
-
79
- bindi.clear # Flushes entire DB
80
- #=> []
37
+ bindi.delete :state_gemstones
38
+ #=> {:alabama=>"Star Blue Quartz", :alaska=>"Nephrite Jade"}
81
39
 
82
40
  bindi.empty?
83
41
  #=> true
84
42
  ```
85
43
 
86
- ### Redis Info
44
+ ### Alternative Serializers
45
+ The default serializer is Marshal but you an alternative serializer can be specified when creating a new Bindi instance:
46
+ ```ruby
47
+ require 'bindi'
48
+ require 'json'
49
+
50
+ bindi = Bindi.new JSON
51
+ #=> #<Redis client v3.0.2 for redis://127.0.0.1:6379/0>
52
+ ```
87
53
 
54
+ A serializer without #dump and #load methods, like [Message Pack](http://msgpack.org), can be used by implementing those methods:
88
55
  ```ruby
89
- bindi
90
- #=> #<Redis client v3.0.4 for redis://127.0.0.1:6379/0>
91
-
92
- bindi.info
93
- #=> {"redis_version"=>"2.6.14",
94
- "redis_git_sha1"=>"00000000",
95
- "redis_git_dirty"=>"0",
96
- "redis_mode"=>"standalone",
97
- ...}
56
+ require 'bindi'
57
+ require 'msgpack'
58
+
59
+ module MessagePack
60
+ def self.dump(data)
61
+ pack(data)
62
+ end
63
+
64
+ def self.load(data)
65
+ unpack(data)
66
+ end
67
+ end
68
+
69
+ bindi = Bindi.new MessagePack
70
+ #=> #<Redis client v3.0.4 for redis://127.0.0.1:6379/0>
98
71
  ```
72
+ ## Installation
73
+ #### Install Bindi
99
74
 
100
- ## Contributing
75
+ $ gem install bindi
76
+
77
+ #### Install Redis
78
+ Brew package:
79
+
80
+ `brew install redis`
101
81
 
82
+ Apt-get package:
83
+
84
+ `sudo apt-get install redis-server`
85
+
86
+ Or build from source:
87
+ ```bash
88
+ wget http://download.redis.io/redis-stable.tar.gz
89
+ tar xvzf redis-stable.tar.gz
90
+ cd redis-stable
91
+ make
92
+ ```
93
+
94
+ Start Redis if it isn't running:
95
+
96
+ $ redis-server
97
+
98
+ ## Contributing
102
99
  1. Fork it
103
100
  2. Commit your changes
104
101
  3. Pull request
102
+ 4. :cake:
@@ -14,7 +14,6 @@ Gem::Specification.new do |gem|
14
14
  gem.name = 'bindi'
15
15
  gem.require_paths = ['lib']
16
16
  gem.version = Bindi::VERSION
17
-
18
- gem.add_development_dependency 'redis'
17
+
19
18
  gem.add_runtime_dependency 'redis'
20
19
  end
@@ -45,6 +45,6 @@ class Bindi
45
45
  alias has_key key?
46
46
 
47
47
  def keys
48
- @redis.keys.map &:to_sym
48
+ @redis.keys
49
49
  end
50
50
  end
@@ -1,3 +1,3 @@
1
1
  class Bindi
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,41 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shannon Skipper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-06 00:00:00.000000000 Z
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: redis
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
19
  version: '0'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - '>='
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  description: Persist your Ruby objects in Redis.
@@ -45,7 +31,7 @@ executables: []
45
31
  extensions: []
46
32
  extra_rdoc_files: []
47
33
  files:
48
- - .gitignore
34
+ - ".gitignore"
49
35
  - Gemfile
50
36
  - LICENSE
51
37
  - README.md
@@ -65,17 +51,17 @@ require_paths:
65
51
  - lib
66
52
  required_ruby_version: !ruby/object:Gem::Requirement
67
53
  requirements:
68
- - - '>='
54
+ - - ">="
69
55
  - !ruby/object:Gem::Version
70
56
  version: '0'
71
57
  required_rubygems_version: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - '>='
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
61
  version: '0'
76
62
  requirements: []
77
63
  rubyforge_project:
78
- rubygems_version: 2.0.3
64
+ rubygems_version: 2.4.1
79
65
  signing_key:
80
66
  specification_version: 4
81
67
  summary: Serialize and store Ruby object in Redis.