grape-path-helpers 1.0.5 → 1.0.6
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e815c5ab96ef4eb2cc8485164b66d52fad17ef84
|
4
|
+
data.tar.gz: ad85602cc19898c77ffe765c4af0806b10485cd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8357a7a8d21d72d1cfd5daa5962e44f0444e1f5d0682c257484d8c22508d4350cb839598fe65cf25f32a9429c32d0c4f603c513ff69fb7532c16165a384d58f2
|
7
|
+
data.tar.gz: 4319294fe446969741d1badabca8c757184f9556aec29533b91f78f3ae13feefb84e2bbf600601281f318f5284a1f376008e9a0515ed44a9a27fc999b9c0ef13
|
data/CHANGELOG.md
CHANGED
@@ -105,7 +105,7 @@ module GrapePathHelpers
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def path_segments
|
108
|
-
pattern = %r{\(/?\.:?\w+\)
|
108
|
+
pattern = %r{\(/?\.:?\w+\)|/(?!\))|(?<=\))|\??\*}
|
109
109
|
route_path.split(pattern).reject(&:blank?)
|
110
110
|
end
|
111
111
|
|
@@ -120,6 +120,10 @@ module GrapePathHelpers
|
|
120
120
|
segment.start_with?(':')
|
121
121
|
end
|
122
122
|
|
123
|
+
def optional_segment?(segment)
|
124
|
+
segment.start_with?('(')
|
125
|
+
end
|
126
|
+
|
123
127
|
def required_helper_segments
|
124
128
|
segments_in_options = dynamic_path_segments.select do |segment|
|
125
129
|
route.options[segment.to_sym]
|
@@ -30,6 +30,10 @@ describe GrapePathHelpers::DecoratedRoute do
|
|
30
30
|
routes.detect { |route| route.route_path =~ /ping/ }
|
31
31
|
end
|
32
32
|
|
33
|
+
let(:optional_route) do
|
34
|
+
routes.detect { |route| route.route_path =~ /optional/ }
|
35
|
+
end
|
36
|
+
|
33
37
|
describe '#sanitize_method_name' do
|
34
38
|
it 'removes characters that are illegal in Ruby method names' do
|
35
39
|
illegal_names = ['beta-1', 'name_with_+', 'name_with_(']
|
@@ -104,6 +108,15 @@ describe GrapePathHelpers::DecoratedRoute do
|
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
111
|
+
describe '#path_segments' do
|
112
|
+
context 'when path has optional segments' do
|
113
|
+
it 'leaves them intact' do
|
114
|
+
result = optional_route.path_segments
|
115
|
+
expect(result).to eq(%w[api :version cats :id (-/) optional])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
107
120
|
describe '#path_segments_with_values' do
|
108
121
|
context 'when path has dynamic segments' do
|
109
122
|
it 'replaces segments with corresponding values found in @options' do
|
@@ -237,5 +250,10 @@ describe GrapePathHelpers::DecoratedRoute do
|
|
237
250
|
end
|
238
251
|
end
|
239
252
|
end
|
253
|
+
|
254
|
+
describe '#optional_segment?' do
|
255
|
+
it { expect(index_route.optional_segment?('mandatory')).to eq(false) }
|
256
|
+
it { expect(index_route.optional_segment?('(optional/)')).to eq(true) }
|
257
|
+
end
|
240
258
|
end
|
241
259
|
# rubocop:enable Metrics/BlockLength
|
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: 1.0.
|
4
|
+
version: 1.0.6
|
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: 2018-
|
12
|
+
date: 2018-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.5.2
|
156
|
+
rubygems_version: 2.5.2
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Route path helpers for Grape
|