arstotzka 1.6.2 → 1.7.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +34 -12
  3. data/.claude/agents/architect.md +48 -0
  4. data/.claude/agents/infra.md +34 -0
  5. data/.claude/agents/ruby.md +43 -0
  6. data/.claude/configuration/arcanum-repo-config.json +3 -0
  7. data/.claude/scripts/check_infra.sh +6 -0
  8. data/.claude/scripts/check_ruby.sh +7 -0
  9. data/.claude/settings.json +10 -0
  10. data/.github/commit_message_template-2.0.md +32 -0
  11. data/.github/commit_message_template.md +10 -0
  12. data/.github/copilot-instructions.md +1 -0
  13. data/.github/pull_request_template.md +17 -0
  14. data/.gitignore +1 -0
  15. data/.rubocop.yml +19 -6
  16. data/AGENTS.md +69 -0
  17. data/CLAUDE.md +1 -0
  18. data/Dockerfile +6 -9
  19. data/Gemfile +20 -3
  20. data/README.md +8 -4
  21. data/Rakefile +2 -0
  22. data/arstotzka.gemspec +4 -24
  23. data/docs/agents/arcanum-split-issue.md +9 -0
  24. data/docs/agents/architecture.md +64 -0
  25. data/docs/agents/contributing.md +202 -0
  26. data/docs/agents/flow.md +28 -0
  27. data/docs/agents/folder-structure.md +29 -0
  28. data/docs/agents/issue-enhancement.md +11 -0
  29. data/docs/agents/issues/.gitkeep +1 -0
  30. data/docs/agents/plans/.gitkeep +1 -0
  31. data/lib/arstotzka/class_methods.rb +1 -1
  32. data/lib/arstotzka/crawler.rb +1 -0
  33. data/lib/arstotzka/exception.rb +1 -0
  34. data/lib/arstotzka/fetcher/cache.rb +1 -0
  35. data/lib/arstotzka/key_reader.rb +2 -1
  36. data/lib/arstotzka/method_builder.rb +1 -0
  37. data/lib/arstotzka/options.rb +1 -1
  38. data/lib/arstotzka/reader.rb +1 -0
  39. data/lib/arstotzka/type_cast.rb +2 -2
  40. data/lib/arstotzka/version.rb +1 -1
  41. data/lib/arstotzka/wrapper.rb +17 -1
  42. data/scripts/bump_version.sh +62 -0
  43. data/spec/integration/yard/arstotzka/class_methods_spec.rb +1 -0
  44. data/spec/integration/yard/arstotzka/config_spec.rb +1 -1
  45. data/spec/integration/yard/arstotzka/fetcher/cache_spec.rb +1 -1
  46. data/spec/integration/yard/arstotzka/options_spec.rb +2 -4
  47. data/spec/integration/yard/arstotzka/type_cast_spec.rb +1 -1
  48. data/spec/integration/yard/arstotzka/wrapper_spec.rb +1 -1
  49. data/spec/lib/arstotzka/fetcher_spec.rb +1 -1
  50. data/spec/lib/arstotzka/options_spec.rb +1 -2
  51. data/spec/lib/arstotzka/type_cast_spec.rb +4 -4
  52. data/spec/lib/arstotzka/wrapper_spec.rb +4 -3
  53. data/spec/spec_helper.rb +13 -4
  54. data/spec/support/models/arstotzka/dummy.rb +1 -0
  55. data/spec/support/models/arstotzka/wrapper/dummy.rb +1 -0
  56. data/spec/support/models/car_collector.rb +1 -1
  57. data/spec/support/models/collector.rb +1 -1
  58. data/spec/support/models/game.rb +1 -0
  59. data/spec/support/models/house.rb +1 -0
  60. data/spec/support/models/my_parser.rb +1 -1
  61. data/spec/support/models.rb +2 -2
  62. metadata +32 -329
