active_orm 4.0.3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,96 +1,100 @@
1
- class ActiveOrm::Redis::String < ActiveOrm::Redis
1
+ # frozen_string_literal: true
2
2
 
3
- def self.find(key)
4
- value = client.get(normalize_key(key))
5
- value = metamorph(value) if evaluate?
6
- value
7
- end
3
+ class ActiveOrm::Redis::String < ActiveOrm::Redis::Base
4
+ class << self
8
5
 
9
- def self.find_each(*args)
10
- args = stringify_keys(args)
11
- value = client.mget(args)
12
- value = metamorph(value) if evaluate?
13
- value
14
- end
6
+ def find(key)
7
+ value = client.get(normalize_key(key))
8
+ value = metamorph(value) if evaluate?
9
+ value
10
+ end
15
11
 
16
- def self.length(key)
17
- client.strlen(normalize_key(key))
18
- end
12
+ def find_each(*args)
13
+ args = stringify_keys(args)
14
+ value = client.mget(args)
15
+ value = metamorph(value) if evaluate?
16
+ value
17
+ end
19
18
 
20
- def self.split(key, start, finish)
21
- client.getrange(normalize_key(key), start, finish)
22
- end
19
+ def length(key)
20
+ client.strlen(normalize_key(key))
21
+ end
23
22
 
24
- def self.create(key, value, opts = {})
25
- client.set(normalize_key(key), value, opts)
26
- end
23
+ def split(key, start, finish)
24
+ client.getrange(normalize_key(key), start, finish)
25
+ end
27
26
 
28
- def self.create!(key, value)
29
- client.setnx(normalize_key(key), value)
30
- end
27
+ def create(key, value, opts = {})
28
+ client.set(normalize_key(key), value, opts)
29
+ end
31
30
 
32
- def self.create_each(*args)
33
- args = stringify_keys(args)
34
- client.mset(args)
35
- end
31
+ def create!(key, value)
32
+ client.setnx(normalize_key(key), value)
33
+ end
36
34
 
37
- def self.create_each!(*args)
38
- args = stringify_keys(args)
39
- client.msetnx(args)
40
- end
35
+ def create_each(*args)
36
+ args = stringify_keys(args)
37
+ client.mset(args)
38
+ end
39
+
40
+ def create_each!(*args)
41
+ args = stringify_keys(args)
42
+ client.msetnx(args)
43
+ end
41
44
 
42
- def self.create_until(key, value, seconds, format = :seconds)
43
- normalized_key = normalize_key(key)
45
+ def create_until(key, value, seconds, format = :seconds)
46
+ normalized_key = normalize_key(key)
44
47
 
45
- if seconds?(format)
46
- client.setex(normalized_key, seconds, value)
47
- else
48
- client.psetex(normalized_key, seconds, value)
48
+ if seconds?(format)
49
+ client.setex(normalized_key, seconds, value)
50
+ else
51
+ client.psetex(normalized_key, seconds, value)
52
+ end
49
53
  end
50
- end
51
54
 
52
- def self.append(key, value)
53
- client.append(normalize_key(key), value)
54
- end
55
+ def append(key, value)
56
+ client.append(normalize_key(key), value)
57
+ end
55
58
 
56
- def self.replace(key, value, offset)
57
- client.setrange(normalize_key(key), offset, value)
58
- end
59
+ def replace(key, value, offset)
60
+ client.setrange(normalize_key(key), offset, value)
61
+ end
59
62
 
60
- def self.decrement(key, value = 1)
61
- normalized_key = normalize_key(key)
63
+ def decrement(key, value = 1)
64
+ normalized_key = normalize_key(key)
62
65
 
63
- value == 1 ? client.decr(normalized_key) : client.decrby(normalized_key, value)
64
- end
66
+ value == 1 ? client.decr(normalized_key) : client.decrby(normalized_key, value)
67
+ end
65
68
 
66
- def self.increment(key, value = 1)
67
- normalized_key = normalize_key(key)
69
+ def increment(key, value = 1)
70
+ normalized_key = normalize_key(key)
68
71
 
69
- if value.is_a?(Float)
70
- client.incrbyfloat(normalized_key, value)
71
- else
72
- value == 1 ? client.incr(normalized_key) : client.incrby(normalized_key, value)
72
+ if value.is_a?(Float)
73
+ client.incrbyfloat(normalized_key, value)
74
+ else
75
+ value == 1 ? client.incr(normalized_key) : client.incrby(normalized_key, value)
76
+ end
73
77
  end
74
- end
75
78
 
76
- def self.reset(key, value = 0)
77
- client.getset(normalize_key(key), value)
78
- end
79
+ def reset(key, value = 0)
80
+ client.getset(normalize_key(key), value)
81
+ end
79
82
 
