immoscout 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/documentation.yml +3 -2
  3. data/.github/workflows/test.yml +6 -5
  4. data/.rspec +2 -1
  5. data/.rubocop.yml +23 -4
  6. data/.simplecov +12 -0
  7. data/Appraisals +1 -5
  8. data/CHANGELOG.md +8 -0
  9. data/Dockerfile +2 -3
  10. data/Envfile +0 -3
  11. data/Guardfile +44 -0
  12. data/LICENSE +1 -1
  13. data/Makefile +24 -10
  14. data/Rakefile +13 -66
  15. data/gemfiles/rails_5.2.gemfile +3 -5
  16. data/immoscout.gemspec +45 -44
  17. data/lib/immoscout/api/client.rb +1 -0
  18. data/lib/immoscout/api/connection.rb +8 -9
  19. data/lib/immoscout/api/request.rb +3 -2
  20. data/lib/immoscout/configuration.rb +12 -6
  21. data/lib/immoscout/errors/failed.rb +1 -0
  22. data/lib/immoscout/models/actions/attachment.rb +2 -3
  23. data/lib/immoscout/models/actions/contact.rb +3 -14
  24. data/lib/immoscout/models/actions/publish.rb +1 -3
  25. data/lib/immoscout/models/actions/real_estate.rb +4 -14
  26. data/lib/immoscout/models/apartment_buy.rb +3 -0
  27. data/lib/immoscout/models/base.rb +2 -1
  28. data/lib/immoscout/models/concerns/modelable.rb +2 -0
  29. data/lib/immoscout/models/concerns/propertiable.rb +4 -1
  30. data/lib/immoscout/models/concerns/renderable.rb +5 -5
  31. data/lib/immoscout/models/contact.rb +2 -0
  32. data/lib/immoscout/models/document.rb +2 -0
  33. data/lib/immoscout/models/house_buy.rb +3 -0
  34. data/lib/immoscout/models/parts/address.rb +3 -0
  35. data/lib/immoscout/models/parts/api_search_data.rb +3 -0
  36. data/lib/immoscout/models/parts/contact.rb +3 -0
  37. data/lib/immoscout/models/parts/coordinate.rb +3 -0
  38. data/lib/immoscout/models/parts/courtage.rb +3 -0
  39. data/lib/immoscout/models/parts/energy_certificate.rb +3 -0
  40. data/lib/immoscout/models/parts/energy_source.rb +3 -0
  41. data/lib/immoscout/models/parts/firing_type.rb +3 -0
  42. data/lib/immoscout/models/parts/geo_code.rb +3 -0
  43. data/lib/immoscout/models/parts/geo_hierarchy.rb +3 -0
  44. data/lib/immoscout/models/parts/international_country_region.rb +3 -0
  45. data/lib/immoscout/models/parts/price.rb +3 -0
  46. data/lib/immoscout/models/parts/publish_channel.rb +3 -0
  47. data/lib/immoscout/models/parts/real_estate.rb +3 -0
  48. data/lib/immoscout/models/parts/url.rb +3 -0
  49. data/lib/immoscout/models/parts/urls.rb +3 -0
  50. data/lib/immoscout/models/picture.rb +2 -0
  51. data/lib/immoscout/models/publish.rb +2 -0
  52. data/lib/immoscout/models.rb +0 -1
  53. data/lib/immoscout/version.rb +19 -1
  54. data/lib/immoscout.rb +1 -0
  55. metadata +96 -76
  56. data/gemfiles/rails_6.0.gemfile +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc74f7180d13859dedf5b42a8502e6d679b6c7348622c5f92de6a41c9daba822
4
- data.tar.gz: 39c5063180247dfe8e9e279c0b0dc9f20d7a4204127ee763dd50690c92013fb7
3
+ metadata.gz: d4cd53b266de26d3e819cdfedba39ced10517813e4aed918c7bb9eb243a1c9e2
4
+ data.tar.gz: 4e9e75201da0c3a21da12f1c162f078c71fc393e4e350837fd39beca00dc83db
5
5
  SHA512:
6
- metadata.gz: 277085348b99e2e1cc4e58157f067a874f78a8fb008970eeb50ca290d121008a8ab2613fc08475ba276d94ca7c62a05236cc68aeabf8cce782742892412639f2
7
- data.tar.gz: 0fcd17a5e12f726a74268e270c9e9113c6ba8d455086e764d503c49bc8897d77b2d3e6071fd36d661fb5bd8ca10e5fee70e5a7bebf77a5e17dc108ddedf55e3c
6
+ metadata.gz: 519df9e86e1f3bf3616c24ff3684b5be431a4261e9b2521afa807ae8ae15f23913552bb543b664559242d5f74bb23b4d6aff34bc2cda1fdf2e8d0086c77cd8c9
7
+ data.tar.gz: 145b56aea60a069fb70b29d7e46774f9f72f05ff50b10df6579d34760939f19c4ff44d7df7ebf089d9c32f2f1d3a3b4beb11b37dc6844d9514b9eb71cfc024ec
@@ -9,16 +9,17 @@ concurrency:
9
9
  jobs:
10
10
  docs:
11
11
  name: Build gem documentation
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  timeout-minutes: 5
14
14
  steps:
15
- - uses: actions/checkout@v2
15
+ - uses: actions/checkout@v3
16
16
 
17
17
  - name: Install the correct Ruby version
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
20
20
  ruby-version: 2.5
21
21
  bundler-cache: true
22
+ rubygems: '3.3.26'
22
23
 
23
24
  - name: Prepare the virtual environment
24
25
  uses: hausgold/actions/ci@master
@@ -13,23 +13,24 @@ concurrency:
13
13
  jobs:
14
14
  test:
15
15
  name: 'Test the gem (Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }})'
16
- runs-on: ubuntu-20.04
16
+ runs-on: ubuntu-22.04
17
17
  timeout-minutes: 5
18
18
  strategy:
19
19
  fail-fast: false
20
20
  matrix:
21
- ruby: [2.5, 2.6, 2.7]
22
- rails: [5.2, '6.0']
21
+ ruby: ['2.5', '2.7']
22
+ rails: ['5.2']
23
23
  env:
24
24
  BUNDLE_GEMFILE: 'gemfiles/rails_${{ matrix.rails }}.gemfile'
25
25
  steps:
26
- - uses: actions/checkout@v2
26
+ - uses: actions/checkout@v3
27
27
 
28
28
  - name: Install the correct Ruby version
29
29
  uses: ruby/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
32
  bundler-cache: true
33
+ rubygems: '3.3.26'
33
34
 
34
35
  - name: Prepare the virtual environment
35
36
  uses: hausgold/actions/ci@master
@@ -46,7 +47,7 @@ jobs:
46
47
 
47
48
  trigger-docs:
48
49
  name: Trigger the documentation upload
49
- runs-on: ubuntu-20.04
50
+ runs-on: ubuntu-22.04
50
51
  timeout-minutes: 2
51
52
  needs: test
52
53
  if: github.ref == 'refs/heads/master'
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
+ --backtrace
2
+ --force-color
1
3
  --format documentation
2
- --color
data/.rubocop.yml CHANGED
@@ -1,14 +1,24 @@
1
- Documentation:
2
- Enabled: false
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-rails
4
+
5
+ Rails:
6
+ Enabled: true
7
+
8
+ Style/Documentation:
9
+ Enabled: true
3
10
 
4
11
  AllCops:
12
+ NewCops: enable
13
+ SuggestExtensions: false
5
14
  DisplayCopNames: true
6
15
  TargetRubyVersion: 2.5
16
+ TargetRailsVersion: 5.2
7
17
  Exclude:
8
18
  - bin/**/*
9
19
  - vendor/**/*
10
20
  - build/**/*
11
- - gemfiles/vendor/**/*
21
+ - gemfiles/**/*
12
22
 
13
23
  Metrics/BlockLength:
14
24
  Exclude:
@@ -20,5 +30,14 @@ Metrics/BlockLength:
20
30
 
21
31
  # We stay at 80 characters per line.
22
32
  # See: https://rubystyle.guide/#max-line-length
23
- Metrics/LineLength:
33
+ Layout/LineLength:
24
34
  Max: 80
35
+
36
+ # MFA is not yet enabled for our gems yet.
37
+ Gemspec/RequireMFA:
38
+ Enabled: false
39
+
40
+ # We use memoized helpers all over the place to construct inputs and output
41
+ # which can be customized at nested contexts easily.
42
+ RSpec/MultipleMemoizedHelpers:
43
+ Enabled: false
data/.simplecov CHANGED
@@ -1,3 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov-html'
4
+ require 'simplecov_json_formatter'
5
+
6
+ SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
7
+ [
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ SimpleCov::Formatter::JSONFormatter
10
+ ]
11
+ )
12
+
1
13
  SimpleCov.start 'test_frameworks' do
2
14
  add_filter '/vendor/bundle/'
3
15
  end
data/Appraisals CHANGED
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  appraise 'rails-5.2' do
4
- gem 'activesupport', '~> 5.2.2'
5
- end
6
-
7
- appraise 'rails-6.0' do
8
- gem 'activesupport', '~> 6.0.0'
4
+ gem 'activesupport', '~> 5.2.0'
9
5
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 1.4.0
2
+
3
+ * Bundler >= 2.3 is from now on required as minimal version (#10)
4
+ * Dropped support for Ruby < 2.5 (#10)
5
+ * Dropped support for Rails < 5.2 (#10)
6
+ * Updated all development/runtime gems to their latest
7
+ Ruby 2.5 compatible version (#10)
8
+
1
9
  ### 1.3.2
2
10
 
3
11
  * Migrated to Github Actions
data/Dockerfile CHANGED
@@ -2,7 +2,7 @@ FROM hausgold/ruby:2.5
2
2
  MAINTAINER Hermann Mayer <hermann.mayer@hausgold.de>
3
3
 
4
4
  # Update system gem
5
- RUN gem update --system
5
+ RUN gem update --system '3.3.26'
6
6
 
7
7
  # Install system packages and the latest bundler
8
8
  RUN apt-get update -yqqq && \
@@ -11,8 +11,7 @@ RUN apt-get update -yqqq && \
11
11
  ca-certificates \
12
12
  bash-completion inotify-tools && \
13
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
14
+ gem install bundler -v '~> 2.3.0' --no-document --no-prerelease
16
15
 
17
16
  # Add new web user
18
17
  RUN mkdir /app && \
data/Envfile CHANGED
@@ -1,6 +1,3 @@
1
1
  LANG=en_US.UTF-8
2
2
  LANGUAGE=en_US.UTF-8
3
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/Guardfile ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ (directories %w[lib spec]).select do |d|
8
+ if Dir.exist?(d)
9
+ d
10
+ else
11
+ UI.warning("Directory #{d} does not exist")
12
+ end
13
+ end
14
+
15
+ ## Note: if you are using the `directories` clause above and you are not
16
+ ## watching the project directory ('.'), then you will want to move
17
+ ## the Guardfile to a watched dir and symlink it back, e.g.
18
+ #
19
+ # $ mkdir config
20
+ # $ mv Guardfile config/
21
+ # $ ln -s config/Guardfile .
22
+ #
23
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
24
+
25
+ # NOTE: The cmd option is now required due to the increasing number of ways
26
+ # rspec may be run, below are examples of the most common uses.
27
+ # * bundler: 'bundle exec rspec'
28
+ # * bundler binstubs: 'bin/rspec'
29
+ # * spring: 'bin/rspec' (This will use spring if running and you have
30
+ # installed the spring binstubs per the docs)
31
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
32
+ # * 'just' rspec: 'rspec'
33
+
34
+ guard :rspec, cmd: 'bundle exec rspec' do
35
+ watch('spec/spec_helper.rb') { 'spec' }
36
+ watch(%r{^lib/immoscout.rb}) { 'spec' }
37
+ watch(%r{^spec/.+_spec\.rb$})
38
+ watch(%r{^lib/immoscout/([^\\]+)\.rb$}) do |m|
39
+ "spec/immoscout/#{m[1]}_spec.rb"
40
+ end
41
+ watch(%r{^lib/immoscout/([^\\]+)/(.*)\.rb$}) do |m|
42
+ "spec/#{m[1]}/#{m[2]}_spec.rb"
43
+ end
44
+ end
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 HAUSGOLD
3
+ Copyright (c) 2023 HAUSGOLD | talocasa GmbH
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Makefile CHANGED
@@ -9,6 +9,7 @@ SHELL := bash
9
9
  # Environment switches
10
10
  MAKE_ENV ?= docker
11
11
  COMPOSE_RUN_SHELL_FLAGS ?= --rm
12
+ BASH_RUN_SHELL_FLAGS ?=
12
13
 
13
14
  # Directories
14
15
  VENDOR_DIR ?= vendor/bundle
@@ -26,12 +27,14 @@ RM ?= rm
26
27
  XARGS ?= xargs
27
28
 
28
29
  # Container binaries
29
- BUNDLE ?= bundle
30
30
  APPRAISAL ?= appraisal
31
+ BUNDLE ?= bundle
31
32
  GEM ?= gem
33
+ GUARD ?= guard
32
34
  RAKE ?= rake
33
- YARD ?= yard
35
+ RSPEC ?= rspec
34
36
  RUBOCOP ?= rubocop
37
+ YARD ?= yard
35
38
 
36
39
  # Files
37
40
  GEMFILES ?= $(subst _,-,$(patsubst $(GEMFILES_DIR)/%.gemfile,%,\
@@ -45,7 +48,8 @@ define run-shell
45
48
  $(COMPOSE) run $(COMPOSE_RUN_SHELL_FLAGS) \
46
49
  -e LANG=en_US.UTF-8 -e LANGUAGE=en_US.UTF-8 -e LC_ALL=en_US.UTF-8 \
47
50
  -e HOME=/home/web -e BUNDLE_APP_CONFIG=/app/.bundle \
48
- -u `$(ID) -u` test bash -c 'sleep 0.1; echo; $(1)'
51
+ -u `$(ID) -u` test \
52
+ bash $(BASH_RUN_SHELL_FLAGS) -c 'sleep 0.1; echo; $(1)'
49
53
  endef
50
54
  else ifeq ($(MAKE_ENV),baremetal)
51
55
  define run-shell
@@ -57,9 +61,13 @@ all:
57
61
  # Immoscout
58
62
  #
59
63
  # install Install the dependencies
60
- # test Run the whole test suite
64
+ # update Update the local Gemset dependencies
61
65
  # clean Clean the dependencies
62
66
  #
67
+ # test Run the whole test suite
68
+ # test-style Test the code styles
69
+ # watch Watch for code changes and rerun the test suite
70
+ #
63
71
  # docs Generate the Ruby documentation of the library
64
72
  # stats Print the code statistics (library and test suite)
65
73
  # notes Print all the notes from the code
@@ -68,19 +76,25 @@ all:
68
76
  # shell Run an interactive shell on the container
69
77
  # shell-irb Run an interactive IRB shell on the container
70
78
 
79
+ .interactive:
80
+ @$(eval BASH_RUN_SHELL_FLAGS = --login)
81
+
71
82
  install:
72
83
  # Install the dependencies
73
84
  @$(MKDIR) -p $(VENDOR_DIR)
74
85
  @$(call run-shell,$(BUNDLE) check || $(BUNDLE) install --path $(VENDOR_DIR))
75
- @$(call run-shell,GEM_HOME=vendor/bundle/ruby/$${RUBY_MAJOR}.0 \
76
- $(GEM) install bundler -v "~> 1.0")
77
86
  @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) install)
78
87
 
79
88
  update:
80
89
  # Install the dependencies
81
90
  @$(MKDIR) -p $(VENDOR_DIR)
91
+ @$(call run-shell,$(BUNDLE) update)
82
92
  @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) update)
83
93
 
94
+ watch: install .interactive
95
+ # Watch for code changes and rerun the test suite
96
+ @$(call run-shell,$(BUNDLE) exec $(GUARD))
97
+
84
98
  test: \
85
99
  test-specs \
86
100
  test-style
@@ -92,7 +106,7 @@ test-specs:
92
106
  $(TEST_GEMFILES): GEMFILE=$(@:test-%=%)
93
107
  $(TEST_GEMFILES):
94
108
  # Run the whole test suite ($(GEMFILE))
95
- @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) $(GEMFILE) $(RAKE))
109
+ @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) $(GEMFILE) $(RSPEC))
96
110
 
97
111
  test-style: \
98
112
  test-style-ruby
@@ -107,8 +121,8 @@ clean:
107
121
  @$(RM) -rf $(VENDOR_DIR)/Gemfile.lock
108
122
  @$(RM) -rf $(GEMFILES_DIR)/vendor
109
123
  @$(RM) -rf $(GEMFILES_DIR)/*.lock
110
- @$(RM) -rf pkg
111
- @$(RM) -rf coverage
124
+ @$(RM) -rf .bundle .yardoc coverage pkg Gemfile.lock doc/api \
125
+ .rspec_status
112
126
 
113
127
  clean-containers:
114
128
  # Clean running containers
@@ -119,7 +133,7 @@ endif
119
133
  clean-images:
120
134
  # Clean build images
121
135
  ifeq ($(MAKE_ENV),docker)
122
- @-$(DOCKER) images | $(GREP) immoscout \
136
+ @-$(DOCKER) images | $(GREP) $(shell basename "`pwd`") \
123
137
  | $(AWK) '{ print $$3 }' \
124
138
  | $(XARGS) -rn1 $(DOCKER) rmi -f
125
139
  endif
data/Rakefile CHANGED
@@ -2,76 +2,23 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
- require 'rails/code_statistics'
6
- require 'pp'
5
+ require 'countless/rake_tasks'
7
6
 
8
7
  RSpec::Core::RakeTask.new(:spec)
9
8
 
10
9
  task default: :spec
11
10
 
12
- # Load some railties tasks
13
- load 'rails/tasks/statistics.rake'
14
- load 'rails/tasks/annotations.rake'
15
-
16
- # Clear the default statistics directory constant
17
- #
18
- # rubocop:disable Style/MutableConstant because we define it
19
- Object.send(:remove_const, :STATS_DIRECTORIES)
20
- ::STATS_DIRECTORIES = []
21
- # rubocop:enable Style/MutableConstant
22
-
23
- # Monkey patch the Rails +CodeStatistics+ class to support configurable
24
- # patterns per path. This is reuqired to support top-level only file matches.
25
- class CodeStatistics
26
- DEFAULT_PATTERN = /^(?!\.).*?\.(rb|js|coffee|rake)$/.freeze
27
-
28
- # Pass the possible +pattern+ argument down to the
29
- # +calculate_directory_statistics+ method call.
30
- def calculate_statistics
31
- Hash[@pairs.map do |pair|
32
- [pair.first, calculate_directory_statistics(*pair[1..-1])]
33
- end]
34
- end
35
-
36
- # Match the pattern against the individual file name and the relative file
37
- # path. This allows top-level only matches.
38
- def calculate_directory_statistics(directory, pattern = DEFAULT_PATTERN)
39
- stats = CodeStatisticsCalculator.new
40
-
41
- Dir.foreach(directory) do |file_name|
42
- path = "#{directory}/#{file_name}"
43
-
44
- if File.directory?(path) && (/^\./ !~ file_name)
45
- stats.add(calculate_directory_statistics(path, pattern))
46
- elsif file_name =~ pattern || path =~ pattern
47
- stats.add_by_file_path(path)
48
- end
49
- end
50
-
51
- stats
52
- end
53
- end
54
-
55
11
  # Configure all code statistics directories
56
- vendors = [
57
- [:unshift, 'Top-levels', 'lib', %r{lib(/immoscout)?/[^/]+\.rb$}],
58
- [:unshift, 'Top-levels specs', 'spec', %r{spec/_spec\.rb$}],
59
-
60
- [:unshift, 'API', 'lib/immoscout/api'],
61
- [:unshift, 'Errors', 'lib/immoscout/errors'],
62
-
63
- [:unshift, 'Models', 'lib/immoscout/models'],
64
- [:unshift, 'Models specs', 'spec/models']
65
- ].reverse
66
-
67
- vendors.each do |method, type, dir, pattern|
68
- ::STATS_DIRECTORIES.send(method, [type, dir, pattern].compact)
69
- ::CodeStatistics::TEST_TYPES << type if type.include? 'specs'
70
- end
71
-
72
- # Setup annotations
73
- ENV['SOURCE_ANNOTATION_DIRECTORIES'] = 'spec,doc'
74
- desc 'Enumerate all annotations'
75
- task :notes do
76
- SourceAnnotationExtractor.enumerate '@?OPTIMIZE|@?FIXME|@?TODO', tag: true
12
+ Countless.configure do |config|
13
+ config.stats_base_directories = [
14
+ { name: 'Top-levels', dir: 'lib',
15
+ pattern: %r{/lib(/immoscout)?/[^/]+\.rb$} },
16
+ { name: 'Top-levels specs', test: true, dir: 'spec',
17
+ pattern: %r{/spec(/immoscout)?/[^/]+_spec\.rb$} },
18
+ { name: 'APIs', pattern: 'lib/immoscout/api/**/*.rb' },
19
+ { name: 'Errors', pattern: 'lib/immoscout/errors/**/*.rb' },
20
+ { name: 'Models', pattern: 'lib/immoscout/models/**/*.rb' },
21
+ { name: 'Models specs', test: true,
22
+ pattern: 'spec/models/**/*_spec.rb' }
23
+ ]
77
24
  end
@@ -1,9 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
1
  # This file was generated by Appraisal
4
2
 
5
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
6
4
 
7
- gem 'activesupport', '~> 5.2.2'
5
+ gem "activesupport", "~> 5.2.0"
8
6
 
9
- gemspec path: '../'
7
+ gemspec path: "../"
data/immoscout.gemspec CHANGED
@@ -5,55 +5,56 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'immoscout/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'immoscout'
9
- spec.version = Immoscout::VERSION
10
- spec.authors = ['Marcus Geissler']
11
- spec.email = ['marcus.geissler@hanseventures.com']
12
-
13
- spec.summary = 'Ruby client for the Immobilienscout24 REST API'
14
- spec.homepage = 'https://github.com/hausgold/immoscout'
15
- spec.license = 'MIT'
16
-
17
- spec.required_ruby_version = '~> 2.5'
18
-
19
- # Prevent pushing this gem to RubyGems.org.
20
- # To allow pushes either set the 'allowed_push_host'
21
- # to allow pushing to a single host or delete this
22
- # section to allow pushing to any host.
23
- if spec.respond_to?(:metadata)
24
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
25
- else
26
- raise 'RubyGems 2.0 or newer is required to protect against ' \
27
- 'public gem pushes.'
28
- end
8
+ spec.name = 'immoscout'
9
+ spec.version = Immoscout::VERSION
10
+ spec.authors = ['Marcus Geissler']
11
+ spec.email = ['marcus3006@gmail.com']
12
+
13
+ spec.license = 'MIT'
14
+ spec.summary = 'Ruby client for the Immobilienscout24 REST API'
15
+
16
+ base_uri = "https://github.com/hausgold/#{spec.name}"
17
+ spec.metadata = {
18
+ 'homepage_uri' => base_uri,
19
+ 'source_code_uri' => base_uri,
20
+ 'changelog_uri' => "#{base_uri}/blob/master/CHANGELOG.md",
21
+ 'bug_tracker_uri' => "#{base_uri}/issues",
22
+ 'documentation_uri' => "https://www.rubydoc.info/gems/#{spec.name}"
23
+ }
29
24
 
