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

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

Build:
Build:
LAST BUILD BRANCH: perf/default-status-single-read
DEFAULT BRANCH: master
Ran 03 Sep 2026 12:59PM 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

03 Sep 2026 12:59PM UTC coverage: 96.954% (+0.006%) from 96.948%
33758398003

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.

`map_str` stays, and now matters more than it did: `Regexp.union` takes only
Strings and Regexps, and `version` accepts Symbols and Inte... (continued)
Pull Request #2889: Constrain the version capture with a Regexp instead of an Array

1244 of 1338 branches covered (92.97%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 4 files covered. (100.0%)

1 existing line in 1 file now uncovered.

3945 of 4014 relevant lines covered (98.28%)

27009.76 hits per line

Coverage Regressions

Lines Coverage ∆ File
1
96.92
0.0% lib/grape/router.rb
Jobs
ID Job ID Ran Files Coverage
1 run-4.0-gemfiles/multi_json_1_20.gemfile - 33758398003.1 03 Sep 2026 12:59PM UTC 168
47.51
GitHub Action Run
2 run-3.3-Gemfile - 33758398003.2 03 Sep 2026 01:00PM UTC 168
95.72
GitHub Action Run
3 run-3.4-gemfiles/rails_8_1.gemfile - 33758398003.3 03 Sep 2026 12:59PM UTC 169
95.72
GitHub Action Run
4 run-4.0-gemfiles/rails_8_1.gemfile - 33758398003.4 03 Sep 2026 12:59PM UTC 169
95.72
GitHub Action Run
5 run-3.3-gemfiles/rails_8_1.gemfile - 33758398003.5 03 Sep 2026 12:59PM UTC 169
95.72
GitHub Action Run
6 run-4.0-gemfiles/grape_entity.gemfile - 33758398003.6 03 Sep 2026 12:59PM UTC 168
50.34
GitHub Action Run
7 run-3.4-gemfiles/rails_7_2.gemfile - 33758398003.7 03 Sep 2026 12:59PM UTC 169
95.72
GitHub Action Run
8 run-4.0-gemfiles/rack_3_1.gemfile - 33758398003.8 03 Sep 2026 12:59PM UTC 168
95.72
GitHub Action Run
9 run-4.0-gemfiles/dry_validation.gemfile - 33758398003.9 03 Sep 2026 12:59PM UTC 168
57.74
GitHub Action Run
10 run-4.0-gemfiles/rack_3_2.gemfile - 33758398003.10 03 Sep 2026 12:59PM UTC 168
95.72
GitHub Action Run
11 run-3.3-gemfiles/rails_7_2.gemfile - 33758398003.11 03 Sep 2026 12:59PM UTC 169
95.72
GitHub Action Run
12 run-3.4-Gemfile - 33758398003.12 03 Sep 2026 12:59PM UTC 168
95.72
GitHub Action Run
13 run-4.0-gemfiles/hashie.gemfile - 33758398003.13 03 Sep 2026 01:00PM UTC 168
61.75
GitHub Action Run
14 run-4.0-gemfiles/rack_3_0.gemfile - 33758398003.14 03 Sep 2026 12:59PM UTC 168
95.72
GitHub Action Run
15 run-3.3-gemfiles/rails_8_0.gemfile - 33758398003.15 03 Sep 2026 12:59PM UTC 169
95.72
GitHub Action Run
16 run-3.3-gemfiles/rack_3_1.gemfile - 33758398003.16 03 Sep 2026 01:00PM UTC 168
95.72
GitHub Action Run
17 run-4.0-gemfiles/multi_json.gemfile - 33758398003.17 03 Sep 2026 12:59PM UTC 168
47.47
GitHub Action Run
18 run-3.4-gemfiles/rack_3_1.gemfile - 33758398003.18 03 Sep 2026 01:00PM UTC 168
95.72
GitHub Action Run
19 run-4.0-gemfiles/rails_7_2.gemfile - 33758398003.19 03 Sep 2026 12:59PM UTC 169
95.72
GitHub Action Run
20 run-3.4-gemfiles/rails_8_0.gemfile - 33758398003.20 03 Sep 2026 12:59PM UTC 169
95.72
GitHub Action Run
21 run-3.3-gemfiles/rack_3_0.gemfile - 33758398003.21 03 Sep 2026 12:59PM UTC 168
95.72
GitHub Action Run
22 run-3.4-gemfiles/rack_3_0.gemfile - 33758398003.22 03 Sep 2026 12:59PM UTC 168
95.72
GitHub Action Run
23 run-4.0-gemfiles/multi_xml.gemfile - 33758398003.23 03 Sep 2026 12:59PM UTC 168
46.93
GitHub Action Run
24 run-3.3-gemfiles/rack_2_2.gemfile - 33758398003.24 03 Sep 2026 01:00PM UTC 168
95.68
GitHub Action Run
25 run-3.4-gemfiles/rack_3_2.gemfile - 33758398003.25 03 Sep 2026 01:00PM UTC 168
95.72
GitHub Action Run
26 run-4.0-gemfiles/multi_xml_0_8.gemfile - 33758398003.26 03 Sep 2026 12:59PM UTC 168
46.97
GitHub Action Run
27 run-3.4-gemfiles/rack_2_2.gemfile - 33758398003.27 03 Sep 2026 12:59PM UTC 168
95.68
GitHub Action Run
28 run-4.0-Gemfile - 33758398003.28 03 Sep 2026 12:59PM UTC 168
95.72
GitHub Action Run
29 run-4.0-gemfiles/rack_2_2.gemfile - 33758398003.29 03 Sep 2026 12:59PM UTC 168
95.68
GitHub Action Run
30 run-3.3-gemfiles/rack_3_2.gemfile - 33758398003.30 03 Sep 2026 12:59PM UTC 168
95.72
GitHub Action Run
31 run-4.0-gemfiles/rails_8_0.gemfile - 33758398003.31 03 Sep 2026 01:00PM UTC 169
95.72
GitHub Action Run
32 run-4.0-gemfiles/grape_swagger.gemfile - 33758398003.32 03 Sep 2026 12:59PM UTC 168
55.2
GitHub Action Run
Source Files on build 33758398003
  • Tree
  • List 169
  • Changed 4
  • Source Changed 4
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #33758398003
  • Pull Request #2889
  • PR Base - master (#33755485219)
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