pricehubble 0.4.1 → 1.0.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/documentation.yml +39 -0
- data/.github/workflows/test.yml +63 -0
- data/.rspec +2 -2
- data/.rubocop.yml +28 -4
- data/.simplecov +12 -0
- data/Appraisals +2 -9
- data/CHANGELOG.md +17 -0
- data/Dockerfile +2 -3
- data/Guardfile +44 -0
- data/LICENSE +1 -1
- data/Makefile +32 -18
- data/README.md +4 -4
- data/Rakefile +20 -69
- data/gemfiles/rails_5.2.gemfile +4 -7
- data/lib/pricehubble/client/dossiers.rb +2 -4
- data/lib/pricehubble/client/request/data_sanitization.rb +1 -1
- data/lib/pricehubble/client/utils/request.rb +8 -8
- data/lib/pricehubble/client/valuation.rb +5 -1
- data/lib/pricehubble/core_ext/hash.rb +2 -2
- data/lib/pricehubble/entity/base_entity.rb +1 -0
- data/lib/pricehubble/entity/concern/associations.rb +6 -4
- data/lib/pricehubble/entity/concern/attributes.rb +13 -6
- data/lib/pricehubble/entity/valuation_request.rb +1 -1
- data/lib/pricehubble/identity.rb +1 -0
- data/lib/pricehubble/utils/decision.rb +1 -1
- data/lib/pricehubble/version.rb +18 -1
- data/lib/pricehubble.rb +0 -1
- data/pricehubble.gemspec +40 -29
- metadata +84 -69
- data/.travis.yml +0 -24
- data/gemfiles/rails_6.0.gemfile +0 -11
@@ -38,8 +38,8 @@ class Hash
|
|
38
38
|
def deep_compact_in_object(object)
|
39
39
|
case object
|
40
40
|
when Hash
|
41
|
-
object = object.compact.
|
42
|
-
|
41
|
+
object = object.compact.transform_values do |value|
|
42
|
+
deep_compact_in_object(value)
|
43
43
|
end
|
44
44
|
object.empty? ? nil : object.compact
|
45
45
|
when Array
|
@@ -55,6 +55,7 @@ module PriceHubble
|
|
55
55
|
#
|
56
56
|
# @param child_class [Class] the child class which inherits us
|
57
57
|
def inherited(child_class)
|
58
|
+
super
|
58
59
|
match = ->(sym) { sym.to_s.start_with? 'inherited_setup_' }
|
59
60
|
trigger = ->(sym) { send(sym, child_class) }
|
60
61
|
methods.select(&match).each(&trigger)
|
@@ -45,8 +45,8 @@ module PriceHubble
|
|
45
45
|
key = opts[:from]
|
46
46
|
|
47
47
|
# Initialize an object on the association, even without data
|
48
|
-
if opts[:initialize] && send(attribute).nil?
|
49
|
-
hash[key] = {}
|
48
|
+
if opts[:initialize] && send(attribute).nil? && !(hash.key? key)
|
49
|
+
hash[key] = {}
|
50
50
|
end
|
51
51
|
|
52
52
|
return [struct, hash] unless hash.key? key
|
@@ -92,8 +92,8 @@ module PriceHubble
|
|
92
92
|
key = opts[:fallback_from] if opts[:fallback_from] && !hash.key?(key)
|
93
93
|
|
94
94
|
# Initialize an empty array on the association
|
95
|
-
if opts[:initialize] && send(attribute).nil?
|
96
|
-
hash[key] = []
|
95
|
+
if opts[:initialize] && send(attribute).nil? && !(hash.key? key)
|
96
|
+
hash[key] = []
|
97
97
|
end
|
98
98
|
|
99
99
|
return [struct, hash] unless hash.key? key
|
@@ -156,6 +156,7 @@ module PriceHubble
|
|
156
156
|
associations[entity] = opts
|
157
157
|
# Generate getters and setters
|
158
158
|
attr_accessor entity
|
159
|
+
|
159
160
|
# Add the entity to the tracked attributes if it should be persisted
|
160
161
|
tracked_attr entity if opts[:persist]
|
161
162
|
end
|
@@ -187,6 +188,7 @@ module PriceHubble
|
|
187
188
|
associations[entity] = opts
|
188
189
|
# Generate getters and setters
|
189
190
|
attr_accessor entity
|
191
|
+
|
190
192
|
# Add the entity to the tracked attributes if it should be persisted
|
191
193
|
tracked_attr entity if opts[:persist]
|
192
194
|
end
|
@@ -27,7 +27,7 @@ module PriceHubble
|
|
27
27
|
#
|
28
28
|
# rubocop:disable Metrics/MethodLength because of the
|
29
29
|
# key/value sanitization handling
|
30
|
-
def attributes(sanitize
|
30
|
+
def attributes(sanitize: false)
|
31
31
|
attribute_names.each_with_object({}) do |key, memo|
|
32
32
|
reader = key
|
33
33
|
|
@@ -43,8 +43,8 @@ module PriceHubble
|
|
43
43
|
memo[key.to_s] = result
|
44
44
|
end
|
45
45
|
end
|
46
|
-
# rubocop:enable Metrics/MethodLength
|
47
46
|
|
47
|
+
# rubocop:enable Metrics/MethodLength
|
48
48
|
# A wrapper for the +ActiveModel#assign_attributes+ method with support
|
49
49
|
# for unmapped attributes. These attributes are put into the
|
50
50
|
# +_unmapped+ struct and all the known attributes are assigned like
|
@@ -73,20 +73,26 @@ module PriceHubble
|
|
73
73
|
# @param obj [Mixed] the object to resolve its attributes
|
74
74
|
# @param sanitize [Boolean] whenever to sanitize the data for transport
|
75
75
|
# @return [Mixed] the attribute(s) data
|
76
|
-
|
76
|
+
#
|
77
|
+
# rubocop:disable Metrics/MethodLength because thats the pure minimum
|
78
|
+
def resolve_attributes(obj, sanitize: false)
|
77
79
|
if obj.respond_to? :attributes
|
78
80
|
obj = if obj.method(:attributes).arity == 1
|
79
|
-
obj.attributes(sanitize)
|
81
|
+
obj.attributes(sanitize: sanitize)
|
80
82
|
else
|
81
83
|
obj.attributes
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
+
if obj.is_a? Array
|
88
|
+
obj = obj.map do |elem|
|
89
|
+
resolve_attributes(elem, sanitize: sanitize)
|
90
|
+
end
|
91
|
+
end
|
87
92
|
|
88
93
|
obj
|
89
94
|
end
|
95
|
+
# rubocop:enable Metrics/MethodLength
|
90
96
|
|
91
97
|
# Explicitly convert the given struct to an +RecursiveOpenStruct+ and a
|
92
98
|
# deep symbolized key copy for further usage.
|
@@ -144,6 +150,7 @@ module PriceHubble
|
|
144
150
|
self.attribute_names += args
|
145
151
|
# Define getters/setters
|
146
152
|
attr_reader(*args)
|
153
|
+
|
147
154
|
args.each do |arg|
|
148
155
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
149
156
|
def #{arg}=(value)
|
@@ -43,7 +43,7 @@ module PriceHubble
|
|
43
43
|
#
|
44
44
|
# @return [Array<Hash{String => Mixed}>] the sanitized properties
|
45
45
|
def sanitize_attr_properties
|
46
|
-
properties.map { |prop| { property: prop.attributes(true) } }
|
46
|
+
properties.map { |prop| { property: prop.attributes(sanitize: true) } }
|
47
47
|
end
|
48
48
|
|
49
49
|
# Perform the property valuation request.
|
data/lib/pricehubble/identity.rb
CHANGED
data/lib/pricehubble/version.rb
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# The gem version details.
|
3
4
|
module PriceHubble
|
4
5
|
# The version of the +price-hubble+ gem
|
5
|
-
VERSION = '0.
|
6
|
+
VERSION = '1.0.0'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# Returns the version of gem as a string.
|
10
|
+
#
|
11
|
+
# @return [String] the gem version as string
|
12
|
+
def version
|
13
|
+
VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the version of the gem as a +Gem::Version+.
|
17
|
+
#
|
18
|
+
# @return [Gem::Version] the gem version as object
|
19
|
+
def gem_version
|
20
|
+
Gem::Version.new VERSION
|
21
|
+
end
|
22
|
+
end
|
6
23
|
end
|
data/lib/pricehubble.rb
CHANGED
data/pricehubble.gemspec
CHANGED
@@ -5,45 +5,56 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'pricehubble/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
8
|
+
spec.name = 'pricehubble'
|
9
|
+
spec.version = PriceHubble::VERSION
|
10
|
+
spec.authors = ['Hermann Mayer']
|
11
|
+
spec.email = ['hermann.mayer92@gmail.com']
|
12
12
|
|
13
|
-
spec.
|
14
|
-
spec.
|
15
|
-
spec.
|
13
|
+
spec.license = 'MIT'
|
14
|
+
spec.summary = 'Ruby client for the PriceHubble REST API'
|
15
|
+
spec.description = 'Ruby client for the PriceHubble REST API'
|
16
16
|
|
17
|
-
|
17
|
+
base_uri = "https://github.com/hausgold/#{spec.name}"
|
18
|
+
spec.metadata = {
|
19
|
+
'homepage_uri' => base_uri,
|
20
|
+
'source_code_uri' => base_uri,
|
21
|
+
'changelog_uri' => "#{base_uri}/blob/master/CHANGELOG.md",
|
22
|
+
'bug_tracker_uri' => "#{base_uri}/issues",
|
23
|
+
'documentation_uri' => "https://www.rubydoc.info/gems/#{spec.name}"
|
24
|
+
}
|
18
25
|
|
19
26
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
27
|
f.match(%r{^(test|spec|features)/})
|
21
28
|
end
|
22
|
-
|
23
|
-
spec.
|
29
|
+
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
32
|
spec.require_paths = ['lib']
|
25
33
|
|
26
|
-
spec.
|
27
|
-
|
34
|
+
spec.required_ruby_version = '>= 2.5'
|
35
|
+
|
36
|
+
spec.add_runtime_dependency 'activemodel', '>= 5.2'
|
37
|
+
spec.add_runtime_dependency 'activesupport', '>= 5.2'
|
28
38
|
spec.add_runtime_dependency 'faraday', '~> 1.0'
|
29
39
|
spec.add_runtime_dependency 'faraday_middleware', '~> 1.0'
|
30
40
|
spec.add_runtime_dependency 'recursive-open-struct', '~> 1.1'
|
31
41
|
|
32
|
-
spec.add_development_dependency 'appraisal'
|
33
|
-
spec.add_development_dependency 'bundler', '
|
34
|
-
spec.add_development_dependency '
|
35
|
-
spec.add_development_dependency '
|
36
|
-
spec.add_development_dependency '
|
37
|
-
spec.add_development_dependency '
|
38
|
-
spec.add_development_dependency 'redcarpet', '~> 3.
|
39
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
40
|
-
spec.add_development_dependency 'rubocop', '~>
|
41
|
-
spec.add_development_dependency 'rubocop-
|
42
|
-
spec.add_development_dependency '
|
43
|
-
spec.add_development_dependency '
|
44
|
-
spec.add_development_dependency '
|
45
|
-
spec.add_development_dependency '
|
46
|
-
spec.add_development_dependency '
|
47
|
-
spec.add_development_dependency '
|
48
|
-
spec.add_development_dependency 'yard
|
42
|
+
spec.add_development_dependency 'appraisal', '~> 2.4'
|
43
|
+
spec.add_development_dependency 'bundler', '~> 2.3'
|
44
|
+
spec.add_development_dependency 'countless', '~> 1.1'
|
45
|
+
spec.add_development_dependency 'factory_bot', '~> 6.2'
|
46
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
47
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
48
|
+
spec.add_development_dependency 'redcarpet', '~> 3.5'
|
49
|
+
spec.add_development_dependency 'rspec', '~> 3.12'
|
50
|
+
spec.add_development_dependency 'rubocop', '~> 1.28'
|
51
|
+
spec.add_development_dependency 'rubocop-rails', '~> 2.14'
|
52
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
|
53
|
+
spec.add_development_dependency 'simplecov', '>= 0.22'
|
54
|
+
spec.add_development_dependency 'terminal-table', '~> 3.0'
|
55
|
+
spec.add_development_dependency 'timecop', '>= 0.9.6'
|
56
|
+
spec.add_development_dependency 'vcr', '~> 6.0'
|
57
|
+
spec.add_development_dependency 'webmock', '~> 3.18'
|
58
|
+
spec.add_development_dependency 'yard', '>= 0.9.28'
|
59
|
+
spec.add_development_dependency 'yard-activesupport-concern', '>= 0.0.1'
|
49
60
|
end
|