grape-path-helpers 1.7.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a9b0351af6ba5b42ba8b521c7bc83a832d4a20a445c30c4c346874f161ddfba
4
- data.tar.gz: abe212bb7ab94afa5d12f738a68b2c7c84b93ec807825d5622022ccacb99c5bd
3
+ metadata.gz: 48d0b31d4510edbe385479f81ca2e91a51cf09454037339d7c71510ea892321e
4
+ data.tar.gz: a8856400f31326e0c13b1ca55397c9d46b7f0e800848ba8f4cbb9df65794cf78
5
5
  SHA512:
6
- metadata.gz: 1c4341eed5f6e6cbbc0f3fa7c35bca36e0f10129948556f6549a4f384e699aa6e6981f61e4c8657e660a7db6d2acfd4adb0b42558bfa58c9e7f8b337014f4f96
7
- data.tar.gz: c996a522cfcfb00b275ab276a9ee3e24280a624fa859e4c434937903de0ad3dc004c50231cf37c5abca9ad467b30d29ec0aff131e6e33a58d88b5d1bed5d3499
6
+ metadata.gz: '0097583d83eb6f56e6063fb4527809411d0970a9aa36622e0e96ae039d3556cb737d7624807a3ef2f0862329babf62474b4b6423bb6ebae6c506c2f5c35f8245'
7
+ data.tar.gz: 945c6f84ebb3ee473f94aadba7780b04c1f813d4e8405c5f634218904f8b54af78a5fc49e12b171de294f6a50b50d2d871c75083779d9d1ed446d0c164db4420
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0
4
+
5
+ * [Adds support for Rack 3](https://gitlab.com/gitlab-org/ruby/gems/grape-path-helpers/-/merge_requests/45)
6
+
7
+ ## 1.7.1
8
+
9
+ * Fix undefined method error (https://gitlab.com/gitlab-org/grape-path-helpers/-/merge_requests/42)
10
+
3
11
  ## 1.7.0
4
12
 
5
13
  * [Further improve performance of route matching](https://gitlab.com/gitlab-org/grape-path-helpers/-/merge_requests/38)
data/Gemfile.lock CHANGED
@@ -1,58 +1,53 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-path-helpers (1.7.0)
4
+ grape-path-helpers (2.0.0)
5
5
  activesupport
6
- grape (~> 1.3)
6
+ grape (~> 2.0)
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 (6.1.3.2)
13
+ activesupport (7.0.3.1)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
- zeitwerk (~> 2.3)
19
18
  ast (2.4.0)
20
19
  builder (3.2.4)
21
20
  coderay (1.1.2)
22
- concurrent-ruby (1.1.8)
21
+ concurrent-ruby (1.2.2)
23
22
  diff-lcs (1.3)
24
- dry-configurable (0.12.1)
23
+ dry-core (1.0.1)
25
24
  concurrent-ruby (~> 1.0)
26
- dry-core (~> 0.5, >= 0.5.0)
27
- dry-container (0.7.2)
25
+ zeitwerk (~> 2.6)
26
+ dry-inflector (1.0.0)
27
+ dry-logic (1.5.0)
28
28
  concurrent-ruby (~> 1.0)
29
- dry-configurable (~> 0.1, >= 0.1.3)
30
- dry-core (0.5.0)
29
+ dry-core (~> 1.0, < 2)
30
+ zeitwerk (~> 2.6)
31
+ dry-types (1.7.1)
31
32
  concurrent-ruby (~> 1.0)
32
- dry-inflector (0.2.0)
33
- dry-logic (1.2.0)
34
- concurrent-ruby (~> 1.0)
35
- dry-core (~> 0.5, >= 0.5)
36
- dry-types (1.5.1)
37
- concurrent-ruby (~> 1.0)
38
- dry-container (~> 0.3)
39
- dry-core (~> 0.5, >= 0.5)
40
- dry-inflector (~> 0.1, >= 0.1.2)
41
- dry-logic (~> 1.0, >= 1.0.2)
42
- grape (1.5.3)
43
- activesupport
33
+ dry-core (~> 1.0)
34
+ dry-inflector (~> 1.0)
35
+ dry-logic (~> 1.4)
36
+ zeitwerk (~> 2.6)
37
+ grape (2.0.0)
38
+ activesupport (>= 5)
44
39
  builder
45
40
  dry-types (>= 1.1)
46
41
  mustermann-grape (~> 1.0.0)
47
42
  rack (>= 1.3.0)
48
43
  rack-accept
49
- i18n (1.8.10)
44
+ i18n (1.14.1)
50
45
  concurrent-ruby (~> 1.0)
51
46
  method_source (0.9.0)
52
- minitest (5.14.4)
53
- mustermann (1.1.1)
47
+ minitest (5.20.0)
48
+ mustermann (3.0.0)
54
49
  ruby2_keywords (~> 0.0.1)
55
- mustermann-grape (1.0.1)
50
+ mustermann-grape (1.0.2)
56
51
  mustermann (>= 1.0.0)
57
52
  parallel (1.12.1)
58
53
  parser (2.5.1.0)
@@ -61,11 +56,11 @@ GEM
61
56
  pry (0.11.3)
62
57
  coderay (~> 1.1.0)
63
58
  method_source (~> 0.9.0)
64
- rack (2.2.3)
59
+ rack (3.0.8)
65
60
  rack-accept (0.4.5)
66
61
  rack (>= 0.4)
67
62
  rainbow (3.0.0)
68
- rake (13.0.3)
63
+ rake (13.1.0)
69
64
  rspec (3.7.0)
70
65
  rspec-core (~> 3.7.0)
71
66
  rspec-expectations (~> 3.7.0)
@@ -87,11 +82,11 @@ GEM
87
82
  ruby-progressbar (~> 1.7)
88
83
  unicode-display_width (~> 1.0, >= 1.0.1)
89
84
  ruby-progressbar (1.9.0)
90
- ruby2_keywords (0.0.4)
91
- tzinfo (2.0.4)
85
+ ruby2_keywords (0.0.5)
86
+ tzinfo (2.0.6)
92
87
  concurrent-ruby (~> 1.0)
93
88
  unicode-display_width (1.3.3)
94
- zeitwerk (2.4.2)
89
+ zeitwerk (2.6.12)
95
90
 
96
91
  PLATFORMS
97
92
  ruby
data/README.md CHANGED
@@ -8,10 +8,6 @@ Provides named route helpers for Grape APIs, similar to [Rails' route helpers](h
8
8
 
9
9
  ### Installation
10
10
 
11
- #### Compatibility with Grape
12
-
13
- If you're using grape 0.16.0 or higher, you'll need version 2.0.0 or higher of grape-path-helpers.
14
-
15
11
  #### Rails
16
12
 
17
13
  p 1.) Add the gem to your Gemfile.
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.homepage = 'https://gitlab.com/gitlab-org/grape-path-helpers'
13
13
 
14
14
  gem.add_runtime_dependency 'activesupport'
15
- gem.add_runtime_dependency 'grape', '~> 1.3'
15
+ gem.add_runtime_dependency 'grape', '~> 2.0'
16
16
  gem.add_runtime_dependency 'rake', '> 12'
17
17
  gem.add_runtime_dependency 'ruby2_keywords', '~> 0.0.2'
18
18
 
@@ -4,6 +4,8 @@ module GrapePathHelpers
4
4
  # helper function name
5
5
  module NamedRouteMatcher
6
6
  def method_missing(method_name, *args)
7
+ return super unless method_name.end_with?('_path')
8
+
7
9
  possible_routes = Grape::API::Instance
8
10
  .decorated_routes_by_helper_name[method_name]
9
11
  return super unless possible_routes
@@ -26,8 +28,13 @@ module GrapePathHelpers
26
28
  ruby2_keywords(:method_missing)
27
29
 
28
30
  def respond_to_missing?(method_name, _include_private = false)
29
- !Grape::API::Instance.decorated_routes_by_helper_name[method_name].nil? ||
30
- super
31
+ grape_route_path?(method_name) || super
32
+ end
33
+
34
+ def grape_route_path?(method_name)
35
+ method_name.end_with?('_path') &&
36
+ !Grape::API::Instance
37
+ .decorated_routes_by_helper_name[method_name].nil?
31
38
  end
32
39
  end
33
40
  end
@@ -3,7 +3,12 @@ module GrapePathHelpers
3
3
  # and required arguments for every Grape::Route.
4
4
  class RouteDisplayer
5
5
  def route_attributes
6
- Grape::API::Instance.decorated_routes.values.flatten.uniq.map do |route|
6
+ Grape::API::Instance
7
+ .decorated_routes_by_helper_name
8
+ .values
9
+ .flatten
10
+ .uniq
11
+ .map do |route|
7
12
  {
8
13
  route_path: route.route_path,
9
14
  route_method: route.route_method,
@@ -1,4 +1,4 @@
1
1
  # Gem version
2
2
  module GrapePathHelpers
3
- VERSION = '1.7.0'.freeze
3
+ VERSION = '2.0.0'.freeze
4
4
  end
@@ -60,6 +60,21 @@ describe GrapePathHelpers::NamedRouteMatcher do
60
60
  end
61
61
 
62
62
  describe '#respond_to_missing?' do
63
+ context 'when method name doesnt end with _path suffix' do
64
+ let(:method_name) { :api_v1_cats }
65
+
66
+ it 'returns false' do
67
+ expect(respond_to_missing?(method_name)).to eq(false)
68
+ end
69
+
70
+ it 'doesnt execute decorated_routes_by_helper_name method' do
71
+ expect(Grape::API::Instance)
72
+ .not_to receive(:decorated_routes_by_helper_name)
73
+
74
+ respond_to_missing?(method_name)
75
+ end
76
+ end
77
+
63
78
  context 'when method name matches a Grape::Route path with segments' do
64
79
  let(:method_name) { :api_v1_cats_path }
65
80
 
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe GrapePathHelpers::RouteDisplayer do
4
+ subject(:route_displayer) { described_class.new }
5
+
6
+ describe '#route_attributes' do
7
+ subject { route_displayer.route_attributes }
8
+
9
+ it 'returns the list of attributes' do
10
+ is_expected.to include(a_hash_including(
11
+ route_path: '/:version/ping(.:format)',
12
+ route_method: 'GET',
13
+ helper_names: ['beta_1_ping_path'],
14
+ helper_arguments: []
15
+ ))
16
+ end
17
+ end
18
+ end
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: 1.7.0
4
+ version: 2.0.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: 2021-08-24 00:00:00.000000000 Z
12
+ date: 2023-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.3'
34
+ version: '2.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.3'
41
+ version: '2.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -140,6 +140,7 @@ files:
140
140
  - spec/grape_path_helpers/all_routes_spec.rb
141
141
  - spec/grape_path_helpers/decorated_route_spec.rb
142
142
  - spec/grape_path_helpers/named_route_matcher_spec.rb
143
+ - spec/grape_path_helpers/route_displayer_spec.rb
143
144
  - spec/spec_helper.rb
144
145
  - spec/support/api.rb
145
146
  homepage: https://gitlab.com/gitlab-org/grape-path-helpers
@@ -161,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
162
  - !ruby/object:Gem::Version
162
163
  version: '0'
163
164
  requirements: []
164
- rubygems_version: 3.2.3
165
+ rubygems_version: 3.5.2
165
166
  signing_key:
166
167
  specification_version: 4
167
168
  summary: Route path helpers for Grape