ozy 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -1
- data/lib/ozy.rb +12 -1
- data/spec/ozy_spec.rb +18 -0
- metadata +6 -8
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
Ozymandias
|
2
2
|
=
|
3
3
|
|
4
|
-
**Ozy** is a simple Hash subclass that persists itself to Redis, if you'll let it. This provides a clean interface to storing data in Redis without calling
|
4
|
+
**Ozy** is a simple Hash subclass that persists itself to Redis, if you'll let it. This provides a clean interface to storing data in Redis without calling
|
5
|
+
all those crazy Redis commands. Of course, Ozy also supports those commands, so go nuts.
|
5
6
|
|
6
7
|
Install
|
7
8
|
==
|
data/lib/ozy.rb
CHANGED
@@ -5,6 +5,10 @@ class Ozy < ::Hash
|
|
5
5
|
class KeyError < ::StandardError; end
|
6
6
|
|
7
7
|
class << self
|
8
|
+
def connect(*args)
|
9
|
+
self.connection = Redis.new(*args)
|
10
|
+
end
|
11
|
+
|
8
12
|
def connection
|
9
13
|
@connection ||= ::Redis.new
|
10
14
|
end
|
@@ -98,7 +102,14 @@ class Ozy < ::Hash
|
|
98
102
|
if @options[:key] && self.class.connection.respond_to?(method)
|
99
103
|
self.class.connection.send(method, *[@options[:key], args].flatten)
|
100
104
|
else
|
101
|
-
|
105
|
+
method = method.to_s
|
106
|
+
if method.chomp!('=')
|
107
|
+
self[method] = args.first
|
108
|
+
elsif args.empty?
|
109
|
+
self[method.to_s] || self[method.to_sym]
|
110
|
+
else
|
111
|
+
super
|
112
|
+
end
|
102
113
|
end
|
103
114
|
end
|
104
115
|
|
data/spec/ozy_spec.rb
CHANGED
@@ -99,6 +99,24 @@ describe Ozy do
|
|
99
99
|
}.should raise_error
|
100
100
|
end
|
101
101
|
|
102
|
+
it "should catch accessors for existing keys" do
|
103
|
+
ozy = Ozy.create("ozy", :foo => :bar)
|
104
|
+
ozy.foo.should == :bar
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should translate strings and symbols for existing keys" do
|
108
|
+
ozy = Ozy.create("ozy", 'foo' => :bar)
|
109
|
+
ozy.foo.should == :bar
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should allow users to use arbitrary writers that didn't previously exist" do
|
113
|
+
ozy = Ozy.create("ozy", :foo => :bar)
|
114
|
+
ozy.baz.should be_nil
|
115
|
+
ozy.baz = "BOOM!"
|
116
|
+
ozy.baz.should == "BOOM!"
|
117
|
+
end
|
118
|
+
|
119
|
+
|
102
120
|
it "should preserve symbols and other fun stuff" do
|
103
121
|
ozy = Ozy.create("ozy", :foo => {:bar => [:baz]})
|
104
122
|
Ozy.get("ozy").should == {:foo => {:bar => [:baz]}}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ozy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Flip Sasser
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-08-23 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rcov
|
@@ -80,7 +79,6 @@ files:
|
|
80
79
|
- README.md
|
81
80
|
- spec/ozy_spec.rb
|
82
81
|
- spec/spec_helper.rb
|
83
|
-
has_rdoc: true
|
84
82
|
homepage: http://github.com/flipsasser/ozymandias
|
85
83
|
licenses: []
|
86
84
|
|
@@ -110,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
108
|
requirements: []
|
111
109
|
|
112
110
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.8.8
|
114
112
|
signing_key:
|
115
113
|
specification_version: 3
|
116
114
|
summary: A Redis-backed Hash class that can be used like a very (very, very) simple ORM
|