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

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

Build:
Build:
LAST BUILD BRANCH: route-param-bare-requirements
DEFAULT BRANCH: master
Ran 02 Sep 2026 09:54PM UTC
Jobs 32
Files 169
Run time 2min
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

02 Sep 2026 09:44PM UTC coverage: 96.94%. Remained the same
33686809238

Pull #2889

github

ericproulx
Constrain the version capture with a Regexp instead of an Array

`Pattern#extract_capture` hands the declared versions to Mustermann as the
Array of Strings they arrive in:

    requirements.merge(version: map_str(version))

Mustermann uses `capture:` for two things: shaping the regexp, and deriving
*param converters*. The second is the problem. `AST::ParamScanner::Capture`
only knows how to build a converter from a Class or a Symbol, so for an Array
of plain Strings every entry contributes nothing — and it still hands one back:

    entries = capture.map { |item| converter(item) }.compact   # => []
    converter = ->(string) do
      _, c = entries.find { |r, _| r.match?(string) }          # => nil
      c&.call(string) || string                                # => string
    end

An identity function, registered for `version` on every path-versioned route.

Its cost is not the call. A non-empty converter table makes
`AST::Pattern#identity_params?` false forever, and that is the predicate
`RegexpBased#build_params` consults to decide whether it may hand back the
capture Hash as it came:

    if @simple_captures
      params = match.named_captures
      return params if params.empty? || identity_params?(params)
      params.each_with_object({}) { |(k, v), h| h[k] = map_param(k, v) }

So every request on the route rebuilt the Hash through `map_param` and called
the do-nothing lambda on each value — `Route#params_for` runs this on every
matched request. Passing `Regexp.union(map_str(version))` registers no
converter at all, and produces a simpler regexp into the bargain:

    array:   (?<version>(?-mix:(?-mix:(?:v|%76)(?:1|%31))|(?-mix:(?:v|%76)(?:2|%32))))
    regexp:  (?<version>(?-mix:v1|v2))

`Regexp.union` escapes its arguments, so versions carrying regexp
metacharacters (`v1.0`, `v2+beta`) still match literally.

One behavioural difference, visible in those two lines: Mustermann expands an
Array entry the way it expands a path literal, so each cha... (continued)
Pull Request #2889: Constrain the version capture with a Regexp instead of an Array

1239 of 1334 branches covered (92.88%)

Branch coverage included in aggregate %.

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

1 existing line in 1 file now uncovered.

3925 of 3993 relevant lines covered (98.3%)

27527.7 hits per line

Coverage Regressions

