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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c572fa0ae21f5c0bc8595134d3ed812e0918829f
4
- data.tar.gz: bd21a15e5f00d97aa1dc63818bd97d3f24f2f582
3
+ metadata.gz: c5692e7422ed670461e14875e647c80b6bcb7a65
4
+ data.tar.gz: 07091befb99b8fc02a3be2158afa52b8e08b987c
5
5
  SHA512:
6
- metadata.gz: 504603935d21ad05dba07ac0d1a93d650415a676cc505e61b1893516e62147ce2203fe2464fb5b96680b7691a663985654a6c11e594274c3c19bb6a78711e117
7
- data.tar.gz: 8bb12d6bb396ad30c9ef7224926c98fe85aa24a44a43d147efdbaf43418fc85c188dda3b02508412c6c76977b356a51f310efd7be7aaf2e0909082b4b52e76db
6
+ metadata.gz: aafb599c4903fbc87e048f9560b3f4cf1351f6d32b4babd0ff22a4206d3d6ad30ce1193eeab13d89bffd403104d7f675368e482ccbf21ef7c5c096a1925328d0
7
+ data.tar.gz: a430b2fa7fc62cfdb924b96f4afb9da9bd3416a243964ec9cae0deee749e0c01942eb434dec3f526df3d71e95d3bc0fb1ddecd8635961a66aab9fc79edbc5f81
data/lib/active_orm.rb CHANGED
@@ -1,29 +1,29 @@
1
- require "rails/railtie"
1
+ require 'rails/railtie'
2
2
 
3
- require "active_orm/version"
4
- require "active_orm/base"
3
+ require 'active_orm/version'
4
+ require 'active_orm/base'
5
5
 
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"
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 "generators/active_orm/install_generator"
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("tasks/*.rake", File.dirname(__FILE__))].each { |ext| load(ext) }
26
+ Dir[File.expand_path('tasks/*.rake'.freeze, File.dirname(__FILE__))].each { |ext| load(ext) }
27
27
  end
28
28
 
29
29
  end
@@ -1,11 +1,11 @@
1
1
  begin
2
- require "fakeredis"
2
+ require 'fakeredis'
3
3
  rescue LoadError
4
- require "redis"
4
+ require 'redis'
5
5
  end
6
6
 
7
- require "active_orm/redis/base"
8
- require "active_orm/redis/configuration"
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
- return(self)
7
+ self
8
8
  end
9
9
 
10
10
  def evaluate?
11
11
  value = @@evaluate
12
12
  @@evaluate = false
13
- return(value)
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 "Array"
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 "Hash"
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
- "append" == order.to_s
46
+ 'append'.freeze == order.to_s
47
47
  end
48
48
 
49
49
  def prepend?(order)
50
- "prepend" == order.to_s
50
+ 'prepend'.freeze == order.to_s
51
51
  end
52
52
 
53
53
  def milliseconds?(format)
54
- "milliseconds" == format.to_s
54
+ 'milliseconds'.freeze == format.to_s
55
55
  end
56
56
 
57
57
  def seconds?(format)
58
- "seconds" == format.to_s
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
30
+ value
31
31
  end
32
32
 
33
33
  def self.value_length(key, field)
@@ -48,7 +48,7 @@ class ActiveOrm::Redis::Key < ActiveOrm::Redis
48
48
  client.dump(normalize_key(key))
49
49
  end
50
50
 
51
- def self.match(pattern="*")
51
+ def self.match(pattern='*'.freeze)
52
52
  value = client.keys(normalize_key(pattern))
53
53
  value = nil if value.empty?
54
54
  return(value)
@@ -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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
110
+ value
111
111
  end
112
112
 
113
113
  end
@@ -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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
78
+ value
79
79
  end
80
80
 
81
81
  def self.all(key, opts={})
82
- value = client.zrange(normalize_key(key), "-inf", "+inf", opts)
82
+ value = client.zrange(normalize_key(key), '-inf'.freeze, '+inf'.freeze, opts)
83
83
  value = metatransform(value)
84
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
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
- return(value)
13
+ value
14
14
  end
15
15
 
16
16
  def self.length(key)
@@ -1,3 +1,3 @@
1
1
  module ActiveOrm
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.0"
3
3
  end
@@ -1,11 +1,11 @@
1
- require "rails/generators"
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("install.rb", "config/initializers/active_orm.rb")
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.2.0
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-08-22 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails