couch_potato 1.12.1 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -7
- data/CHANGES.md +7 -0
- data/Rakefile +2 -2
- data/couch_potato-rspec.gemspec +1 -1
- data/couch_potato.gemspec +2 -2
- data/gemfiles/active_support_7_0 +1 -1
- data/gemfiles/{active_support_6_1 → active_support_7_1} +1 -1
- data/lib/couch_potato/persistence/properties.rb +5 -1
- data/lib/couch_potato/persistence/simple_property.rb +2 -1
- data/lib/couch_potato/persistence/type_caster.rb +1 -1
- data/lib/couch_potato/version.rb +2 -2
- data/spec/unit/attributes_spec.rb +5 -57
- metadata +8 -9
- data/gemfiles/active_support_6_0 +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c36fc0534a7564b1fcf3b2a59ca91e3e4e97452c2a74d77e30540eb4b7617211
|
4
|
+
data.tar.gz: b1583818a743459e8ab86d88350f7ad5c6953c058c3b49c8b90da50610bdd197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ceffb27b13b2cf9825cd5fcf507bb0e13a6ed9b5caa612fd1f5f27ba98934eb9dae34c4f4dc70835352a9176bc4562e49da12d489b925ebbeb37a3c9eaa964f4
|
7
|
+
data.tar.gz: c5e01a2d0d83ea11b14a618f218fe3ff66af35be893a4d74644089938b852045c52a8e1d8ecf31b53e70396737f9db0a8849ef0fbacd843c89137ec4d8bfc0e2
|
data/.github/workflows/ruby.yml
CHANGED
@@ -16,18 +16,13 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: [
|
19
|
+
ruby: ["3.0", "3.1", "3.2", "jruby"]
|
20
20
|
gemfile:
|
21
|
-
- "active_support_6_0"
|
22
|
-
- "active_support_6_1"
|
23
21
|
- "active_support_7_0"
|
22
|
+
- "active_support_7_1"
|
24
23
|
exclude:
|
25
24
|
- ruby: "jruby"
|
26
25
|
gemfile: "active_support_7_0"
|
27
|
-
- ruby: "3.0"
|
28
|
-
gemfile: "active_support_6_0"
|
29
|
-
- ruby: "3.1"
|
30
|
-
gemfile: "active_support_6_0"
|
31
26
|
steps:
|
32
27
|
- uses: actions/checkout@v2
|
33
28
|
- name: Set up CouchDB
|
data/CHANGES.md
CHANGED
data/Rakefile
CHANGED
@@ -26,8 +26,8 @@ end
|
|
26
26
|
|
27
27
|
desc 'Run all specs for all gemfiles'
|
28
28
|
task :spec do
|
29
|
-
%w(7_0
|
30
|
-
Bundler.
|
29
|
+
%w(7_1 7_0).each do |version|
|
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"
|
33
33
|
sh "env BUNDLE_GEMFILE=gemfiles/active_support_#{version} bundle exec rake spec_unit spec_functional"
|
data/couch_potato-rspec.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.version = CouchPotato::RSPEC_VERSION
|
12
12
|
s.platform = Gem::Platform::RUBY
|
13
13
|
|
14
|
-
s.add_dependency 'rspec', '~>3.
|
14
|
+
s.add_dependency 'rspec', '~>3.12'
|
15
15
|
s.add_development_dependency 'rake'
|
16
16
|
s.add_dependency 'execjs', '~>2.7'
|
17
17
|
|
data/couch_potato.gemspec
CHANGED
@@ -13,12 +13,12 @@ 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', ['>= 5.0', '<
|
16
|
+
s.add_dependency 'activemodel', ['>= 5.0', '< 8.0']
|
17
17
|
s.add_dependency 'couchrest', '~>2.0.0'
|
18
18
|
s.add_dependency 'json', '~> 2.3'
|
19
19
|
|
20
20
|
s.add_development_dependency 'rake', '~>12.0'
|
21
|
-
s.add_development_dependency 'rspec', '~>3.
|
21
|
+
s.add_development_dependency 'rspec', '~>3.12.0'
|
22
22
|
s.add_development_dependency 'timecop'
|
23
23
|
s.add_development_dependency 'tzinfo'
|
24
24
|
|
data/gemfiles/active_support_7_0
CHANGED
@@ -93,7 +93,11 @@ module CouchPotato
|
|
93
93
|
active_support_module.module_eval do
|
94
94
|
undef_method(name) if instance_methods.include?(name)
|
95
95
|
end
|
96
|
-
cache =
|
96
|
+
cache = if respond_to?(:attribute_method_matchers_cache, true) # activemodel 7.0
|
97
|
+
send(:attribute_method_matchers_cache)
|
98
|
+
else # activemodel 7.1
|
99
|
+
send(:attribute_method_patterns_cache)
|
100
|
+
end
|
97
101
|
cache.delete(name)
|
98
102
|
|
99
103
|
define_attribute_method name
|
@@ -15,12 +15,13 @@ module CouchPotato
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class SimpleProperty #:nodoc:
|
18
|
-
attr_accessor :name, :type
|
18
|
+
attr_accessor :name, :type, :default_value
|
19
19
|
|
20
20
|
def initialize(owner_clazz, name, options = {})
|
21
21
|
self.name = name
|
22
22
|
@setter_name = "#{name}="
|
23
23
|
self.type = options[:type]
|
24
|
+
self.default_value = options[:default]
|
24
25
|
@type_caster = TypeCaster.new
|
25
26
|
owner_clazz.send :include, PropertyMethods unless owner_clazz.ancestors.include?(PropertyMethods)
|
26
27
|
|
@@ -32,7 +32,7 @@ module CouchPotato
|
|
32
32
|
def cast_native(value, type)
|
33
33
|
if type && !value.is_a?(type)
|
34
34
|
|
35
|
-
if %w[Integer Bignum
|
35
|
+
if %w[Integer Bignum].include?(type.to_s)
|
36
36
|
value.to_s.scan(NUMBER_REGEX).join.to_d.round unless value.blank?
|
37
37
|
elsif type == Float
|
38
38
|
value.to_s.scan(NUMBER_REGEX).join.to_f unless value.blank?
|
data/lib/couch_potato/version.rb
CHANGED
@@ -9,7 +9,6 @@ end
|
|
9
9
|
class Plant
|
10
10
|
include CouchPotato::Persistence
|
11
11
|
property :leaf_count
|
12
|
-
property :typed_leaf_count, type: Fixnum
|
13
12
|
property :integer_something, type: Integer
|
14
13
|
property :typed_leaf_size, type: Float
|
15
14
|
property :branch, type: Branch
|
@@ -42,7 +41,7 @@ describe 'attributes' do
|
|
42
41
|
|
43
42
|
expect(plant.attributes).to eq('leaf_count' => 1, 'created_at' => nil,
|
44
43
|
'integer_something' => nil,
|
45
|
-
'updated_at' => nil,
|
44
|
+
'updated_at' => nil,
|
46
45
|
'typed_leaf_size' => nil, 'branch' => nil)
|
47
46
|
end
|
48
47
|
|
@@ -112,25 +111,25 @@ describe 'attributes' do
|
|
112
111
|
end
|
113
112
|
|
114
113
|
describe 'integer' do
|
115
|
-
it 'rounds a float to
|
114
|
+
it 'rounds a float to an integer' do
|
116
115
|
@plant.integer_something = 4.5
|
117
116
|
|
118
117
|
expect(@plant.integer_something).to eq(5)
|
119
118
|
end
|
120
119
|
|
121
|
-
it 'converts a string into
|
120
|
+
it 'converts a string into an integer' do
|
122
121
|
@plant.integer_something = '4'
|
123
122
|
|
124
123
|
expect(@plant.integer_something).to eq(4)
|
125
124
|
end
|
126
125
|
|
127
|
-
it 'converts a string into a negative
|
126
|
+
it 'converts a string into a negative integer' do
|
128
127
|
@plant.integer_something = '-4'
|
129
128
|
|
130
129
|
expect(@plant.integer_something).to eq(-4)
|
131
130
|
end
|
132
131
|
|
133
|
-
it 'leaves
|
132
|
+
it 'leaves an integer as is' do
|
134
133
|
@plant.integer_something = 4
|
135
134
|
|
136
135
|
expect(@plant.integer_something).to eq(4)
|
@@ -161,57 +160,6 @@ describe 'attributes' do
|
|
161
160
|
end
|
162
161
|
end
|
163
162
|
|
164
|
-
|
165
|
-
describe 'fixnum' do
|
166
|
-
it 'rounds a float to a fixnum' do
|
167
|
-
@plant.typed_leaf_count = 4.5
|
168
|
-
|
169
|
-
expect(@plant.typed_leaf_count).to eq(5)
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'converts a string into a fixnum' do
|
173
|
-
@plant.typed_leaf_count = '4'
|
174
|
-
|
175
|
-
expect(@plant.typed_leaf_count).to eq(4)
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'converts a string into a negative fixnum' do
|
179
|
-
@plant.typed_leaf_count = '-4'
|
180
|
-
|
181
|
-
expect(@plant.typed_leaf_count).to eq(-4)
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'leaves a fixnum as is' do
|
185
|
-
@plant.typed_leaf_count = 4
|
186
|
-
|
187
|
-
expect(@plant.typed_leaf_count).to eq(4)
|
188
|
-
end
|
189
|
-
|
190
|
-
it 'leaves nil as is' do
|
191
|
-
@plant.typed_leaf_count = nil
|
192
|
-
|
193
|
-
expect(@plant.typed_leaf_count).to be_nil
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'sets the attributes to zero if a string given' do
|
197
|
-
@plant.typed_leaf_count = 'x'
|
198
|
-
|
199
|
-
expect(@plant.typed_leaf_count).to eq(0)
|
200
|
-
end
|
201
|
-
|
202
|
-
it 'parses numbers out of a string' do
|
203
|
-
@plant.typed_leaf_count = 'x123'
|
204
|
-
|
205
|
-
expect(@plant.typed_leaf_count).to eq(123)
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'sets the attributes to nil if given a blank string' do
|
209
|
-
@plant.typed_leaf_count = ''
|
210
|
-
|
211
|
-
expect(@plant.typed_leaf_count).to be_nil
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
163
|
context 'float' do
|
216
164
|
it 'converts a number in a string with a decimal place' do
|
217
165
|
@plant.typed_leaf_size = '0.5001'
|
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.13.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: 2024-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: couchrest
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 3.
|
81
|
+
version: 3.12.0
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 3.
|
88
|
+
version: 3.12.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: timecop
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,9 +130,8 @@ files:
|
|
130
130
|
- Rakefile
|
131
131
|
- couch_potato-rspec.gemspec
|
132
132
|
- couch_potato.gemspec
|
133
|
-
- gemfiles/active_support_6_0
|
134
|
-
- gemfiles/active_support_6_1
|
135
133
|
- gemfiles/active_support_7_0
|
134
|
+
- gemfiles/active_support_7_1
|
136
135
|
- init.rb
|
137
136
|
- lib/core_ext/date.rb
|
138
137
|
- lib/core_ext/time.rb
|
@@ -231,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
230
|
- !ruby/object:Gem::Version
|
232
231
|
version: '0'
|
233
232
|
requirements: []
|
234
|
-
rubygems_version: 3.
|
233
|
+
rubygems_version: 3.4.7
|
235
234
|
signing_key:
|
236
235
|
specification_version: 4
|
237
236
|
summary: Ruby persistence layer for CouchDB
|