pricehubble 0.4.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c029e790cdf1ec21949212567077f03271666ca6332a3b84a902a262ae6625e
4
- data.tar.gz: 3df77cae40f611c456283a23e215a840ce88936748aefb9c729a205c61ebd7d8
3
+ metadata.gz: 85745808382e5b8d332d66c00b5a15c5b31677d5969655951a987a3c1a877b4d
4
+ data.tar.gz: 2269357cd88afc29a2dcf145a9a579542d2b33ae88b09cb88771442f960aba9c
5
5
  SHA512:
6
- metadata.gz: 6421682c63aa011271eca9931587badf8fbf7ad1c64aadbfa9bccef42dd170e68dd3dee5ed9f8e965ee47e2055e0fdca398ed355370bd91c8a28e045fbc26729
7
- data.tar.gz: ebe7f75db3e959c48074e0c74092ca6a9a94789645aba5051ab1a972fb8be66295092fe1a07f62a680f53c977152724e8aef31ae06e32afc316b47092e46c66f
6
+ metadata.gz: 0e647a10162f859a8ea645b0ffc2cb2da064fc0e3802e4f4646b877221e56e2930894ba189d74837ec097a1bb26dd48cce4b343d5e60271d6cb6cdc366f19c14
7
+ data.tar.gz: e040750996b8266d30174b7c6bf692477b8467aa852791e67b2ab864800b267136deb77a86baeebcc038944bedf4b3492d6e379a70887160e3cbdd7e797f129b
@@ -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
@@ -0,0 +1,47 @@
1
+ name: Release
2
+ run-name: Release ${{ github.event.inputs.VERSION }}
3
+
4
+ on:
5
+ workflow_dispatch:
6
+ inputs:
7
+ VERSION:
8
+ description: The new version to release. (eg. `1.0.0`) Check the
9
+ changelog for the latest version.
10
+
11
+ concurrency:
12
+ group: '${{ github.event.inputs.VERSION }}'
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ docs:
17
+ name: Release the gem
18
+ runs-on: ubuntu-22.04
19
+ timeout-minutes: 5
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+
23
+ - name: Install Ruby 2.5
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: 2.5
27
+ bundler-cache: true
28
+ rubygems: '3.3.26'
29
+
30
+ - name: Prepare the virtual environment
31
+ uses: hausgold/actions/ci@master
32
+ with:
33
+ clone_token: '${{ secrets.CLONE_TOKEN }}'
34
+ settings: '${{ github.repository }}'
35
+ target: ci/gem-test
36
+
37
+ - name: Switch to SSH remotes for the Git repository
38
+ run: git-ssh-remotes
39
+
40
+ - name: Enforce version '${{ github.event.inputs.VERSION }}'
41
+ run: set-gem-version '${{ github.event.inputs.VERSION }}'
42
+
43
+ - name: Prepare the Git release commit
44
+ run: git-release-commit '${{ github.event.inputs.VERSION }}'
45
+
46
+ - name: Push the release Git commit/tag and package to the registry
47
+ run: make release
@@ -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,3 +1,3 @@
1
+ --backtrace
2
+ --force-color
1
3
  --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,19 +1,24 @@
1
- require: rubocop-rspec
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-rails
2
4
 
3
5
  Rails:
4
6
  Enabled: true
5
7
 
6
- Documentation:
8
+ Style/Documentation:
7
9
  Enabled: true
8
10
 
9
11
  AllCops:
12
+ NewCops: enable
13
+ SuggestExtensions: false
10
14
  DisplayCopNames: true
11
15
  TargetRubyVersion: 2.5
16
+ TargetRailsVersion: 5.2
12
17
  Exclude:
13
18
  - bin/**/*
14
19
  - vendor/**/*
15
20
  - build/**/*
16
- - gemfiles/vendor/**/*
21
+ - gemfiles/**/*
17
22
 
18
23
  Metrics/BlockLength:
19
24
  Exclude:
@@ -27,6 +32,15 @@ Metrics/BlockLength:
27
32
  - lib/pricehubble/client/request/**/*.rb
28
33
  - lib/pricehubble/client/response/**/*.rb
29
34
 
35
+ # Our examples use +pp+ a lot
36
+ Lint/Debugger:
37
+ Exclude:
38
+ - doc/examples/**/*.rb
39
+
40
+ # MFA is not yet enabled for our gems yet.
41
+ Gemspec/RequireMFA:
42
+ Enabled: false
43
+
30
44
  # Document all the things.
31
45
  Style/DocumentationMethod:
32
46
  Enabled: true
@@ -63,5 +77,20 @@ Lint/ShadowingOuterLocalVariable:
63
77
 
64
78
  # We stay at 80 characters per line.
65
79
  # See: https://rubystyle.guide/#max-line-length
66
- Metrics/LineLength:
80
+ Layout/LineLength:
67
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
+ # That are false-positives because we implement similar working
89
+ # helpers for associations like +.has_one+.
90
+ Rails/ReflectionClassName:
91
+ Enabled: false
92
+
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
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,13 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  appraise 'rails-5.2' do
4
- gem 'activemodel', '~> 5.2.2'
5
- gem 'activesupport', '~> 5.2.2'
6
- gem 'railties', '~> 5.2.2'
7
- end
8
-
9
- appraise 'rails-6.0' do
10
- gem 'activemodel', '~> 6.0.0'
11
- gem 'activesupport', '~> 6.0.0'
12
- gem 'railties', '~> 6.0.0'
4
+ gem 'activemodel', '~> 5.2.0'
5
+ gem 'activesupport', '~> 5.2.0'
13
6
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ### next
2
+
3
+ * TODO: Replace this bullet point with an actual description of a change.
4
+
5
+ ### 1.1.0
6
+
7
+ * Added support for Gem release automation
8
+
9
+ ### 1.0.0
10
+
11
+ * Bundler >= 2.3 is from now on required as minimal version (#5)
12
+ * Dropped support for Ruby < 2.5 (#5)
13
+ * Dropped support for Rails < 5.2 (#5)
14
+ * Updated all development/runtime gems to their latest
15
+ Ruby 2.5 compatible version (#5)
16
+ * [Breaking Change] The `sanitize` argument of the
17
+ `PriceHubble::BaseEntity#attributes(sanitize = false)` method has changed to
18
+ a keyword argument `PriceHubble::BaseEntity#attributes(sanitize: false)` (#5)
19
+
1
20
  ### 0.4.2
2
21
 
3
22
  * Migrated to Github Actions
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at development@hausgold.de. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
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/pricehubble.rb}) { 'spec' }
37
+ watch(%r{^spec/.+_spec\.rb$})
38
+ watch(%r{^lib/pricehubble/([^\\]+)\.rb$}) do |m|
39
+ "spec/pricehubble/#{m[1]}_spec.rb"
40
+ end
41
+ watch(%r{^lib/pricehubble/([^\\]+)/(.*)\.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) 2019 HAUSGOLD | talocasa GmbH
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
@@ -62,6 +66,7 @@ all:
62
66
  #
63
67
  # test Run the whole test suite
64
68
  # test-style Test the code styles
69
+ # watch Watch for code changes and rerun the test suite
65
70
  #
66
71
  # docs Generate the Ruby documentation of the library
67
72
  # stats Print the code statistics (library and test suite)
@@ -71,27 +76,37 @@ all:
71
76
  # shell Run an interactive shell on the container
72
77
  # shell-irb Run an interactive IRB shell on the container
73
78
 
79
+ .interactive:
80
+ @$(eval BASH_RUN_SHELL_FLAGS = --login)
81
+
74
82
  install:
75
83
  # Install the dependencies
76
84
  @$(MKDIR) -p $(VENDOR_DIR)
77
85
  @$(call run-shell,$(BUNDLE) check || $(BUNDLE) install --path $(VENDOR_DIR))
78
- @$(call run-shell,GEM_HOME=vendor/bundle/ruby/$${RUBY_MAJOR}.0 \
79
- $(GEM) install bundler -v "~> 1.0")
80
86
  @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) install)
81
87
 
82
88
  update:
83
89
  # Install the dependencies
84
90
  @$(MKDIR) -p $(VENDOR_DIR)
91
+ @$(call run-shell,$(BUNDLE) update)
85
92
  @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) update)
86
93
 
87
- test:
94
+ watch: install .interactive
95
+ # Watch for code changes and rerun the test suite
96
+ @$(call run-shell,$(BUNDLE) exec $(GUARD))
97
+
98
+ test: \
99
+ test-specs \
100
+ test-style
101
+
102
+ test-specs:
88
103
  # Run the whole test suite
89
104
  @$(call run-shell,$(BUNDLE) exec $(RAKE) stats spec)
90
105
 
91
106
  $(TEST_GEMFILES): GEMFILE=$(@:test-%=%)
92
107
  $(TEST_GEMFILES):
93
108
  # Run the whole test suite ($(GEMFILE))
94
- @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) $(GEMFILE) $(RAKE))
109
+ @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) $(GEMFILE) $(RSPEC))
95
110
 
96
111
  test-style: \
97
112
  test-style-ruby
@@ -106,8 +121,8 @@ clean:
106
121
  @$(RM) -rf $(VENDOR_DIR)/Gemfile.lock
107
122
  @$(RM) -rf $(GEMFILES_DIR)/vendor
108
123
  @$(RM) -rf $(GEMFILES_DIR)/*.lock
109
- @$(RM) -rf pkg
110
- @$(RM) -rf coverage
124
+ @$(RM) -rf .bundle .yardoc coverage pkg Gemfile.lock doc/api \
125
+ .rspec_status
111
126
 
112
127
  clean-containers:
113
128
  # Clean running containers
@@ -118,7 +133,7 @@ endif
118
133
  clean-images:
119
134
  # Clean build images
120
135
  ifeq ($(MAKE_ENV),docker)
121
- @-$(DOCKER) images | $(GREP) pricehubble \
136
+ @-$(DOCKER) images | $(GREP) $(shell basename "`pwd`") \
122
137
  | $(AWK) '{ print $$3 }' \
123
138
  | $(XARGS) -rn1 $(DOCKER) rmi -f
124
139
  endif
data/README.md CHANGED
@@ -27,7 +27,9 @@ so feel free to send a pull request.
27
27
  - [Advanced Request Examples](#advanced-request-examples)
28
28
  - [Dossiers](#dossiers)
29
29
  - [Development](#development)
30
+ - [Code of Conduct](#code-of-conduct)
30
31
  - [Contributing](#contributing)
32
+ - [Releasing](#releasing)
31
33
 
32
34
  ## Installation
33
35
 
@@ -423,17 +425,28 @@ pp dossier.link
423
425
 
424
426
  ## Development
425
427
 
426
- After checking out the repo, run `bin/setup` to install dependencies. Then, run
427
- `bundle exec rake spec` to run the tests. You can also run `bin/console` for an
428
+ After checking out the repo, run `make install` to install dependencies. Then,
429
+ run `make test` to run the tests. You can also run `make shell-irb` for an
428
430
  interactive prompt that will allow you to experiment.
429
431
 
430
- To install this gem onto your local machine, run `bundle exec rake install`. To
431
- release a new version, update the version number in `version.rb`, and then run
432
- `bundle exec rake release`, which will create a git tag for the version, push
433
- git commits and tags, and push the `.gem` file to
434
- [rubygems.org](https://rubygems.org).
432
+ ## Code of Conduct
433
+
434
+ Everyone interacting in the project codebase, issue tracker, chat
435
+ rooms and mailing lists is expected to follow the [code of
436
+ conduct](./CODE_OF_CONDUCT.md).
435
437
 
436
438
  ## Contributing
437
439
 
438
440
  Bug reports and pull requests are welcome on GitHub at
439
- https://github.com/hausgold/pricehubble.
441
+ https://github.com/hausgold/pricehubble. Make sure that every pull request adds
442
+ a bullet point to the [changelog](./CHANGELOG.md) file with a reference to the
443
+ actual pull request.
444
+
445
+ ## Releasing
446
+
447
+ The release process of this Gem is fully automated. You just need to open the
448
+ Github Actions [Release
449
+ Workflow](https://github.com/hausgold/pricehubble/actions/workflows/release.yml)
450
+ and trigger a new run via the **Run workflow** button. Insert the new version
451
+ number (check the [changelog](./CHANGELOG.md) first for the latest release) and
452
+ you're done.
data/Rakefile CHANGED
@@ -2,84 +2,30 @@
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(/pricehubble)?/[^/]+\.rb$}],
58
- [:unshift, 'Top-levels specs', 'spec',
59
- %r{spec/pricehubble(_spec\.rb|/[^/]+\.rb$)}],
60
-
61
- [:unshift, 'Clients', 'lib/pricehubble/client'],
62
- [:unshift, 'Clients specs', 'spec/client'],
63
-
64
- [:unshift, 'Entities', 'lib/pricehubble/entity'],
65
- [:unshift, 'Entities specs', 'spec/entity'],
66
-
67
- [:unshift, 'Utilities', 'lib/pricehubble/utils'],
68
- [:unshift, 'Utilities specs', 'spec/utils'],
69
-
70
- [:unshift, 'Instrumentation', 'lib/pricehubble/instrumentation'],
71
- [:unshift, 'Core Extensions', 'lib/pricehubble/core_ext']
72
- ].reverse
73
-
74
- vendors.each do |method, type, dir, pattern|
75
- ::STATS_DIRECTORIES.send(method, [type, dir, pattern].compact)
76
- ::CodeStatistics::TEST_TYPES << type if type.include? 'specs'
77
- end
78
-
79
- # Setup annotations
80
- ENV['SOURCE_ANNOTATION_DIRECTORIES'] = 'spec,doc'
81
-
82
- desc 'Enumerate all annotations'
83
- task :notes do
84
- 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(/pricehubble)?/[^/]+\.rb$} },
16
+ { name: 'Top-levels specs', test: true, dir: 'spec',
17
+ pattern: %r{/spec(/pricehubble)?/[^/]+_spec\.rb$} },
18
+ { name: 'Clients', pattern: 'lib/pricehubble/client/**/*.rb' },
19
+ { name: 'Clients specs', test: true,
20
+ pattern: 'spec/client/**/*_spec.rb' },
21
+ { name: 'Entities', pattern: 'lib/pricehubble/entity/**/*.rb' },
22
+ { name: 'Entities specs', test: true,
23
+ pattern: 'spec/entity/**/*_spec.rb' },
24
+ { name: 'Utilities', pattern: 'lib/pricehubble/utils/**/*.rb' },
25
+ { name: 'Utilities specs', test: true,
26
+ pattern: 'spec/utils/**/*_spec.rb' },
27
+ { name: 'Instrumentation',
28
+ pattern: 'lib/pricehubble/instrumentation/**/*.rb' },
29
+ { name: 'Core Extensions', pattern: 'lib/pricehubble/core_ext/**/*.rb' }
30
+ ]
85
31
  end