risky 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/risky/indexes.rb +4 -3
- data/lib/risky/version.rb +1 -1
- data/lib/risky.rb +11 -18
- metadata +4 -4
data/lib/risky/indexes.rb
CHANGED
@@ -25,11 +25,11 @@ module Risky::Indexes
|
|
25
25
|
from_riak_object(
|
26
26
|
Riak::RObject.new(
|
27
27
|
riak[#{opts[:bucket].inspect}],
|
28
|
-
value
|
28
|
+
value.to_s
|
29
29
|
).walk(:bucket => #{@bucket_name.inspect}).first.first
|
30
30
|
)
|
31
31
|
rescue Riak::FailedRequest => e
|
32
|
-
raise e unless e.
|
32
|
+
raise e unless e.not_found?
|
33
33
|
nil
|
34
34
|
end
|
35
35
|
end
|
@@ -59,6 +59,7 @@ module Risky::Indexes
|
|
59
59
|
current = opts[:proc][self] rescue self[attr.to_s]
|
60
60
|
old = @old_indexed_values[attr]
|
61
61
|
@old_indexed_values[attr] = current
|
62
|
+
|
62
63
|
unless old == current
|
63
64
|
# Remove old index
|
64
65
|
if old
|
@@ -67,7 +68,7 @@ module Risky::Indexes
|
|
67
68
|
|
68
69
|
# Create new index
|
69
70
|
unless current.nil?
|
70
|
-
index = Riak::RObject.new(self.class.riak[opts[:bucket]], current)
|
71
|
+
index = Riak::RObject.new(self.class.riak[opts[:bucket]], current.to_s)
|
71
72
|
index.content_type = 'text/plain'
|
72
73
|
index.data = ''
|
73
74
|
index.links = Set.new([@riak_object.to_link('value')])
|
data/lib/risky/version.rb
CHANGED
data/lib/risky.rb
CHANGED
@@ -26,7 +26,7 @@ class Risky
|
|
26
26
|
begin
|
27
27
|
new(key).reload(opts)
|
28
28
|
rescue Riak::FailedRequest => e
|
29
|
-
raise unless e.
|
29
|
+
raise e unless e.not_found?
|
30
30
|
nil
|
31
31
|
end
|
32
32
|
end
|
@@ -84,22 +84,13 @@ class Risky
|
|
84
84
|
casted
|
85
85
|
end
|
86
86
|
|
87
|
-
# Counts the number of
|
88
|
-
def self.count
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
function(counts, arg) {
|
95
|
-
return [
|
96
|
-
counts.reduce(
|
97
|
-
function(acc, value) {
|
98
|
-
return acc + value
|
99
|
-
}, 0)
|
100
|
-
];
|
101
|
-
}
|
102
|
-
", :keep => true).run.first
|
87
|
+
# Counts the number of values in the bucket via key streaming
|
88
|
+
def self.count(opts = {:reload => true})
|
89
|
+
count = 0
|
90
|
+
bucket.keys(opts) do |keys|
|
91
|
+
count += keys.length
|
92
|
+
end
|
93
|
+
count
|
103
94
|
end
|
104
95
|
|
105
96
|
# Returns true when record deleted.
|
@@ -113,7 +104,9 @@ class Risky
|
|
113
104
|
def self.each
|
114
105
|
bucket.keys(:reload => true) do |keys|
|
115
106
|
keys.each do |key|
|
116
|
-
|
107
|
+
if x = self[key]
|
108
|
+
yield x
|
109
|
+
end
|
117
110
|
end
|
118
111
|
end
|
119
112
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: risky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kyle Kingsbury
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-25 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|