couch_potato 1.16.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +4 -4
- data/CHANGES.md +11 -0
- data/Rakefile +1 -1
- data/couch_potato.gemspec +1 -1
- data/gemfiles/{active_support_7_0 → active_support_7_2} +1 -1
- data/gemfiles/{active_support_7_1 → active_support_8_0} +1 -1
- data/lib/couch_potato/database.rb +3 -2
- data/lib/couch_potato/version.rb +1 -1
- data/spec/unit/caching_spec.rb +20 -16
- data/spec/unit/database_spec.rb +6 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 541fbb6f39b68bad864b70d9abb9f824ccf5b85a42b0a652282f9362c1fa4a5b
|
4
|
+
data.tar.gz: 9684d42c720dad80be99d3e225a12fc0db0d413e6ef987accceddc0d46bab526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e882ea7f5a1cfaeab4d62b610b5e34b18b7231f1923499a7bfc8b77b2f89a845303597d9ef0a85b681d39ff2ece08c465c7a98e2d4f74baa9c923f199136902
|
7
|
+
data.tar.gz: 2e6aef8d870ef30869c5154a7dd544f644592879ac8d46b3843854602eb378154850b07899c17f6fca99e0ca20e8b41598c116093ef9db2bf95c5fb89e312cf0
|
data/.github/workflows/ruby.yml
CHANGED
@@ -16,13 +16,13 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: ["3.
|
19
|
+
ruby: ["3.2", "3.3", "jruby"]
|
20
20
|
gemfile:
|
21
|
-
- "
|
22
|
-
- "
|
21
|
+
- "active_support_7_2"
|
22
|
+
- "active_support_8_0"
|
23
23
|
exclude:
|
24
24
|
- ruby: "jruby"
|
25
|
-
gemfile: "
|
25
|
+
gemfile: "active_support_8_0"
|
26
26
|
steps:
|
27
27
|
- uses: actions/checkout@v2
|
28
28
|
- name: Set up CouchDB
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
## Changes
|
2
2
|
|
3
|
+
# 1.18.0
|
4
|
+
|
5
|
+
- add testing Rails 7.2/8 on CI
|
6
|
+
- change gemspec to allow for Rails 8
|
7
|
+
- remove support for Rails < 7.2
|
8
|
+
|
9
|
+
# 1.17.0
|
10
|
+
|
11
|
+
- filter out nil ids for loading multiple documents
|
12
|
+
- cache nil documents
|
13
|
+
|
3
14
|
# 1.16.0
|
4
15
|
|
5
16
|
- add payload to ActiveSupport instrumentation calls
|
data/Rakefile
CHANGED
@@ -26,7 +26,7 @@ end
|
|
26
26
|
|
27
27
|
desc 'Run all specs for all gemfiles'
|
28
28
|
task :spec do
|
29
|
-
%w(
|
29
|
+
%w(7_2 8_0).each do |version|
|
30
30
|
Bundler.with_original_env do
|
31
31
|
puts "Running tests with ActiveSupport #{version.sub('_', '.')}"
|
32
32
|
sh "env BUNDLE_GEMFILE=gemfiles/active_support_#{version} bundle install"
|
data/couch_potato.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.version = CouchPotato::VERSION
|
14
14
|
s.platform = Gem::Platform::RUBY
|
15
15
|
|
16
|
-
s.add_dependency 'activemodel', ['>=
|
16
|
+
s.add_dependency 'activemodel', ['>= 7.2', '< 8.1']
|
17
17
|
s.add_dependency 'couchrest', '~>2.0.0'
|
18
18
|
s.add_dependency 'json', '~> 2.3'
|
19
19
|
|
@@ -149,7 +149,7 @@ module CouchPotato
|
|
149
149
|
|
150
150
|
cached = cache && cache[id]
|
151
151
|
if cache
|
152
|
-
if
|
152
|
+
if cache.key?(id)
|
153
153
|
ActiveSupport::Notifications.instrument('couch_potato.load.cached', id: id, doc: cached) do
|
154
154
|
cached
|
155
155
|
end
|
@@ -164,6 +164,7 @@ module CouchPotato
|
|
164
164
|
alias load load_document
|
165
165
|
|
166
166
|
def load_documents(ids)
|
167
|
+
ids = ids.compact
|
167
168
|
return [] if ids.empty?
|
168
169
|
|
169
170
|
uncached_ids = ids - (cache&.keys || [])
|
@@ -177,7 +178,7 @@ module CouchPotato
|
|
177
178
|
if cache
|
178
179
|
uncached_ids.each do |id|
|
179
180
|
doc = uncached_docs_by_id[id]
|
180
|
-
cache[id] = doc
|
181
|
+
cache[id] = doc
|
181
182
|
end
|
182
183
|
end
|
183
184
|
ids.filter_map { |id| (cached_docs_by_id[id]) || uncached_docs_by_id[id] }
|
data/lib/couch_potato/version.rb
CHANGED
data/spec/unit/caching_spec.rb
CHANGED
@@ -37,6 +37,15 @@ RSpec.describe 'database caching' do
|
|
37
37
|
db.load '1'
|
38
38
|
end
|
39
39
|
|
40
|
+
it 'caches nil' do
|
41
|
+
allow(couchrest_db).to receive(:get).with('1').and_return(nil)
|
42
|
+
|
43
|
+
db.load '1'
|
44
|
+
db.load '1'
|
45
|
+
|
46
|
+
expect(couchrest_db).to have_received(:get).with('1').exactly(1).times
|
47
|
+
end
|
48
|
+
|
40
49
|
it 'gets an object from the cache the 2nd time via #load!' do
|
41
50
|
expect(couchrest_db).to receive(:get).with('1').exactly(1).times
|
42
51
|
|
@@ -92,6 +101,17 @@ RSpec.describe 'database caching' do
|
|
92
101
|
expect(couchrest_db).to have_received(:bulk_load).with(['2']).exactly(1).times
|
93
102
|
end
|
94
103
|
|
104
|
+
it 'caches nil' do
|
105
|
+
allow(couchrest_db).to receive(:bulk_load).with(['1']).and_return('rows' => [{'doc' => nil}])
|
106
|
+
allow(couchrest_db).to receive(:bulk_load).with(['2']).and_return('rows' => [{'doc' => doc2}])
|
107
|
+
|
108
|
+
|
109
|
+
db.load_document(['1'])
|
110
|
+
db.load_document(['1', '2'])
|
111
|
+
|
112
|
+
expect(couchrest_db).to have_received(:bulk_load).with(['1']).exactly(1).times
|
113
|
+
end
|
114
|
+
|
95
115
|
it 'instruments the load call' do
|
96
116
|
allow(couchrest_db).to receive(:bulk_load).with(['1'])
|
97
117
|
.and_return('rows' => [{'doc' => doc1}])
|
@@ -137,22 +157,6 @@ RSpec.describe 'database caching' do
|
|
137
157
|
|
138
158
|
expect(result).to eql([doc1, doc2])
|
139
159
|
end
|
140
|
-
|
141
|
-
it 'does not cache documents that do not respond to id' do
|
142
|
-
doc1 = {
|
143
|
-
'id' => '1',
|
144
|
-
}
|
145
|
-
doc2 = {
|
146
|
-
'id' => '2',
|
147
|
-
}
|
148
|
-
allow(couchrest_db).to receive(:bulk_load).with(['1', '2'])
|
149
|
-
.and_return('rows' => [{'doc' => doc1}, {'doc' => doc2}])
|
150
|
-
|
151
|
-
db.load_document(['1', '2'])
|
152
|
-
db.load_document(['1', '2'])
|
153
|
-
|
154
|
-
expect(couchrest_db).to have_received(:bulk_load).with(['1', '2']).exactly(2).times
|
155
|
-
end
|
156
160
|
end
|
157
161
|
|
158
162
|
context 'when switching the database' do
|
data/spec/unit/database_spec.rb
CHANGED
@@ -92,6 +92,12 @@ describe CouchPotato::Database, 'load' do
|
|
92
92
|
db.load %w[1 2 3]
|
93
93
|
end
|
94
94
|
|
95
|
+
it 'does not request anything when nil is given' do
|
96
|
+
expect(db.load([nil])).to eq([])
|
97
|
+
|
98
|
+
expect(couchrest_db).not_to have_received(:bulk_load)
|
99
|
+
end
|
100
|
+
|
95
101
|
it 'returns only found documents' do
|
96
102
|
expect(db.load(%w[1 2 3]).size).to eq(2)
|
97
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couch_potato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Lang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '8.
|
22
|
+
version: '8.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '7.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '8.
|
32
|
+
version: '8.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: couchrest
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,8 +130,8 @@ files:
|
|
130
130
|
- Rakefile
|
131
131
|
- couch_potato-rspec.gemspec
|
132
132
|
- couch_potato.gemspec
|
133
|
-
- gemfiles/
|
134
|
-
- gemfiles/
|
133
|
+
- gemfiles/active_support_7_2
|
134
|
+
- gemfiles/active_support_8_0
|
135
135
|
- init.rb
|
136
136
|
- lib/core_ext/date.rb
|
137
137
|
- lib/core_ext/time.rb
|