Lines Coverage ∆ File
1
97.01
0.0% lib/grape/router.rb
Jobs
ID Job ID Ran Files Coverage
1 run-4.0-gemfiles/multi_xml.gemfile - 33686809238.1 02 Sep 2026 09:55PM UTC 168
46.95
GitHub Action Run
2 run-4.0-gemfiles/rails_8_0.gemfile - 33686809238.2 02 Sep 2026 09:56PM UTC 169
95.7
GitHub Action Run
3 run-4.0-Gemfile - 33686809238.3 02 Sep 2026 09:54PM UTC 168
95.7
GitHub Action Run
4 run-4.0-gemfiles/rack_3_1.gemfile - 33686809238.4 02 Sep 2026 09:57PM UTC 168
95.7
GitHub Action Run
5 run-3.4-Gemfile - 33686809238.5 02 Sep 2026 09:57PM UTC 168
95.7
GitHub Action Run
6 run-4.0-gemfiles/rails_7_2.gemfile - 33686809238.6 02 Sep 2026 09:54PM UTC 169
95.7
GitHub Action Run
7 run-3.3-gemfiles/rack_2_2.gemfile - 33686809238.7 02 Sep 2026 09:55PM UTC 168
95.66
GitHub Action Run
8 run-3.3-gemfiles/rails_8_1.gemfile - 33686809238.8 02 Sep 2026 09:57PM UTC 169
95.7
GitHub Action Run
9 run-3.3-gemfiles/rack_3_0.gemfile - 33686809238.9 02 Sep 2026 09:56PM UTC 168
95.7
GitHub Action Run
10 run-3.4-gemfiles/rails_8_0.gemfile - 33686809238.10 02 Sep 2026 09:55PM UTC 169
95.7
GitHub Action Run
11 run-4.0-gemfiles/grape_entity.gemfile - 33686809238.11 02 Sep 2026 09:55PM UTC 168
50.31
GitHub Action Run
12 run-4.0-gemfiles/rails_8_1.gemfile - 33686809238.12 02 Sep 2026 09:55PM UTC 169
95.7
GitHub Action Run
13 run-3.3-gemfiles/rails_7_2.gemfile - 33686809238.13 02 Sep 2026 09:57PM UTC 169
95.7
GitHub Action Run
14 run-3.4-gemfiles/rails_8_1.gemfile - 33686809238.14 02 Sep 2026 09:57PM UTC 169
95.7
GitHub Action Run
15 run-4.0-gemfiles/rack_3_0.gemfile - 33686809238.15 02 Sep 2026 09:54PM UTC 168
95.7
GitHub Action Run
16 run-3.4-gemfiles/rack_3_2.gemfile - 33686809238.16 02 Sep 2026 09:57PM UTC 168
95.7
GitHub Action Run
17 run-4.0-gemfiles/grape_swagger.gemfile - 33686809238.17 02 Sep 2026 09:55PM UTC 168
55.2
GitHub Action Run
18 run-3.3-gemfiles/rails_8_0.gemfile - 33686809238.18 02 Sep 2026 09:56PM UTC 169
95.7
GitHub Action Run
19 run-4.0-gemfiles/rack_2_2.gemfile - 33686809238.19 02 Sep 2026 09:57PM UTC 168
95.66
GitHub Action Run
20 run-3.4-gemfiles/rails_7_2.gemfile - 33686809238.20 02 Sep 2026 09:55PM UTC 169
95.7
GitHub Action Run
21 run-3.3-gemfiles/rack_3_1.gemfile - 33686809238.21 02 Sep 2026 09:57PM UTC 168
95.7
GitHub Action Run
22 run-3.4-gemfiles/rack_3_0.gemfile - 33686809238.22 02 Sep 2026 09:57PM UTC 168
95.7
GitHub Action Run
23 run-4.0-gemfiles/multi_json_1_20.gemfile - 33686809238.23 02 Sep 2026 09:56PM UTC 168
47.47
GitHub Action Run
24 run-4.0-gemfiles/rack_3_2.gemfile - 33686809238.24 02 Sep 2026 09:54PM UTC 168
95.7
GitHub Action Run
25 run-3.3-gemfiles/rack_3_2.gemfile - 33686809238.25 02 Sep 2026 09:55PM UTC 168
95.7
GitHub Action Run
26 run-4.0-gemfiles/multi_json.gemfile - 33686809238.26 02 Sep 2026 09:56PM UTC 168
47.43
GitHub Action Run
27 run-4.0-gemfiles/dry_validation.gemfile - 33686809238.27 02 Sep 2026 09:57PM UTC 168
57.81
GitHub Action Run
28 run-3.4-gemfiles/rack_2_2.gemfile - 33686809238.28 02 Sep 2026 09:54PM UTC 168
95.66
GitHub Action Run
29 run-3.4-gemfiles/rack_3_1.gemfile - 33686809238.29 02 Sep 2026 09:58PM UTC 168
95.7
GitHub Action Run
30 run-4.0-gemfiles/multi_xml_0_8.gemfile - 33686809238.30 02 Sep 2026 09:54PM UTC 168
46.98
GitHub Action Run
31 run-4.0-gemfiles/hashie.gemfile - 33686809238.31 02 Sep 2026 09:58PM UTC 168
61.77
GitHub Action Run
32 run-3.3-Gemfile - 33686809238.32 02 Sep 2026 09:56PM UTC 168
95.7
GitHub Action Run
Source Files on build 33686809238
  • Tree
  • List 169
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #33686809238
  • Pull Request #2889
  • PR Base - master (#33686307519)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc