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

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

Build:
Build:
LAST BUILD BRANCH: perf/request-path-and-router
DEFAULT BRANCH: master
Ran 03 Sep 2026 01:01PM 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 01:00PM UTC coverage: 96.948%. Remained the same
33758582524

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

1238 of 1332 branches covered (92.94%)

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.

3939 of 4008 relevant lines covered (98.28%)

27041.41 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_xml.gemfile - 33758582524.1 03 Sep 2026 01:01PM UTC 168
47.0
GitHub Action Run
2 run-4.0-gemfiles/dry_validation.gemfile - 33758582524.2 03 Sep 2026 01:01PM UTC 168
57.84
GitHub Action Run
3 run-3.4-gemfiles/rack_2_2.gemfile - 33758582524.3 03 Sep 2026 01:01PM UTC 168
95.67
GitHub Action Run
4 run-4.0-gemfiles/hashie.gemfile - 33758582524.4 03 Sep 2026 01:01PM UTC 168
61.85
GitHub Action Run
5 run-4.0-gemfiles/multi_xml_0_8.gemfile - 33758582524.5 03 Sep 2026 01:01PM UTC 168
47.04
GitHub Action Run
6 run-4.0-gemfiles/rack_2_2.gemfile - 33758582524.6 03 Sep 2026 01:01PM UTC 168
95.67
GitHub Action Run
7 run-3.4-gemfiles/rack_3_0.gemfile - 33758582524.7 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
8 run-4.0-gemfiles/multi_json_1_20.gemfile - 33758582524.8 03 Sep 2026 01:01PM UTC 168
47.58
GitHub Action Run
9 run-4.0-gemfiles/rails_8_1.gemfile - 33758582524.9 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
10 run-4.0-Gemfile - 33758582524.10 03 Sep 2026 01:02PM UTC 168
95.71
GitHub Action Run
11 run-3.4-gemfiles/rack_3_2.gemfile - 33758582524.11 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
12 run-3.4-gemfiles/rack_3_1.gemfile - 33758582524.12 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
13 run-3.3-gemfiles/rails_7_2.gemfile - 33758582524.13 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
14 run-4.0-gemfiles/rack_3_0.gemfile - 33758582524.14 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
15 run-3.4-gemfiles/rails_8_1.gemfile - 33758582524.15 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
16 run-3.3-gemfiles/rails_8_0.gemfile - 33758582524.16 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
17 run-4.0-gemfiles/rails_8_0.gemfile - 33758582524.17 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
18 run-3.4-gemfiles/rails_8_0.gemfile - 33758582524.18 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
19 run-3.3-gemfiles/rails_8_1.gemfile - 33758582524.19 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
20 run-4.0-gemfiles/rack_3_1.gemfile - 33758582524.20 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
21 run-4.0-gemfiles/multi_json.gemfile - 33758582524.21 03 Sep 2026 01:01PM UTC 168
47.54
GitHub Action Run
22 run-3.4-gemfiles/rails_7_2.gemfile - 33758582524.22 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
23 run-4.0-gemfiles/grape_entity.gemfile - 33758582524.23 03 Sep 2026 01:01PM UTC 168
50.41
GitHub Action Run
24 run-4.0-gemfiles/rails_7_2.gemfile - 33758582524.24 03 Sep 2026 01:01PM UTC 169
95.71
GitHub Action Run
25 run-3.3-gemfiles/rack_3_2.gemfile - 33758582524.25 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
26 run-3.3-gemfiles/rack_3_0.gemfile - 33758582524.26 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
27 run-3.4-Gemfile - 33758582524.27 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
28 run-4.0-gemfiles/grape_swagger.gemfile - 33758582524.28 03 Sep 2026 01:01PM UTC 168
55.29
GitHub Action Run
29 run-3.3-gemfiles/rack_2_2.gemfile - 33758582524.29 03 Sep 2026 01:01PM UTC 168
95.67
GitHub Action Run
30 run-3.3-Gemfile - 33758582524.30 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
31 run-4.0-gemfiles/rack_3_2.gemfile - 33758582524.31 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
32 run-3.3-gemfiles/rack_3_1.gemfile - 33758582524.32 03 Sep 2026 01:01PM UTC 168
95.71
GitHub Action Run
Source Files on build 33758582524
  • 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 #33758582524
  • 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