30
25
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
31
26
  f.match(%r{^(test|spec|features)/})
32
27
  end
33
- spec.bindir = 'exe'
34
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
31
  spec.require_paths = ['lib']
36
- spec.add_dependency 'activesupport', '>= 5.2.0'
37
- spec.add_dependency 'faraday', '~> 1.0'
38
- spec.add_dependency 'faraday_middleware', '~> 1.0'
32
+
33
+ spec.required_ruby_version = '>= 2.5'
34
+
35
+ spec.add_dependency 'activesupport', '>= 5.2'
36
+ spec.add_dependency 'faraday', '~> 1.10'
37
+ spec.add_dependency 'faraday_middleware', '~> 1.2'
39
38
  spec.add_dependency 'simple_oauth', '>= 0.3'
40
39
 
41
- spec.add_development_dependency 'appraisal'
42
- spec.add_development_dependency 'bundler', '>= 1.16', '< 3'
43
- spec.add_development_dependency 'factory_bot', '~> 4.11'
44
- spec.add_development_dependency 'railties', '>= 4.2.0', '< 6.1'
45
- spec.add_development_dependency 'rake', '~> 10.0'
46
- spec.add_development_dependency 'rdoc', '~> 6.1'
47
- spec.add_development_dependency 'redcarpet', '~> 3.4'
48
- spec.add_development_dependency 'rspec', '~> 3.0'
49
- spec.add_development_dependency 'rspec-json_expectations', '~> 1.4'
50
- spec.add_development_dependency 'rubocop', '~> 0.63.1'
51
- spec.add_development_dependency 'rubocop-rspec', '~> 1.31'
52
- spec.add_development_dependency 'simplecov', '< 0.18'
53
- spec.add_development_dependency 'terminal-table', '~> 1.8'
54
- spec.add_development_dependency 'timecop', '~> 0.9.1'
55
- spec.add_development_dependency 'vcr', '~> 3.0'
56
- spec.add_development_dependency 'webmock', '~> 3.5'
57
- spec.add_development_dependency 'yard', '~> 0.9.18'
58
- spec.add_development_dependency 'yard-activesupport-concern', '~> 0.0.1'
40
+ spec.add_development_dependency 'appraisal', '~> 2.4'
41
+ spec.add_development_dependency 'bundler', '~> 2.3'
42
+ spec.add_development_dependency 'countless', '~> 1.1'
43
+ spec.add_development_dependency 'factory_bot', '~> 6.2'
44
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
45
+ spec.add_development_dependency 'railties', '>= 5.2'
46
+ spec.add_development_dependency 'rake', '~> 13.0'
47
+ spec.add_development_dependency 'redcarpet', '~> 3.5'
48
+ spec.add_development_dependency 'rspec', '~> 3.12'
49
+ spec.add_development_dependency 'rspec-json_expectations', '~> 2.2'
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'
59
60
  end
