grape-path-helpers 2.0.1 → 2.2.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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +21 -5
- data/.rubocop.yml +5 -5
- data/CHANGELOG.md +9 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +99 -61
- data/Gemfile.next +8 -0
- data/Gemfile.next.lock +139 -0
- data/Rakefile +2 -0
- data/grape-path-helpers.gemspec +6 -3
- data/lib/grape/path_helpers.rb +2 -0
- data/lib/grape-path-helpers/all_routes.rb +9 -4
- data/lib/grape-path-helpers/decorated_route.rb +17 -5
- data/lib/grape-path-helpers/named_route_matcher.rb +6 -0
- data/lib/grape-path-helpers/railtie.rb +2 -0
- data/lib/grape-path-helpers/route_displayer.rb +6 -8
- data/lib/grape-path-helpers/tasks.rb +2 -0
- data/lib/grape-path-helpers/version.rb +3 -1
- data/lib/grape-path-helpers.rb +2 -0
- data/lib/tasks/grape_path_helpers.rake +2 -0
- data/spec/grape_path_helpers/all_routes_spec.rb +15 -4
- data/spec/grape_path_helpers/decorated_route_spec.rb +3 -1
- data/spec/grape_path_helpers/named_route_matcher_spec.rb +8 -0
- data/spec/grape_path_helpers/route_displayer_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/support/api.rb +13 -0
- metadata +17 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ceaf5b98957d3b445254e411294acddf2c7cdf484ae5f6d190ccb3f1947c996
|
|
4
|
+
data.tar.gz: fcfd0e19ca6aeb2d5185af2528680c4f64a1d97749f9515481bebd330a6bed44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e7dbe728e2998b3797a06028cff1c06914e189721355260da982266cf13b71d0e4ed476132fb0db5dc4f1c5ee6df20fb435f9d43af6c9f7135074fe57a69c54
|
|
7
|
+
data.tar.gz: 436b0ae0f6db17e8f25d39275542b58c28d524fccdc76d207f840cd95adb3d69054b935fdc4a7fe0cfd1393b6b32373ac7709d989bff78d504a8274c28e16b72
|
data/.gitlab-ci.yml
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
include:
|
|
2
|
+
- component: gitlab.com/gitlab-org/components/gem-release/gem-release@~latest
|
|
3
|
+
|
|
4
|
+
image: "ruby:${RUBY_VERSION}-alpine"
|
|
5
|
+
|
|
6
|
+
variables:
|
|
7
|
+
RUBY_VERSION: "3.3"
|
|
8
|
+
BUNDLE_GEMFILE: "Gemfile"
|
|
2
9
|
|
|
3
10
|
cache:
|
|
4
11
|
paths:
|
|
5
12
|
- vendor/ruby
|
|
6
|
-
key: ruby
|
|
13
|
+
key: "ruby-${RUBY_VERSION}-${BUNDLE_GEMFILE}"
|
|
7
14
|
|
|
8
15
|
before_script:
|
|
9
|
-
- apk add --update git
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
- apk add --update git build-base
|
|
17
|
+
# Install the exact bundler version pinned in the active lockfile so
|
|
18
|
+
# `bundle install --frozen` doesn't respawn into a mismatched version.
|
|
19
|
+
- bundler_version=$(grep -A1 'BUNDLED WITH' "${BUNDLE_GEMFILE}.lock" | tail -1 | tr -d ' ')
|
|
20
|
+
- gem install bundler --version "${bundler_version}" --no-document
|
|
21
|
+
- bundle config set --local path vendor/ruby
|
|
22
|
+
- bundle config set --local frozen true
|
|
23
|
+
- bundle install --jobs=$(nproc) --retry=3
|
|
12
24
|
|
|
13
25
|
rubocop:
|
|
14
26
|
script:
|
|
15
27
|
- bundle exec rubocop
|
|
16
28
|
|
|
17
29
|
rspec:
|
|
30
|
+
parallel:
|
|
31
|
+
matrix:
|
|
32
|
+
- RUBY_VERSION: ["3.3", "3.4"]
|
|
33
|
+
BUNDLE_GEMFILE: ["Gemfile", "Gemfile.next"]
|
|
18
34
|
script:
|
|
19
35
|
- bundle exec rspec spec
|
data/.rubocop.yml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: disable
|
|
3
|
+
SuggestExtensions: false
|
|
4
|
+
|
|
1
5
|
Metrics/ClassLength:
|
|
2
6
|
Max: 104
|
|
3
7
|
Enabled: false
|
|
@@ -6,9 +10,5 @@ Metrics/MethodLength:
|
|
|
6
10
|
Max: 21
|
|
7
11
|
Enabled: false
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
Enabled: false
|
|
11
|
-
|
|
12
|
-
# Removed in newer versions of Rubocop
|
|
13
|
-
Lint/SplatKeywordArguments:
|
|
13
|
+
Naming/FileName:
|
|
14
14
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
* [Support Grape 4.x](https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers/-/merge_requests/55)
|
|
6
|
+
|
|
7
|
+
## 2.1.0
|
|
8
|
+
|
|
9
|
+
* [Support Grape 3.x](https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers/-/merge_requests/50)
|
|
10
|
+
* [Replace the removed protected `prepare_routes` with the public `routes` API](https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers/-/merge_requests/49)
|
|
11
|
+
|
|
3
12
|
## 2.0.1
|
|
4
13
|
|
|
5
14
|
* [Fix helpers not available by default in Grape endpoints](https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers/-/merge_requests/46)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,101 +1,139 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
grape-path-helpers (2.0
|
|
4
|
+
grape-path-helpers (2.2.0)
|
|
5
5
|
activesupport
|
|
6
|
-
grape (
|
|
6
|
+
grape (>= 2.0, < 5)
|
|
7
7
|
rake (> 12)
|
|
8
8
|
ruby2_keywords (~> 0.0.2)
|
|
9
9
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
activesupport (
|
|
14
|
-
|
|
13
|
+
activesupport (8.1.4.1)
|
|
14
|
+
base64
|
|
15
|
+
bigdecimal
|
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
17
|
+
connection_pool (>= 2.2.5)
|
|
18
|
+
drb
|
|
15
19
|
i18n (>= 1.6, < 2)
|
|
20
|
+
json
|
|
21
|
+
logger (>= 1.4.2)
|
|
16
22
|
minitest (>= 5.1)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
securerandom (>= 0.3)
|
|
24
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
25
|
+
uri (>= 0.13.1)
|
|
26
|
+
ast (2.4.3)
|
|
27
|
+
base64 (0.3.0)
|
|
28
|
+
bigdecimal (4.1.3)
|
|
29
|
+
coderay (1.1.3)
|
|
30
|
+
concurrent-ruby (1.3.8)
|
|
31
|
+
connection_pool (3.0.3)
|
|
32
|
+
diff-lcs (1.6.2)
|
|
33
|
+
drb (2.2.3)
|
|
34
|
+
dry-configurable (1.4.0)
|
|
35
|
+
dry-core (~> 1.0)
|
|
36
|
+
zeitwerk (~> 2.6)
|
|
37
|
+
dry-core (1.2.0)
|
|
24
38
|
concurrent-ruby (~> 1.0)
|
|
39
|
+
logger
|
|
25
40
|
zeitwerk (~> 2.6)
|
|
26
|
-
dry-inflector (1.
|
|
27
|
-
dry-logic (1.
|
|
41
|
+
dry-inflector (1.3.1)
|
|
42
|
+
dry-logic (1.6.0)
|
|
43
|
+
bigdecimal
|
|
28
44
|
concurrent-ruby (~> 1.0)
|
|
29
|
-
dry-core (~> 1.
|
|
45
|
+
dry-core (~> 1.1)
|
|
30
46
|
zeitwerk (~> 2.6)
|
|
31
|
-
dry-types (1.
|
|
47
|
+
dry-types (1.9.1)
|
|
48
|
+
bigdecimal (>= 3.0)
|
|
32
49
|
concurrent-ruby (~> 1.0)
|
|
33
50
|
dry-core (~> 1.0)
|
|
34
51
|
dry-inflector (~> 1.0)
|
|
35
52
|
dry-logic (~> 1.4)
|
|
36
53
|
zeitwerk (~> 2.6)
|
|
37
|
-
grape (
|
|
38
|
-
activesupport (>=
|
|
39
|
-
|
|
54
|
+
grape (3.3.5)
|
|
55
|
+
activesupport (>= 7.2)
|
|
56
|
+
dry-configurable (>= 1.0)
|
|
40
57
|
dry-types (>= 1.1)
|
|
41
|
-
mustermann
|
|
42
|
-
rack (>=
|
|
43
|
-
|
|
44
|
-
i18n (1.
|
|
58
|
+
mustermann (>= 4.0)
|
|
59
|
+
rack (>= 2.2.4)
|
|
60
|
+
zeitwerk (>= 2.6)
|
|
61
|
+
i18n (1.15.2)
|
|
45
62
|
concurrent-ruby (~> 1.0)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
io-console (0.8.2)
|
|
64
|
+
json (2.21.2)
|
|
65
|
+
language_server-protocol (3.17.0.5)
|
|
66
|
+
lint_roller (1.1.0)
|
|
67
|
+
logger (1.7.0)
|
|
68
|
+
method_source (1.1.0)
|
|
69
|
+
minitest (6.1.0)
|
|
70
|
+
drb (~> 2.0)
|
|
71
|
+
prism (>= 1.5, < 3)
|
|
72
|
+
mustermann (4.0.0)
|
|
73
|
+
parallel (2.1.0)
|
|
74
|
+
parser (3.3.11.1)
|
|
75
|
+
ast (~> 2.4.1)
|
|
76
|
+
racc
|
|
77
|
+
prism (1.9.0)
|
|
78
|
+
pry (0.16.0)
|
|
79
|
+
coderay (~> 1.1)
|
|
80
|
+
method_source (~> 1.0)
|
|
81
|
+
reline (>= 0.6.0)
|
|
82
|
+
racc (1.8.1)
|
|
83
|
+
rack (3.2.6)
|
|
84
|
+
rainbow (3.1.1)
|
|
85
|
+
rake (13.4.2)
|
|
86
|
+
regexp_parser (2.12.0)
|
|
87
|
+
reline (0.6.3)
|
|
88
|
+
io-console (~> 0.5)
|
|
89
|
+
rspec (3.13.2)
|
|
90
|
+
rspec-core (~> 3.13.0)
|
|
91
|
+
rspec-expectations (~> 3.13.0)
|
|
92
|
+
rspec-mocks (~> 3.13.0)
|
|
93
|
+
rspec-core (3.13.6)
|
|
94
|
+
rspec-support (~> 3.13.0)
|
|
95
|
+
rspec-expectations (3.13.5)
|
|
71
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
72
|
-
rspec-support (~> 3.
|
|
73
|
-
rspec-mocks (3.
|
|
97
|
+
rspec-support (~> 3.13.0)
|
|
98
|
+
rspec-mocks (3.13.8)
|
|
74
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
75
|
-
rspec-support (~> 3.
|
|
76
|
-
rspec-support (3.7
|
|
77
|
-
rubocop (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
rspec-support (~> 3.13.0)
|
|
101
|
+
rspec-support (3.13.7)
|
|
102
|
+
rubocop (1.86.2)
|
|
103
|
+
json (~> 2.3)
|
|
104
|
+
language_server-protocol (~> 3.17.0.2)
|
|
105
|
+
lint_roller (~> 1.1.0)
|
|
106
|
+
parallel (>= 1.10)
|
|
107
|
+
parser (>= 3.3.0.2)
|
|
81
108
|
rainbow (>= 2.2.2, < 4.0)
|
|
109
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
110
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
82
111
|
ruby-progressbar (~> 1.7)
|
|
83
|
-
unicode-display_width (
|
|
84
|
-
|
|
112
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
113
|
+
rubocop-ast (1.49.1)
|
|
114
|
+
parser (>= 3.3.7.2)
|
|
115
|
+
prism (~> 1.7)
|
|
116
|
+
ruby-progressbar (1.13.0)
|
|
85
117
|
ruby2_keywords (0.0.5)
|
|
118
|
+
securerandom (0.4.1)
|
|
86
119
|
tzinfo (2.0.6)
|
|
87
120
|
concurrent-ruby (~> 1.0)
|
|
88
|
-
unicode-display_width (
|
|
89
|
-
|
|
121
|
+
unicode-display_width (3.2.0)
|
|
122
|
+
unicode-emoji (~> 4.1)
|
|
123
|
+
unicode-emoji (4.2.0)
|
|
124
|
+
uri (1.1.2)
|
|
125
|
+
zeitwerk (2.8.1)
|
|
90
126
|
|
|
91
127
|
PLATFORMS
|
|
128
|
+
arm64-darwin-25
|
|
92
129
|
ruby
|
|
93
130
|
|
|
94
131
|
DEPENDENCIES
|
|
132
|
+
grape (~> 3.2)
|
|
95
133
|
grape-path-helpers!
|
|
96
134
|
pry (~> 0.11)
|
|
97
135
|
rspec (~> 3.7)
|
|
98
|
-
rubocop (~>
|
|
136
|
+
rubocop (~> 1.50)
|
|
99
137
|
|
|
100
138
|
BUNDLED WITH
|
|
101
|
-
2.2
|
|
139
|
+
2.7.2
|
data/Gemfile.next
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gemspec
|
|
4
|
+
|
|
5
|
+
# `.next` mirrors the convention used in gitlab-org/gitlab: this Gemfile
|
|
6
|
+
# tracks the version of Grape we're moving towards (4.x) while the root
|
|
7
|
+
# `Gemfile` stays pinned to the version currently in production (3.x).
|
|
8
|
+
gem 'grape', '~> 4.0'
|
data/Gemfile.next.lock
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
grape-path-helpers (2.2.0)
|
|
5
|
+
activesupport
|
|
6
|
+
grape (>= 2.0, < 5)
|
|
7
|
+
rake (> 12)
|
|
8
|
+
ruby2_keywords (~> 0.0.2)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
activesupport (8.1.4.1)
|
|
14
|
+
base64
|
|
15
|
+
bigdecimal
|
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
17
|
+
connection_pool (>= 2.2.5)
|
|
18
|
+
drb
|
|
19
|
+
i18n (>= 1.6, < 2)
|
|
20
|
+
json
|
|
21
|
+
logger (>= 1.4.2)
|
|
22
|
+
minitest (>= 5.1)
|
|
23
|
+
securerandom (>= 0.3)
|
|
24
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
25
|
+
uri (>= 0.13.1)
|
|
26
|
+
ast (2.4.3)
|
|
27
|
+
base64 (0.3.0)
|
|
28
|
+
bigdecimal (4.1.3)
|
|
29
|
+
coderay (1.1.3)
|
|
30
|
+
concurrent-ruby (1.3.8)
|
|
31
|
+
connection_pool (3.0.3)
|
|
32
|
+
diff-lcs (1.6.2)
|
|
33
|
+
drb (2.2.3)
|
|
34
|
+
dry-configurable (1.4.0)
|
|
35
|
+
dry-core (~> 1.0)
|
|
36
|
+
zeitwerk (~> 2.6)
|
|
37
|
+
dry-core (1.2.0)
|
|
38
|
+
concurrent-ruby (~> 1.0)
|
|
39
|
+
logger
|
|
40
|
+
zeitwerk (~> 2.6)
|
|
41
|
+
dry-inflector (1.3.1)
|
|
42
|
+
dry-logic (1.6.0)
|
|
43
|
+
bigdecimal
|
|
44
|
+
concurrent-ruby (~> 1.0)
|
|
45
|
+
dry-core (~> 1.1)
|
|
46
|
+
zeitwerk (~> 2.6)
|
|
47
|
+
dry-types (1.9.2)
|
|
48
|
+
bigdecimal (>= 3.0)
|
|
49
|
+
concurrent-ruby (~> 1.0)
|
|
50
|
+
dry-core (~> 1.0)
|
|
51
|
+
dry-inflector (~> 1.0)
|
|
52
|
+
dry-logic (~> 1.4)
|
|
53
|
+
zeitwerk (~> 2.6)
|
|
54
|
+
grape (4.1.0)
|
|
55
|
+
activesupport (>= 7.2)
|
|
56
|
+
dry-configurable (>= 1.0)
|
|
57
|
+
dry-types (>= 1.1)
|
|
58
|
+
mustermann (>= 4.0)
|
|
59
|
+
rack (>= 2.2.4)
|
|
60
|
+
zeitwerk (>= 2.6)
|
|
61
|
+
i18n (1.15.2)
|
|
62
|
+
concurrent-ruby (~> 1.0)
|
|
63
|
+
io-console (0.8.2)
|
|
64
|
+
json (2.21.2)
|
|
65
|
+
language_server-protocol (3.17.0.5)
|
|
66
|
+
lint_roller (1.1.0)
|
|
67
|
+
logger (1.7.0)
|
|
68
|
+
method_source (1.1.0)
|
|
69
|
+
minitest (6.1.0)
|
|
70
|
+
drb (~> 2.0)
|
|
71
|
+
prism (>= 1.5, < 3)
|
|
72
|
+
mustermann (4.0.1)
|
|
73
|
+
parallel (2.1.0)
|
|
74
|
+
parser (3.3.11.1)
|
|
75
|
+
ast (~> 2.4.1)
|
|
76
|
+
racc
|
|
77
|
+
prism (1.9.0)
|
|
78
|
+
pry (0.16.0)
|
|
79
|
+
coderay (~> 1.1)
|
|
80
|
+
method_source (~> 1.0)
|
|
81
|
+
reline (>= 0.6.0)
|
|
82
|
+
racc (1.8.1)
|
|
83
|
+
rack (3.2.8)
|
|
84
|
+
rainbow (3.1.1)
|
|
85
|
+
rake (13.4.2)
|
|
86
|
+
regexp_parser (2.12.0)
|
|
87
|
+
reline (0.6.3)
|
|
88
|
+
io-console (~> 0.5)
|
|
89
|
+
rspec (3.13.2)
|
|
90
|
+
rspec-core (~> 3.13.0)
|
|
91
|
+
rspec-expectations (~> 3.13.0)
|
|
92
|
+
rspec-mocks (~> 3.13.0)
|
|
93
|
+
rspec-core (3.13.6)
|
|
94
|
+
rspec-support (~> 3.13.0)
|
|
95
|
+
rspec-expectations (3.13.5)
|
|
96
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
97
|
+
rspec-support (~> 3.13.0)
|
|
98
|
+
rspec-mocks (3.13.8)
|
|
99
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
100
|
+
rspec-support (~> 3.13.0)
|
|
101
|
+
rspec-support (3.13.7)
|
|
102
|
+
rubocop (1.86.2)
|
|
103
|
+
json (~> 2.3)
|
|
104
|
+
language_server-protocol (~> 3.17.0.2)
|
|
105
|
+
lint_roller (~> 1.1.0)
|
|
106
|
+
parallel (>= 1.10)
|
|
107
|
+
parser (>= 3.3.0.2)
|
|
108
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
109
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
110
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
111
|
+
ruby-progressbar (~> 1.7)
|
|
112
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
113
|
+
rubocop-ast (1.49.1)
|
|
114
|
+
parser (>= 3.3.7.2)
|
|
115
|
+
prism (~> 1.7)
|
|
116
|
+
ruby-progressbar (1.13.0)
|
|
117
|
+
ruby2_keywords (0.0.5)
|
|
118
|
+
securerandom (0.4.1)
|
|
119
|
+
tzinfo (2.0.6)
|
|
120
|
+
concurrent-ruby (~> 1.0)
|
|
121
|
+
unicode-display_width (3.2.0)
|
|
122
|
+
unicode-emoji (~> 4.1)
|
|
123
|
+
unicode-emoji (4.2.0)
|
|
124
|
+
uri (1.1.2)
|
|
125
|
+
zeitwerk (2.8.3)
|
|
126
|
+
|
|
127
|
+
PLATFORMS
|
|
128
|
+
arm64-darwin-25
|
|
129
|
+
ruby
|
|
130
|
+
|
|
131
|
+
DEPENDENCIES
|
|
132
|
+
grape (~> 4.0)
|
|
133
|
+
grape-path-helpers!
|
|
134
|
+
pry (~> 0.11)
|
|
135
|
+
rspec (~> 3.7)
|
|
136
|
+
rubocop (~> 1.50)
|
|
137
|
+
|
|
138
|
+
BUNDLED WITH
|
|
139
|
+
2.7.2
|
data/Rakefile
CHANGED
data/grape-path-helpers.gemspec
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require File.join(Dir.pwd, 'lib', 'grape-path-helpers', 'version')
|
|
2
4
|
|
|
3
5
|
Gem::Specification.new do |gem|
|
|
@@ -9,14 +11,15 @@ Gem::Specification.new do |gem|
|
|
|
9
11
|
gem.authors = ['Drew Blessing', 'Harper Henn']
|
|
10
12
|
gem.email = ''
|
|
11
13
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
12
|
-
gem.homepage = 'https://gitlab.com/gitlab-org/grape-path-helpers'
|
|
14
|
+
gem.homepage = 'https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers'
|
|
15
|
+
gem.required_ruby_version = '>= 3.2'
|
|
13
16
|
|
|
14
17
|
gem.add_runtime_dependency 'activesupport'
|
|
15
|
-
gem.add_runtime_dependency 'grape', '
|
|
18
|
+
gem.add_runtime_dependency 'grape', '>= 2.0', '< 5'
|
|
16
19
|
gem.add_runtime_dependency 'rake', '> 12'
|
|
17
20
|
gem.add_runtime_dependency 'ruby2_keywords', '~> 0.0.2'
|
|
18
21
|
|
|
19
22
|
gem.add_development_dependency 'pry', '~> 0.11'
|
|
20
23
|
gem.add_development_dependency 'rspec', '~> 3.7'
|
|
21
|
-
gem.add_development_dependency 'rubocop', '~>
|
|
24
|
+
gem.add_development_dependency 'rubocop', '~> 1.50'
|
|
22
25
|
end
|
data/lib/grape/path_helpers.rb
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module GrapePathHelpers
|
|
2
4
|
# methods to extend Grape::API's behavior so it can get a
|
|
3
5
|
# list of routes from all APIs and decorate them with
|
|
4
6
|
# the DecoratedRoute class
|
|
5
7
|
module AllRoutes
|
|
6
|
-
def decorated_routes_by_helper_name
|
|
7
|
-
return @decorated_routes_by_helper_name if @decorated_routes_by_helper_name
|
|
8
|
+
def decorated_routes_by_helper_name # rubocop:disable Metrics/AbcSize
|
|
9
|
+
return @decorated_routes_by_helper_name if @decorated_routes_by_helper_name
|
|
8
10
|
|
|
9
11
|
routes = {}
|
|
10
12
|
|
|
@@ -23,9 +25,12 @@ module GrapePathHelpers
|
|
|
23
25
|
@decorated_routes_by_helper_name = routes
|
|
24
26
|
end
|
|
25
27
|
|
|
28
|
+
# Grape 4 no longer carries the computed version in the route options,
|
|
29
|
+
# so it has to be part of the route identity explicitly, otherwise the
|
|
30
|
+
# same path under two versions would collapse into one route
|
|
26
31
|
def all_routes
|
|
27
|
-
routes = descendants.flat_map { |
|
|
28
|
-
routes.uniq { |r| r.
|
|
32
|
+
routes = descendants.flat_map { |d| d.endpoints.flat_map(&:routes) }
|
|
33
|
+
routes.uniq { |r| [r.path, r.version, r.options] }
|
|
29
34
|
end
|
|
30
35
|
end
|
|
31
36
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module GrapePathHelpers
|
|
2
4
|
# wrapper around Grape::Route that adds a helper method
|
|
3
5
|
class DecoratedRoute
|
|
@@ -21,9 +23,10 @@ module GrapePathHelpers
|
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def default_extension
|
|
24
|
-
pattern = /\((
|
|
26
|
+
pattern = /\((\.:?\w+)\)$/
|
|
25
27
|
match = route_path.match(pattern)
|
|
26
28
|
return '' unless match
|
|
29
|
+
|
|
27
30
|
ext = match.captures.first
|
|
28
31
|
if ext == '.:format'
|
|
29
32
|
''
|
|
@@ -60,7 +63,7 @@ module GrapePathHelpers
|
|
|
60
63
|
if params.nil?
|
|
61
64
|
''
|
|
62
65
|
else
|
|
63
|
-
|
|
66
|
+
"?#{params.to_param}"
|
|
64
67
|
end
|
|
65
68
|
end
|
|
66
69
|
|
|
@@ -89,12 +92,19 @@ module GrapePathHelpers
|
|
|
89
92
|
end
|
|
90
93
|
|
|
91
94
|
sanitized_name = self.class.sanitize_method_name(name)
|
|
92
|
-
sanitized_name
|
|
95
|
+
"#{sanitized_name}_path"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# values the route supplies for its own dynamic segments, like the
|
|
99
|
+
# version of a path-versioned API. Grape 4 exposes the version through
|
|
100
|
+
# a reader only, earlier versions also carried it in the route options
|
|
101
|
+
def route_defaults
|
|
102
|
+
@route_defaults ||= route_options.to_h.merge(version: route_version)
|
|
93
103
|
end
|
|
94
104
|
|
|
95
105
|
def segment_to_value(segment, opts = {})
|
|
96
106
|
if dynamic_segment?(segment)
|
|
97
|
-
options =
|
|
107
|
+
options = route_defaults.merge(stringify_keys(opts))
|
|
98
108
|
key = segment.slice(1..-1).to_sym
|
|
99
109
|
options[key]
|
|
100
110
|
else
|
|
@@ -102,6 +112,7 @@ module GrapePathHelpers
|
|
|
102
112
|
end
|
|
103
113
|
end
|
|
104
114
|
|
|
115
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
|
105
116
|
def path_segments_with_values(opts, include_wildcard_segments = false)
|
|
106
117
|
segments = path_segments(include_wildcard_segments).map do |s|
|
|
107
118
|
segment_to_value(s, opts)
|
|
@@ -117,6 +128,7 @@ module GrapePathHelpers
|
|
|
117
128
|
end
|
|
118
129
|
route_path.split(pattern).reject(&:blank?)
|
|
119
130
|
end
|
|
131
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
|
120
132
|
|
|
121
133
|
def dynamic_path_segments
|
|
122
134
|
segments = path_segments.select do |segment|
|
|
@@ -135,7 +147,7 @@ module GrapePathHelpers
|
|
|
135
147
|
|
|
136
148
|
def required_helper_segments
|
|
137
149
|
segments_in_options = dynamic_path_segments.select do |segment|
|
|
138
|
-
|
|
150
|
+
route_defaults[segment.to_sym]
|
|
139
151
|
end
|
|
140
152
|
dynamic_path_segments - segments_in_options
|
|
141
153
|
end
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module GrapePathHelpers
|
|
2
4
|
# methods to extend Grape::Endpoint so that calls
|
|
3
5
|
# to unknown methods will look for a route with a matching
|
|
4
6
|
# helper function name
|
|
5
7
|
module NamedRouteMatcher
|
|
8
|
+
# Dispatch method: short-circuits when the call can't be a route helper,
|
|
9
|
+
# otherwise finds the decorated route that matches the supplied segments.
|
|
10
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
6
11
|
def method_missing(method_name, *args)
|
|
7
12
|
return super unless method_name.end_with?('_path')
|
|
8
13
|
|
|
@@ -25,6 +30,7 @@ module GrapePathHelpers
|
|
|
25
30
|
super
|
|
26
31
|
end
|
|
27
32
|
end
|
|
33
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
28
34
|
ruby2_keywords(:method_missing)
|
|
29
35
|
|
|
30
36
|
def respond_to_missing?(method_name, _include_private = false)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module GrapePathHelpers
|
|
2
4
|
# class for displaying the path, helper method name,
|
|
3
5
|
# and required arguments for every Grape::Route.
|
|
@@ -21,14 +23,10 @@ module GrapePathHelpers
|
|
|
21
23
|
def display
|
|
22
24
|
puts("== GRAPE ROUTE HELPERS ==\n\n")
|
|
23
25
|
route_attributes.each do |attributes|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
attributes[:helper_names].join(', '))
|
|
29
|
-
printf("%s: %s\n",
|
|
30
|
-
'Arguments',
|
|
31
|
-
attributes[:helper_arguments].join(', '))
|
|
26
|
+
puts("Verb: #{attributes[:route_method]}")
|
|
27
|
+
puts("Path: #{attributes[:route_path]}")
|
|
28
|
+
puts("Helper Method: #{attributes[:helper_names].join(', ')}")
|
|
29
|
+
puts("Arguments: #{attributes[:helper_arguments].join(', ')}")
|
|
32
30
|
puts("\n")
|
|
33
31
|
end
|
|
34
32
|
end
|
data/lib/grape-path-helpers.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
# rubocop:disable Metrics/BlockLength
|
|
@@ -11,9 +13,10 @@ describe GrapePathHelpers::AllRoutes do
|
|
|
11
13
|
it 'does not include the same route twice' do
|
|
12
14
|
mounting_api
|
|
13
15
|
|
|
14
|
-
# A route is unique if no other route shares the same
|
|
16
|
+
# A route is unique if no other route shares the same path, version
|
|
17
|
+
# and set of options
|
|
15
18
|
all_route_options = Grape::API::Instance.all_routes.map do |r|
|
|
16
|
-
r.instance_variable_get(:@options)
|
|
19
|
+
[r.path, r.version, r.instance_variable_get(:@options)]
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
duplicates = all_route_options.select do |o|
|
|
@@ -24,7 +27,16 @@ describe GrapePathHelpers::AllRoutes do
|
|
|
24
27
|
end
|
|
25
28
|
end
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
context 'when two APIs share a path under different versions' do
|
|
31
|
+
it 'returns the route of each version' do
|
|
32
|
+
versions = Grape::API::Instance.all_routes.select do |r|
|
|
33
|
+
r.path == '/api/:version/ping(.json)'
|
|
34
|
+
end.map(&:version)
|
|
35
|
+
|
|
36
|
+
expect(versions).to include('v1', 'v2')
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
28
40
|
context 'when there are multiple POST routes with the same namespace in the same API' do
|
|
29
41
|
it 'returns all POST routes' do
|
|
30
42
|
expected_routes = Spec::Support::MultiplePostsAPI.routes.map(&:path)
|
|
@@ -40,7 +52,6 @@ describe GrapePathHelpers::AllRoutes do
|
|
|
40
52
|
expect(Grape::API::Instance.all_routes.map(&:origin)).to include('/derived_ping')
|
|
41
53
|
end
|
|
42
54
|
end
|
|
43
|
-
# rubocop:enable Metrics/LineLength
|
|
44
55
|
end
|
|
45
56
|
end
|
|
46
57
|
# rubocop:enable Metrics/BlockLength
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
# rubocop:disable Metrics/BlockLength
|
|
@@ -323,7 +325,7 @@ describe GrapePathHelpers::DecoratedRoute do
|
|
|
323
325
|
it 'creates a query string' do
|
|
324
326
|
query = { foo: :bar, baz: :zot }
|
|
325
327
|
path = index_route.api_v1_cats_path(params: query)
|
|
326
|
-
expect(path).to eq(
|
|
328
|
+
expect(path).to eq("/api/v1/cats.json?#{query.to_param}")
|
|
327
329
|
end
|
|
328
330
|
end
|
|
329
331
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
# rubocop:disable Metrics/BlockLength
|
|
@@ -50,6 +52,12 @@ describe GrapePathHelpers::NamedRouteMatcher do
|
|
|
50
52
|
end
|
|
51
53
|
end
|
|
52
54
|
|
|
55
|
+
context 'when another API shares the path under another version' do
|
|
56
|
+
it 'returns the path of each version' do
|
|
57
|
+
expect(helper_class.api_v2_ping_path).to eq('/api/v2/ping.json')
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
53
61
|
context 'when route requires dynamic segments but none are passed in' do
|
|
54
62
|
it 'returns super method_missing' do
|
|
55
63
|
expect(helper_class.api_v1_cats_owners_path)
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/api.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Spec
|
|
2
4
|
module Support
|
|
3
5
|
# Test API
|
|
@@ -47,6 +49,17 @@ module Spec
|
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
51
|
|
|
52
|
+
# API sharing a path with the test API under another version
|
|
53
|
+
class APIWithAnotherVersion < Grape::API::Instance
|
|
54
|
+
version 'v2'
|
|
55
|
+
prefix 'api'
|
|
56
|
+
format 'json'
|
|
57
|
+
|
|
58
|
+
get 'ping' do
|
|
59
|
+
'pong'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
50
63
|
# API with more than one version
|
|
51
64
|
class APIWithMultipleVersions < Grape::API::Instance
|
|
52
65
|
version %w[beta alpha v1]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: grape-path-helpers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Drew Blessing
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -29,16 +29,22 @@ dependencies:
|
|
|
29
29
|
name: grape
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- - "
|
|
32
|
+
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
34
|
version: '2.0'
|
|
35
|
+
- - "<"
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '5'
|
|
35
38
|
type: :runtime
|
|
36
39
|
prerelease: false
|
|
37
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
41
|
requirements:
|
|
39
|
-
- - "
|
|
42
|
+
- - ">="
|
|
40
43
|
- !ruby/object:Gem::Version
|
|
41
44
|
version: '2.0'
|
|
45
|
+
- - "<"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5'
|
|
42
48
|
- !ruby/object:Gem::Dependency
|
|
43
49
|
name: rake
|
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -101,14 +107,14 @@ dependencies:
|
|
|
101
107
|
requirements:
|
|
102
108
|
- - "~>"
|
|
103
109
|
- !ruby/object:Gem::Version
|
|
104
|
-
version: '
|
|
110
|
+
version: '1.50'
|
|
105
111
|
type: :development
|
|
106
112
|
prerelease: false
|
|
107
113
|
version_requirements: !ruby/object:Gem::Requirement
|
|
108
114
|
requirements:
|
|
109
115
|
- - "~>"
|
|
110
116
|
- !ruby/object:Gem::Version
|
|
111
|
-
version: '
|
|
117
|
+
version: '1.50'
|
|
112
118
|
description: Route path helpers for Grape
|
|
113
119
|
email: ''
|
|
114
120
|
executables: []
|
|
@@ -123,6 +129,8 @@ files:
|
|
|
123
129
|
- CONTRIBUTING.md
|
|
124
130
|
- Gemfile
|
|
125
131
|
- Gemfile.lock
|
|
132
|
+
- Gemfile.next
|
|
133
|
+
- Gemfile.next.lock
|
|
126
134
|
- LICENSE.txt
|
|
127
135
|
- README.md
|
|
128
136
|
- Rakefile
|
|
@@ -143,7 +151,7 @@ files:
|
|
|
143
151
|
- spec/grape_path_helpers/route_displayer_spec.rb
|
|
144
152
|
- spec/spec_helper.rb
|
|
145
153
|
- spec/support/api.rb
|
|
146
|
-
homepage: https://gitlab.com/gitlab-org/grape-path-helpers
|
|
154
|
+
homepage: https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers
|
|
147
155
|
licenses:
|
|
148
156
|
- MIT
|
|
149
157
|
metadata: {}
|
|
@@ -155,14 +163,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
155
163
|
requirements:
|
|
156
164
|
- - ">="
|
|
157
165
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: '
|
|
166
|
+
version: '3.2'
|
|
159
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
168
|
requirements:
|
|
161
169
|
- - ">="
|
|
162
170
|
- !ruby/object:Gem::Version
|
|
163
171
|
version: '0'
|
|
164
172
|
requirements: []
|
|
165
|
-
rubygems_version: 3.5.
|
|
173
|
+
rubygems_version: 3.5.22
|
|
166
174
|
signing_key:
|
|
167
175
|
specification_version: 4
|
|
168
176
|
summary: Route path helpers for Grape
|