pricehubble 2.1.0 → 2.3.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/release.yml +2 -2
- data/.github/workflows/test.yml +2 -2
- data/.rubocop.yml +6 -51
- data/Appraisals +0 -5
- data/CHANGELOG.md +9 -0
- data/Dockerfile +1 -1
- data/Envfile +1 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/Makefile +3 -2
- data/README.md +2 -2
- data/gemfiles/rails_7.2.gemfile +1 -1
- data/gemfiles/rails_8.0.gemfile +1 -1
- data/gemfiles/rails_8.1.gemfile +1 -1
- data/lib/price_hubble/client/base.rb +0 -3
- data/lib/price_hubble/client/dossiers.rb +0 -14
- data/lib/price_hubble/client/utils/response.rb +0 -4
- data/lib/price_hubble/client/valuation.rb +0 -11
- data/lib/price_hubble/client.rb +1 -1
- data/lib/price_hubble/core_ext/hash.rb +1 -5
- data/lib/price_hubble/entity/authentication.rb +1 -1
- data/lib/price_hubble/entity/concern/associations.rb +1 -17
- data/lib/price_hubble/entity/concern/attributes.rb +2 -11
- data/lib/price_hubble/identity.rb +1 -1
- data/lib/price_hubble/utils/bangers.rb +1 -5
- data/lib/price_hubble/utils/decision.rb +2 -2
- data/lib/price_hubble/version.rb +1 -1
- data/pricehubble.gemspec +3 -3
- metadata +6 -8
- data/gemfiles/rails_6.1.gemfile +0 -26
- data/gemfiles/rails_7.1.gemfile +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89f3b68ce765efc6959c7c69cd2aabc052c4bc89bfd0f1a0a0b3e6f49f807d6f
|
|
4
|
+
data.tar.gz: 9d5f1b942cceb09a113bc133844f3e7b83cf6288da3fc6b659b056eef628d4cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8fc3f28932bcf73a079e64174fd02041361d9f243e8923b516cc264822cad0e68588c3721fe04ea72415d669abfb7eb918729757eae95f75d2ffadefbc06ce34
|
|
7
|
+
data.tar.gz: 6ac02c81da2f70cfed922a3343058b600849dfbb67a89b84b35db4707b15fbf5d8beacb6507dbf4f2035b8536943c39f23266aa2d126b0b55359c9b76519fe56
|
data/.github/workflows/test.yml
CHANGED
|
@@ -18,8 +18,8 @@ jobs:
|
|
|
18
18
|
strategy:
|
|
19
19
|
fail-fast: false
|
|
20
20
|
matrix:
|
|
21
|
-
ruby: ['3.
|
|
22
|
-
rails: ['7.
|
|
21
|
+
ruby: ['3.3', '3.4', '4.0']
|
|
22
|
+
rails: ['7.2', '8.0', '8.1']
|
|
23
23
|
env:
|
|
24
24
|
BUNDLE_GEMFILE: 'gemfiles/rails_${{ matrix.rails }}.gemfile'
|
|
25
25
|
steps:
|
data/.rubocop.yml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
inherit_from:
|
|
2
|
+
- https://potpourri.hausgold.de/config/rubocop.yml
|
|
3
|
+
- https://potpourri.hausgold.de/config/rubocop-gem.yml
|
|
4
|
+
|
|
1
5
|
plugins:
|
|
2
6
|
- rubocop-rspec
|
|
3
7
|
- rubocop-rails
|
|
@@ -5,63 +9,29 @@ plugins:
|
|
|
5
9
|
Rails:
|
|
6
10
|
Enabled: true
|
|
7
11
|
|
|
8
|
-
Style/Documentation:
|
|
9
|
-
Enabled: true
|
|
10
|
-
|
|
11
12
|
AllCops:
|
|
12
13
|
NewCops: enable
|
|
13
14
|
SuggestExtensions: false
|
|
14
15
|
DisplayCopNames: true
|
|
15
|
-
TargetRubyVersion: 3.
|
|
16
|
-
TargetRailsVersion: 7.
|
|
16
|
+
TargetRubyVersion: 3.3
|
|
17
|
+
TargetRailsVersion: 7.2
|
|
17
18
|
Exclude:
|
|
18
19
|
- bin/**/*
|
|
19
20
|
- vendor/**/*
|
|
20
21
|
- build/**/*
|
|
21
22
|
- gemfiles/**/*
|
|
22
23
|
|
|
23
|
-
Metrics/BlockLength:
|
|
24
|
-
Exclude:
|
|
25
|
-
- Rakefile
|
|
26
|
-
- '*.gemspec'
|
|
27
|
-
- spec/**/*.rb
|
|
28
|
-
- '**/*.rake'
|
|
29
|
-
- doc/**/*.rb
|
|
30
|
-
# Concerns and middlewares contain by nature long blocks
|
|
31
|
-
- lib/price*hubble/entity/concern/**/*.rb
|
|
32
|
-
- lib/price*hubble/client/request/**/*.rb
|
|
33
|
-
- lib/price*hubble/client/response/**/*.rb
|
|
34
|
-
|
|
35
24
|
# Our examples use +pp+ a lot
|
|
36
25
|
Lint/Debugger:
|
|
37
26
|
Exclude:
|
|
38
27
|
- doc/examples/**/*.rb
|
|
39
28
|
|
|
40
|
-
# MFA is not yet enabled for our gems yet.
|
|
41
|
-
Gemspec/RequireMFA:
|
|
42
|
-
Enabled: false
|
|
43
|
-
|
|
44
|
-
# Document all the things.
|
|
45
|
-
Style/DocumentationMethod:
|
|
46
|
-
Enabled: true
|
|
47
|
-
RequireForNonPublicMethods: true
|
|
48
|
-
|
|
49
29
|
# It's a deliberate idiom in RSpec.
|
|
50
30
|
# See: https://github.com/bbatsov/rubocop/issues/4222
|
|
51
31
|
Lint/AmbiguousBlockAssociation:
|
|
52
32
|
Exclude:
|
|
53
33
|
- "spec/**/*"
|
|
54
34
|
|
|
55
|
-
# Because +expect_any_instance_of().to have_received()+ is not
|
|
56
|
-
# supported with the +with(hash_including)+ matchers
|
|
57
|
-
RSpec/MessageSpies:
|
|
58
|
-
EnforcedStyle: receive
|
|
59
|
-
|
|
60
|
-
# Because nesting makes sense here to group the feature tests
|
|
61
|
-
# more effective. This increases maintainability.
|
|
62
|
-
RSpec/NestedGroups:
|
|
63
|
-
Max: 4
|
|
64
|
-
|
|
65
35
|
# Disable regular Rails spec paths.
|
|
66
36
|
Rails/FilePath:
|
|
67
37
|
Enabled: false
|
|
@@ -75,26 +45,11 @@ Lint/ShadowingOuterLocalVariable:
|
|
|
75
45
|
Exclude:
|
|
76
46
|
- "doc/**/*"
|
|
77
47
|
|
|
78
|
-
# We stay at 80 characters per line.
|
|
79
|
-
# See: https://rubystyle.guide/#max-line-length
|
|
80
|
-
Layout/LineLength:
|
|
81
|
-
Max: 80
|
|
82
|
-
|
|
83
|
-
# We use memoized helpers all over the place to construct inputs and output
|
|
84
|
-
# which can be customized at nested contexts easily.
|
|
85
|
-
RSpec/MultipleMemoizedHelpers:
|
|
86
|
-
Enabled: false
|
|
87
|
-
|
|
88
48
|
# That are false-positives because we implement similar working
|
|
89
49
|
# helpers for associations like +.has_one+.
|
|
90
50
|
Rails/ReflectionClassName:
|
|
91
51
|
Enabled: false
|
|
92
52
|
|
|
93
|
-
# A very nice feature, but it does not work for non-method code parts atow.
|
|
94
|
-
# So just disabling it for now.
|
|
95
|
-
Style/DocumentDynamicEvalDefinition:
|
|
96
|
-
Enabled: false
|
|
97
|
-
|
|
98
53
|
# For our examples it's fine to use +pp+ and +puts+,
|
|
99
54
|
# as they are living examples.
|
|
100
55
|
Rails/Output:
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
* TODO: Replace this bullet point with an actual description of a change.
|
|
4
4
|
|
|
5
|
+
### 2.3.0 (26 December 2025)
|
|
6
|
+
|
|
7
|
+
* Added Ruby 4.0 support ([#23](https://github.com/hausgold/pricehubble/pull/23))
|
|
8
|
+
* Dropped Ruby 3.2 and Rails 7.1 support ([#22](https://github.com/hausgold/pricehubble/pull/22))
|
|
9
|
+
|
|
10
|
+
### 2.2.0 (19 December 2025)
|
|
11
|
+
|
|
12
|
+
* Migrated to a shared Rubocop configuration for HAUSGOLD gems ([#21](https://github.com/hausgold/pricehubble/pull/21))
|
|
13
|
+
|
|
5
14
|
### 2.1.0 (23 October 2025)
|
|
6
15
|
|
|
7
16
|
* Added support for Rails 8.1 ([#19](https://github.com/hausgold/pricehubble/pull/19))
|
data/Dockerfile
CHANGED
data/Envfile
CHANGED
data/Gemfile
CHANGED
|
@@ -9,7 +9,7 @@ gemspec
|
|
|
9
9
|
|
|
10
10
|
# Development dependencies
|
|
11
11
|
gem 'appraisal', '~> 2.4'
|
|
12
|
-
gem 'bundler', '
|
|
12
|
+
gem 'bundler', '>= 2.6', '< 5'
|
|
13
13
|
gem 'countless', '~> 2.2'
|
|
14
14
|
# TODO: Remove the upper lock when
|
|
15
15
|
# https://github.com/thoughtbot/factory_bot/issues/1614 is solved.
|
data/LICENSE
CHANGED
data/Makefile
CHANGED
|
@@ -85,7 +85,8 @@ all:
|
|
|
85
85
|
install:
|
|
86
86
|
# Install the dependencies
|
|
87
87
|
@$(MKDIR) -p $(VENDOR_DIR)
|
|
88
|
-
@$(call run-shell,$(BUNDLE)
|
|
88
|
+
@$(call run-shell,$(BUNDLE) config set --local path '$(VENDOR_DIR)')
|
|
89
|
+
@$(call run-shell,$(BUNDLE) check || $(BUNDLE) install)
|
|
89
90
|
@$(call run-shell,$(BUNDLE) exec $(APPRAISAL) install)
|
|
90
91
|
|
|
91
92
|
update:
|
|
@@ -117,7 +118,7 @@ test-style: \
|
|
|
117
118
|
test-style-ruby:
|
|
118
119
|
# Run the static code analyzer (rubocop)
|
|
119
120
|
@$(call run-shell,$(BUNDLE) exec $(RUBOCOP) -a \
|
|
120
|
-
|| ($(TEST) $$($(RUBY_VERSION)) != '3.
|
|
121
|
+
|| ($(TEST) $$($(RUBY_VERSION)) != '3.3' && true))
|
|
121
122
|
|
|
122
123
|
clean:
|
|
123
124
|
# Clean the dependencies
|
data/README.md
CHANGED
|
@@ -123,7 +123,7 @@ PriceHubble.identity.expires_at
|
|
|
123
123
|
|
|
124
124
|
The pricehubble gem allows you to decide how to react on errors on a
|
|
125
125
|
per-request basis. (except the transparent authentication) All request
|
|
126
|
-
performing methods are
|
|
126
|
+
performing methods are shipped in a bang and non-bang variant.
|
|
127
127
|
|
|
128
128
|
The bang variants (eg. `PriceHubble::ValuationRequest#perform!`, mind
|
|
129
129
|
the exclamation mark at the end) will raise an child instance of the
|
|
@@ -133,7 +133,7 @@ occur. This comes in handy on asynchronous jobs which are retried on
|
|
|
133
133
|
exceptions.
|
|
134
134
|
|
|
135
135
|
The non-bang variants (eg. `PriceHubble::ValuationRequest#perform`,
|
|
136
|
-
without the exclamation mark)
|
|
136
|
+
without the exclamation mark) won't raise and just return empty results
|
|
137
137
|
(eg. `false` or `[]`). This might me comfortable in complex control
|
|
138
138
|
flows or when you do not care if one out of 100 times the data is
|
|
139
139
|
missing. But watch out for bad/invalid requests you might mask with
|
data/gemfiles/rails_7.2.gemfile
CHANGED
data/gemfiles/rails_8.0.gemfile
CHANGED
data/gemfiles/rails_8.1.gemfile
CHANGED
|
@@ -23,8 +23,6 @@ module PriceHubble
|
|
|
23
23
|
# end
|
|
24
24
|
#
|
|
25
25
|
# @param con [Faraday::Connection] the connection object
|
|
26
|
-
#
|
|
27
|
-
# rubocop:disable Metrics/MethodLength -- because of the middleware list
|
|
28
26
|
def configure(con)
|
|
29
27
|
con.use :instrumentation
|
|
30
28
|
|
|
@@ -44,7 +42,6 @@ module PriceHubble
|
|
|
44
42
|
|
|
45
43
|
con.adapter Faraday.default_adapter
|
|
46
44
|
end
|
|
47
|
-
# rubocop:enable Metrics/MethodLength
|
|
48
45
|
|
|
49
46
|
# Create a new Faraday connection on the first shot, and pass the cached
|
|
50
47
|
# connection object on subsequent calls.
|
|
@@ -10,9 +10,6 @@ module PriceHubble
|
|
|
10
10
|
# @param args [Hash{Symbol => Mixed}] additional arguments
|
|
11
11
|
# @return [PriceHubble::Dossier, nil] the PriceHubble dossier,
|
|
12
12
|
# or +nil+ on error
|
|
13
|
-
#
|
|
14
|
-
# rubocop:disable Metrics/MethodLength -- because thats the bare minimum
|
|
15
|
-
# handling is quite complex
|
|
16
13
|
def create_dossier(entity, **args)
|
|
17
14
|
res = connection.post do |req|
|
|
18
15
|
req.path = '/api/v1/dossiers'
|
|
@@ -26,7 +23,6 @@ module PriceHubble
|
|
|
26
23
|
successful?(res)
|
|
27
24
|
end
|
|
28
25
|
end
|
|
29
|
-
# rubocop:enable Metrics/MethodLength
|
|
30
26
|
|
|
31
27
|
# Generates a permalink for the specified dossier which will expire after
|
|
32
28
|
# the set number of days.
|
|
@@ -35,10 +31,6 @@ module PriceHubble
|
|
|
35
31
|
# @param ttl [ActiveSupport::Duration] the time to live for the new link
|
|
36
32
|
# @param locale [String] the user frontend locale
|
|
37
33
|
# @param args [Hash{Symbol => Mixed}] additional arguments
|
|
38
|
-
#
|
|
39
|
-
# rubocop:disable Metrics/MethodLength -- because thats the bare minimum
|
|
40
|
-
# rubocop:disable Metrics/AbcSize -- because the decission handling is
|
|
41
|
-
# quite complex
|
|
42
34
|
def share_dossier(entity, ttl:, locale:, **args)
|
|
43
35
|
res = connection.post do |req|
|
|
44
36
|
req.path = '/api/v1/dossiers/links'
|
|
@@ -57,16 +49,11 @@ module PriceHubble
|
|
|
57
49
|
successful?(res)
|
|
58
50
|
end
|
|
59
51
|
end
|
|
60
|
-
# rubocop:enable Metrics/MethodLength
|
|
61
|
-
# rubocop:enable Metrics/AbcSize
|
|
62
52
|
|
|
63
53
|
# Delete a dossier entity.
|
|
64
54
|
#
|
|
65
55
|
# @param entity [PriceHubble::Dossier] the entity to delete
|
|
66
56
|
# @param args [Hash{Symbol => Mixed}] additional arguments
|
|
67
|
-
#
|
|
68
|
-
# rubocop:disable Metrics/MethodLength -- because thats the bare
|
|
69
|
-
# minimumbecause the decission handling is quite complex
|
|
70
57
|
def delete_dossier(entity, **args)
|
|
71
58
|
res = connection.delete do |req|
|
|
72
59
|
req.path = "/api/v1/dossiers/#{entity.id}"
|
|
@@ -82,7 +69,6 @@ module PriceHubble
|
|
|
82
69
|
end
|
|
83
70
|
end
|
|
84
71
|
|
|
85
|
-
# rubocop:enable Metrics/MethodLength
|
|
86
72
|
# Update a dossier entity.
|
|
87
73
|
#
|
|
88
74
|
# TODO: Implement this.
|
|
@@ -4,9 +4,6 @@ module PriceHubble
|
|
|
4
4
|
module Client
|
|
5
5
|
module Utils
|
|
6
6
|
# Some helpers to work with responses in a general way.
|
|
7
|
-
#
|
|
8
|
-
# rubocop:disable Metrics/BlockLength -- because of
|
|
9
|
-
# ActiveSupport::Concern
|
|
10
7
|
module Response
|
|
11
8
|
extend ActiveSupport::Concern
|
|
12
9
|
|
|
@@ -82,7 +79,6 @@ module PriceHubble
|
|
|
82
79
|
end
|
|
83
80
|
end
|
|
84
81
|
end
|
|
85
|
-
# rubocop:enable Metrics/BlockLength
|
|
86
82
|
end
|
|
87
83
|
end
|
|
88
84
|
end
|
|
@@ -10,9 +10,6 @@ module PriceHubble
|
|
|
10
10
|
# @param args [Hash{Symbol => Mixed}] the authentication credentials
|
|
11
11
|
# @return [Array<PriceHubble::Valuation>, nil] the valuation results,
|
|
12
12
|
# or +nil+ on error
|
|
13
|
-
#
|
|
14
|
-
# rubocop:disable Metrics/MethodLength -- because of the request handling
|
|
15
|
-
# rubocop:disable Metrics/AbcSize -- ditto
|
|
16
13
|
def property_value(request, **args)
|
|
17
14
|
data = request.attributes(sanitize: true)
|
|
18
15
|
res = connection.post do |req|
|
|
@@ -27,8 +24,6 @@ module PriceHubble
|
|
|
27
24
|
successful?(res)
|
|
28
25
|
end
|
|
29
26
|
end
|
|
30
|
-
# rubocop:enable Metrics/MethodLength
|
|
31
|
-
# rubocop:enable Metrics/AbcSize
|
|
32
27
|
|
|
33
28
|
# Map and assign the valuation response to our local
|
|
34
29
|
# +PriceHubble::Valuation+ representation. While taking care of the
|
|
@@ -41,10 +36,6 @@ module PriceHubble
|
|
|
41
36
|
# valuations data
|
|
42
37
|
# @param request [PriceHubble::ValuationRequest] the original request
|
|
43
38
|
# @return [Proc] the valuation mapping code
|
|
44
|
-
#
|
|
45
|
-
# rubocop:disable Metrics/MethodLength -- because of the request to
|
|
46
|
-
# response mapping
|
|
47
|
-
# rubocop:disable Metrics/AbcSize -- ditto
|
|
48
39
|
def assign_valuations(data, request)
|
|
49
40
|
lambda do
|
|
50
41
|
# valuations[i][j] contains the valuation for property i on date j
|
|
@@ -62,8 +53,6 @@ module PriceHubble
|
|
|
62
53
|
end.flatten
|
|
63
54
|
end
|
|
64
55
|
end
|
|
65
|
-
# rubocop:enable Metrics/MethodLength
|
|
66
|
-
# rubocop:enable Metrics/AbcSize
|
|
67
56
|
|
|
68
57
|
# Generate bang method variants
|
|
69
58
|
bangers :property_value
|
data/lib/price_hubble/client.rb
CHANGED
|
@@ -7,7 +7,7 @@ module PriceHubble
|
|
|
7
7
|
|
|
8
8
|
class_methods do
|
|
9
9
|
# Get a low level client for the requested application. This returns an
|
|
10
|
-
# already
|
|
10
|
+
# already instantiated client object, ready to use.
|
|
11
11
|
#
|
|
12
12
|
# @param name [Symbol, String] the client name
|
|
13
13
|
# @return [PriceHubble::Client::Base] a compatible client instance
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# All our Ruby core extensions for the +Hash+ class.
|
|
4
4
|
class Hash
|
|
5
5
|
# Perform the regular +Hash#compact+ method on the object but takes care of
|
|
6
|
-
# deeply nested
|
|
6
|
+
# deeply nested hashes.
|
|
7
7
|
#
|
|
8
8
|
# @return [Hash]
|
|
9
9
|
def deep_compact
|
|
@@ -32,9 +32,6 @@ class Hash
|
|
|
32
32
|
#
|
|
33
33
|
# @param object [Mixed] the object to compact
|
|
34
34
|
# @return [Mixed] the compacted object
|
|
35
|
-
#
|
|
36
|
-
# rubocop:disable Metrics/MethodLength -- because of the extra empty hash
|
|
37
|
-
# compaction logic
|
|
38
35
|
def deep_compact_in_object(object)
|
|
39
36
|
case object
|
|
40
37
|
when Hash
|
|
@@ -48,5 +45,4 @@ class Hash
|
|
|
48
45
|
object
|
|
49
46
|
end
|
|
50
47
|
end
|
|
51
|
-
# rubocop:enable Metrics/MethodLength
|
|
52
48
|
end
|
|
@@ -6,7 +6,7 @@ module PriceHubble
|
|
|
6
6
|
#
|
|
7
7
|
# @see https://docs.pricehubble.com/#introduction-authentication
|
|
8
8
|
class Authentication < BaseEntity
|
|
9
|
-
# The expiration leeway to
|
|
9
|
+
# The expiration leeway to subtract to guarantee
|
|
10
10
|
# acceptance on remote application calls
|
|
11
11
|
EXPIRATION_LEEWAY = 5.minutes
|
|
12
12
|
|
|
@@ -8,7 +8,7 @@ module PriceHubble
|
|
|
8
8
|
extend ActiveSupport::Concern
|
|
9
9
|
|
|
10
10
|
included do
|
|
11
|
-
# Collect all the
|
|
11
|
+
# Collect all the registered association configurations
|
|
12
12
|
class_attribute :associations
|
|
13
13
|
|
|
14
14
|
private
|
|
@@ -37,9 +37,6 @@ module PriceHubble
|
|
|
37
37
|
# @param hash [Hash{Symbol => Mixed}] all the data as hash
|
|
38
38
|
# @return [Array<RecursiveOpenStruct, Hash{Symbol => Mixed}>] the
|
|
39
39
|
# left over data
|
|
40
|
-
#
|
|
41
|
-
# rubocop:disable Metrics/AbcSize -- because of the complex logic
|
|
42
|
-
# rubocop:disable Metrics/MethodLength -- because of the complex logic
|
|
43
40
|
def map_has_one_association(attribute, opts, struct, hash)
|
|
44
41
|
# Early exit when the source key is missing on the given data
|
|
45
42
|
key = opts[:from]
|
|
@@ -62,8 +59,6 @@ module PriceHubble
|
|
|
62
59
|
# Pass back the new data
|
|
63
60
|
[struct, hash]
|
|
64
61
|
end
|
|
65
|
-
# rubocop:enable Metrics/AbcSize
|
|
66
|
-
# rubocop:enable Metrics/MethodLength
|
|
67
62
|
|
|
68
63
|
# Map an simple has_many association to the resulting entity attribute.
|
|
69
64
|
# The source key is stripped off according to the association
|
|
@@ -76,13 +71,6 @@ module PriceHubble
|
|
|
76
71
|
# @param hash [Hash{Symbol => Mixed}] all the data as hash
|
|
77
72
|
# @return [Array<RecursiveOpenStruct, Hash{Symbol => Mixed}>] the
|
|
78
73
|
# left over data
|
|
79
|
-
#
|
|
80
|
-
# rubocop:disable Metrics/AbcSize -- because of the complex logic
|
|
81
|
-
# rubocop:disable Metrics/CyclomaticComplexity -- because of the
|
|
82
|
-
# complex logic
|
|
83
|
-
# rubocop:disable Metrics/PerceivedComplexity -- because of the complex
|
|
84
|
-
# logic
|
|
85
|
-
# rubocop:disable Metrics/MethodLength -- because of the complex logic
|
|
86
74
|
def map_has_many_association(attribute, opts, struct, hash)
|
|
87
75
|
# Early exit when the source key is missing on the given data
|
|
88
76
|
key = opts[:from]
|
|
@@ -114,10 +102,6 @@ module PriceHubble
|
|
|
114
102
|
# Pass back the new data
|
|
115
103
|
[struct, hash]
|
|
116
104
|
end
|
|
117
|
-
# rubocop:enable Metrics/AbcSize
|
|
118
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
119
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
|
120
|
-
# rubocop:enable Metrics/MethodLength
|
|
121
105
|
end
|
|
122
106
|
|
|
123
107
|
class_methods do
|
|
@@ -5,7 +5,6 @@ module PriceHubble
|
|
|
5
5
|
# An ActiveRecord-like attribute management feature, with the exception
|
|
6
6
|
# that the attributes are not generated through a schema file, but are
|
|
7
7
|
# defined inline the entity class.
|
|
8
|
-
#
|
|
9
8
|
module Attributes
|
|
10
9
|
extend ActiveSupport::Concern
|
|
11
10
|
|
|
@@ -16,7 +15,7 @@ module PriceHubble
|
|
|
16
15
|
include Attributes::Range
|
|
17
16
|
include Attributes::StringInquirer
|
|
18
17
|
|
|
19
|
-
# Collect all
|
|
18
|
+
# Collect all registered attribute names as symbols
|
|
20
19
|
class_attribute :attribute_names
|
|
21
20
|
|
|
22
21
|
# Export all attributes as data hash, as requested by the ActiveModel
|
|
@@ -24,9 +23,6 @@ module PriceHubble
|
|
|
24
23
|
#
|
|
25
24
|
# @param sanitize [Boolean] whenever to sanitize the data for transport
|
|
26
25
|
# @return [Hash{String => Mixed}] the attribute data
|
|
27
|
-
#
|
|
28
|
-
# rubocop:disable Metrics/MethodLength -- because of the key/value
|
|
29
|
-
# sanitization handling
|
|
30
26
|
def attributes(sanitize: false)
|
|
31
27
|
attribute_names.each_with_object({}) do |key, memo|
|
|
32
28
|
reader = key
|
|
@@ -44,7 +40,6 @@ module PriceHubble
|
|
|
44
40
|
end
|
|
45
41
|
end
|
|
46
42
|
|
|
47
|
-
# rubocop:enable Metrics/MethodLength
|
|
48
43
|
# A wrapper for the +ActiveModel#assign_attributes+ method with support
|
|
49
44
|
# for unmapped attributes. These attributes are put into the
|
|
50
45
|
# +_unmapped+ struct and all the known attributes are assigned like
|
|
@@ -73,9 +68,6 @@ module PriceHubble
|
|
|
73
68
|
# @param obj [Mixed] the object to resolve its attributes
|
|
74
69
|
# @param sanitize [Boolean] whenever to sanitize the data for transport
|
|
75
70
|
# @return [Mixed] the attribute(s) data
|
|
76
|
-
#
|
|
77
|
-
# rubocop:disable Metrics/MethodLength -- because thats the pure
|
|
78
|
-
# minimum
|
|
79
71
|
def resolve_attributes(obj, sanitize: false)
|
|
80
72
|
if obj.respond_to? :attributes
|
|
81
73
|
obj = if obj.method(:attributes).arity == 1
|
|
@@ -93,7 +85,6 @@ module PriceHubble
|
|
|
93
85
|
|
|
94
86
|
obj
|
|
95
87
|
end
|
|
96
|
-
# rubocop:enable Metrics/MethodLength
|
|
97
88
|
|
|
98
89
|
# Explicitly convert the given struct to an +RecursiveOpenStruct+ and a
|
|
99
90
|
# deep symbolized key copy for further usage.
|
|
@@ -122,7 +113,7 @@ module PriceHubble
|
|
|
122
113
|
# @param hash [Hash{Symbol => Mixed}] all the data as hash
|
|
123
114
|
# @return [Hash{Symbol => Mixed}] the known attributes
|
|
124
115
|
def initialize_attributes(struct, hash)
|
|
125
|
-
#
|
|
116
|
+
# Subtract known keys, to move them to the +_unmapped+ variable
|
|
126
117
|
attribute_names.each { |key| struct.delete_field(key) }
|
|
127
118
|
# Merge the previous unmapped struct and the given data
|
|
128
119
|
self._unmapped =
|
|
@@ -14,13 +14,10 @@ module PriceHubble
|
|
|
14
14
|
# @param methods [Array<Symbol>] the source method names
|
|
15
15
|
# @raise [NoMethodError] when a source method is not defined
|
|
16
16
|
# @raise [ArgumentError] when a source method does not accept arguments
|
|
17
|
-
#
|
|
18
|
-
# rubocop:disable Metrics/MethodLength -- because the method template
|
|
19
|
-
# is better inlined
|
|
20
17
|
def bangers(*methods)
|
|
21
18
|
methods.each do |meth|
|
|
22
19
|
raise NoMethodError, "#{self}##{meth} does not exit" \
|
|
23
|
-
unless
|
|
20
|
+
unless method_defined?(meth, false)
|
|
24
21
|
|
|
25
22
|
if instance_method(meth).arity.zero?
|
|
26
23
|
raise ArgumentError,
|
|
@@ -34,7 +31,6 @@ module PriceHubble
|
|
|
34
31
|
RUBY
|
|
35
32
|
end
|
|
36
33
|
end
|
|
37
|
-
# rubocop:enable Metrics/MethodLength
|
|
38
34
|
end
|
|
39
35
|
end
|
|
40
36
|
end
|
|
@@ -25,7 +25,7 @@ module PriceHubble
|
|
|
25
25
|
# switch statement. It contains three decision result paths, the happy
|
|
26
26
|
# case (good), an error case for regular issues (fail) and a error case
|
|
27
27
|
# for fatal issues (bang). You can configure the decision which error
|
|
28
|
-
#
|
|
28
|
+
# behaviour you prefer by setting the +bang+ argument to true or
|
|
29
29
|
# false.
|
|
30
30
|
#
|
|
31
31
|
# @param bang [Boolean] whenever to bang or not
|
|
@@ -73,7 +73,7 @@ module PriceHubble
|
|
|
73
73
|
@good_proc = block
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
# Returns the
|
|
76
|
+
# Returns the preferred error method block, based on the +on_error+
|
|
77
77
|
# setting.
|
|
78
78
|
#
|
|
79
79
|
# @return [Proc] the error block we should use
|
data/lib/price_hubble/version.rb
CHANGED
data/pricehubble.gemspec
CHANGED
|
@@ -31,10 +31,10 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
32
32
|
spec.require_paths = ['lib']
|
|
33
33
|
|
|
34
|
-
spec.required_ruby_version = '>= 3.
|
|
34
|
+
spec.required_ruby_version = '>= 3.3'
|
|
35
35
|
|
|
36
|
-
spec.add_dependency 'activemodel', '>= 7.
|
|
37
|
-
spec.add_dependency 'activesupport', '>= 7.
|
|
36
|
+
spec.add_dependency 'activemodel', '>= 7.2'
|
|
37
|
+
spec.add_dependency 'activesupport', '>= 7.2'
|
|
38
38
|
spec.add_dependency 'faraday', '~> 1.0'
|
|
39
39
|
spec.add_dependency 'faraday_middleware', '~> 1.0'
|
|
40
40
|
spec.add_dependency 'mutex_m', '>= 0.3'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pricehubble
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hermann Mayer
|
|
@@ -15,28 +15,28 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '7.
|
|
18
|
+
version: '7.2'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '7.
|
|
25
|
+
version: '7.2'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: activesupport
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '7.
|
|
32
|
+
version: '7.2'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '7.
|
|
39
|
+
version: '7.2'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: faraday
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -147,8 +147,6 @@ files:
|
|
|
147
147
|
- doc/examples/property_valuations_errors.rb
|
|
148
148
|
- doc/examples/simple_property_valuations.rb
|
|
149
149
|
- docker-compose.yml
|
|
150
|
-
- gemfiles/rails_6.1.gemfile
|
|
151
|
-
- gemfiles/rails_7.1.gemfile
|
|
152
150
|
- gemfiles/rails_7.2.gemfile
|
|
153
151
|
- gemfiles/rails_8.0.gemfile
|
|
154
152
|
- gemfiles/rails_8.1.gemfile
|
|
@@ -216,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
216
214
|
requirements:
|
|
217
215
|
- - ">="
|
|
218
216
|
- !ruby/object:Gem::Version
|
|
219
|
-
version: '3.
|
|
217
|
+
version: '3.3'
|
|
220
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
219
|
requirements:
|
|
222
220
|
- - ">="
|
data/gemfiles/rails_6.1.gemfile
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "appraisal", "~> 2.4"
|
|
6
|
-
gem "bundler", "~> 2.3"
|
|
7
|
-
gem "countless", "~> 1.1"
|
|
8
|
-
gem "factory_bot", "~> 6.2", "< 6.4.5"
|
|
9
|
-
gem "guard-rspec", "~> 4.7"
|
|
10
|
-
gem "rake", "~> 13.0"
|
|
11
|
-
gem "redcarpet", "~> 3.5"
|
|
12
|
-
gem "rspec", "~> 3.12"
|
|
13
|
-
gem "rubocop"
|
|
14
|
-
gem "rubocop-rails"
|
|
15
|
-
gem "rubocop-rspec"
|
|
16
|
-
gem "simplecov", ">= 0.22"
|
|
17
|
-
gem "terminal-table", "~> 3.0"
|
|
18
|
-
gem "timecop", ">= 0.9.6"
|
|
19
|
-
gem "vcr", "~> 6.0"
|
|
20
|
-
gem "webmock", "~> 3.18"
|
|
21
|
-
gem "yard", ">= 0.9.28"
|
|
22
|
-
gem "yard-activesupport-concern", ">= 0.0.1"
|
|
23
|
-
gem "activemodel", "~> 6.1.0"
|
|
24
|
-
gem "activesupport", "~> 6.1.0"
|
|
25
|
-
|
|
26
|
-
gemspec path: "../"
|
data/gemfiles/rails_7.1.gemfile
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "appraisal", "~> 2.4"
|
|
6
|
-
gem "bundler", "~> 2.6"
|
|
7
|
-
gem "countless", "~> 2.2"
|
|
8
|
-
gem "factory_bot", "~> 6.2", "< 6.4.5"
|
|
9
|
-
gem "guard-rspec", "~> 4.7"
|
|
10
|
-
gem "rake", "~> 13.0"
|
|
11
|
-
gem "redcarpet", "~> 3.5"
|
|
12
|
-
gem "rspec", "~> 3.12"
|
|
13
|
-
gem "rubocop"
|
|
14
|
-
gem "rubocop-rails"
|
|
15
|
-
gem "rubocop-rspec"
|
|
16
|
-
gem "simplecov", ">= 0.22"
|
|
17
|
-
gem "terminal-table", "~> 3.0"
|
|
18
|
-
gem "timecop", ">= 0.9.6"
|
|
19
|
-
gem "vcr", "~> 6.0"
|
|
20
|
-
gem "webmock", "~> 3.18"
|
|
21
|
-
gem "yard", ">= 0.9.28"
|
|
22
|
-
gem "yard-activesupport-concern", ">= 0.0.1"
|
|
23
|
-
gem "activemodel", "~> 7.1.0"
|
|
24
|
-
gem "activesupport", "~> 7.1.0"
|
|
25
|
-
|
|
26
|
-
gemspec path: "../"
|