@@ -6,6 +6,7 @@ require_relative 'request'
6
6
 
7
7
  module Immoscout
8
8
  module Api
9
+ # The immoscout API client object.
9
10
  class Client
10
11
  include Singleton
11
12
  include Immoscout::Api::Connection
@@ -5,22 +5,21 @@ require 'faraday_middleware'
5
5
 
6
6
  module Immoscout
7
7
  module Api
8
+ # A connection builder/handler for reusable connections.
8
9
  module Connection
9
- # :reek:FeatureEnvy
10
10
  def connection
11
11
  @connection ||= Faraday::Connection.new(url: url) do |builder|
12
12
  configure_oauth(builder)
13
- builder.request :multipart
14
- builder.request :url_encoded
15
- builder.request :json
16
- builder.response :follow_redirects
17
- builder.response :json, content_type: /\bjson$/
18
- builder.adapter :net_http
13
+ builder.request :multipart
14
+ builder.request :url_encoded
15
+ builder.request :json
16
+ builder.response :follow_redirects
17
+ builder.response :json, content_type: /\bjson$/
18
+ builder.adapter :net_http
19
19
  end
20
- @connection
21
20
  end
22
21
 
23
- private
22
+ protected
24
23
 
25
24
  def configure_oauth(builder)
26
25
  builder.request(
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Immoscout
4
4
  module Api
5
+ # An abstract HTTP/API request.
5
6
  module Request
6
7
  def get(path, payload = nil, multipart = nil)
7
8
  request(:get, path, payload, multipart)
@@ -25,12 +26,12 @@ module Immoscout
25
26
  if multipart
26
27
  request.headers['Content-Type'] = 'multipart/form-data'
27
28
  else
28
- request.body = payload if payload
29
+ request.body = payload if payload
29
30
  request.headers['Content-Type'] = 'application/json;charset=UTF-8'
30
31
  end
31
32
  request.headers['Accept'] = 'application/json'
32
33
  request.headers['User-Agent'] = \
33
- "HausgoldImmoscout/#{Immoscout::VERSION}"
34
+ "RubyImmoscout/#{Immoscout::VERSION}"
34
35
  end
35
36
  end
36
37
  # rubocop:enable Metrics/MethodLength
@@ -1,13 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Immoscout
4
+ # The configuration object of the +immoscout+ gem.
4
5
  class Configuration
5
6
  include ActiveSupport::Configurable
6
- config_accessor(:consumer_key) { ENV['IMMOSCOUT_CONSUMER_KEY'] }
7
- config_accessor(:consumer_secret) { ENV['IMMOSCOUT_CONSUMER_SECRET'] }
8
7
 
9
- config_accessor(:oauth_token) { ENV['IMMOSCOUT_OAUTH_TOKEN'] }
10
- config_accessor(:oauth_token_secret) { ENV['IMMOSCOUT_OAUTH_TOKEN_SECRET'] }
8
+ config_accessor(:consumer_key) { ENV.fetch('IMMOSCOUT_CONSUMER_KEY', nil) }
9
+ config_accessor(:consumer_secret) do
10
+ ENV.fetch('IMMOSCOUT_CONSUMER_SECRET', nil)
11
+ end
12
+
13
+ config_accessor(:oauth_token) { ENV.fetch('IMMOSCOUT_OAUTH_TOKEN', nil) }
14
+ config_accessor(:oauth_token_secret) do
15
+ ENV.fetch('IMMOSCOUT_OAUTH_TOKEN_SECRET', nil)
16
+ end
11
17
 
12
18
  config_accessor(:use_sandbox) { false }
13
19
 
@@ -17,11 +23,11 @@ module Immoscout
17
23
 
18
24
  config_accessor(:api_url_live) do
19
25
  'https://rest.immobilienscout24.de/' \
20
- "restapi/api/offer/#{api_version}"
26
+ "restapi/api/offer/#{api_version}"
21
27
  end
22
28
  config_accessor(:api_url_sandbox) do
23
29
  'https://rest.sandbox-immobilienscout24.de/' \
24
- "restapi/api/offer/#{api_version}"
30
+ "restapi/api/offer/#{api_version}"
25
31
  end
26
32
  end
27
33
  end