pricehubble 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +30 -0
  3. data/.gitignore +16 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +62 -0
  6. data/.simplecov +3 -0
  7. data/.travis.yml +27 -0
  8. data/.yardopts +6 -0
  9. data/Appraisals +25 -0
  10. data/CHANGELOG.md +9 -0
  11. data/Dockerfile +29 -0
  12. data/Envfile +6 -0
  13. data/Gemfile +8 -0
  14. data/LICENSE +21 -0
  15. data/Makefile +149 -0
  16. data/README.md +385 -0
  17. data/Rakefile +80 -0
  18. data/bin/console +16 -0
  19. data/bin/run +12 -0
  20. data/bin/setup +8 -0
  21. data/config/docker/.bash_profile +3 -0
  22. data/config/docker/.bashrc +48 -0
  23. data/config/docker/.inputrc +17 -0
  24. data/doc/assets/project.svg +68 -0
  25. data/doc/examples/authentication.rb +19 -0
  26. data/doc/examples/complex_property_valuations.rb +91 -0
  27. data/doc/examples/config.rb +30 -0
  28. data/doc/examples/property_valuations_errors.rb +30 -0
  29. data/doc/examples/simple_property_valuations.rb +69 -0
  30. data/docker-compose.yml +9 -0
  31. data/gemfiles/rails_4.2.gemfile +11 -0
  32. data/gemfiles/rails_5.0.gemfile +11 -0
  33. data/gemfiles/rails_5.1.gemfile +11 -0
  34. data/gemfiles/rails_5.2.gemfile +11 -0
  35. data/lib/price_hubble.rb +3 -0
  36. data/lib/pricehubble/client/authentication.rb +29 -0
  37. data/lib/pricehubble/client/base.rb +59 -0
  38. data/lib/pricehubble/client/request/data_sanitization.rb +28 -0
  39. data/lib/pricehubble/client/request/default_headers.rb +33 -0
  40. data/lib/pricehubble/client/response/data_sanitization.rb +29 -0
  41. data/lib/pricehubble/client/response/recursive_open_struct.rb +31 -0
  42. data/lib/pricehubble/client/utils/request.rb +41 -0
  43. data/lib/pricehubble/client/utils/response.rb +60 -0
  44. data/lib/pricehubble/client/valuation.rb +68 -0
  45. data/lib/pricehubble/client.rb +25 -0
  46. data/lib/pricehubble/configuration.rb +26 -0
  47. data/lib/pricehubble/configuration_handling.rb +50 -0
  48. data/lib/pricehubble/core_ext/hash.rb +52 -0
  49. data/lib/pricehubble/entity/address.rb +11 -0
  50. data/lib/pricehubble/entity/authentication.rb +34 -0
  51. data/lib/pricehubble/entity/base_entity.rb +63 -0
  52. data/lib/pricehubble/entity/concern/associations.rb +197 -0
  53. data/lib/pricehubble/entity/concern/attributes/date_array.rb +29 -0
  54. data/lib/pricehubble/entity/concern/attributes/enum.rb +57 -0
  55. data/lib/pricehubble/entity/concern/attributes/range.rb +32 -0
  56. data/lib/pricehubble/entity/concern/attributes/string_inquirer.rb +27 -0
  57. data/lib/pricehubble/entity/concern/attributes.rb +171 -0
  58. data/lib/pricehubble/entity/concern/callbacks.rb +19 -0
  59. data/lib/pricehubble/entity/concern/client.rb +31 -0
  60. data/lib/pricehubble/entity/coordinates.rb +11 -0
  61. data/lib/pricehubble/entity/location.rb +14 -0
  62. data/lib/pricehubble/entity/property.rb +32 -0
  63. data/lib/pricehubble/entity/property_conditions.rb +20 -0
  64. data/lib/pricehubble/entity/property_qualities.rb +20 -0
  65. data/lib/pricehubble/entity/property_type.rb +21 -0
  66. data/lib/pricehubble/entity/valuation.rb +48 -0
  67. data/lib/pricehubble/entity/valuation_request.rb +60 -0
  68. data/lib/pricehubble/entity/valuation_scores.rb +11 -0
  69. data/lib/pricehubble/errors.rb +60 -0
  70. data/lib/pricehubble/faraday.rb +12 -0
  71. data/lib/pricehubble/identity.rb +46 -0
  72. data/lib/pricehubble/railtie.rb +16 -0
  73. data/lib/pricehubble/utils/bangers.rb +44 -0
  74. data/lib/pricehubble/utils/decision.rb +97 -0
  75. data/lib/pricehubble/version.rb +6 -0
  76. data/lib/pricehubble.rb +103 -0
  77. data/pricehubble.gemspec +47 -0
  78. metadata +432 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3a6dec9a50e1bc53530adc56e69bccf3c0309b0c38b8819be5862ac01b78aa24
