modis 3.2.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.rubocop.yml +23 -6
- data/.ruby-version +1 -1
- data/.travis.yml +11 -7
- data/CHANGELOG.md +55 -11
- data/Gemfile.lock +96 -0
- data/README.md +16 -8
- data/benchmark/persistence.rb +1 -1
- data/gemfiles/{rails_4.2.gemfile → rails_6.1.gemfile} +2 -2
- data/lib/modis/finder.rb +9 -4
- data/lib/modis/persistence.rb +12 -12
- data/lib/modis/transaction.rb +1 -1
- data/lib/modis/version.rb +1 -1
- data/lib/modis.rb +1 -1
- data/modis.gemspec +4 -4
- data/spec/persistence_spec.rb +18 -4
- data/spec/spec_helper.rb +2 -0
- metadata +28 -29
- data/gemfiles/rails_5.0.gemfile +0 -8
- data/gemfiles/rails_5.1.gemfile +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90338a93da41f45150c96831168e346edc9c408aa587bd7e1d82cb6e735e1b5b
|
4
|
+
data.tar.gz: 87894188fb86b5f4f5f5586990a99744a3c88eedda54e1e1bb5d588df3c33db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b80e7a9f7d6b546f100a03d0b49f0d6f095832cc97aeaea6fd4edb23428fd741c9851e76e1ad011d785e478f4f0bbd77eea31e77c2c420df447506ec328fc114
|
7
|
+
data.tar.gz: c43be4893954d2826f6f31c39c2a035bce50907f32fe224a475b4f0b71d038a42379c13132192297271ab30ad4922abcabec463db4832f40f9c5c2ac293aedb0
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -3,23 +3,24 @@ AllCops:
|
|
3
3
|
- modis.gemspec
|
4
4
|
- vendor/**/*
|
5
5
|
- gemfiles/**/*
|
6
|
+
TargetRubyVersion: 2.3
|
6
7
|
|
7
|
-
LineLength:
|
8
|
+
Layout/LineLength:
|
8
9
|
Enabled: false
|
9
10
|
|
10
|
-
StringLiterals:
|
11
|
+
Style/StringLiterals:
|
11
12
|
Enabled: false
|
12
13
|
|
13
|
-
Documentation:
|
14
|
+
Style/Documentation:
|
14
15
|
Enabled: false
|
15
16
|
|
16
|
-
MethodLength:
|
17
|
+
Metrics/MethodLength:
|
17
18
|
Enabled: false
|
18
19
|
|
19
|
-
ClassLength:
|
20
|
+
Metrics/ClassLength:
|
20
21
|
Enabled: false
|
21
22
|
|
22
|
-
CyclomaticComplexity:
|
23
|
+
Metrics/CyclomaticComplexity:
|
23
24
|
Enabled: false
|
24
25
|
|
25
26
|
Style/SignalException:
|
@@ -42,3 +43,19 @@ Metrics/BlockLength:
|
|
42
43
|
|
43
44
|
Security/YAMLLoad:
|
44
45
|
Enabled: false
|
46
|
+
|
47
|
+
Lint/RaiseException:
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
Lint/StructNewOverride:
|
51
|
+
Enabled: true
|
52
|
+
|
53
|
+
Style/HashEachMethods:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Style/HashTransformKeys:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Style/HashTransformValues:
|
60
|
+
Enabled: true
|
61
|
+
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.5
|
data/.travis.yml
CHANGED
@@ -12,15 +12,14 @@ rvm:
|
|
12
12
|
- 2.4
|
13
13
|
- 2.5
|
14
14
|
- 2.6
|
15
|
-
-
|
16
|
-
-
|
15
|
+
- 2.7
|
16
|
+
- 3.0
|
17
|
+
- jruby-9.2.17.0
|
17
18
|
|
18
19
|
gemfile:
|
19
|
-
- gemfiles/rails_4.2.gemfile
|
20
|
-
- gemfiles/rails_5.0.gemfile
|
21
|
-
- gemfiles/rails_5.1.gemfile
|
22
20
|
- gemfiles/rails_5.2.gemfile
|
23
21
|
- gemfiles/rails_6.0.gemfile
|
22
|
+
- gemfiles/rails_6.1.gemfile
|
24
23
|
|
25
24
|
matrix:
|
26
25
|
fast_finish: true
|
@@ -28,10 +27,15 @@ matrix:
|
|
28
27
|
# Rails 6 requires Ruby 2.5 or higher
|
29
28
|
- gemfile: gemfiles/rails_6.0.gemfile
|
30
29
|
rvm: 2.3
|
30
|
+
- gemfile: gemfiles/rails_6.1.gemfile
|
31
|
+
rvm: 2.3
|
31
32
|
- gemfile: gemfiles/rails_6.0.gemfile
|
32
33
|
rvm: 2.4
|
33
|
-
- gemfile: gemfiles/rails_6.
|
34
|
-
rvm:
|
34
|
+
- gemfile: gemfiles/rails_6.1.gemfile
|
35
|
+
rvm: 2.4
|
36
|
+
# Rails 5.2 isn't compatible with Ruby 3.0 or higher
|
37
|
+
- gemfile: gemfiles/rails_5.2.gemfile
|
38
|
+
rvm: 3.0
|
35
39
|
|
36
40
|
env:
|
37
41
|
global:
|
data/CHANGELOG.md
CHANGED
@@ -1,20 +1,61 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## [v4.0.1](https://github.com/rpush/modis/tree/v4.0.1) (2022-03-02)
|
4
4
|
|
5
|
-
|
5
|
+
[Full Changelog](https://github.com/rpush/modis/compare/v4.0.0...v4.0.1)
|
6
6
|
|
7
|
-
|
7
|
+
**Merged pull requests:**
|
8
8
|
|
9
|
-
-
|
10
|
-
- Drop i18n dependency (credit goes to [@jas14](https://github.com/jas14) in [#23](https://github.com/rpush/modis/pull/23))
|
9
|
+
- Fix deprectated pipeline calls for Redis 4.6.0 [\#32](https://github.com/rpush/modis/pull/32) ([justinhoward](https://github.com/justinhoward))
|
11
10
|
|
12
|
-
##
|
11
|
+
## [v4.0.0](https://github.com/rpush/modis/tree/v4.0.0) (2021-04-28)
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
[Full Changelog](https://github.com/rpush/modis/compare/v3.3.0...v4.0.0)
|
14
|
+
|
15
|
+
**Merged pull requests:**
|
16
|
+
|
17
|
+
- Makes hiredis a development dependency [\#31](https://github.com/rpush/modis/pull/31) ([fdocr](https://github.com/fdocr))
|
18
|
+
|
19
|
+
## [v3.3.0](https://github.com/rpush/modis/tree/v3.3.0) (2020-07-07)
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/rpush/modis/compare/v3.2.0...v3.3.0)
|
22
|
+
|
23
|
+
**Merged pull requests:**
|
24
|
+
|
25
|
+
- Fix deprecation warnings [\#30](https://github.com/rpush/modis/pull/30) ([rofreg](https://github.com/rofreg))
|
26
|
+
- Test with Ruby 2.7 [\#28](https://github.com/rpush/modis/pull/28) ([aried3r](https://github.com/aried3r))
|
27
|
+
|
28
|
+
## [v3.2.0](https://github.com/rpush/modis/tree/v3.2.0) (2019-12-12)
|
29
|
+
|
30
|
+
[Full Changelog](https://github.com/rpush/modis/compare/v3.1.0...v3.2.0)
|
31
|
+
|
32
|
+
**Merged pull requests:**
|
33
|
+
|
34
|
+
- Add missing `\#update` and `\#update!` persistance methods [\#27](https://github.com/rpush/modis/pull/27) ([dsantosmerino](https://github.com/dsantosmerino))
|
35
|
+
|
36
|
+
## [v3.1.0](https://github.com/rpush/modis/tree/v3.1.0) (2019-10-18)
|
37
|
+
|
38
|
+
[Full Changelog](https://github.com/rpush/modis/compare/3.0.0...v3.1.0)
|
39
|
+
|
40
|
+
**Merged pull requests:**
|
41
|
+
|
42
|
+
- Remove i18n dependency [\#26](https://github.com/rpush/modis/pull/26) ([aried3r](https://github.com/aried3r))
|
43
|
+
- Test with Rails 6, Ubuntu 18.04, Ruby 2.6 [\#25](https://github.com/rpush/modis/pull/25) ([aried3r](https://github.com/aried3r))
|
44
|
+
- Fix build status badge [\#22](https://github.com/rpush/modis/pull/22) ([jas14](https://github.com/jas14))
|
45
|
+
|
46
|
+
## [3.0.0](https://github.com/rpush/modis/tree/3.0.0) (2018-12-20)
|
47
|
+
|
48
|
+
[Full Changelog](https://github.com/rpush/modis/compare/v2.1.0...3.0.0)
|
49
|
+
|
50
|
+
**Merged pull requests:**
|
51
|
+
|
52
|
+
- Prep 3.0.0 release [\#21](https://github.com/rpush/modis/pull/21) ([garettarrowood](https://github.com/garettarrowood))
|
53
|
+
- Lock i18n version [\#20](https://github.com/rpush/modis/pull/20) ([garettarrowood](https://github.com/garettarrowood))
|
54
|
+
- Compatability with Rails 5.2's ActiveModel::Dirty [\#19](https://github.com/rpush/modis/pull/19) ([benlangfeld](https://github.com/benlangfeld))
|
55
|
+
- Resolve rubocop violations and lock version [\#17](https://github.com/rpush/modis/pull/17) ([garettarrowood](https://github.com/garettarrowood))
|
56
|
+
- Fix CI failures by resolving RuboCop offenses [\#12](https://github.com/rpush/modis/pull/12) ([garettarrowood](https://github.com/garettarrowood))
|
57
|
+
- get rid of old school rocket syntax [\#11](https://github.com/rpush/modis/pull/11) ([DmytroStepaniuk](https://github.com/DmytroStepaniuk))
|
58
|
+
- fix wrong readme example [\#10](https://github.com/rpush/modis/pull/10) ([DmytroStepaniuk](https://github.com/DmytroStepaniuk))
|
18
59
|
|
19
60
|
## v2.1.0
|
20
61
|
|
@@ -24,3 +65,6 @@
|
|
24
65
|
|
25
66
|
- Support MRI 2.2.2+ and JRuby 9k+ [#5](https://github.com/rpush/modis/pull/5)
|
26
67
|
- Remove YAML (de)serialization support [#5](https://github.com/rpush/modis/pull/5)
|
68
|
+
|
69
|
+
|
70
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
modis (4.0.1)
|
5
|
+
activemodel (>= 5.2)
|
6
|
+
activesupport (>= 5.2)
|
7
|
+
connection_pool (>= 2)
|
8
|
+
msgpack (>= 0.5)
|
9
|
+
redis (>= 3.0)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
activemodel (6.0.3.4)
|
15
|
+
activesupport (= 6.0.3.4)
|
16
|
+
activesupport (6.0.3.4)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (>= 0.7, < 2)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
22
|
+
appraisal (2.3.0)
|
23
|
+
bundler
|
24
|
+
rake
|
25
|
+
thor (>= 0.14.0)
|
26
|
+
ast (2.4.2)
|
27
|
+
cane (3.0.0)
|
28
|
+
parallel
|
29
|
+
codeclimate-test-reporter (1.0.7)
|
30
|
+
simplecov
|
31
|
+
concurrent-ruby (1.1.7)
|
32
|
+
connection_pool (2.2.3)
|
33
|
+
diff-lcs (1.4.4)
|
34
|
+
docile (1.3.2)
|
35
|
+
hiredis (0.6.3)
|
36
|
+
i18n (1.8.5)
|
37
|
+
concurrent-ruby (~> 1.0)
|
38
|
+
jaro_winkler (1.5.4)
|
39
|
+
minitest (5.14.2)
|
40
|
+
msgpack (1.3.3)
|
41
|
+
parallel (1.20.1)
|
42
|
+
parser (3.0.1.0)
|
43
|
+
ast (~> 2.4.1)
|
44
|
+
rainbow (3.0.0)
|
45
|
+
rake (13.0.1)
|
46
|
+
redis (4.6.0)
|
47
|
+
rexml (3.2.5)
|
48
|
+
rspec (3.9.0)
|
49
|
+
rspec-core (~> 3.9.0)
|
50
|
+
rspec-expectations (~> 3.9.0)
|
51
|
+
rspec-mocks (~> 3.9.0)
|
52
|
+
rspec-core (3.9.2)
|
53
|
+
rspec-support (~> 3.9.3)
|
54
|
+
rspec-expectations (3.9.2)
|
55
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
+
rspec-support (~> 3.9.0)
|
57
|
+
rspec-mocks (3.9.1)
|
58
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
59
|
+
rspec-support (~> 3.9.0)
|
60
|
+
rspec-support (3.9.3)
|
61
|
+
rubocop (0.81.0)
|
62
|
+
jaro_winkler (~> 1.5.1)
|
63
|
+
parallel (~> 1.10)
|
64
|
+
parser (>= 2.7.0.1)
|
65
|
+
rainbow (>= 2.2.2, < 4.0)
|
66
|
+
rexml
|
67
|
+
ruby-progressbar (~> 1.7)
|
68
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
69
|
+
ruby-progressbar (1.11.0)
|
70
|
+
simplecov (0.18.5)
|
71
|
+
docile (~> 1.1)
|
72
|
+
simplecov-html (~> 0.11)
|
73
|
+
simplecov-html (0.12.2)
|
74
|
+
thor (1.0.1)
|
75
|
+
thread_safe (0.3.6)
|
76
|
+
tzinfo (1.2.7)
|
77
|
+
thread_safe (~> 0.1)
|
78
|
+
unicode-display_width (1.7.0)
|
79
|
+
zeitwerk (2.4.0)
|
80
|
+
|
81
|
+
PLATFORMS
|
82
|
+
ruby
|
83
|
+
|
84
|
+
DEPENDENCIES
|
85
|
+
appraisal
|
86
|
+
cane
|
87
|
+
codeclimate-test-reporter
|
88
|
+
hiredis (>= 0.5)
|
89
|
+
modis!
|
90
|
+
rake
|
91
|
+
rspec
|
92
|
+
rubocop (= 0.81.0)
|
93
|
+
simplecov
|
94
|
+
|
95
|
+
BUNDLED WITH
|
96
|
+
2.2.21
|
data/README.md
CHANGED
@@ -8,21 +8,29 @@ ActiveModel + Redis with the aim to mimic ActiveRecord where possible.
|
|
8
8
|
|
9
9
|
## Requirements
|
10
10
|
|
11
|
-
Modis supports
|
11
|
+
Modis 4.0+ supports Rails 5.2 and higher, including Rails 6.1, as well as Ruby 2.3 and above, including Ruby 3.0. Tests are also being run with JRuby. For details please check the current CI setup.
|
12
|
+
|
13
|
+
For releases supporting older Rails versions such as 4.2-5.1 please check out the 3.x releases.
|
12
14
|
|
13
15
|
## Installation
|
14
16
|
|
15
17
|
Add this line to your application's Gemfile:
|
16
18
|
|
17
|
-
|
19
|
+
```ruby
|
20
|
+
gem 'modis'
|
21
|
+
```
|
18
22
|
|
19
23
|
And then execute:
|
20
24
|
|
21
|
-
|
25
|
+
```console
|
26
|
+
$ bundle
|
27
|
+
```
|
22
28
|
|
23
29
|
Or install it yourself as:
|
24
30
|
|
25
|
-
|
31
|
+
```console
|
32
|
+
$ gem install modis
|
33
|
+
```
|
26
34
|
|
27
35
|
## Usage
|
28
36
|
|
@@ -41,10 +49,10 @@ MyModel.create!(name: 'Ian', age: 28)
|
|
41
49
|
Modis, by default, creates an `all` index in redis in which it stores all the IDs for records created. As a result, a large amount of memory will be consumed if many ids are stored. The `all` index functionality can be turned off by using `enable_all_index`
|
42
50
|
|
43
51
|
```ruby
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
52
|
+
class MyModel
|
53
|
+
include Modis::Model
|
54
|
+
enable_all_index false
|
55
|
+
end
|
48
56
|
```
|
49
57
|
|
50
58
|
By disabling the `all` index functionality, the IDs of each record created won't be saved. As a side effect, using `all` finder method will raise a `IndexError` exception as we would not have enough information to fetch all records. See https://github.com/rpush/modis/pull/7 for more context.
|
data/benchmark/persistence.rb
CHANGED
data/lib/modis/finder.rb
CHANGED
@@ -20,8 +20,8 @@ module Modis
|
|
20
20
|
|
21
21
|
records = Modis.with_connection do |redis|
|
22
22
|
ids = redis.smembers(key_for(:all))
|
23
|
-
redis.pipelined do
|
24
|
-
ids.map { |id| record_for(
|
23
|
+
redis.pipelined do |pipeline|
|
24
|
+
ids.map { |id| record_for(pipeline, id) }
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -42,8 +42,13 @@ module Modis
|
|
42
42
|
raise RecordNotFound, "Couldn't find #{name} without an ID" if ids.empty?
|
43
43
|
|
44
44
|
records = Modis.with_connection do |redis|
|
45
|
-
|
46
|
-
|
45
|
+
if ids.count == 1
|
46
|
+
ids.map { |id| record_for(redis, id) }
|
47
|
+
else
|
48
|
+
redis.pipelined do |pipeline|
|
49
|
+
ids.map { |id| record_for(pipeline, id) }
|
50
|
+
end
|
51
|
+
end
|
47
52
|
end
|
48
53
|
|
49
54
|
models = records_to_models(records)
|
data/lib/modis/persistence.rb
CHANGED
@@ -135,13 +135,13 @@ module Modis
|
|
135
135
|
def destroy
|
136
136
|
self.class.transaction do |redis|
|
137
137
|
run_callbacks :destroy do
|
138
|
-
redis.pipelined do
|
139
|
-
remove_from_indexes(
|
138
|
+
redis.pipelined do |pipeline|
|
139
|
+
remove_from_indexes(pipeline)
|
140
140
|
if self.class.all_index_enabled?
|
141
|
-
|
142
|
-
|
141
|
+
pipeline.srem(self.class.key_for(:all), id)
|
142
|
+
pipeline.srem(self.class.sti_base_key_for(:all), id) if self.class.sti_child?
|
143
143
|
end
|
144
|
-
|
144
|
+
pipeline.del(key)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
@@ -185,7 +185,7 @@ module Modis
|
|
185
185
|
validate(args)
|
186
186
|
future = persist
|
187
187
|
|
188
|
-
if future && (future == :unchanged || future.value == 'OK')
|
188
|
+
if future && ((future.is_a?(Symbol) && future == :unchanged) || future.value == 'OK')
|
189
189
|
changes_applied
|
190
190
|
@new_record = false
|
191
191
|
true
|
@@ -210,19 +210,19 @@ module Modis
|
|
210
210
|
self.class.transaction do |redis|
|
211
211
|
run_callbacks :save do
|
212
212
|
run_callbacks callback do
|
213
|
-
redis.pipelined do
|
213
|
+
redis.pipelined do |pipeline|
|
214
214
|
attrs = coerced_attributes
|
215
215
|
key = self.class.sti_child? ? self.class.sti_base_key_for(id) : self.class.key_for(id)
|
216
|
-
future = attrs.any? ?
|
216
|
+
future = attrs.any? ? pipeline.hmset(key, attrs) : :unchanged
|
217
217
|
|
218
218
|
if new_record?
|
219
219
|
if self.class.all_index_enabled?
|
220
|
-
|
221
|
-
|
220
|
+
pipeline.sadd(self.class.key_for(:all), id)
|
221
|
+
pipeline.sadd(self.class.sti_base_key_for(:all), id) if self.class.sti_child?
|
222
222
|
end
|
223
|
-
add_to_indexes(
|
223
|
+
add_to_indexes(pipeline)
|
224
224
|
else
|
225
|
-
update_indexes(
|
225
|
+
update_indexes(pipeline)
|
226
226
|
end
|
227
227
|
end
|
228
228
|
end
|
data/lib/modis/transaction.rb
CHANGED
data/lib/modis/version.rb
CHANGED
data/lib/modis.rb
CHANGED
data/modis.gemspec
CHANGED
@@ -20,10 +20,9 @@ Gem::Specification.new do |gem|
|
|
20
20
|
|
21
21
|
gem.required_ruby_version = ">= 2.3.0"
|
22
22
|
|
23
|
-
gem.add_runtime_dependency 'activemodel', '>=
|
24
|
-
gem.add_runtime_dependency 'activesupport', '>=
|
23
|
+
gem.add_runtime_dependency 'activemodel', '>= 5.2'
|
24
|
+
gem.add_runtime_dependency 'activesupport', '>= 5.2'
|
25
25
|
gem.add_runtime_dependency 'redis', '>= 3.0'
|
26
|
-
gem.add_runtime_dependency 'hiredis', '>= 0.5'
|
27
26
|
gem.add_runtime_dependency 'connection_pool', '>= 2'
|
28
27
|
|
29
28
|
if defined? JRUBY_VERSION
|
@@ -38,6 +37,7 @@ Gem::Specification.new do |gem|
|
|
38
37
|
gem.add_development_dependency 'rspec'
|
39
38
|
gem.add_development_dependency 'codeclimate-test-reporter'
|
40
39
|
gem.add_development_dependency 'cane'
|
41
|
-
gem.add_development_dependency 'rubocop', '0.
|
40
|
+
gem.add_development_dependency 'rubocop', '0.81.0'
|
42
41
|
gem.add_development_dependency 'simplecov'
|
42
|
+
gem.add_development_dependency 'hiredis', '>= 0.5'
|
43
43
|
end
|
data/spec/persistence_spec.rb
CHANGED
@@ -111,8 +111,13 @@ describe Modis::Persistence do
|
|
111
111
|
|
112
112
|
it 'does not track the ID if the underlying Redis command failed' do
|
113
113
|
redis = double(hmset: double(value: nil), sadd: nil)
|
114
|
-
|
115
|
-
|
114
|
+
if Gem::Version.new(Redis::VERSION) > Gem::Version.new('4.6.0')
|
115
|
+
expect(model.class).to receive(:transaction).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline::Multi.new(redis)))
|
116
|
+
expect(redis).to receive(:pipelined).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline.new(redis)))
|
117
|
+
else
|
118
|
+
expect(model.class).to receive(:transaction).and_yield(redis)
|
119
|
+
expect(redis).to receive(:pipelined).and_yield(redis)
|
120
|
+
end
|
116
121
|
model.save
|
117
122
|
expect { model.class.find(model.id) }.to raise_error(Modis::RecordNotFound)
|
118
123
|
end
|
@@ -135,8 +140,13 @@ describe Modis::Persistence do
|
|
135
140
|
model.age = 11
|
136
141
|
redis = double
|
137
142
|
expect(redis).to receive(:hmset).with("modis:persistence_spec:mock_model:1", ["age", "\v"]).and_return(double(value: 'OK'))
|
138
|
-
|
139
|
-
|
143
|
+
if Gem::Version.new(Redis::VERSION) > Gem::Version.new('4.6.0')
|
144
|
+
expect(model.class).to receive(:transaction).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline::Multi.new(redis)))
|
145
|
+
expect(redis).to receive(:pipelined).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline.new(redis)))
|
146
|
+
else
|
147
|
+
expect(model.class).to receive(:transaction).and_yield(redis)
|
148
|
+
expect(redis).to receive(:pipelined).and_yield(redis)
|
149
|
+
end
|
140
150
|
model.save!
|
141
151
|
expect(model.age).to eq(11)
|
142
152
|
end
|
@@ -277,6 +287,8 @@ describe Modis::Persistence do
|
|
277
287
|
end
|
278
288
|
|
279
289
|
describe 'update_attributes!' do
|
290
|
+
around(:each) { |example| ActiveSupport::Deprecation.silence { example.run } }
|
291
|
+
|
280
292
|
it 'updates the given attributes' do
|
281
293
|
model.update_attributes!(name: 'Derp', age: 29)
|
282
294
|
model.reload
|
@@ -329,6 +341,8 @@ describe Modis::Persistence do
|
|
329
341
|
end
|
330
342
|
|
331
343
|
describe 'update_attributes' do
|
344
|
+
around(:each) { |example| ActiveSupport::Deprecation.silence { example.run } }
|
345
|
+
|
332
346
|
it 'updates the given attributes' do
|
333
347
|
model.update_attributes(name: 'Derp', age: 29)
|
334
348
|
model.reload
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Leitch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '5.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: redis
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: hiredis
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.5'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.5'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: connection_pool
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +156,14 @@ dependencies:
|
|
170
156
|
requirements:
|
171
157
|
- - '='
|
172
158
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
159
|
+
version: 0.81.0
|
174
160
|
type: :development
|
175
161
|
prerelease: false
|
176
162
|
version_requirements: !ruby/object:Gem::Requirement
|
177
163
|
requirements:
|
178
164
|
- - '='
|
179
165
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
166
|
+
version: 0.81.0
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: simplecov
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +178,20 @@ dependencies:
|
|
192
178
|
- - ">="
|
193
179
|
- !ruby/object:Gem::Version
|
194
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: hiredis
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0.5'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0.5'
|
195
195
|
description: ActiveModel + Redis
|
196
196
|
email:
|
197
197
|
- port001@gmail.com
|
@@ -206,6 +206,7 @@ files:
|
|
206
206
|
- Appraisals
|
207
207
|
- CHANGELOG.md
|
208
208
|
- Gemfile
|
209
|
+
- Gemfile.lock
|
209
210
|
- LICENSE.txt
|
210
211
|
- README.md
|
211
212
|
- Rakefile
|
@@ -213,11 +214,9 @@ files:
|
|
213
214
|
- benchmark/find.rb
|
214
215
|
- benchmark/persistence.rb
|
215
216
|
- benchmark/redis/connection/fakedis.rb
|
216
|
-
- gemfiles/rails_4.2.gemfile
|
217
|
-
- gemfiles/rails_5.0.gemfile
|
218
|
-
- gemfiles/rails_5.1.gemfile
|
219
217
|
- gemfiles/rails_5.2.gemfile
|
220
218
|
- gemfiles/rails_6.0.gemfile
|
219
|
+
- gemfiles/rails_6.1.gemfile
|
221
220
|
- lib/modis.rb
|
222
221
|
- lib/modis/attribute.rb
|
223
222
|
- lib/modis/configuration.rb
|
@@ -244,7 +243,7 @@ homepage: https://github.com/rpush/modis
|
|
244
243
|
licenses:
|
245
244
|
- MIT
|
246
245
|
metadata: {}
|
247
|
-
post_install_message:
|
246
|
+
post_install_message:
|
248
247
|
rdoc_options: []
|
249
248
|
require_paths:
|
250
249
|
- lib
|
@@ -259,8 +258,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
258
|
- !ruby/object:Gem::Version
|
260
259
|
version: '0'
|
261
260
|
requirements: []
|
262
|
-
rubygems_version: 3.
|
263
|
-
signing_key:
|
261
|
+
rubygems_version: 3.1.4
|
262
|
+
signing_key:
|
264
263
|
specification_version: 4
|
265
264
|
summary: ActiveModel + Redis
|
266
265
|
test_files:
|
data/gemfiles/rails_5.0.gemfile
DELETED