80
- def self.bit_count(key, start = 0, finish = -1)
81
- client.bitcount(normalize_key(key), start, finish)
82
- end
83
+ def bit_count(key, start = 0, finish = -1)
84
+ client.bitcount(normalize_key(key), start, finish)
85
+ end
83
86
 
84
- def self.bit_where(operation, key, *keys)
85
- client.bitop(operation, key, *keys)
86
- end
87
+ def bit_where(operation, key, *keys)
88
+ client.bitop(operation, key, *keys)
89
+ end
87
90
 
88
- def self.get_bit(key, offset)
89
- client.getbit(normalize_key(key), offset)
90
- end
91
+ def get_bit(key, offset)
92
+ client.getbit(normalize_key(key), offset)
93
+ end
91
94
 
92
- def self.set_bit(key, offset, bit)
93
- client.setbit(normalize_key(key), offset, bit)
94
- end
95
+ def set_bit(key, offset, bit)
96
+ client.setbit(normalize_key(key), offset, bit)
97
+ end
95
98
 
99
+ end
96
100
  end
@@ -1,23 +1,27 @@
1
- class ActiveOrm::Redis::Transaction < ActiveOrm::Redis
1
+ # frozen_string_literal: true
2
2
 
3
- def self.discard
4
- client.discard
5
- end
3
+ class ActiveOrm::Redis::Transaction < ActiveOrm::Redis::Base
4
+ class << self
6
5
 
7
- def self.exec
8
- client.exec
9
- end
6
+ def discard
7
+ client.discard
8
+ end
10
9
 
11
- def self.multi(&block)
12
- client.multi(&block)
13
- end
10
+ def exec
11
+ client.exec
12
+ end
14
13
 
15
- def self.watch(*args)
16
- client.watch(args)
17
- end
14
+ def multi(&block)
15
+ client.multi(&block)
16
+ end
18
17
 
19
- def self.unwatch
20
- client.unwatch
21
- end
18
+ def watch(*args)
19
+ client.watch(args)
20
+ end
21
+
22
+ def unwatch
23
+ client.unwatch
24
+ end
22
25
 
26
+ end
23
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveOrm
2
- VERSION = '4.0.3'.freeze
4
+ VERSION ||= '5.0.0'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
 
3
5
  class ActiveOrm::InstallGenerator < Rails::Generators::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if defined?(Redis)
2
4
  ActiveOrm::Redis.configure do |config|
3
5
  config.client = Redis.new
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :db do
2
4
  namespace :redis do
3
5
 
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: 4.0.3
4
+ version: 5.0.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: 2017-05-30 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: dry-configurable
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -158,7 +144,6 @@ extensions: []
158
144
  extra_rdoc_files: []
159
145
  files:
160
146
  - ".DS_Store"
161
- - ".coveralls.yml"
162
147
  - ".fasterer.yml"
163
148
  - ".gitignore"
164
149
  - ".reek"
@@ -176,9 +161,7 @@ files:
176
161
  - lib/.DS_Store
177
162
  - lib/active_orm.rb
178
163
  - lib/active_orm/.DS_Store
179
- - lib/active_orm/base.rb
180
164
  - lib/active_orm/railtie.rb
181
- - lib/active_orm/redis.rb
182
165
  - lib/active_orm/redis/.DS_Store
183
166
  - lib/active_orm/redis/base.rb
184
167
  - lib/active_orm/redis/configuration.rb
@@ -218,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
201
  version: '0'
219
202
  requirements: []
220
203
  rubyforge_project:
221
- rubygems_version: 2.6.12
204
+ rubygems_version: 2.6.13
222
205
  signing_key:
223
206
  specification_version: 4
224
207
  summary: Gem for commonly used database ORM.
@@ -1 +0,0 @@
1
- service_name: travis-ci
@@ -1,13 +0,0 @@
1
- class ActiveOrm::Base
2
-
3
- attr_accessor :configuration
4
-
5
- def self.configuration
6
- @configuration ||= Configuration.new
7
- end
8
-
9
- def self.configure
10
- yield(configuration)
11
- end
12
-
13
- end
@@ -1,23 +0,0 @@
1
- begin
2
- require 'fakeredis'
3
- rescue LoadError
4
- require 'redis'
5
- end
6
-
7
- require 'active_orm/redis/base'
8
- require 'active_orm/redis/configuration'
9
-
10
- class ActiveOrm::Redis < ActiveOrm::Base
11
- extend Base
12
-
13
- attr_accessor :client
14
-
15
- def initialize(client = nil)
16
- @client ||= (client.nil? ? ActiveOrm::Redis.configuration.client : client)
17
- end
18
-
19
- def self.client(client = nil)
20
- client.nil? ? new.client : new(client).client
21
- end
22
-
23
- end