grape-path-helpers 2.0.1 → 2.1.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 +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +96 -60
- data/Gemfile.next +8 -0
- data/Gemfile.next.lock +141 -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 +5 -3
- data/lib/grape-path-helpers/decorated_route.rb +8 -3
- 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 +2 -2
- data/spec/grape_path_helpers/decorated_route_spec.rb +3 -1
- data/spec/grape_path_helpers/named_route_matcher_spec.rb +2 -0
- data/spec/grape_path_helpers/route_displayer_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/support/api.rb +2 -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: ef633560ae5d3ff3ce265a852961fbe64f36363aabb3d454f29f081abc4e865b
|
|
4
|
+
data.tar.gz: 8434f1082e0c1ffef30e2c2c53835939f2b9ae2b2354476139886838a5b83ef3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f621e91cd80c07dcdfafa85836e9445f9c69fbea6995afcf850bff7b2715fa4b5753b534ba6dfc6eaf9594cd538da99ea47480b67cdb086830b35195c4ee9ad
|
|
7
|
+
data.tar.gz: 80816e454a2866151cbfa21521bc6b3411e08893156e2d1d94b88d493bc7de04dae2b4929ebf8bd09de178a71d23873b4bad7def8adbefea7028aa31e11ad928
|
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,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
* [Support Grape 3.x](https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers/-/merge_requests/50)
|
|
6
|
+
* [Replace the removed protected `prepare_routes` with the public `routes` API](https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers/-/merge_requests/49)
|
|
7
|
+
|
|
3
8
|
## 2.0.1
|
|
4
9
|
|
|
5
10
|
* [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,137 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
grape-path-helpers (2.0
|
|
4
|
+
grape-path-helpers (2.1.0)
|
|
5
5
|
activesupport
|
|
6
|
-
grape (
|
|
6
|
+
grape (>= 2.0, < 4)
|
|
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.3)
|
|
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.2)
|
|
29
|
+
coderay (1.1.3)
|
|
30
|
+
concurrent-ruby (1.3.6)
|
|
31
|
+
connection_pool (3.0.2)
|
|
32
|
+
diff-lcs (1.6.2)
|
|
33
|
+
drb (2.2.3)
|
|
34
|
+
dry-core (1.2.0)
|
|
24
35
|
concurrent-ruby (~> 1.0)
|
|
36
|
+
logger
|
|
25
37
|
zeitwerk (~> 2.6)
|
|
26
|
-
dry-inflector (1.
|
|
27
|
-
dry-logic (1.
|
|
38
|
+
dry-inflector (1.3.1)
|
|
39
|
+
dry-logic (1.6.0)
|
|
40
|
+
bigdecimal
|
|
28
41
|
concurrent-ruby (~> 1.0)
|
|
29
|
-
dry-core (~> 1.
|
|
42
|
+
dry-core (~> 1.1)
|
|
30
43
|
zeitwerk (~> 2.6)
|
|
31
|
-
dry-types (1.
|
|
44
|
+
dry-types (1.9.1)
|
|
45
|
+
bigdecimal (>= 3.0)
|
|
32
46
|
concurrent-ruby (~> 1.0)
|
|
33
47
|
dry-core (~> 1.0)
|
|
34
48
|
dry-inflector (~> 1.0)
|
|
35
49
|
dry-logic (~> 1.4)
|
|
36
50
|
zeitwerk (~> 2.6)
|
|
37
|
-
grape (2.
|
|
38
|
-
activesupport (>=
|
|
39
|
-
builder
|
|
51
|
+
grape (2.4.0)
|
|
52
|
+
activesupport (>= 6.1)
|
|
40
53
|
dry-types (>= 1.1)
|
|
41
|
-
mustermann-grape (~> 1.
|
|
42
|
-
rack (>=
|
|
43
|
-
|
|
44
|
-
i18n (1.14.
|
|
54
|
+
mustermann-grape (~> 1.1.0)
|
|
55
|
+
rack (>= 2)
|
|
56
|
+
zeitwerk
|
|
57
|
+
i18n (1.14.8)
|
|
45
58
|
concurrent-ruby (~> 1.0)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
io-console (0.8.2)
|
|
60
|
+
json (2.19.5)
|
|
61
|
+
language_server-protocol (3.17.0.5)
|
|
62
|
+
lint_roller (1.1.0)
|
|
63
|
+
logger (1.7.0)
|
|
64
|
+
method_source (1.1.0)
|
|
65
|
+
minitest (6.0.6)
|
|
66
|
+
drb (~> 2.0)
|
|
67
|
+
prism (~> 1.5)
|
|
68
|
+
mustermann (4.0.0)
|
|
69
|
+
mustermann-grape (1.1.0)
|
|
51
70
|
mustermann (>= 1.0.0)
|
|
52
|
-
parallel (1.
|
|
53
|
-
parser (
|
|
54
|
-
ast (~> 2.4.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
rspec
|
|
69
|
-
rspec-
|
|
70
|
-
|
|
71
|
+
parallel (2.1.0)
|
|
72
|
+
parser (3.3.11.1)
|
|
73
|
+
ast (~> 2.4.1)
|
|
74
|
+
racc
|
|
75
|
+
prism (1.9.0)
|
|
76
|
+
pry (0.16.0)
|
|
77
|
+
coderay (~> 1.1)
|
|
78
|
+
method_source (~> 1.0)
|
|
79
|
+
reline (>= 0.6.0)
|
|
80
|
+
racc (1.8.1)
|
|
81
|
+
rack (3.2.6)
|
|
82
|
+
rainbow (3.1.1)
|
|
83
|
+
rake (13.4.2)
|
|
84
|
+
regexp_parser (2.12.0)
|
|
85
|
+
reline (0.6.3)
|
|
86
|
+
io-console (~> 0.5)
|
|
87
|
+
rspec (3.13.2)
|
|
88
|
+
rspec-core (~> 3.13.0)
|
|
89
|
+
rspec-expectations (~> 3.13.0)
|
|
90
|
+
rspec-mocks (~> 3.13.0)
|
|
91
|
+
rspec-core (3.13.6)
|
|
92
|
+
rspec-support (~> 3.13.0)
|
|
93
|
+
rspec-expectations (3.13.5)
|
|
71
94
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
72
|
-
rspec-support (~> 3.
|
|
73
|
-
rspec-mocks (3.
|
|
95
|
+
rspec-support (~> 3.13.0)
|
|
96
|
+
rspec-mocks (3.13.8)
|
|
74
97
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
75
|
-
rspec-support (~> 3.
|
|
76
|
-
rspec-support (3.7
|
|
77
|
-
rubocop (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
rspec-support (~> 3.13.0)
|
|
99
|
+
rspec-support (3.13.7)
|
|
100
|
+
rubocop (1.86.2)
|
|
101
|
+
json (~> 2.3)
|
|
102
|
+
language_server-protocol (~> 3.17.0.2)
|
|
103
|
+
lint_roller (~> 1.1.0)
|
|
104
|
+
parallel (>= 1.10)
|
|
105
|
+
parser (>= 3.3.0.2)
|
|
81
106
|
rainbow (>= 2.2.2, < 4.0)
|
|
107
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
108
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
82
109
|
ruby-progressbar (~> 1.7)
|
|
83
|
-
unicode-display_width (
|
|
84
|
-
|
|
110
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
111
|
+
rubocop-ast (1.49.1)
|
|
112
|
+
parser (>= 3.3.7.2)
|
|
113
|
+
prism (~> 1.7)
|
|
114
|
+
ruby-progressbar (1.13.0)
|
|
85
115
|
ruby2_keywords (0.0.5)
|
|
116
|
+
securerandom (0.4.1)
|
|
86
117
|
tzinfo (2.0.6)
|
|
87
118
|
concurrent-ruby (~> 1.0)
|
|
88
|
-
unicode-display_width (
|
|
89
|
-
|
|
119
|
+
unicode-display_width (3.2.0)
|
|
120
|
+
unicode-emoji (~> 4.1)
|
|
121
|
+
unicode-emoji (4.2.0)
|
|
122
|
+
uri (1.1.1)
|
|
123
|
+
zeitwerk (2.8.1)
|
|
90
124
|
|
|
91
125
|
PLATFORMS
|
|
126
|
+
arm64-darwin-25
|
|
92
127
|
ruby
|
|
93
128
|
|
|
94
129
|
DEPENDENCIES
|
|
130
|
+
grape (~> 2.4.0)
|
|
95
131
|
grape-path-helpers!
|
|
96
132
|
pry (~> 0.11)
|
|
97
133
|
rspec (~> 3.7)
|
|
98
|
-
rubocop (~>
|
|
134
|
+
rubocop (~> 1.50)
|
|
99
135
|
|
|
100
136
|
BUNDLED WITH
|
|
101
|
-
2.2
|
|
137
|
+
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 (3.x) while the root
|
|
7
|
+
# `Gemfile` stays pinned to the version currently in production (2.4).
|
|
8
|
+
gem 'grape', '~> 3.0'
|
data/Gemfile.next.lock
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
grape-path-helpers (2.1.0)
|
|
5
|
+
activesupport
|
|
6
|
+
grape (>= 2.0, < 4)
|
|
7
|
+
rake (> 12)
|
|
8
|
+
ruby2_keywords (~> 0.0.2)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
activesupport (8.1.3)
|
|
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.2)
|
|
29
|
+
coderay (1.1.3)
|
|
30
|
+
concurrent-ruby (1.3.6)
|
|
31
|
+
connection_pool (3.0.2)
|
|
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.1)
|
|
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 (3.2.1)
|
|
55
|
+
activesupport (>= 7.2)
|
|
56
|
+
dry-configurable
|
|
57
|
+
dry-types (>= 1.1)
|
|
58
|
+
mustermann-grape (~> 1.1.0)
|
|
59
|
+
rack (>= 2)
|
|
60
|
+
zeitwerk
|
|
61
|
+
i18n (1.14.8)
|
|
62
|
+
concurrent-ruby (~> 1.0)
|
|
63
|
+
io-console (0.8.2)
|
|
64
|
+
json (2.19.5)
|
|
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.0.6)
|
|
70
|
+
drb (~> 2.0)
|
|
71
|
+
prism (~> 1.5)
|
|
72
|
+
mustermann (4.0.0)
|
|
73
|
+
mustermann-grape (1.1.0)
|
|
74
|
+
mustermann (>= 1.0.0)
|
|
75
|
+
parallel (2.1.0)
|
|
76
|
+
parser (3.3.11.1)
|
|
77
|
+
ast (~> 2.4.1)
|
|
78
|
+
racc
|
|
79
|
+
prism (1.9.0)
|
|
80
|
+
pry (0.16.0)
|
|
81
|
+
coderay (~> 1.1)
|
|
82
|
+
method_source (~> 1.0)
|
|
83
|
+
reline (>= 0.6.0)
|
|
84
|
+
racc (1.8.1)
|
|
85
|
+
rack (3.2.6)
|
|
86
|
+
rainbow (3.1.1)
|
|
87
|
+
rake (13.4.2)
|
|
88
|
+
regexp_parser (2.12.0)
|
|
89
|
+
reline (0.6.3)
|
|
90
|
+
io-console (~> 0.5)
|
|
91
|
+
rspec (3.13.2)
|
|
92
|
+
rspec-core (~> 3.13.0)
|
|
93
|
+
rspec-expectations (~> 3.13.0)
|
|
94
|
+
rspec-mocks (~> 3.13.0)
|
|
95
|
+
rspec-core (3.13.6)
|
|
96
|
+
rspec-support (~> 3.13.0)
|
|
97
|
+
rspec-expectations (3.13.5)
|
|
98
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
99
|
+
rspec-support (~> 3.13.0)
|
|
100
|
+
rspec-mocks (3.13.8)
|
|
101
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
102
|
+
rspec-support (~> 3.13.0)
|
|
103
|
+
rspec-support (3.13.7)
|
|
104
|
+
rubocop (1.86.2)
|
|
105
|
+
json (~> 2.3)
|
|
106
|
+
language_server-protocol (~> 3.17.0.2)
|
|
107
|
+
lint_roller (~> 1.1.0)
|
|
108
|
+
parallel (>= 1.10)
|
|
109
|
+
parser (>= 3.3.0.2)
|
|
110
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
111
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
112
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
113
|
+
ruby-progressbar (~> 1.7)
|
|
114
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
115
|
+
rubocop-ast (1.49.1)
|
|
116
|
+
parser (>= 3.3.7.2)
|
|
117
|
+
prism (~> 1.7)
|
|
118
|
+
ruby-progressbar (1.13.0)
|
|
119
|
+
ruby2_keywords (0.0.5)
|
|
120
|
+
securerandom (0.4.1)
|
|
121
|
+
tzinfo (2.0.6)
|
|
122
|
+
concurrent-ruby (~> 1.0)
|
|
123
|
+
unicode-display_width (3.2.0)
|
|
124
|
+
unicode-emoji (~> 4.1)
|
|
125
|
+
unicode-emoji (4.2.0)
|
|
126
|
+
uri (1.1.1)
|
|
127
|
+
zeitwerk (2.8.1)
|
|
128
|
+
|
|
129
|
+
PLATFORMS
|
|
130
|
+
arm64-darwin-25
|
|
131
|
+
ruby
|
|
132
|
+
|
|
133
|
+
DEPENDENCIES
|
|
134
|
+
grape (~> 3.0)
|
|
135
|
+
grape-path-helpers!
|
|
136
|
+
pry (~> 0.11)
|
|
137
|
+
rspec (~> 3.7)
|
|
138
|
+
rubocop (~> 1.50)
|
|
139
|
+
|
|
140
|
+
BUNDLED WITH
|
|
141
|
+
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', '< 4'
|
|
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
|
|
|
@@ -24,7 +26,7 @@ module GrapePathHelpers
|
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def all_routes
|
|
27
|
-
routes = descendants.flat_map { |
|
|
29
|
+
routes = descendants.flat_map { |d| d.endpoints.flat_map(&:routes) }
|
|
28
30
|
routes.uniq { |r| r.options.merge(path: r.path) }
|
|
29
31
|
end
|
|
30
32
|
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,7 +92,7 @@ module GrapePathHelpers
|
|
|
89
92
|
end
|
|
90
93
|
|
|
91
94
|
sanitized_name = self.class.sanitize_method_name(name)
|
|
92
|
-
sanitized_name
|
|
95
|
+
"#{sanitized_name}_path"
|
|
93
96
|
end
|
|
94
97
|
|
|
95
98
|
def segment_to_value(segment, opts = {})
|
|
@@ -102,6 +105,7 @@ module GrapePathHelpers
|
|
|
102
105
|
end
|
|
103
106
|
end
|
|
104
107
|
|
|
108
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
|
105
109
|
def path_segments_with_values(opts, include_wildcard_segments = false)
|
|
106
110
|
segments = path_segments(include_wildcard_segments).map do |s|
|
|
107
111
|
segment_to_value(s, opts)
|
|
@@ -117,6 +121,7 @@ module GrapePathHelpers
|
|
|
117
121
|
end
|
|
118
122
|
route_path.split(pattern).reject(&:blank?)
|
|
119
123
|
end
|
|
124
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
|
120
125
|
|
|
121
126
|
def dynamic_path_segments
|
|
122
127
|
segments = path_segments.select do |segment|
|
|
@@ -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
|
|
@@ -24,7 +26,6 @@ describe GrapePathHelpers::AllRoutes do
|
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
# rubocop:disable Metrics/LineLength
|
|
28
29
|
context 'when there are multiple POST routes with the same namespace in the same API' do
|
|
29
30
|
it 'returns all POST routes' do
|
|
30
31
|
expected_routes = Spec::Support::MultiplePostsAPI.routes.map(&:path)
|
|
@@ -40,7 +41,6 @@ describe GrapePathHelpers::AllRoutes do
|
|
|
40
41
|
expect(Grape::API::Instance.all_routes.map(&:origin)).to include('/derived_ping')
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
|
-
# rubocop:enable Metrics/LineLength
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
# 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
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/api.rb
CHANGED
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.1.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-08-05 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: '4'
|
|
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: '4'
|
|
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
|