@@ -0,0 +1,202 @@
1
+ # Contributing
2
+
3
+ ## Commit Guidelines
4
+
5
+ - **Atomic and Unitary:** Each commit must represent a single logical change.
6
+ *Example:*
7
+ - Good: `Add before option to Wrapper`
8
+ - Bad: `Add before option and refactor Crawler logic`
9
+ - **No Unrelated Changes:** Do not mix unrelated changes in the same commit.
10
+ - **Separate Refactoring:** Whenever possible, separate refactoring commits from new feature or bugfix commits.
11
+
12
+ ## Pull Requests
13
+
14
+ - **Descriptive Summary:** Every PR must include a clear and descriptive summary of its purpose and changes.
15
+ - **PR Description Files:** If a description cannot be provided directly in the PR, generate a file with the PR description (e.g., `docs/agents/issues/<pr_number>_description.md`), but do not commit this file.
16
+
17
+ ## Definition of Done for PRs
18
+
19
+ A PR is considered complete when:
20
+
21
+ - The stated objective has been achieved.
22
+ - All tests are passing.
23
+ - Linting (`rubocop`) passes without errors.
24
+ - Code coverage is as high as reasonably possible.
25
+ - New/changed public code is documented with YARD and Yardstick coverage does not drop.
26
+ - `@example` blocks added to YARD docs or `README.md` are covered by specs in
27
+ `spec/integration/yard` or `spec/integration/readme`.
28
+ - When the version is bumped, `README.md` links the new version's YARD docs.
29
+ - Code is not overly complex:
30
+ - Classes and methods should have clear, focused responsibilities.
31
+ - If a class or method is taking on too many responsibilities, refactor to simplify.
32
+ - Methods should be small and do exactly one thing. If a method is growing, extract parts into private helper methods or separate classes.
33
+ - *Example:*
34
+
35
+ ```ruby
36
+ # Good: each method does one thing
37
+ class Fetcher
38
+ def fetch
39
+ post_processor.process(crawler.value(hash))
40
+ end
41
+
42
+ private
43
+
44
+ def crawler
45
+ @crawler ||= Crawler.new(options)
46
+ end
47
+ end
48
+
49
+ # Bad: one method does too much
50
+ class Fetcher
51
+ def fetch
52
+ hash = options.instance.send(options.json)
53
+ value = options.keys.inject(hash) { |h, key| h[key.to_s] || h[key.to_sym] }
54
+ value = value.flatten if options.flatten
55
+ options.instance.send(options.after, value)
56
+ end
57
+ end
58
+ ```
59
+
60
+ - This requirement applies primarily to source code. For specs, refactor only if there is excessive duplication.
61
+
62
+ ### CI Checks
63
+
64
+ Before a PR is considered complete, all CI checks relevant to the modified parts of the project must pass locally.
65
+
66
+ The project has a single CircleCI `test` job, run for every change:
67
+
68
+ | Modified folder | CircleCI job | Local commands |
69
+ | --- | --- | --- |
70
+ | any (`lib/`, `spec/`, `config/`, `README.md`, ...) | `test` | `bundle exec rspec`<br>`rubocop`<br>`bundle exec rake verify_measurements` (Yardstick)<br>`scripts/check_readme.sh` (README links current version docs)<br>`bundle exec rubycritic --format console --branch origin/master -t 0 --maximum-decrease 1 <changed lib files>`<br>every `lib/` file has a spec under `spec/lib/` (`check_specs`, see `config/check_specs.yml`) |
71
+
72
+ The same can be run in Docker with `docker-compose run test_all` (RSpec + YARD + Yardstick)
73
+ plus `docker-compose run arstotzka rubocop`.
74
+
75
+ The `build-and-release` job only runs on version tags on `master` and needs no local check.
76
+
77
+ This same process must be followed when **planning how to resolve an issue**: include a final step in the plan that lists the CI commands to run before opening a PR.
78
+
79
+ ## Code Organization
80
+
81
+ ### File Responsibility: Class Declarers vs Scripts
82
+
83
+ Every source file under `lib/` must act as a **class declarer** — it should define one class or module. Files must not act as **scripts** (i.e., they must not execute logic at load time or perform side effects directly).
84
+
85
+ The only entrypoint is `lib/arstotzka.rb`, which requires dependencies, defines the
86
+ `Arstotzka` concern, autoloads the other classes and calls `configurable_by`.
87
+
88
+ *Example:*
89
+
90
+ ```ruby
91
+ # Good: class declarer
92
+ module Arstotzka
93
+ class KeyChanger
94
+ def initialize(base_key, options_hash = {})
95
+ ...
96
+ end
97
+ end
98
+ end
99
+
100
+ # Bad: script — executes logic at load time
101
+ changer = Arstotzka::KeyChanger.new('the_key', case: :lower_camel)
102
+ puts changer.key
103
+ ```
104
+
105
+ Spec files are exempt from this rule and may execute setup code freely.
106
+
107
+ ### File Naming: snake_case Matching the Class
108
+
109
+ Files use **snake_case** naming matching the class or module they define, and the
110
+ directory structure mirrors the namespace:
111
+
112
+ - `Arstotzka::KeyChanger` → `lib/arstotzka/key_changer.rb`
113
+ - `Arstotzka::Fetcher::Cache` → `lib/arstotzka/fetcher/cache.rb`
114
+
115
+ Specs mirror the source path with a `_spec.rb` suffix:
116
+
117
+ - `lib/arstotzka/key_changer.rb` → `spec/lib/arstotzka/key_changer_spec.rb`
118
+
119
+ New classes must also be registered with `autoload` in `lib/arstotzka.rb`.
120
+
121
+ ### Method Order: Public Before Private
122
+
123
+ Within a class, **public methods must be declared before `protected` and `private` methods**. Private methods serve as implementation helpers and appear at the end of the class body.
124
+
125
+ *Example:*
126
+
127
+ ```ruby
128
+ # Good: public methods first, private methods last
129
+ class Wrapper
130
+ def wrap(value)
131
+ return wrap_array(value) if value.is_a?(Array)
132
+
133
+ wrap_element(value)
134
+ end
135
+
136
+ private
137
+
138
+ def wrap_array(array) ... end
139
+ def wrap_element(value) ... end
140
+ end
141
+
142
+ # Bad: private helpers mixed in before public methods
143
+ class Wrapper
144
+ private
145
+
146
+ def wrap_array(array) ... end
147
+
148
+ public
149
+
150
+ def wrap(value) ... end
151
+ end
152
+ ```
153
+
154
+ ## Dependency Injection
155
+
156
+ Classes must receive their dependencies (data, options, collaborators) as constructor arguments. A class must never reach out to load files, read environment variables, or fetch configuration on its own.
157
+
158
+ In Arstotzka, global configuration is resolved once — by `FetcherBuilder#build` via
159
+ `Arstotzka.config.options(...)` — and the resulting `Options` object (including the
160
+ `instance`) is passed down to every collaborator (`Fetcher`, `Crawler`, `Wrapper`, ...).
161
+
162
+ This makes every class independently testable: specs simply instantiate the class with the options they need.
163
+
164
+ *Example:*
165
+
166
+ ```ruby
167
+ # Good: class receives options as an argument — easy to test
168
+ class Wrapper
169
+ def initialize(options = {})
170
+ @options = options
171
+ end
172
+ end
173
+
174
+ Arstotzka::Wrapper.new(type: :integer).wrap('10') # => 10
175
+
176
+ # Bad: class reads global configuration on its own
177
+ class Wrapper
178
+ def wrap(value)
179
+ cast(value, Arstotzka.config.type) # ❌
180
+ end
181
+ end
182
+ ```
183
+
184
+ This principle applies to all classes — including helpers. If a class needs data, it gets it through its constructor.
185
+
186
+ ## Refactoring Guidelines
187
+
188
+ When refactoring, aim to:
189
+
190
+ - **Reduce Code Duplication:**
191
+ *Example:* Move repeated setup in specs to `let` blocks, shared examples
192
+ (`spec/support/shared_examples`) or support models (`spec/support/models`).
193
+
194
+ ```ruby
195
+ # Good
196
+ let(:options) { { path: 'person', case: :snake } }
197
+ let(:fetcher) { described_class.new(options.merge(instance: instance)) }
198
+
199
+ # Bad
200
+ fetcher = described_class.new(path: 'person', case: :snake, instance: instance)
201
+ # ...repeated in many examples
202
+ ```
@@ -0,0 +1,28 @@
1
+ # Flow
2
+
3
+ ## Overview
4
+
5
+ ### Declaration (class load time)
6
+
7
+ 1. `include Arstotzka` extends the class with `Arstotzka::ClassMethods`.
8
+ 2. `expose :attr, **options` creates an `Arstotzka::MethodBuilder` with the attribute names
9
+ and options.
10
+ 3. For each attribute, `MethodBuilder` registers a `FetcherBuilder` in the class
11
+ (`add_fetcher`) and defines the instance method `attr`.
12
+
13
+ ### Fetching (method call time)
14
+
15
+ 1. `instance.attr` calls `self.class.fetcher_for(:attr, self)`, which finds the
16
+ `FetcherBuilder` (looking up superclasses) and builds a `Fetcher` with
17
+ `Arstotzka.config.options(options.merge(instance: self))`.
18
+ 2. `Fetcher#fetch` goes through `Fetcher::Cache`: if `cached` is set and a value is
19
+ already stored, it is returned.
20
+ 3. Otherwise `HashReader` gets the hash from the instance (the `json` option).
21
+ 4. `Crawler#value` walks the keys (`path` + attribute name, or `full_path`), using `Reader`
22
+ → `KeyReader` → `KeyChanger` to read each key in the configured case. Arrays are
23
+ crawled element by element; missing keys yield `default`, and `compact` drops `nil`s.
24
+ 5. Each final value passes through `Wrapper#wrap`: `before`, type cast (`TypeCast`),
25
+ wrapping in `klass`, and `after_each`.
26
+ 6. `PostProcessor#process` applies `flatten` and calls the instance's `after` method on
27
+ the whole result.
28
+ 7. The result is cached (if requested) and returned.
@@ -0,0 +1,29 @@
1
+ # Folder Structure
2
+
3
+ ## Project Root
4
+
5
+ | Directory / File | Description |
6
+ |-----------------|-------------|
7
+ | `lib/` | Gem source code: `lib/arstotzka.rb` (the concern entrypoint) and `lib/arstotzka/` (internal classes). See [architecture.md](architecture.md). |
8
+ | `spec/` | RSpec test suite (unit, integration, fixtures and support models). |
9
+ | `config/` | Configuration for quality tooling: Yardstick (`yardstick.rb`, `yardstick.yml`), RubyCritic (`rubycritc.rb`) and `check_specs.yml` (lib files exempt from requiring a spec). |
10
+ | `scripts/` | CI helper scripts: `check_readme.sh` (README links the current version's YARD docs) and `rubycritic.sh` (RubyCritic comparison against `master`). |
11
+ | `docs/agents/` | Agent-facing documentation, issue files and implementation plans. |
12
+ | `.circleci/` | CircleCI pipeline: `test` job (RSpec, RuboCop, coverage, Yardstick, README check, RubyCritic, check_specs) and `build-and-release` job (gem push on version tags). |
13
+ | `.github/` | PR template, commit message template and Copilot instructions. |
14
+ | `arstotzka.gemspec` | Gem specification and dependencies. |
15
+ | `Dockerfile`, `docker-compose.yml` | Containerised development environment (`arstotzka` runs RSpec, `test_all` runs RSpec + YARD + Yardstick). |
16
+ | `Rakefile` | Rake tasks: RSpec, gem tasks, Yardstick measurement/verification. |
17
+ | `.rubocop.yml`, `.rubocop_todo.yml` | RuboCop configuration. |
18
+ | `.yardopts` | YARD documentation options. |
19
+ | `README.md` | User-facing documentation with usage examples (exercised by `spec/integration/readme`). |
20
+
21
+ ## spec/
22
+
23
+ | Subdirectory | Description |
24
+ |--------------|-------------|
25
+ | `lib/` | Unit specs mirroring `lib/` one-to-one (`lib/arstotzka/foo.rb` → `spec/lib/arstotzka/foo_spec.rb`). |
26
+ | `integration/readme/` | Specs asserting the examples from `README.md` work. |
27
+ | `integration/yard/` | Specs asserting the `@example` blocks from the YARD docs work. |
28
+ | `fixtures/` | JSON fixtures loaded by specs. |
29
+ | `support/` | Spec helpers, shared examples and `models/` — sample classes including `Arstotzka` used by specs and doc examples. |
@@ -0,0 +1,11 @@
1
+ # Issue Enhancement
2
+
3
+ A checklist of concerns to consider when fleshing out a vague issue idea (tagged `Idea`/`Writting`) before it reaches the `Created` stage. Not exhaustive — adjust or extend the list for this project's needs.
4
+
5
+ - **Scope boundaries** — what's explicitly in scope and what's explicitly out.
6
+ - **Alternative solutions** — other ways to solve the same problem, and why this one was chosen.
7
+ - **Edge cases** — inputs, states, or timing the happy path doesn't cover.
8
+ - **Backward compatibility** — whether this breaks existing behavior, data, or integrations.
9
+ - **Testing strategy** — how the change will be verified.
10
+ - **Performance & security considerations** — anything relevant to load, latency, or attack surface.
11
+ - **Public API & docs impact** — new or changed `expose` options / public classes, required YARD docs and README examples (with their integration specs), and whether a version bump is needed.
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -43,7 +43,7 @@ module Arstotzka
43
43
  # @return [TrueClass,FalseClass]
44
44
  def fetcher_for?(attribute)
45
45
  return true if fetcher_builders.key?(attribute)
46
- return unless superclass.include?(Arstotzka)
46
+ return false unless superclass.include?(Arstotzka)
47
47
 
48
48
  superclass.fetcher_for?(attribute)
49
49
  end
@@ -99,6 +99,7 @@ module Arstotzka
99
99
  private
100
100
 
101
101
  attr_reader :block, :options
102
+
102
103
  # @method block
103
104
  # @api private
104
105
  # @private
@@ -17,6 +17,7 @@ module Arstotzka
17
17
  #
18
18
  # @return [FetcherBuilderNotFound]
19
19
  def initialize(attribute, klass)
20
+ super()
20
21
  @attribute = attribute
21
22
  @klass = klass
22
23
  end
@@ -103,6 +103,7 @@ module Arstotzka
103
103
  private
104
104
 
105
105
  attr_reader :block, :options
106
+
106
107
  delegate :cached, :key, :instance, to: :options
107
108
 
108
109
  # @private
@@ -48,6 +48,7 @@ module Arstotzka
48
48
  private
49
49
 
50
50
  attr_reader :hash, :base_key, :options
51
+
51
52
  delegate :key, to: :key_changer
52
53
 
53
54
  # @private
@@ -61,7 +62,7 @@ module Arstotzka
61
62
  #
62
63
  # @see #check_key!
63
64
  def key?
64
- return unless hash
65
+ return false unless hash
65
66
 
66
67
  hash.key?(key) || hash.key?(key.to_sym)
67
68
  end
@@ -59,6 +59,7 @@ module Arstotzka
59
59
 
60
60
  # @private
61
61
  attr_reader :attr_names, :options
62
+
62
63
  delegate to: :options
63
64
 
64
65
  # @private
@@ -267,7 +267,7 @@ module Arstotzka
267
267
  warn ":class has been deprecated, prefer 'expose klass: #{klass}'" if klass
268
268
  options_hash[:klass] ||= klass
269
269
 
270
- super(options_hash)
270
+ super
271
271
  end
272
272
 
273
273
  # @private
@@ -80,6 +80,7 @@ module Arstotzka
80
80
 
81
81
  # @private
82
82
  attr_reader :options
83
+
83
84
  delegate :keys, to: :options
84
85
  end
85
86
  end
@@ -37,7 +37,7 @@ module Arstotzka
37
37
  # module Arstotzka
38
38
  # module TypeCast
39
39
  # def to_car(hash)
40
- # Car.new(hash.symbolize_keys)
40
+ # Car.new(**hash.symbolize_keys)
41
41
  # end
42
42
  # end
43
43
  # end
@@ -120,7 +120,7 @@ module Arstotzka
120
120
  #
121
121
  # model.TypeCaster.new(hash)
122
122
  #
123
- # model.payload # returns '{"key"=>"value"}'
123
+ # model.payload # returns '{"key" => "value"}'
124
124
  def to_string(value)
125
125
  value.to_s
126
126
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arstotzka
4
- VERSION = '1.6.2'
4
+ VERSION = '1.7.0'
5
5
  end
@@ -56,7 +56,7 @@ module Arstotzka
56
56
  # wrapper = Arstotzka::Wrapper.new(type: :string, klass: Request)
57
57
  # request = wrapper.wrap(value)
58
58
  #
59
- # request.payload # returns '{"key"=>"value"}'
59
+ # request.payload # returns '{"key" => "value"}'
60
60
  def wrap(value)
61
61
  return wrap_array(value) if value.is_a?(Array)
62
62
 
@@ -67,6 +67,7 @@ module Arstotzka
67
67
 
68
68
  # @private
69
69
  attr_reader :options
70
+
70
71
  delegate :klass, :type, :after_each, to: :options
71
72
 
72
73
  # @private
@@ -133,13 +134,28 @@ module Arstotzka
133
134
  #
134
135
  # Wrap resulting value in class
135
136
  #
137
+ # When the value is a +Hash+ and the class initializer
138
+ # accepts keyword arguments, the hash is passed as keywords
139
+ #
136
140
  # @return [Object] instance of +options.klass+
137
141
  def wrap_in_class(value)
138
142
  return value unless klass
143
+ return klass.new(**value) if value.is_a?(Hash) && keyword_initializer?
139
144
 
140
145
  klass.new(value)
141
146
  end
142
147
 
148
+ # @private
149
+ #
150
+ # Checks if +options.klass+ initializer accepts keyword arguments
151
+ #
152
+ # @return [TrueClass,FalseClass]
153
+ def keyword_initializer?
154
+ klass.instance_method(:initialize).parameters.any? do |type, _|
155
+ %i[key keyreq keyrest].include?(type)
156
+ end
157
+ end
158
+
143
159
  # @private
144
160
  #
145
161
  # Process and wrap value trhough a method call
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+ # Usage: scripts/bump_version.sh [major|minor|patch|X.Y.Z]
3
+ # Without arguments, bumps the patch version of the current version.
4
+
5
+ set -euo pipefail
6
+
7
+ ROOT="$(git rev-parse --show-toplevel)"
8
+ README="$ROOT/README.md"
9
+ VERSION_FILE="$ROOT/lib/arstotzka/version.rb"
10
+ LOCKFILE="$ROOT/Gemfile.lock"
11
+ GEM="arstotzka"
12
+
13
+ current=$(grep -oE "VERSION = '[0-9]+\.[0-9]+\.[0-9]+'" "$VERSION_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
14
+ IFS='.' read -r cmajor cminor cpatch <<< "$current"
15
+
16
+ arg="${1:-patch}"
17
+
18
+ case "$arg" in
19
+ major) new_version="$((cmajor + 1)).0.0" ;;
20
+ minor) new_version="${cmajor}.$((cminor + 1)).0" ;;
21
+ patch) new_version="${cmajor}.${cminor}.$((cpatch + 1))" ;;
22
+ *) new_version="$arg" ;;
23
+ esac
24
+
25
+ # Validate semver format
26
+ if ! echo "$new_version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
27
+ echo "Error: version must be major, minor, patch or X.Y.Z" >&2
28
+ exit 1
29
+ fi
30
+
31
+ # Next release: following minor
32
+ IFS='.' read -r major minor _patch <<< "$new_version"
33
+ next_release="${major}.$((minor + 1)).0"
34
+
35
+ echo "Current version: $current"
36
+ echo "New version: $new_version"
37
+ echo "Next release: $next_release"
38
+
39
+ # version.rb
40
+ sed -i '' "s|VERSION = '[0-9.]*'|VERSION = '${new_version}'|" "$VERSION_FILE"
41
+
42
+ # README: YARD docs link
43
+ sed -i '' \
44
+ "s|rubydoc.info/gems/${GEM}/[0-9.]*|rubydoc.info/gems/${GEM}/${new_version}|g" \
45
+ "$README"
46
+
47
+ # README: Current Release line
48
+ sed -i '' \
49
+ "s|\*\*Current Release\*\*: \[[0-9.]*\](https://github.com/darthjee/arstotzka/tree/[0-9.]*)|**Current Release**: [${new_version}](https://github.com/darthjee/arstotzka/tree/${new_version})|" \
50
+ "$README"
51
+
52
+ # README: Next release line
53
+ sed -i '' \
54
+ "s|\*\*Next release\*\*: \[[0-9.]*\](https://github.com/darthjee/arstotzka/compare/[0-9.]*\.\.\.main)|**Next release**: [${next_release}](https://github.com/darthjee/arstotzka/compare/${new_version}...main)|" \
55
+ "$README"
56
+
57
+ # Gemfile.lock
58
+ if [ -f "$LOCKFILE" ]; then
59
+ sed -i '' "s|^\( *${GEM} (\)[0-9.]*)|\1${new_version})|" "$LOCKFILE"
60
+ fi
61
+
62
+ echo "Done."
@@ -8,6 +8,7 @@ describe Arstotzka::ClassMethods do
8
8
  let(:klass) do
9
9
  Class.new(MyModel) do
10
10
  include Arstotzka
11
+
11
12
  expose :first_name, full_path: 'name.first'
12
13
  expose :age, 'cars', type: :integer
13
14
  end
@@ -22,7 +22,7 @@ describe Arstotzka::Config do
22
22
  end
23
23
 
24
24
  let(:error_message) do
25
- "undefined method `json' for #{office}\nDid you mean? JSON"
25
+ "undefined method 'json' for an instance of Office"
26
26
  end
27
27
 
28
28
  it do
@@ -55,7 +55,7 @@ describe Arstotzka::Fetcher::Cache do
55
55
  expect(cache.fetch).to eq(5050)
56
56
  end
57
57
 
58
- it ' does not recalculates when cache is not nil' do
58
+ it 'does not recalculates when cache is not nil' do
59
59
  cache.fetch
60
60
  settings[:calculate] = true
61
61
  cache.fetch
@@ -49,22 +49,21 @@ describe Arstotzka::Options do
49
49
  ]
50
50
  end
51
51
 
52
- # rubocop:disable RSpec/LeakyConstantDeclaration
53
52
  before do
53
+ # rubocop:disable-next Lint/ConstantDefinitionInBlock
54
54
  module Arstotzka::TypeCast
55
55
  def to_symbolized_hash(value)
56
56
  value.symbolize_keys
57
57
  end
58
58
  end
59
59
  end
60
- # rubocop:enable RSpec/LeakyConstantDeclaration
61
60
 
62
61
  it 'returns inflated drinks' do
63
62
  expect(instance.drinks).to eq(expected)
64
63
  end
65
64
  end
66
65
 
67
- # rubocop:disable RSpec/SubjectStub
66
+ # rubocop:disable-next RSpec/SubjectStub
68
67
  describe 'Using cached, compact, after and full_path' do
69
68
  let(:clazz) { Application }
70
69
 
@@ -101,7 +100,6 @@ describe Arstotzka::Options do
101
100
  expect(instance).to have_received(:warn).exactly(3).times
102
101
  end
103
102
  end
104
- # rubocop:enable RSpec/SubjectStub
105
103
 
106
104
  describe 'working with snake case hash' do
107
105
  let(:clazz) { JobSeeker }
@@ -21,7 +21,7 @@ describe Arstotzka::TypeCast do
21
21
 
22
22
  describe 'string' do
23
23
  it 'converts value to string' do
24
- expect(model.payload).to eq('{"key"=>"value"}')
24
+ expect(model.payload).to eq('{"key" => "value"}')
25
25
  end
26
26
  end
27
27
 
@@ -37,7 +37,7 @@ describe Arstotzka::Wrapper do
37
37
  end
38
38
 
39
39
  it 'casts before wrapping' do
40
- expect(request.payload).to eq('{"key"=>"value"}')
40
+ expect(request.payload).to eq('{"key" => "value"}')
41
41
  end
42
42
  end
43
43
  end
@@ -85,7 +85,7 @@ describe Arstotzka::Fetcher do
85
85
  { after: :sum, key: :value }
86
86
  end
87
87
 
88
- it 'applies after call ' do
88
+ it 'applies after call' do
89
89
  expect(fetcher.fetch).to eq(325)
90
90
  end
91
91
  end
@@ -160,7 +160,7 @@ describe Arstotzka::Options do
160
160
  end
161
161
 
162
162
  # rubocop:disable RSpec/SubjectStub
163
- # rubocop:disable RSpec/AnyInstance
163
+ # rubocop:disable-next RSpec/AnyInstance
164
164
  describe '#klass' do
165
165
  before do
166
166
  allow_any_instance_of(described_class)
@@ -191,7 +191,6 @@ describe Arstotzka::Options do
191
191
  end
192
192
  end
193
193
  end
194
- # rubocop:enable RSpec/AnyInstance
195
194
  # rubocop:enable RSpec/SubjectStub
196
195
 
197
196
  describe '#merge' do
@@ -9,7 +9,7 @@ describe Arstotzka::TypeCast do
9
9
 
