zermelo 1.2.0 → 1.2.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +3 -12
- data/lib/zermelo/associations/multiple.rb +7 -6
- data/lib/zermelo/backends/redis.rb +15 -7
- data/lib/zermelo/filter.rb +7 -0
- data/lib/zermelo/filters/steps/empty_step.rb +45 -0
- data/lib/zermelo/filters/steps/set_step.rb +3 -1
- data/lib/zermelo/records/class_methods.rb +7 -6
- data/lib/zermelo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8442ff692747d2d56fc983ec85bc6665656748a
|
4
|
+
data.tar.gz: a2ef423d8095fb2d9e7f12f5cf84ca2dadc9c528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5364e3f2a9ea70de9f7ec5142909736952d4ab3d3167823877ed40c49759ddbffa002756cbe730d60357776768707f92f0557120b1fe3877439d30a56833ef45
|
7
|
+
data.tar.gz: d15a22b19592f45711c46b684d0fe0d943c971c87a21843a2d291692c5af51756cb8542545e55e7a88042429c45c5021158e35034bf9b98916ecf3dca006072c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Zermelo Changelog
|
2
2
|
|
3
|
+
# 1.2.1 - 2015-08-07
|
4
|
+
|
5
|
+
* 'empty' filter method (637d0c9c)
|
6
|
+
* bugfix; temp redis set not deleted when matching against multiple values for a field (9df5241d)
|
7
|
+
* use Redis .scan instead of .keys for regex index lookup if available (de75802c)
|
8
|
+
|
3
9
|
# 1.2.0 - 2015-06-24
|
4
10
|
|
5
11
|
* spec cleanup, apply to multiple backends if not backend-specific
|
data/Gemfile
CHANGED
@@ -1,20 +1,11 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
gemspec :name => 'zermelo-ruby1.8'
|
5
|
-
else
|
6
|
-
gemspec :name => 'zermelo'
|
7
|
-
end
|
3
|
+
gemspec :name => 'zermelo'
|
8
4
|
|
9
5
|
group :test do
|
10
|
-
gem 'influxdb'
|
6
|
+
gem 'influxdb', '0.1.9'
|
11
7
|
gem 'redis'
|
12
8
|
gem 'rspec', '>= 3.0.0'
|
13
9
|
gem 'simplecov', :require => false
|
14
|
-
|
15
|
-
if RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '8'
|
16
|
-
gem 'timecop', '0.6.1'
|
17
|
-
else
|
18
|
-
gem 'timecop'
|
19
|
-
end
|
10
|
+
gem 'timecop'
|
20
11
|
end
|
@@ -6,12 +6,13 @@ module Zermelo
|
|
6
6
|
|
7
7
|
extend Forwardable
|
8
8
|
|
9
|
-
def_delegators :filter,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
def_delegators :filter,
|
10
|
+
:intersect, :union, :diff, :sort, :offset, :page, :empty,
|
11
|
+
:find_by_id, :find_by_ids, :find_by_id!, :find_by_ids!,
|
12
|
+
:all, :each, :collect, :map,
|
13
|
+
:select, :find_all, :reject, :destroy_all,
|
14
|
+
:ids, :count, :empty?, :exists?,
|
15
|
+
:associated_ids_for
|
15
16
|
|
16
17
|
def initialize(type, parent_klass, parent_id, name)
|
17
18
|
@type = type
|
@@ -15,10 +15,6 @@ module Zermelo
|
|
15
15
|
# :timestamp
|
16
16
|
# end
|
17
17
|
|
18
|
-
def generate_lock
|
19
|
-
Zermelo::Locks::RedisLock.new
|
20
|
-
end
|
21
|
-
|
22
18
|
def filter(ids_key, associated_class, callback_target_class = nil,
|
23
19
|
callback_target_id = nil, callbacks = nil, sort_order = nil)
|
24
20
|
|
@@ -194,10 +190,22 @@ module Zermelo
|
|
194
190
|
:object => :index
|
195
191
|
))
|
196
192
|
|
197
|
-
|
193
|
+
key_pat = "#{key_root}:?*"
|
194
|
+
|
195
|
+
matching_sets = if (Zermelo.redis_version.split('.') <=> ['2', '8', '0']) == 1
|
196
|
+
# lock will be subsumed by outer lock if present -- required to
|
197
|
+
# know that scan is getting consistent results
|
198
|
+
associated_class.lock do
|
199
|
+
Zermelo.redis.scan_each(:match => key_pat).to_a
|
200
|
+
end
|
201
|
+
else
|
202
|
+
# SCAN is only supported in Redis >= 2.8.0
|
203
|
+
Zermelo.redis.keys(key_pat)
|
204
|
+
end
|
205
|
+
|
206
|
+
matching_sets.select! do |k|
|
198
207
|
k =~ /^#{key_root}:(.+)$/
|
199
|
-
|
200
|
-
memo
|
208
|
+
value === $1
|
201
209
|
end
|
202
210
|
|
203
211
|
Zermelo.redis.sunionstore(idx_result, matching_sets) unless matching_sets.empty?
|
data/lib/zermelo/filter.rb
CHANGED
@@ -4,6 +4,7 @@ require 'zermelo/records/errors'
|
|
4
4
|
|
5
5
|
require 'zermelo/filters/steps/list_step'
|
6
6
|
require 'zermelo/filters/steps/set_step'
|
7
|
+
require 'zermelo/filters/steps/empty_step'
|
7
8
|
require 'zermelo/filters/steps/sort_step'
|
8
9
|
|
9
10
|
module Zermelo
|
@@ -76,6 +77,12 @@ module Zermelo
|
|
76
77
|
:limit => per_page}, {}))
|
77
78
|
end
|
78
79
|
|
80
|
+
def empty
|
81
|
+
self.class.new(@backend, @initial_key, @associated_class,
|
82
|
+
@callback_target_class, @callback_target_id, @callbacks, @sort_order,
|
83
|
+
self, ::Zermelo::Filters::Steps::EmptyStep.new({}, {}))
|
84
|
+
end
|
85
|
+
|
79
86
|
# step users
|
80
87
|
def exists?(e_id)
|
81
88
|
lock(false) { _exists?(e_id) }
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'zermelo/filters/steps/base_step'
|
2
|
+
|
3
|
+
# NB: temp keys for now are bare redis keys, should be full Key objects
|
4
|
+
module Zermelo
|
5
|
+
module Filters
|
6
|
+
class Steps
|
7
|
+
class EmptyStep < Zermelo::Filters::Steps::BaseStep
|
8
|
+
def self.accepted_types
|
9
|
+
[:set, :sorted_set, :list]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.returns_type
|
13
|
+
nil # same as the source type
|
14
|
+
end
|
15
|
+
|
16
|
+
def resolve(backend, associated_class, opts = {})
|
17
|
+
case backend
|
18
|
+
when Zermelo::Backends::Redis
|
19
|
+
source = opts[:source]
|
20
|
+
temp_keys = opts[:temp_keys]
|
21
|
+
shortcut = opts[:shortcut]
|
22
|
+
|
23
|
+
dest_set = associated_class.send(:temp_key, source.type)
|
24
|
+
r_dest_set = backend.key_to_redis_key(dest_set)
|
25
|
+
temp_keys << dest_set
|
26
|
+
|
27
|
+
return dest_set if shortcut.nil?
|
28
|
+
|
29
|
+
shortcut_params = case source.type
|
30
|
+
when :sorted_set
|
31
|
+
[r_dest_set, order] + opts[:shortcut_args]
|
32
|
+
else
|
33
|
+
[r_dest_set] + opts[:shortcut_args]
|
34
|
+
end
|
35
|
+
|
36
|
+
Zermelo::Filters::Redis::SHORTCUTS[source.type][shortcut].
|
37
|
+
call(*shortcut_params)
|
38
|
+
when Zermelo::Backends::InfluxDB
|
39
|
+
# FIXME
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -39,6 +39,7 @@ module Zermelo
|
|
39
39
|
|
40
40
|
if val.is_a?(Enumerable)
|
41
41
|
conditions_set = associated_class.send(:temp_key, source.type)
|
42
|
+
temp_keys << conditions_set
|
42
43
|
r_conditions_set = backend.key_to_redis_key(conditions_set)
|
43
44
|
|
44
45
|
backend.temp_key_wrap do |conditions_temp_keys|
|
@@ -130,7 +131,8 @@ module Zermelo
|
|
130
131
|
|
131
132
|
return dest_set if shortcut.nil?
|
132
133
|
|
133
|
-
shortcut_params =
|
134
|
+
shortcut_params = case source.type
|
135
|
+
when :sorted_set
|
134
136
|
[r_dest_set, order] + opts[:shortcut_args]
|
135
137
|
else
|
136
138
|
[r_dest_set] + opts[:shortcut_args]
|
@@ -20,12 +20,13 @@ module Zermelo
|
|
20
20
|
|
21
21
|
extend Forwardable
|
22
22
|
|
23
|
-
def_delegators :filter,
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def_delegators :filter,
|
24
|
+
:intersect, :union, :diff, :sort, :offset, :page, :empty,
|
25
|
+
:find_by_id, :find_by_ids, :find_by_id!, :find_by_ids!,
|
26
|
+
:all, :each, :collect, :map,
|
27
|
+
:select, :find_all, :reject, :destroy_all,
|
28
|
+
:ids, :count, :empty?, :exists?,
|
29
|
+
:associated_ids_for
|
29
30
|
|
30
31
|
def generate_id
|
31
32
|
return SecureRandom.uuid if SecureRandom.respond_to?(:uuid)
|
data/lib/zermelo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zermelo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ali Graham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/zermelo/filters/influxdb.rb
|
86
86
|
- lib/zermelo/filters/redis.rb
|
87
87
|
- lib/zermelo/filters/steps/base_step.rb
|
88
|
+
- lib/zermelo/filters/steps/empty_step.rb
|
88
89
|
- lib/zermelo/filters/steps/list_step.rb
|
89
90
|
- lib/zermelo/filters/steps/set_step.rb
|
90
91
|
- lib/zermelo/filters/steps/sort_step.rb
|