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.
- checksums.yaml +4 -4
- data/.reek +4 -10
- data/.rubocop.yml +0 -20
- data/Gemfile +2 -0
- data/README.md +0 -1
- data/Rakefile +2 -0
- data/active_orm.gemspec +2 -1
- data/bin/console +1 -0
- data/bin/rake +2 -2
- data/lib/active_orm.rb +9 -5
- data/lib/active_orm/railtie.rb +2 -0
- data/lib/active_orm/redis/base.rb +71 -60
- data/lib/active_orm/redis/configuration.rb +32 -5
- data/lib/active_orm/redis/connection.rb +77 -73
- data/lib/active_orm/redis/geo.rb +23 -19
- data/lib/active_orm/redis/hash.rb +61 -57
- data/lib/active_orm/redis/hyper_log_log.rb +14 -10
- data/lib/active_orm/redis/key.rb +70 -66
- data/lib/active_orm/redis/list.rb +125 -121
- data/lib/active_orm/redis/pub_sub.rb +26 -22
- data/lib/active_orm/redis/script.rb +14 -10
- data/lib/active_orm/redis/set.rb +55 -51
- data/lib/active_orm/redis/sorted_set.rb +150 -146
- data/lib/active_orm/redis/string.rb +75 -71
- data/lib/active_orm/redis/transaction.rb +20 -16
- data/lib/active_orm/version.rb +3 -1
- data/lib/generators/active_orm/install_generator.rb +2 -0
- data/lib/generators/active_orm/templates/install.rb +2 -0
- data/lib/tasks/redis.rake +2 -0
- metadata +3 -20
- data/.coveralls.yml +0 -1
- data/lib/active_orm/base.rb +0 -13
- data/lib/active_orm/redis.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e54ca0d570dbde6643e8920cc5dbbbfe7e07615e
|
4
|
+
data.tar.gz: 07f7455f9ee50e95bf214b74088acc770b74cf4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18926c723a16a6317b20db4eaa970ebe4100e6e7520107b3a208ed35916ad9a2b641e63b25a51314360f40104c77e1ee8aa3bb597eb711cc4d011c729f9141f6
|
7
|
+
data.tar.gz: be0525d9c1494541c8762c0e6e168b129ac8b1f0fcfd90401db93e828f472c462bfe254b7fad2ec495732c0bc6ddec7d019ac82120f207a92ea21732363762b3
|
data/.reek
CHANGED
@@ -7,6 +7,8 @@ ClassVariable:
|
|
7
7
|
enabled: false
|
8
8
|
ControlParameter:
|
9
9
|
enabled: false
|
10
|
+
DataClump:
|
11
|
+
enabled: false
|
10
12
|
DuplicateMethodCall:
|
11
13
|
exclude:
|
12
14
|
- 'Base#metamorph'
|
@@ -16,19 +18,11 @@ IrresponsibleModule:
|
|
16
18
|
enabled: false
|
17
19
|
LongParameterList:
|
18
20
|
enabled: false
|
19
|
-
ManualDispatch:
|
20
|
-
enabled: false
|
21
|
-
NestedIterators:
|
22
|
-
max_allowed_nesting: 2
|
23
21
|
NilCheck:
|
24
22
|
enabled: false
|
25
|
-
PrimaDonnaMethod:
|
26
|
-
enabled: false
|
27
23
|
RepeatedConditional:
|
28
24
|
enabled: false
|
25
|
+
TooManyMethods:
|
26
|
+
enabled: false
|
29
27
|
TooManyStatements:
|
30
28
|
max_statements: 10
|
31
|
-
exclude:
|
32
|
-
- 'Base#metamorph'
|
33
|
-
UtilityFunction:
|
34
|
-
enabled: false
|
data/.rubocop.yml
CHANGED
@@ -4,41 +4,21 @@ AllCops:
|
|
4
4
|
TargetRubyVersion: 2.4
|
5
5
|
Exclude:
|
6
6
|
- 'spec/**/**/*'
|
7
|
-
Layout/ClosingParenthesisIndentation:
|
8
|
-
Enabled: false
|
9
7
|
Layout/EmptyLinesAroundBlockBody:
|
10
8
|
Enabled: false
|
11
9
|
Layout/EmptyLinesAroundClassBody:
|
12
10
|
Enabled: false
|
13
11
|
Layout/EmptyLinesAroundModuleBody:
|
14
12
|
Enabled: false
|
15
|
-
Layout/FirstParameterIndentation:
|
16
|
-
Enabled: false
|
17
|
-
Layout/MultilineMethodCallIndentation:
|
18
|
-
EnforcedStyle: aligned
|
19
13
|
LineLength:
|
20
14
|
Max: 100
|
21
15
|
Lint/ScriptPermission:
|
22
16
|
Enabled: false
|
23
17
|
Metrics/ClassLength:
|
24
18
|
Enabled: false
|
25
|
-
Metrics/ModuleLength:
|
26
|
-
Enabled: false
|
27
|
-
Style/Alias:
|
28
|
-
EnforcedStyle: prefer_alias_method
|
29
|
-
Style/BracesAroundHashParameters:
|
30
|
-
Enabled: false
|
31
19
|
Style/ClassAndModuleChildren:
|
32
20
|
EnforcedStyle: compact
|
33
21
|
Style/ClassVars:
|
34
22
|
Enabled: false
|
35
23
|
Style/Documentation:
|
36
24
|
Enabled: false
|
37
|
-
Style/HashSyntax:
|
38
|
-
Enabled: false
|
39
|
-
Style/FrozenStringLiteralComment:
|
40
|
-
Enabled: false
|
41
|
-
Style/NumericLiterals:
|
42
|
-
Enabled: false
|
43
|
-
Style/RescueModifier:
|
44
|
-
Enabled: false
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/active_orm.svg)](http://badge.fury.io/rb/active_orm)
|
4
4
|
[![Build Status](https://travis-ci.org/drexed/active_orm.svg?branch=master)](https://travis-ci.org/drexed/active_orm)
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/github/drexed/active_orm/badge.svg?branch=master)](https://coveralls.io/github/drexed/active_orm?branch=master)
|
6
5
|
|
7
6
|
ActiveOrm is a library for object ruby mapping of different databases.
|
8
7
|
|
data/Rakefile
CHANGED
data/active_orm.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# coding: utf-8
|
2
4
|
|
3
5
|
lib = File.expand_path('../lib', __FILE__)
|
@@ -21,7 +23,6 @@ Gem::Specification.new do |spec|
|
|
21
23
|
spec.require_paths = %w[lib]
|
22
24
|
|
23
25
|
spec.add_runtime_dependency 'rails'
|
24
|
-
spec.add_runtime_dependency 'dry-configurable'
|
25
26
|
|
26
27
|
spec.add_development_dependency 'bundler'
|
27
28
|
spec.add_development_dependency 'coveralls'
|
data/bin/console
CHANGED
data/bin/rake
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
3
4
|
# This file was generated by Bundler.
|
4
5
|
#
|
5
6
|
# The application 'rake' is installed as part of a gem, and
|
6
7
|
# this file is here to facilitate running it.
|
7
|
-
#
|
8
8
|
|
9
9
|
require 'pathname'
|
10
10
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
data/lib/active_orm.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/railtie'
|
2
4
|
|
3
|
-
%w[version railtie
|
5
|
+
%w[version railtie].each do |file_name|
|
4
6
|
require "active_orm/#{file_name}"
|
5
7
|
end
|
6
8
|
|
7
|
-
%w[
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
%w[
|
10
|
+
configuration base connection geo hash hyper_log_log key list pub_sub script set sorted_set
|
11
|
+
string transaction
|
12
|
+
].each do |file_name|
|
13
|
+
require "active_orm/redis/#{file_name}"
|
14
|
+
end
|
11
15
|
|
12
16
|
require 'generators/active_orm/install_generator'
|
data/lib/active_orm/railtie.rb
CHANGED
@@ -1,76 +1,87 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
class ActiveOrm::Redis::Base
|
4
|
+
class << self
|
4
5
|
|
5
|
-
|
6
|
-
@@evaluate = value
|
7
|
-
self
|
8
|
-
end
|
6
|
+
@@evaluate = false
|
9
7
|
|
10
|
-
|
8
|
+
def client(new_client = nil)
|
9
|
+
new_client || ActiveOrm::Redis.configuration.client
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
12
|
+
def evaluate(value = true)
|
13
|
+
@@evaluate = value
|
14
|
+
self
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
order.to_s == 'append'
|
20
|
-
end
|
17
|
+
private
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
19
|
+
def evaluate?
|
20
|
+
value = @@evaluate
|
21
|
+
@@evaluate = false
|
22
|
+
value
|
23
|
+
end
|
24
|
+
|
25
|
+
def append?(order)
|
26
|
+
order.to_s == 'append'
|
27
|
+
end
|
28
|
+
|
29
|
+
# rubocop:disable Lint/RescueException, Security/Eval
|
30
|
+
def metaform(value)
|
31
|
+
value.nil? ? value : eval(value)
|
32
|
+
rescue Exception
|
33
|
+
value
|
34
|
+
end
|
35
|
+
# rubocop:enable Lint/RescueException, Security/Eval
|
36
|
+
|
37
|
+
def metaform_array(datum)
|
38
|
+
datum.map { |val| metaform(val) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def metaform_hash(datum)
|
42
|
+
datum.lazy.each { |key, val| datum[key] = metaform(val) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def metamorph_array(datum)
|
46
|
+
case datum.first.class.name
|
47
|
+
when 'Array' then datum.map { |arr| metaform_array(arr) }
|
48
|
+
when 'Hash' then datum.map { |hsh| metaform_hash(hsh) }
|
49
|
+
else metaform_array(datum)
|
42
50
|
end
|
43
|
-
when 'Hash'
|
44
|
-
datum.each { |key, val| datum.store(key, metaform(val)) }
|
45
|
-
else
|
46
|
-
metaform(datum)
|
47
51
|
end
|
48
|
-
end
|
49
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
def metamorph(datum)
|
54
|
+
case datum.class.name
|
55
|
+
when 'Array' then metamorph_array(datum)
|
56
|
+
when 'Hash' then metaform_hash(datum)
|
57
|
+
else metaform(datum)
|
58
|
+
end
|
59
|
+
end
|
55
60
|
|
56
|
-
|
57
|
-
|
58
|
-
|
61
|
+
def metatransform(datum)
|
62
|
+
return if datum.empty?
|
63
|
+
evaluate? ? metamorph(datum) : datum
|
64
|
+
end
|
59
65
|
|
60
|
-
|
61
|
-
|
62
|
-
|
66
|
+
def milliseconds?(format)
|
67
|
+
format.to_s == 'milliseconds'
|
68
|
+
end
|
63
69
|
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
def normalize_key(key)
|
71
|
+
key.to_s
|
72
|
+
end
|
67
73
|
|
68
|
-
|
69
|
-
|
70
|
-
|
74
|
+
def prepend?(order)
|
75
|
+
order.to_s == 'prepend'
|
76
|
+
end
|
71
77
|
|
72
|
-
|
73
|
-
|
74
|
-
|
78
|
+
def seconds?(format)
|
79
|
+
format.to_s == 'seconds'
|
80
|
+
end
|
81
|
+
|
82
|
+
def stringify_keys(value)
|
83
|
+
value.map { |key, _| key.to_s }
|
84
|
+
end
|
75
85
|
|
86
|
+
end
|
76
87
|
end
|
@@ -1,9 +1,36 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
# rubocop:disable Style/ClassAndModuleChildren
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
begin
|
6
|
+
require 'fakeredis'
|
7
|
+
rescue LoadError
|
8
|
+
require 'redis'
|
9
|
+
end
|
10
|
+
|
11
|
+
module ActiveOrm
|
12
|
+
module Redis
|
13
|
+
class Configuration
|
14
|
+
|
15
|
+
attr_accessor :client
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@client = ::Redis.new
|
19
|
+
end
|
8
20
|
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.configuration
|
24
|
+
@configuration ||= Configuration.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.configuration=(config)
|
28
|
+
@configuration = config
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.configure
|
32
|
+
yield(configuration)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
9
36
|
end
|
@@ -1,99 +1,103 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
end
|
3
|
+
class ActiveOrm::Redis::Connection < ActiveOrm::Redis::Base
|
4
|
+
class << self
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def authenticate(password)
|
7
|
+
client.auth(password)
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def connected?
|
11
|
+
client.connected?
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def database(index)
|
15
|
+
client.select(index)
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def database_id
|
19
|
+
client.database_id
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def database_size
|
23
|
+
client.dbsize
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def debug(*args)
|
27
|
+
client.debug(args)
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def disconnect
|
31
|
+
client.disconnect
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def echo(message)
|
35
|
+
client.echo(message)
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
def flush
|
39
|
+
client.flushdb
|
40
|
+
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
def flush_all
|
43
|
+
client.flushall
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def info
|
47
|
+
client.info
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
def ping
|
51
|
+
client.ping
|
52
|
+
end
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
def quit
|
55
|
+
client.quit
|
56
|
+
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
def reconnect
|
59
|
+
client.reconnect
|
60
|
+
end
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def rewrite_aof
|
63
|
+
client.bgrewriteaof
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
def save
|
67
|
+
client.bgsave
|
68
|
+
end
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
def saved_at
|
71
|
+
client.lastsave
|
72
|
+
end
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
def shutdown
|
75
|
+
client.shutdown
|
76
|
+
end
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
def slave_of(host, port)
|
79
|
+
client.slaveof(host, port)
|
80
|
+
end
|
82
81
|
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
def slowlog(command, length = nil)
|
83
|
+
client.slowlog(command, length)
|
84
|
+
end
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
def synchronize
|
87
|
+
client.synchronize
|
88
|
+
end
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
|
90
|
+
def time
|
91
|
+
client.time
|
92
|
+
end
|
94
93
|
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
def with_reconnect(&block)
|
95
|
+
client.with_reconnect(true, &block)
|
96
|
+
end
|
97
|
+
|
98
|
+
def without_reconnect(&block)
|
99
|
+
client.with_reconnect(false, &block)
|
100
|
+
end
|
98
101
|
|
102
|
+
end
|
99
103
|
end
|