10
10
  describe '.to_integer' do
11
11
  context 'when value is nil' do
12
- let(:value) {}
12
+ let(:value) { nil }
13
13
 
14
14
  it { expect(caster.to_integer(value)).to be_nil }
15
15
  end
@@ -71,7 +71,7 @@ describe Arstotzka::TypeCast do
71
71
 
72
72
  describe '.to_string' do
73
73
  context 'when value is nil' do
74
- let(:value) {}
74
+ let(:value) { nil }
75
75
 
76
76
  it { expect(caster.to_string(value)).to eq('') }
77
77
  end
@@ -111,7 +111,7 @@ describe Arstotzka::TypeCast do
111
111
 
112
112
  describe '.to_float' do
113
113
  context 'when value is nil' do
114
- let(:value) {}
114
+ let(:value) { nil }
115
115
 
116
116
  it { expect(caster.to_float(value)).to be_nil }
117
117
  end
@@ -172,7 +172,7 @@ describe Arstotzka::TypeCast do
172
172
 
173
173
  describe '.to_symbol' do
174
174
  context 'when value is nil' do
175
- let(:value) {}
175
+ let(:value) { nil }
176
176
 
177
177
  it { expect(caster.to_symbol(value)).to be_nil }
178
178
  end
@@ -3,8 +3,9 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Arstotzka::Wrapper do
6
+ subject { described_class.new options }
7
+
6
8
  let(:options) { {} }
7
- let(:subject) { described_class.new options }
8
9
  let(:hash) { { a: 1 } }
9
10
 
10
11
  describe '#wrap' do
@@ -65,7 +66,7 @@ describe Arstotzka::Wrapper do
65
66
  expect(result.name).to eq(hash[:name])
66
67
  end
67
68
 
68
- it 'updates the hash before ' do
69
+ it 'updates the hash before' do
69
70
  expect(result.age).to eq(10)
70
71
  end
71
72
 
@@ -84,7 +85,7 @@ describe Arstotzka::Wrapper do
84
85
  expect(result.map(&:name)).to all(eq(hash[:name]))
85
86
  end
86
87
 
87
- it 'updates the hash before ' do
88
+ it 'updates the hash before' do
88
89
  expect(result.map(&:age)).to all(eq(10))
89
90
  end
90
91
  end