active_orm 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_orm.rb +18 -18
- data/lib/active_orm/redis.rb +4 -4
- data/lib/active_orm/redis/base.rb +8 -8
- data/lib/active_orm/redis/hash.rb +5 -5
- data/lib/active_orm/redis/key.rb +1 -1
- data/lib/active_orm/redis/list.rb +9 -9
- data/lib/active_orm/redis/set.rb +5 -5
- data/lib/active_orm/redis/sorted_set.rb +16 -16
- data/lib/active_orm/redis/string.rb +2 -2
- data/lib/active_orm/version.rb +1 -1
- data/lib/generators/active_orm/install_generator.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5692e7422ed670461e14875e647c80b6bcb7a65
|
4
|
+
data.tar.gz: 07091befb99b8fc02a3be2158afa52b8e08b987c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aafb599c4903fbc87e048f9560b3f4cf1351f6d32b4babd0ff22a4206d3d6ad30ce1193eeab13d89bffd403104d7f675368e482ccbf21ef7c5c096a1925328d0
|
7
|
+
data.tar.gz: a430b2fa7fc62cfdb924b96f4afb9da9bd3416a243964ec9cae0deee749e0c01942eb434dec3f526df3d71e95d3bc0fb1ddecd8635961a66aab9fc79edbc5f81
|
data/lib/active_orm.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
require
|
1
|
+
require 'rails/railtie'
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'active_orm/version'
|
4
|
+
require 'active_orm/base'
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
6
|
+
require 'active_orm/redis'
|
7
|
+
require 'active_orm/redis/connection'
|
8
|
+
require 'active_orm/redis/geo'
|
9
|
+
require 'active_orm/redis/hash'
|
10
|
+
require 'active_orm/redis/hyper_log_log'
|
11
|
+
require 'active_orm/redis/key'
|
12
|
+
require 'active_orm/redis/list'
|
13
|
+
require 'active_orm/redis/pub_sub'
|
14
|
+
require 'active_orm/redis/script'
|
15
|
+
require 'active_orm/redis/set'
|
16
|
+
require 'active_orm/redis/sorted_set'
|
17
|
+
require 'active_orm/redis/string'
|
18
|
+
require 'active_orm/redis/transaction'
|
19
19
|
|
20
|
-
require
|
20
|
+
require 'generators/active_orm/install_generator'
|
21
21
|
|
22
22
|
module ActiveOrm
|
23
23
|
class Railtie < Rails::Railtie
|
24
24
|
|
25
25
|
rake_tasks do
|
26
|
-
Dir[File.expand_path(
|
26
|
+
Dir[File.expand_path('tasks/*.rake'.freeze, File.dirname(__FILE__))].each { |ext| load(ext) }
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/lib/active_orm/redis.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require 'fakeredis'
|
3
3
|
rescue LoadError
|
4
|
-
require
|
4
|
+
require 'redis'
|
5
5
|
end
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require 'active_orm/redis/base'
|
8
|
+
require 'active_orm/redis/configuration'
|
9
9
|
class ActiveOrm::Redis < ActiveOrm::Base
|
10
10
|
|
11
11
|
extend Base
|
@@ -4,13 +4,13 @@ module Base
|
|
4
4
|
|
5
5
|
def evaluate(value=true)
|
6
6
|
@@evaluate = value
|
7
|
-
|
7
|
+
self
|
8
8
|
end
|
9
9
|
|
10
10
|
def evaluate?
|
11
11
|
value = @@evaluate
|
12
12
|
@@evaluate = false
|
13
|
-
|
13
|
+
value
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -21,9 +21,9 @@ module Base
|
|
21
21
|
|
22
22
|
def metamorph(args)
|
23
23
|
case args.class.name
|
24
|
-
when
|
24
|
+
when 'Array'.freeze
|
25
25
|
args.first.is_a?(Array) ? args.map { |h| h.map { |v| metaform(v) } } : args.map { |v| metaform(v) }
|
26
|
-
when
|
26
|
+
when 'Hash'.freeze
|
27
27
|
args.each { |k, v| args[k] = metaform(v) }
|
28
28
|
else
|
29
29
|
metaform(args)
|
@@ -43,19 +43,19 @@ module Base
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def append?(order)
|
46
|
-
|
46
|
+
'append'.freeze == order.to_s
|
47
47
|
end
|
48
48
|
|
49
49
|
def prepend?(order)
|
50
|
-
|
50
|
+
'prepend'.freeze == order.to_s
|
51
51
|
end
|
52
52
|
|
53
53
|
def milliseconds?(format)
|
54
|
-
|
54
|
+
'milliseconds'.freeze == format.to_s
|
55
55
|
end
|
56
56
|
|
57
57
|
def seconds?(format)
|
58
|
-
|
58
|
+
'seconds'.freeze == format.to_s
|
59
59
|
end
|
60
60
|
|
61
61
|
end
|
@@ -3,31 +3,31 @@ class ActiveOrm::Redis::Hash < ActiveOrm::Redis
|
|
3
3
|
def self.find(key, field)
|
4
4
|
value = client.hget(normalize_key(key), field)
|
5
5
|
value = metamorph(value) if evaluate?
|
6
|
-
|
6
|
+
value
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.find_each(key, *args)
|
10
10
|
value = client.hmget(normalize_key(key), args)
|
11
11
|
value = metamorph(value) if evaluate?
|
12
|
-
|
12
|
+
value
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.all(key)
|
16
16
|
value = client.hgetall(normalize_key(key))
|
17
17
|
value = metamorph(value) if evaluate?
|
18
|
-
|
18
|
+
value
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.keys(key)
|
22
22
|
value = client.hkeys(normalize_key(key))
|
23
23
|
value = metamorph(value) if evaluate?
|
24
|
-
|
24
|
+
value
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.values(key)
|
28
28
|
value = client.hvals(normalize_key(key))
|
29
29
|
value = metamorph(value) if evaluate?
|
30
|
-
|
30
|
+
value
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.value_length(key, field)
|
data/lib/active_orm/redis/key.rb
CHANGED
@@ -3,33 +3,33 @@ class ActiveOrm::Redis::List < ActiveOrm::Redis
|
|
3
3
|
def self.find(key, position=1)
|
4
4
|
value = client.lindex(normalize_key(key), (position - 1))
|
5
5
|
value = metamorph(value) if evaluate?
|
6
|
-
|
6
|
+
value
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.first(key, limit=1)
|
10
10
|
value = client.lrange(normalize_key(key), 0, -1)
|
11
11
|
value = ((limit == 1) ? value.first : value.first(limit))
|
12
12
|
value = metamorph(value) if evaluate?
|
13
|
-
|
13
|
+
value
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.last(key, limit=1)
|
17
17
|
value = client.lrange(normalize_key(key), 0, -1)
|
18
18
|
value = ((limit == 1) ? value.last : value.last(limit))
|
19
19
|
value = metamorph(value) if evaluate?
|
20
|
-
|
20
|
+
value
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.between(key, start=1, finish=0)
|
24
24
|
value = client.lrange(normalize_key(key), (start - 1), (finish - 1))
|
25
25
|
value = metatransform(value)
|
26
|
-
|
26
|
+
value
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.all(key)
|
30
30
|
value = client.lrange(normalize_key(key), 0, -1)
|
31
31
|
value = metatransform(value)
|
32
|
-
|
32
|
+
value
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.count(key)
|
@@ -69,13 +69,13 @@ class ActiveOrm::Redis::List < ActiveOrm::Redis
|
|
69
69
|
def self.move(key, desination)
|
70
70
|
value = client.rpoplpush(normalize_key(key), normalize_key(desination))
|
71
71
|
value = metamorph(value) if evaluate?
|
72
|
-
|
72
|
+
value
|
73
73
|
end
|
74
74
|
|
75
75
|
def self.move_blocking(key, desination, opts={})
|
76
76
|
value = brpoplpush(normalize_key(key), normalize_key(desination))
|
77
77
|
value = metamorph(value) if evaluate?
|
78
|
-
|
78
|
+
value
|
79
79
|
end
|
80
80
|
|
81
81
|
def self.destroy(key, count, value)
|
@@ -101,13 +101,13 @@ class ActiveOrm::Redis::List < ActiveOrm::Redis
|
|
101
101
|
def self.pop(key, order=:prepend)
|
102
102
|
value = append?(order) ? client.rpop(key) : client.lpop(key)
|
103
103
|
value = metamorph(value) if evaluate?
|
104
|
-
|
104
|
+
value
|
105
105
|
end
|
106
106
|
|
107
107
|
def self.pop_blocking(keys, opts={})
|
108
108
|
value = append?(opts.fetch(:order, :prepend)) ? client.brpop(keys, opts.fetch(:timeout, 0)) : client.blpop(keys, opts.fetch(:timeout, 0))
|
109
109
|
value = metamorph(value) if evaluate?
|
110
|
-
|
110
|
+
value
|
111
111
|
end
|
112
112
|
|
113
113
|
end
|
data/lib/active_orm/redis/set.rb
CHANGED
@@ -3,31 +3,31 @@ class ActiveOrm::Redis::Set < ActiveOrm::Redis
|
|
3
3
|
def self.find(key)
|
4
4
|
value = client.smembers(normalize_key(key))
|
5
5
|
value = metatransform(value)
|
6
|
-
|
6
|
+
value
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.combine(*args)
|
10
10
|
value = client.sunion(*args)
|
11
11
|
value = metatransform(value)
|
12
|
-
|
12
|
+
value
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.difference(*args)
|
16
16
|
value = client.sdiff(*args)
|
17
17
|
value = metatransform(value)
|
18
|
-
|
18
|
+
value
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.intersection(key, *args)
|
22
22
|
value = client.sinter(normalize_key(key), *args)
|
23
23
|
value = metatransform(value)
|
24
|
-
|
24
|
+
value
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.sample(key, value=1)
|
28
28
|
value = client.srandmember(normalize_key(key), value)
|
29
29
|
value = metatransform(value)
|
30
|
-
|
30
|
+
value
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.value?(key, value)
|
@@ -4,96 +4,96 @@ class ActiveOrm::Redis::SortedSet < ActiveOrm::Redis
|
|
4
4
|
value = client.zrange(normalize_key(key), (position - 1), (position - 1), opts)
|
5
5
|
value = value.first
|
6
6
|
value = metamorph(value) if evaluate?
|
7
|
-
|
7
|
+
value
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.find_score(key, position, opts={})
|
11
11
|
value = client.zrangebyscore(normalize_key(key), position, position, opts)
|
12
12
|
value = value.first
|
13
13
|
value = metamorph(value) if evaluate?
|
14
|
-
|
14
|
+
value
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.first(key, opts={})
|
18
18
|
value = client.zrange(normalize_key(key), 0, 0, opts)
|
19
19
|
value = value.first
|
20
20
|
value = metamorph(value) if evaluate?
|
21
|
-
|
21
|
+
value
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.first_score(key, opts={})
|
25
25
|
value = client.zrangebyscore(normalize_key(key), 1, 1, opts)
|
26
26
|
value = value.first
|
27
27
|
value = metamorph(value) if evaluate?
|
28
|
-
|
28
|
+
value
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.last(key, opts={})
|
32
32
|
value = client.zrevrange(normalize_key(key), 0, 0, opts)
|
33
33
|
value = value.first
|
34
34
|
value = metamorph(value) if evaluate?
|
35
|
-
|
35
|
+
value
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.last_score(key, opts={})
|
39
39
|
value = client.zrevrangebyscore(normalize_key(key), 1, 1, opts)
|
40
40
|
value = value.first
|
41
41
|
value = metamorph(value) if evaluate?
|
42
|
-
|
42
|
+
value
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.between(key, start, finish, opts={})
|
46
46
|
value = client.zrange(normalize_key(key), (start - 1), (finish - 1), opts)
|
47
47
|
value = metatransform(value)
|
48
|
-
|
48
|
+
value
|
49
49
|
end
|
50
50
|
|
51
51
|
def self.between_reverse(key, start, finish, opts={})
|
52
52
|
value = client.zrevrange(normalize_key(key), (start - 1), (finish - 1), opts)
|
53
53
|
value = metatransform(value)
|
54
|
-
|
54
|
+
value
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.between_scores(key, min, max, opts={})
|
58
58
|
value = client.zrangebyscore(normalize_key(key), min, max, opts)
|
59
59
|
value = metatransform(value)
|
60
|
-
|
60
|
+
value
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.between_scores_reverse(key, min, max, opts={})
|
64
64
|
value = client.zrevrangebyscore(normalize_key(key), min, max, opts)
|
65
65
|
value = metatransform(value)
|
66
|
-
|
66
|
+
value
|
67
67
|
end
|
68
68
|
|
69
69
|
def self.between_lex(key, min, max, opts={})
|
70
70
|
value = client.zrangebylex(normalize_key(key), min, max, opts)
|
71
71
|
value = metatransform(value)
|
72
|
-
|
72
|
+
value
|
73
73
|
end
|
74
74
|
|
75
75
|
def self.between_lex_reverse(key, min, max, opts={})
|
76
76
|
value = client.zrevrangebylex(normalize_key(key), min, max, opts)
|
77
77
|
value = metatransform(value)
|
78
|
-
|
78
|
+
value
|
79
79
|
end
|
80
80
|
|
81
81
|
def self.all(key, opts={})
|
82
|
-
value = client.zrange(normalize_key(key),
|
82
|
+
value = client.zrange(normalize_key(key), '-inf'.freeze, '+inf'.freeze, opts)
|
83
83
|
value = metatransform(value)
|
84
|
-
|
84
|
+
value
|
85
85
|
end
|
86
86
|
|
87
87
|
def self.position(key, value)
|
88
88
|
value = client.zrank(normalize_key(key), value)
|
89
89
|
value = value + 1 unless value.nil?
|
90
|
-
|
90
|
+
value
|
91
91
|
end
|
92
92
|
|
93
93
|
def self.position_reverse(key, value)
|
94
94
|
value = client.zrevrank(normalize_key(key), value)
|
95
95
|
value = value + 1 unless value.nil?
|
96
|
-
|
96
|
+
value
|
97
97
|
end
|
98
98
|
|
99
99
|
def self.score(key, value)
|
@@ -3,14 +3,14 @@ class ActiveOrm::Redis::String < ActiveOrm::Redis
|
|
3
3
|
def self.find(key)
|
4
4
|
value = client.get(normalize_key(key))
|
5
5
|
value = metamorph(value) if evaluate?
|
6
|
-
|
6
|
+
value
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.find_each(*args)
|
10
10
|
args = stringify_keys(args)
|
11
11
|
value = client.mget(args)
|
12
12
|
value = metamorph(value) if evaluate?
|
13
|
-
|
13
|
+
value
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.length(key)
|
data/lib/active_orm/version.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'rails/generators'
|
2
2
|
|
3
3
|
module ActiveOrm
|
4
4
|
class InstallGenerator < Rails::Generators::Base
|
5
5
|
source_root File.expand_path('../templates', __FILE__)
|
6
6
|
|
7
7
|
def copy_initializer_file
|
8
|
-
copy_file(
|
8
|
+
copy_file('install.rb'.freeze, 'config/initializers/active_orm.rb'.freeze)
|
9
9
|
end
|
10
10
|
|
11
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_orm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|