4
+ data.tar.gz: edb1ce1a5667290d8d8481edfeb41c39cffc09d35efea6a7e6f1d81f38f00095
5
+ SHA512:
6
+ metadata.gz: 4c02c6a1153849bbad1f2ba7f171a5b526be7fb6d42001f7419099901df2bf80abb61943948e3a2322e92ab202ef96122533f2c4887fd1c385db6fd3c4c897a9
7
+ data.tar.gz: ee651835c4f91e894a9967d5477cb44a9efb13dc64dbb3cde557b6315c71b8837806f6a9c3c2356e772c3a4b5e202870a8d7f7e399ea972cc336da1647e91386
data/.editorconfig ADDED
@@ -0,0 +1,30 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = true
14
+
15
+ [*.json]
16
+ indent_style = space
17
+ indent_size = 2
18
+
19
+ [*.yml]
20
+ indent_style = space
21
+ indent_size = 2
22
+
23
+ [Makefile]
24
+ trim_trailing_whitespace = true
25
+ indent_style = tab
26
+ indent_size = 4
27
+
28
+ [*.sh]
29
+ indent_style = space
30
+ indent_size = 2
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/api/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor/
10
+ /gemfiles/vendor/
11
+ /Gemfile.lock
12
+ *.gemfile.lock
13
+ /spec/.credentials
14
+
15
+ # rspec failure tracking
16
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,62 @@
1
+ require: rubocop-rspec
2
+
3
+ Rails:
4
+ Enabled: true
5
+
6
+ Documentation:
7
+ Enabled: true
8
+
9
+ AllCops:
10
+ DisplayCopNames: true
11
+ TargetRubyVersion: 2.3
12
+ Exclude:
13
+ - bin/**/*
14
+ - vendor/**/*
15
+ - build/**/*
16
+ - gemfiles/vendor/**/*
17
+
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - Rakefile
21
+ - '*.gemspec'
22
+ - spec/**/*.rb
23
+ - '**/*.rake'
24
+ - doc/**/*.rb
25
+ # Concerns and middlewares contain by nature long blocks
26
+ - lib/pricehubble/entity/concern/**/*.rb
27
+ - lib/pricehubble/client/request/**/*.rb
28
+ - lib/pricehubble/client/response/**/*.rb
29
+
30
+ # Document all the things.
31
+ Style/DocumentationMethod:
32
+ Enabled: true
33
+ RequireForNonPublicMethods: true
34
+
35
+ # It's a deliberate idiom in RSpec.
36
+ # See: https://github.com/bbatsov/rubocop/issues/4222
37
+ Lint/AmbiguousBlockAssociation:
38
+ Exclude:
39
+ - "spec/**/*"
40
+
41
+ # Because +expect_any_instance_of().to have_received()+ is not
42
+ # supported with the +with(hash_including)+ matchers
43
+ RSpec/MessageSpies:
44
+ EnforcedStyle: receive
45
+
46
+ # Because nesting makes sense here to group the feature tests
47
+ # more effective. This increases maintainability.
48
+ RSpec/NestedGroups:
49
+ Max: 4
50
+
51
+ # Disable regular Rails spec paths.
52
+ RSpec/FilePath:
53
+ Enabled: false
54
+
55
+ # Because we just implemented the ActiveRecord API.
56
+ Rails/SkipsModelValidations:
57
+ Enabled: false
58
+
59
+ # Because of the clean wording on the examples.
60
+ Lint/ShadowingOuterLocalVariable:
61
+ Exclude:
62
+ - "doc/**/*"
data/.simplecov ADDED
@@ -0,0 +1,3 @@
1
+ SimpleCov.start 'test_frameworks' do
2
+ add_filter '/vendor/bundle/'
3
+ end
data/.travis.yml ADDED
@@ -0,0 +1,27 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=e80bc2fc948962da41f411047330599fe2bdafcc378bd99a1c3bffbfae74c20f
4
+
5
+ sudo: false
6
+ language: ruby
7
+ cache: bundler
8
+ rvm:
9
+ - 2.6
10
+ - 2.5
11
+ - 2.4
12
+ - 2.3
13
+
14
+ gemfile:
15
+ - gemfiles/rails_4.2.gemfile
16
+ - gemfiles/rails_5.0.gemfile
17
+ - gemfiles/rails_5.1.gemfile
18
+ - gemfiles/rails_5.2.gemfile
19
+
20
+ before_install: gem install bundler
21
+ before_script:
22
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
23
+ - chmod +x ./cc-test-reporter
24
+ - ./cc-test-reporter before-build
25
+ script: bundle exec rake
26
+ after_script:
27
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --output-dir=doc/api
2
+ --plugin activesupport-concern
3
+ --markup=rdoc
4
+ -
5
+ README.md
6
+ lib/**/*.rb
data/Appraisals ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'rails-4.2' do
4
+ gem 'activemodel', '~> 4.2.11'
5
+ gem 'activesupport', '~> 4.2.11'
6
+ gem 'railties', '~> 4.2.11'
7
+ end
8
+
9
+ appraise 'rails-5.0' do
10
+ gem 'activemodel', '~> 5.0.7'
11
+ gem 'activesupport', '~> 5.0.7'
12
+ gem 'railties', '~> 5.0.7'
13
+ end
14
+
15
+ appraise 'rails-5.1' do
16
+ gem 'activemodel', '~> 5.1.6'
17
+ gem 'activesupport', '~> 5.1.6'
18
+ gem 'railties', '~> 5.1.6'
19
+ end
20
+
21
+ appraise 'rails-5.2' do
22
+ gem 'activemodel', '~> 5.2.2'
23
+ gem 'activesupport', '~> 5.2.2'
24
+ gem 'railties', '~> 5.2.2'
25
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ### 0.1.0
2
+
3
+ * Implemented a transparent authentication handling
4
+ * Implemented all shared data types (`PriceHubble::Location`,
5
+ `PriceHubble::Coordinates`, `PriceHubble::Address`, `PriceHubble::Property`,
6
+ `PriceHubble::PropertyType`)
7
+ * Implemented the international property valuation
8
+ (`PriceHubble::ValuationRequest`)
9
+ * Added a set of examples and wrote the usage documentation
data/Dockerfile ADDED
@@ -0,0 +1,29 @@
1
+ FROM hausgold/ruby:2.3
2
+ MAINTAINER Hermann Mayer <hermann.mayer@hausgold.de>
3
+
4
+ # Update system gem
5
+ RUN gem update --system
6
+
7
+ # Install system packages and the latest bundler
8
+ RUN apt-get update -yqqq && \
9
+ apt-get install -y \
10
+ build-essential locales sudo vim \
11
+ ca-certificates \
12
+ bash-completion inotify-tools && \
13
+ echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && /usr/sbin/locale-gen && \
14
+ gem install bundler -v '~> 2.0' --no-document --no-prerelease && \
15
+ gem install bundler -v '~> 1.0' --no-document --no-prerelease
16
+
17
+ # Add new web user
18
+ RUN mkdir /app && \
19
+ adduser web --home /home/web --shell /bin/bash \
20
+ --disabled-password --gecos ""
21
+ COPY config/docker/* /home/web/
22
+ RUN chown web:web -R /app /home/web /usr/local/bundle && \
23
+ mkdir -p /home/web/.ssh
24
+
25
+ # Set the root password and grant root access to web
26
+ RUN echo 'root:root' | chpasswd
27
+ RUN echo 'web ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
28
+
29
+ WORKDIR /app
data/Envfile ADDED
@@ -0,0 +1,6 @@
1
+ LANG=en_US.UTF-8
2
+ LANGUAGE=en_US.UTF-8
3
+ LC_ALL=en_US.UTF-8
4
+
5
+ # Just fix this, so Appraisals with Rails 4 are working fine
6
+ BUNDLER_VERSION=1.17.3
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in price_hubble.gemspec
8
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 HAUSGOLD | talocasa GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,149 @@
1
+ MAKEFLAGS += --warn-undefined-variables -j1
2
+ SHELL := bash
3
+ .SHELLFLAGS := -eu -o pipefail -c
4
+ .DEFAULT_GOAL := all
5
+ .DELETE_ON_ERROR:
6
+ .SUFFIXES:
7
+ .PHONY:
8
+
9
+ # Environment switches
10
+ MAKE_ENV ?= docker
11
+ COMPOSE_RUN_SHELL_FLAGS ?= --rm
12
+
13
+ # Directories
14
+ VENDOR_DIR ?= vendor/bundle
15
+ GEMFILES_DIR ?= gemfiles
16
+
17
+ # Host binaries
18
+ AWK ?= awk
19
+ BASH ?= bash
20
+ COMPOSE ?= docker-compose
21
+ DOCKER ?= docker
22
+ GREP ?= grep
23
+ ID ?= id
24
+ MKDIR ?= mkdir
25
+ RM ?= rm
26
+ XARGS ?= xargs
27
+
28
+ # Container binaries
29
+ BUNDLE ?= bundle
30
+ APPRAISAL ?= appraisal
31
+ RAKE ?= rake
32
+ YARD ?= yard
33
+ RAKE ?= rake
34
+ RUBOCOP ?= rubocop
35
+
36
+ # Files
37
+ GEMFILES ?= $(subst _,-,$(patsubst $(GEMFILES_DIR)/%.gemfile,%,\
38
+ $(wildcard $(GEMFILES_DIR)/*.gemfile)))
39
+ TEST_GEMFILES := $(GEMFILES:%=test-%)
40
+
41
+ # Define a generic shell run wrapper
42
+ # $1 - The command to run
43
+ ifeq ($(MAKE_ENV),docker)
44
+ define run-shell
45
+ $(COMPOSE) run $(COMPOSE_RUN_SHELL_FLAGS) \
46
+ -e LANG=en_US.UTF-8 -e LANGUAGE=en_US.UTF-8 -e LC_ALL=en_US.UTF-8 \
47
+ -e HOME=/home/web -e BUNDLE_APP_CONFIG=/app/.bundle \
48
+ -u `$(ID) -u` test bash -c 'sleep 0.1; echo; $(1)'
49
+ endef
50
+ else ifeq ($(MAKE_ENV),baremetal)
51
+ define run-shell
52
+ $(1)
53
+ endef
54
+ endif
55
+
56
+ all:
57
+ # PriceHubble
58
+ #
59
+ # install Install the dependencies
60
+ # update Update the local Gemset dependencies
61
+ # clean Clean the dependencies
62
+ #
63
+ # test Run the whole test suite
64
+ # test-style Test the code styles
65
+ #
66
+ # docs Generate the Ruby documentation of the library
67
+ # stats Print the code statistics (library and test suite)
68
+ # notes Print all the notes from the code
69
+ # release Release a new Gem version (maintainers only)
70
+ #
71
+ # shell Run an interactive shell on the container
72
+ # shell-irb Run an interactive IRB shell on the container
73
+
74
+ install:
75
+ # Install the dependencies
76
+ @$(MKDIR) -p $(VENDOR_DIR)
77
+ @$(call run-shell,$(BUNDLE) check || $(BUNDLE) install --path $(VENDOR_DIR))
78
+ @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) install)
79
+
80
+ update: install
81
+ # Install the dependencies
82
+ @$(MKDIR) -p $(VENDOR_DIR)
83
+ @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) update)
84
+
85
+ test: #install
86
+ # Run the whole test suite
87
+ @$(call run-shell,$(BUNDLE) exec $(RAKE))
88
+
89
+ $(TEST_GEMFILES): GEMFILE=$(@:test-%=%)
90
+ $(TEST_GEMFILES):
91
+ # Run the whole test suite ($(GEMFILE))
92
+ @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) $(GEMFILE) $(RAKE))
93
+
94
+ test-style: \
95
+ test-style-ruby
96
+
97
+ test-style-ruby:
98
+ # Run the static code analyzer (rubocop)
99
+ @$(call run-shell,$(BUNDLE) exec $(RUBOCOP) -a)
100
+
101
+ clean:
102
+ # Clean the dependencies
103
+ @$(RM) -rf $(VENDOR_DIR)
104
+ @$(RM) -rf $(VENDOR_DIR)/Gemfile.lock
105
+ @$(RM) -rf $(GEMFILES_DIR)/vendor
106
+ @$(RM) -rf $(GEMFILES_DIR)/*.lock
107
+ @$(RM) -rf pkg
108
+ @$(RM) -rf coverage
109
+
110
+ clean-containers:
111
+ # Clean running containers
112
+ ifeq ($(MAKE_ENV),docker)
113
+ @$(COMPOSE) down
114
+ endif
115
+
116
+ clean-images:
117
+ # Clean build images
118
+ ifeq ($(MAKE_ENV),docker)
119
+ @-$(DOCKER) images | $(GREP) price-hubble \
120
+ | $(AWK) '{ print $$3 }' \
121
+ | $(XARGS) -rn1 $(DOCKER) rmi -f
122
+ endif
123
+
124
+ distclean: clean clean-containers clean-images
125
+
126
+ shell: install
127
+ # Run an interactive shell on the container
128
+ @$(call run-shell,$(BASH) -i)
129
+
130
+ shell-irb: install
131
+ # Run an interactive IRB shell on the container
132
+ @$(call run-shell,bin/console)
133
+
134
+ docs: install
135
+ # Build the API documentation
136
+ @$(call run-shell,$(BUNDLE) exec $(YARD) -q && \
137
+ $(BUNDLE) exec $(YARD) stats --list-undoc --compact)
138
+
139
+ notes: install
140
+ # Print the code statistics (library and test suite)
141
+ @$(call run-shell,$(BUNDLE) exec $(RAKE) notes)
142
+
143
+ stats: install
144
+ # Print all the notes from the code
145
+ @$(call run-shell,$(BUNDLE) exec $(RAKE) stats)
146
+
147
+ release:
148
+ # Release a new gem version
149
+ @$(RAKE) release