grape-path-helpers 1.7.0 → 1.7.1

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: 8df03144931341081ba2a02ba59cc45d6a74cc55a5d465d40cf8a333c5032ac1
4
+ data.tar.gz: 1a173198fadb720a0aa3a23632f2657ba24425fae84720dcf3703d3e8281fd71
5
5
  SHA512:
6
- metadata.gz: 1c4341eed5f6e6cbbc0f3fa7c35bca36e0f10129948556f6549a4f384e699aa6e6981f61e4c8657e660a7db6d2acfd4adb0b42558bfa58c9e7f8b337014f4f96
7
- data.tar.gz: c996a522cfcfb00b275ab276a9ee3e24280a624fa859e4c434937903de0ad3dc004c50231cf37c5abca9ad467b30d29ec0aff131e6e33a58d88b5d1bed5d3499
6
+ metadata.gz: 855800980e102dc069cac30f31f85d77e0e8681fdd312b1a0d574151b9331ebd34fbb1b7756c06cd0ca4602f865b6d585841eef0da1b38cacf9e3b117b964b4d
7
+ data.tar.gz: ddeb1c0471150615131ed8d2af3c7dfc2b5ad9254c9f6046d0dd43d2e589511935a13107bf59502df3d6f8f7d378bedfee8bc04025f2aaec17537e9c29ac798a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.1
4
+
5
+ * Fix undefined method error (https://gitlab.com/gitlab-org/grape-path-helpers/-/merge_requests/42)
6
+
3
7
  ## 1.7.0
4
8
 
5
9
  * [Further improve performance of route matching](https://gitlab.com/gitlab-org/grape-path-helpers/-/merge_requests/38)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-path-helpers (1.7.0)
4
+ grape-path-helpers (1.7.1)
5
5
  activesupport
6
6
  grape (~> 1.3)
7
7
  rake (> 12)
@@ -10,26 +10,21 @@ PATH
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.1.10)
23
22
  diff-lcs (1.3)
24
- dry-configurable (0.12.1)
23
+ dry-container (0.10.1)
25
24
  concurrent-ruby (~> 1.0)
26
- dry-core (~> 0.5, >= 0.5.0)
27
- dry-container (0.7.2)
25
+ dry-core (0.8.1)
28
26
  concurrent-ruby (~> 1.0)
29
- dry-configurable (~> 0.1, >= 0.1.3)
30
- dry-core (0.5.0)
31
- concurrent-ruby (~> 1.0)
32
- dry-inflector (0.2.0)
27
+ dry-inflector (0.3.0)
33
28
  dry-logic (1.2.0)
34
29
  concurrent-ruby (~> 1.0)
35
30
  dry-core (~> 0.5, >= 0.5)
@@ -39,20 +34,20 @@ GEM
39
34
  dry-core (~> 0.5, >= 0.5)
40
35
  dry-inflector (~> 0.1, >= 0.1.2)
41
36
  dry-logic (~> 1.0, >= 1.0.2)
42
- grape (1.5.3)
37
+ grape (1.6.2)
43
38
  activesupport
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.12.0)
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.16.2)
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 (2.2.4)
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.0.6)
69
64
  rspec (3.7.0)
70
65
  rspec-core (~> 3.7.0)
71
66
  rspec-expectations (~> 3.7.0)
@@ -87,11 +82,10 @@ 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.5)
92
87
  concurrent-ruby (~> 1.0)
93
88
  unicode-display_width (1.3.3)
94
- zeitwerk (2.4.2)
95
89
 
96
90
  PLATFORMS
97
91
  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.
@@ -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 = '1.7.1'.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,15 +1,15 @@
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: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Blessing
8
8
  - Harper Henn
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-08-24 00:00:00.000000000 Z
12
+ date: 2022-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -140,13 +140,14 @@ 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
146
147
  licenses:
147
148
  - MIT
148
149
  metadata: {}
149
- post_install_message:
150
+ post_install_message:
150
151
  rdoc_options: []
151
152
  require_paths:
152
153
  - lib
@@ -161,8 +162,8 @@ 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
- signing_key:
165
+ rubygems_version: 3.3.19
166
+ signing_key:
166
167
  specification_version: 4
167
168
  summary: Route path helpers for Grape
168
169
  test_files: []