blombo 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/Manifest +1 -1
- data/README +1 -2
- data/blombo.gemspec +3 -3
- data/lib/blombo.rb +26 -1
- data/test/test_all.rb +8 -0
- metadata +5 -5
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
data/README
CHANGED
data/blombo.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "blombo"
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Andrew Snow"]
|
9
|
-
s.date = "2012-02-
|
9
|
+
s.date = "2012-02-17"
|
10
10
|
s.description = "Blombo: Treat redis-server like a deep ruby hash"
|
11
11
|
s.email = "andrew@modulus.org"
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "README", "lib/blombo.rb"]
|
13
|
-
s.files = ["CHANGELOG", "README", "Rakefile", "lib/blombo.rb", "test/test_all.rb", "test/test_helper.rb", "
|
13
|
+
s.files = ["CHANGELOG", "Manifest", "README", "Rakefile", "lib/blombo.rb", "test/test_all.rb", "test/test_helper.rb", "blombo.gemspec"]
|
14
14
|
s.homepage = "http://github.com/andys/blombo"
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Blombo", "--main", "README"]
|
16
16
|
s.require_paths = ["lib"]
|
data/lib/blombo.rb
CHANGED
@@ -26,6 +26,17 @@ class Blombo
|
|
26
26
|
str
|
27
27
|
end
|
28
28
|
end
|
29
|
+
def [](name)
|
30
|
+
new(name)
|
31
|
+
end
|
32
|
+
def method_missing(meth, *params, &bl)
|
33
|
+
if params.empty? && meth =~ /^[a-z_][a-z0-9_]*$/i
|
34
|
+
new meth
|
35
|
+
else
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
29
40
|
end
|
30
41
|
|
31
42
|
def redis
|
@@ -33,9 +44,19 @@ class Blombo
|
|
33
44
|
end
|
34
45
|
|
35
46
|
def initialize(name, blombo_parent=nil)
|
36
|
-
@name = name
|
47
|
+
@name = name.to_s
|
37
48
|
@blombo_parent = blombo_parent
|
38
49
|
end
|
50
|
+
|
51
|
+
def with_timeout(secs)
|
52
|
+
begin
|
53
|
+
Timeout.timeout(secs) do
|
54
|
+
yield(self)
|
55
|
+
end
|
56
|
+
rescue Timeout::Error
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
39
60
|
|
40
61
|
def <=>(other)
|
41
62
|
@name <=> other.blombo_name
|
@@ -91,6 +112,10 @@ class Blombo
|
|
91
112
|
self.class.redis.hvals(blombo_key).map {|v| self.class.from_redis_val(v) }
|
92
113
|
end
|
93
114
|
|
115
|
+
def clear
|
116
|
+
redis.del(blombo_key)
|
117
|
+
end
|
118
|
+
|
94
119
|
def type
|
95
120
|
@type ||= (t = Blombo.redis.type(blombo_key)) && t != 'none' && t || nil
|
96
121
|
end
|
data/test/test_all.rb
CHANGED
@@ -98,4 +98,12 @@ class TestBlombo < Test::Unit::TestCase
|
|
98
98
|
assert_equal 'list', @blombo.listy.type
|
99
99
|
end
|
100
100
|
|
101
|
+
def test_new_by_square_brackets
|
102
|
+
assert_equal Blombo.new(:asdf), Blombo[:asdf]
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_new_by_method
|
106
|
+
assert_equal Blombo.asdf, Blombo.asdf
|
107
|
+
end
|
108
|
+
|
101
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blombo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &81973240 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *81973240
|
25
25
|
description: ! 'Blombo: Treat redis-server like a deep ruby hash'
|
26
26
|
email: andrew@modulus.org
|
27
27
|
executables: []
|
@@ -32,12 +32,12 @@ extra_rdoc_files:
|
|
32
32
|
- lib/blombo.rb
|
33
33
|
files:
|
34
34
|
- CHANGELOG
|
35
|
+
- Manifest
|
35
36
|
- README
|
36
37
|
- Rakefile
|
37
38
|
- lib/blombo.rb
|
38
39
|
- test/test_all.rb
|
39
40
|
- test/test_helper.rb
|
40
|
-
- Manifest
|
41
41
|
- blombo.gemspec
|
42
42
|
homepage: http://github.com/andys/blombo
|
43
43
|
licenses: []
|