• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 25875362278
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: robust_mounted_app_comparison
DEFAULT BRANCH: master
Ran 14 May 2026 05:37PM UTC
Jobs 37
Files 161
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

14 May 2026 05:36PM UTC coverage: 97.019%. First build
25875362278

push

github

ericproulx
[DRAFT] Generalize middleware options to per-class Data value objects

Demonstration / discussion PR. Right now every middleware that wants
typed accessors over its options has to hand-write the same boilerplate:

  DEFAULT_OPTIONS = { foo: nil, bar: nil, ... }.freeze
  attr_reader :foo, :bar, ...
  def initialize(app, **options)
    super
    @foo = @options[:foo]
    @bar = @options[:bar]
    ...
  end

Since `@options` was already frozen by design (Middleware::Base#initialize
post-PR #2696), the natural next step is to replace the Hash with a
per-subclass `Options = Data.define(...)` and let `Forwardable` cover the
accessor wiring.

Mechanism added in this draft:

- `Grape::Middleware::OptionsCompat` — a small mixin Options classes
  include to keep the legacy `options[:key]` idiom working (notably for
  `Middleware::Base#content_types` and `#content_type`). Unknown keys
  return `nil` to match Hash semantics.
- `Middleware::Base#initialize` detects `self.class::Options` and routes
  kwargs through `Options.new(**options)`. Subclasses that still rely on
  `DEFAULT_OPTIONS` Hash + deep_merge keep working unchanged.

Demonstrated on `Middleware::Formatter`:

- Replaces 5-line DEFAULT_OPTIONS Hash + 4-line `attr_reader` list +
  6-line initialize body with:

    Options = Data.define(:content_types, :default_format, :format,
                          :formatters, :parsers) do
      include Grape::Middleware::OptionsCompat
      def initialize(content_types: nil, default_format: :txt, format: nil,
                     formatters: nil, parsers: nil)
        super
      end
    end

    def_delegators :options, :default_format, :format, :formatters, :parsers

- Defaults move from the freeze'd Hash to `#initialize` signature.
- Immutability is implicit (Data instances).

Behaviour change: passing an unknown kwarg to a middleware whose `Options`
class doesn't declare it now raises `ArgumentError` instead of being
silently swallowed by `**options`. One form... (continued)

1087 of 1171 branches covered (92.83%)

Branch coverage included in aggregate %.

17 of 17 new or added lines in 3 files covered. (100.0%)

3502 of 3559 relevant lines covered (98.4%)

32049.64 hits per line

Jobs
ID Job ID Ran Files Coverage
1 run-4.0-gemfiles/rack_2_2.gemfile - 25875362278.1 14 May 2026 05:37PM UTC 160
95.68
GitHub Action Run
2 run-3.2-gemfiles/rails_8_0.gemfile - 25875362278.2 14 May 2026 05:37PM UTC 161
95.77
GitHub Action Run
3 run-3.2-gemfiles/rack_3_1.gemfile - 25875362278.3 14 May 2026 05:37PM UTC 160
95.76
GitHub Action Run
4 run-3.3-gemfiles/rails_8_0.gemfile - 25875362278.4 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
5 run-3.2-gemfiles/rack_3_2.gemfile - 25875362278.5 14 May 2026 05:37PM UTC 160
95.76
GitHub Action Run
6 run-3.2-gemfiles/rack_2_2.gemfile - 25875362278.6 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
7 run-4.0-gemfiles/rails_8_0.gemfile - 25875362278.7 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
8 run-4.0-gemfiles/multi_xml.gemfile - 25875362278.8 14 May 2026 05:37PM UTC 160
36.38
GitHub Action Run
9 run-4.0-gemfiles/rails_7_2.gemfile - 25875362278.9 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
10 run-3.3-gemfiles/rails_7_2.gemfile - 25875362278.10 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
11 run-3.4-gemfiles/rack_3_0.gemfile - 25875362278.11 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
12 run-3.4-gemfiles/rails_7_2.gemfile - 25875362278.12 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
13 run-3.3-gemfiles/rails_8_1.gemfile - 25875362278.13 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
14 run-4.0-gemfiles/multi_json.gemfile - 25875362278.14 14 May 2026 05:37PM UTC 160
36.38
GitHub Action Run
15 run-3.4-gemfiles/rack_2_2.gemfile - 25875362278.15 14 May 2026 05:37PM UTC 160
95.68
GitHub Action Run
16 run-4.0-gemfiles/grape_entity.gemfile - 25875362278.16 14 May 2026 05:37PM UTC 160
50.08
GitHub Action Run
17 run-3.3-gemfiles/rack_2_2.gemfile - 25875362278.17 14 May 2026 05:37PM UTC 160
95.68
GitHub Action Run
18 run-4.0-gemfiles/rack_3_0.gemfile - 25875362278.18 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
19 run-3.3-gemfiles/rack_3_1.gemfile - 25875362278.19 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
20 run-3.4-gemfiles/rack_3_1.gemfile - 25875362278.20 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
21 run-4.0-gemfiles/rails_8_1.gemfile - 25875362278.21 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
22 run-3.3-Gemfile - 25875362278.22 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
23 run-3.4-gemfiles/rack_3_2.gemfile - 25875362278.23 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
24 run-4.0-gemfiles/hashie.gemfile - 25875362278.24 14 May 2026 05:37PM UTC 160
62.46
GitHub Action Run
25 run-4.0-Gemfile - 25875362278.25 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
26 run-3.2-gemfiles/rails_7_2.gemfile - 25875362278.26 14 May 2026 05:37PM UTC 161
95.77
GitHub Action Run
27 run-3.4-Gemfile - 25875362278.27 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
28 run-3.2-Gemfile - 25875362278.28 14 May 2026 05:37PM UTC 160
95.76
GitHub Action Run
29 run-3.4-gemfiles/rails_8_0.gemfile - 25875362278.29 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
30 run-4.0-gemfiles/rack_3_1.gemfile - 25875362278.30 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
31 run-3.3-gemfiles/rack_3_2.gemfile - 25875362278.31 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
32 run-3.4-gemfiles/rails_8_1.gemfile - 25875362278.32 14 May 2026 05:37PM UTC 161
95.72
GitHub Action Run
33 run-3.2-gemfiles/rack_3_0.gemfile - 25875362278.33 14 May 2026 05:37PM UTC 160
95.76
GitHub Action Run
34 run-3.2-gemfiles/rails_8_1.gemfile - 25875362278.34 14 May 2026 05:37PM UTC 161
95.77
GitHub Action Run
35 run-3.3-gemfiles/rack_3_0.gemfile - 25875362278.35 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
36 run-4.0-gemfiles/rack_3_2.gemfile - 25875362278.36 14 May 2026 05:37PM UTC 160
95.72
GitHub Action Run
37 run-4.0-gemfiles/dry_validation.gemfile - 25875362278.37 14 May 2026 05:37PM UTC 160
58.11
GitHub Action Run
Source Files on build 25875362278
  • Tree
  • List 161
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #25875362278
  • ba9b2e78 on github
  • Prev Build on master (#25873678149)
  • Next Build on draft/middleware-options-data (#25878904332)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc