mustermann-grape 1.0.0.beta2 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 59f3857bd11fa4d62fa26e0f1422a808dd83c718
4
- data.tar.gz: fb3eb8734628318aa8bdf86ee6ca23cb92cc7337
2
+ SHA256:
3
+ metadata.gz: 53d8315ebe7d6f7d074dc0477fdac54e0f8c420450f30406c8d742f274dfd72f
4
+ data.tar.gz: a9bc253a7d11d2c84d027703b186a1e7b04b980820416565af140024f65e6b2f
5
5
  SHA512:
6
- metadata.gz: 78ebe72b92e2c839654727783a68fa42cfcf97aa07611596c863b06f7830c8e883a9c8dbd52ee7f987ce330e70aeb338a49a4747f48304cd5989b46a5d050f35
7
- data.tar.gz: cccea206122f5d923669e68f5b5073d8b1c3db22f4a6092a31e2601dd2cc3a08f430b6f2f8a333b9ee4beacdc9e47296c2923658e5ad7d8f12a6c783a6030309
6
+ metadata.gz: acde3ddbc4e0580de9232ae572f9a94cc5b80b5a56a9c5e75edbd7abb165dfeef1cd59ea40bf00aa3231beb8565d68273980af99fe817f1da5d58b47af77f41b
7
+ data.tar.gz: b804417c751c40c11bae887170748f640a7973c2343e26a9b3c15af466f963e7d67439f264d8b3b813ab61f6da347360cd9d85f656e620e52ab867861f81fc1d
@@ -0,0 +1,23 @@
1
+ name: tests
2
+ on:
3
+ [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ matrix:
12
+ ruby-version: ['2.5', '2.6', '2.7']
13
+
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+ - name: Set up Ruby ${{ matrix.ruby-version }}
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true
21
+ - name: Run tests
22
+ run: bundle exec rake
23
+
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,4 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
- gem 'support', git: 'git@github.com:sinatra/mustermann.git'
5
+ gem 'support', git: 'https://github.com/sinatra/mustermann.git'
6
+
4
7
  gemspec
8
+
9
+ gem 'rake'
10
+ gem 'rspec-core'
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Mustermann-Grape Contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This gem implements the `grape` pattern type for Mustermann.
4
4
 
5
+ [![tests](https://github.com/ruby-grape/mustermann-grape/workflows/tests/badge.svg)](https://github.com/ruby-grape/mustermann-grape/actions?query=workflow%3Atests)
6
+
5
7
  ## Overview
6
8
 
7
9
  **Supported options:**
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ Bundler.setup :default, :test, :development
6
+
7
+ Bundler::GemHelper.install_tasks
8
+
1
9
  task(default: :rspec)
2
10
  task(:rspec) { ruby '-S rspec' }
@@ -1,7 +1,5 @@
1
- require 'mustermann/grape'
1
+ # frozen_string_literal: true
2
2
 
3
- module Mustermann
4
- class Grape
5
- VERSION = '1.0.0.beta2'
6
- end
3
+ module MustermannGrape
4
+ VERSION = '1.0.2'
7
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mustermann'
2
4
  require 'mustermann/ast/pattern'
3
5
 
@@ -12,23 +14,23 @@ module Mustermann
12
14
  class Grape < AST::Pattern
13
15
  register :grape
14
16
 
15
- on(nil, ??, ?)) { |c| unexpected(c) }
17
+ on(nil, '?', ')') { |c| unexpected(c) }
16
18
 
17
- on(?*) { |c| scan(/\w+/) ? node(:named_splat, buffer.matched) : node(:splat) }
18
- on(?:) { |c| node(:capture, constraint: "[^/\\?#\.]") { scan(/\w+/) } }
19
- on(?\\) { |c| node(:char, expect(/./)) }
20
- on(?() { |c| node(:optional, node(:group) { read unless scan(?)) }) }
21
- on(?|) { |c| node(:or) }
19
+ on('*') { |_c| scan(/\w+/) ? node(:named_splat, buffer.matched) : node(:splat) }
20
+ on(':') { |_c| node(:capture, constraint: "[^/\\?#\.]") { scan(/\w+/) } }
21
+ on('\\') { |_c| node(:char, expect(/./)) }
22
+ on('(') { |_c| node(:optional, node(:group) { read unless scan(')') }) }
23
+ on('|') { |_c| node(:or) }
22
24
 
23
- on ?{ do |char|
24
- type = scan(?+) ? :named_splat : :capture
25
+ on '{' do |_char|
26
+ type = scan('+') ? :named_splat : :capture
25
27
  name = expect(/[\w\.]+/)
26
- type = :splat if type == :named_splat and name == 'splat'
27
- expect(?})
28
+ type = :splat if (type == :named_splat) && (name == 'splat')
29
+ expect('}')
28
30
  node(type, name)
29
31
  end
30
32
 
31
- suffix ?? do |char, element|
33
+ suffix '?' do |_char, element|
32
34
  node(:optional, element)
33
35
  end
34
36
  end
@@ -1,18 +1,21 @@
1
- $:.unshift File.expand_path("../lib", __FILE__)
2
- require "mustermann/grape/version"
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require 'mustermann/grape/version'
3
6
 
4
7
  Gem::Specification.new do |s|
5
- s.name = "mustermann-grape"
6
- s.version = Mustermann::Grape::VERSION
7
- s.authors = ["namusyaka", "Konstantin Haase"]
8
- s.email = "namusyaka@gmail.com"
9
- s.homepage = "https://github.com/ruby-grape/mustermann-grape"
10
- s.summary = %q{Grape syntax for Mustermann}
11
- s.description = %q{Adds Grape style patterns to Mustermman}
8
+ s.name = 'mustermann-grape'
9
+ s.version = MustermannGrape::VERSION
10
+ s.authors = ['namusyaka', 'Konstantin Haase', 'Daniel Doubrovkine']
11
+ s.email = 'namusyaka@gmail.com'
12
+ s.homepage = 'https://github.com/ruby-grape/mustermann-grape'
13
+ s.summary = 'Grape syntax for Mustermann'
14
+ s.description = 'Adds Grape style patterns to Mustermman'
12
15
  s.license = 'MIT'
13
16
  s.required_ruby_version = '>= 2.1.0'
14
17
  s.files = `git ls-files`.split("\n")
15
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
- s.add_dependency 'mustermann', '1.0.0.beta2'
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
+ s.add_dependency 'mustermann', '>= 1.0.0'
18
21
  end
data/spec/grape_spec.rb CHANGED
@@ -1,11 +1,13 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
2
5
  require 'support/env'
3
6
  require 'support/match_matcher'
4
7
  require 'support/expand_matcher'
5
8
  require 'support/pattern'
6
9
  require 'support/generate_template_matcher'
7
10
  require 'support/scan_matcher'
8
- require File.expand_path('lib/mustermann/grape')
9
11
 
10
12
  describe Mustermann::Grape do
11
13
  extend Support::Pattern
@@ -59,11 +61,11 @@ describe Mustermann::Grape do
59
61
  end
60
62
 
61
63
  pattern '/föö' do
62
- it { should match("/f%C3%B6%C3%B6") }
64
+ it { should match('/f%C3%B6%C3%B6') }
63
65
  end
64
66
 
65
- pattern "/:foo/:bar" do
66
- it { should match('/foo/bar') .capturing foo: 'foo', bar: 'bar' }
67
+ pattern '/:foo/:bar' do
68
+ it { should match('/foo/bar') .capturing foo: 'foo', bar: 'bar' }
67
69
  it { should_not match('/foo.bar/bar.foo') }
68
70
  it { should_not match('/user@example.com/name') }
69
71
  it { should_not match('/10.1/te.st') }
@@ -72,13 +74,13 @@ describe Mustermann::Grape do
72
74
  it { should_not match('/foo%2Fbar') }
73
75
  it { should_not match('/foo%2fbar') }
74
76
 
75
- example { pattern.params('/bar/foo').should be == {"foo" => "bar", "bar" => "foo"} }
77
+ example { pattern.params('/bar/foo').should be == { 'foo' => 'bar', 'bar' => 'foo' } }
76
78
  example { pattern.params('').should be_nil }
77
79
 
78
80
  it { should generate_template('/{foo}/{bar}') }
79
81
  end
80
82
 
81
- pattern "/{foo}/{bar}" do
83
+ pattern '/{foo}/{bar}' do
82
84
  it { should match('/foo/bar') .capturing foo: 'foo', bar: 'bar' }
83
85
  it { should match('/foo.bar/bar.foo') .capturing foo: 'foo.bar', bar: 'bar.foo' }
84
86
  it { should match('/user@example.com/name') .capturing foo: 'user@example.com', bar: 'name' }
@@ -88,7 +90,7 @@ describe Mustermann::Grape do
88
90
  it { should_not match('/foo%2Fbar') }
89
91
  it { should_not match('/foo%2fbar') }
90
92
 
91
- example { pattern.params('/bar/foo').should be == {"foo" => "bar", "bar" => "foo"} }
93
+ example { pattern.params('/bar/foo').should be == { 'foo' => 'bar', 'bar' => 'foo' } }
92
94
  example { pattern.params('').should be_nil }
93
95
 
94
96
  it { should generate_template('/{foo}/{bar}') }
@@ -117,7 +119,7 @@ describe Mustermann::Grape do
117
119
  it { should_not expand(baz: '') }
118
120
 
119
121
  it { should_not match('/hello/world/') }
120
- it { should generate_templates("", "/", "//", "//{bar}", "/{bar}", "/{foo}", "/{foo}/", "/{foo}/{bar}", "/{foo}{bar}", "{bar}", "{foo}", "{foo}/", "{foo}/{bar}", "{foo}{bar}") }
122
+ it { should generate_templates('', '/', '//', '//{bar}', '/{bar}', '/{foo}', '/{foo}/', '/{foo}/{bar}', '/{foo}{bar}', '{bar}', '{foo}', '{foo}/', '{foo}/{bar}', '{foo}{bar}') }
121
123
  end
122
124
 
123
125
  pattern '/:foo_bar' do
@@ -126,7 +128,7 @@ describe Mustermann::Grape do
126
128
  end
127
129
 
128
130
  pattern '/{foo.bar}' do
129
- it { should match('/hello').capturing :"foo.bar" => 'hello' }
131
+ it { should match('/hello').capturing "foo.bar": 'hello' }
130
132
  it { should generate_template('/{foo.bar}') }
131
133
  end
132
134
 
@@ -136,7 +138,7 @@ describe Mustermann::Grape do
136
138
  it { should match('/foo/bar') .capturing splat: 'foo/bar' }
137
139
  it { should generate_template('/{+splat}') }
138
140
 
139
- example { pattern.params('/foo').should be == {"splat" => ["foo"]} }
141
+ example { pattern.params('/foo').should be == { 'splat' => ['foo'] } }
140
142
  end
141
143
 
142
144
  pattern '/{+splat}' do
@@ -145,7 +147,7 @@ describe Mustermann::Grape do
145
147
  it { should match('/foo/bar') .capturing splat: 'foo/bar' }
146
148
  it { should generate_template('/{+splat}') }
147
149
 
148
- example { pattern.params('/foo').should be == {"splat" => ["foo"]} }
150
+ example { pattern.params('/foo').should be == { 'splat' => ['foo'] } }
149
151
  end
150
152
 
151
153
  pattern '/*foo' do
@@ -154,8 +156,8 @@ describe Mustermann::Grape do
154
156
  it { should match('/foo/bar') .capturing foo: 'foo/bar' }
155
157
  it { should generate_template('/{+foo}') }
156
158
 
157
- example { pattern.params('/foo') .should be == {"foo" => "foo" } }
158
- example { pattern.params('/foo/bar') .should be == {"foo" => "foo/bar" } }
159
+ example { pattern.params('/foo') .should be == { 'foo' => 'foo' } }
160
+ example { pattern.params('/foo/bar') .should be == { 'foo' => 'foo/bar' } }
159
161
  end
160
162
 
161
163
  pattern '/{+foo}' do
@@ -164,8 +166,8 @@ describe Mustermann::Grape do
164
166
  it { should match('/foo/bar') .capturing foo: 'foo/bar' }
165
167
  it { should generate_template('/{+foo}') }
166
168
 
167
- example { pattern.params('/foo') .should be == {"foo" => "foo" } }
168
- example { pattern.params('/foo/bar') .should be == {"foo" => "foo/bar" } }
169
+ example { pattern.params('/foo') .should be == { 'foo' => 'foo' } }
170
+ example { pattern.params('/foo/bar') .should be == { 'foo' => 'foo/bar' } }
169
171
  end
170
172
 
171
173
  pattern '/*foo/*bar' do
@@ -179,25 +181,25 @@ describe Mustermann::Grape do
179
181
  end
180
182
 
181
183
  pattern '/:foo/*' do
182
- it { should match("/foo/bar/baz") .capturing foo: 'foo', splat: 'bar/baz' }
183
- it { should match("/foo/") .capturing foo: 'foo', splat: '' }
184
+ it { should match('/foo/bar/baz') .capturing foo: 'foo', splat: 'bar/baz' }
185
+ it { should match('/foo/') .capturing foo: 'foo', splat: '' }
184
186
  it { should match('/h%20w/h%20a%20y') .capturing foo: 'h%20w', splat: 'h%20a%20y' }
185
187
  it { should_not match('/foo') }
186
188
  it { should generate_template('/{foo}/{+splat}') }
187
189
 
188
- example { pattern.params('/bar/foo').should be == {"splat" => ["foo"], "foo" => "bar"} }
189
- example { pattern.params('/bar/foo/f%20o').should be == {"splat" => ["foo/f o"], "foo" => "bar"} }
190
+ example { pattern.params('/bar/foo').should be == { 'splat' => ['foo'], 'foo' => 'bar' } }
191
+ example { pattern.params('/bar/foo/f%20o').should be == { 'splat' => ['foo/f o'], 'foo' => 'bar' } }
190
192
  end
191
193
 
192
194
  pattern '/{foo}/*' do
193
- it { should match("/foo/bar/baz") .capturing foo: 'foo', splat: 'bar/baz' }
194
- it { should match("/foo/") .capturing foo: 'foo', splat: '' }
195
+ it { should match('/foo/bar/baz') .capturing foo: 'foo', splat: 'bar/baz' }
196
+ it { should match('/foo/') .capturing foo: 'foo', splat: '' }
195
197
  it { should match('/h%20w/h%20a%20y') .capturing foo: 'h%20w', splat: 'h%20a%20y' }
196
198
  it { should_not match('/foo') }
197
199
  it { should generate_template('/{foo}/{+splat}') }
198
200
 
199
- example { pattern.params('/bar/foo').should be == {"splat" => ["foo"], "foo" => "bar"} }
200
- example { pattern.params('/bar/foo/f%20o').should be == {"splat" => ["foo/f o"], "foo" => "bar"} }
201
+ example { pattern.params('/bar/foo').should be == { 'splat' => ['foo'], 'foo' => 'bar' } }
202
+ example { pattern.params('/bar/foo/f%20o').should be == { 'splat' => ['foo/f o'], 'foo' => 'bar' } }
201
203
  end
202
204
 
203
205
  pattern '/test$/' do
@@ -210,7 +212,7 @@ describe Mustermann::Grape do
210
212
  it { should_not match('/teest/') }
211
213
  end
212
214
 
213
- pattern "/path with spaces" do
215
+ pattern '/path with spaces' do
214
216
  it { should match('/path%20with%20spaces') }
215
217
  it { should match('/path%2Bwith%2Bspaces') }
216
218
  it { should match('/path+with+spaces') }
@@ -229,15 +231,15 @@ describe Mustermann::Grape do
229
231
  pattern '/*/:foo/*/*' do
230
232
  it { should match('/bar/foo/bling/baz/boom') }
231
233
 
232
- it "should capture all splat parts" do
234
+ it 'should capture all splat parts' do
233
235
  match = pattern.match('/bar/foo/bling/baz/boom')
234
236
  match.captures.should be == ['bar', 'foo', 'bling', 'baz/boom']
235
- match.names.should be == ['splat', 'foo']
237
+ match.names.should be == %w[splat foo]
236
238
  end
237
239
 
238
240
  it 'should map to proper params' do
239
241
  pattern.params('/bar/foo/bling/baz/boom').should be == {
240
- "foo" => "foo", "splat" => ['bar', 'bling', 'baz/boom']
242
+ 'foo' => 'foo', 'splat' => ['bar', 'bling', 'baz/boom']
241
243
  }
242
244
  end
243
245
  end
@@ -245,15 +247,15 @@ describe Mustermann::Grape do
245
247
  pattern '/{+splat}/{foo}/{+splat}/{+splat}' do
246
248
  it { should match('/bar/foo/bling/baz/boom') }
247
249
 
248
- it "should capture all splat parts" do
250
+ it 'should capture all splat parts' do
249
251
  match = pattern.match('/bar/foo/bling/baz/boom')
250
252
  match.captures.should be == ['bar', 'foo', 'bling', 'baz/boom']
251
- match.names.should be == ['splat', 'foo']
253
+ match.names.should be == %w[splat foo]
252
254
  end
253
255
 
254
256
  it 'should map to proper params' do
255
257
  pattern.params('/bar/foo/bling/baz/boom').should be == {
256
- "foo" => "foo", "splat" => ['bar', 'bling', 'baz/boom']
258
+ 'foo' => 'foo', 'splat' => ['bar', 'bling', 'baz/boom']
257
259
  }
258
260
  end
259
261
  end
@@ -274,7 +276,7 @@ describe Mustermann::Grape do
274
276
  it { should match('/pony正%2ejpg') .capturing file: 'pony正', ext: 'jpg' }
275
277
 
276
278
  it { should_not match('/pony正..jpg') }
277
- it { should_not match('/.jpg') }
279
+ it { should_not match('/.jpg') }
278
280
  end
279
281
 
280
282
  pattern '/(:a)x?' do
@@ -287,7 +289,7 @@ describe Mustermann::Grape do
287
289
  end
288
290
 
289
291
  pattern '/:user(@:host)?' do
290
- it { should match('/foo@bar') .capturing user: 'foo', host: 'bar' }
292
+ it { should match('/foo@bar') .capturing user: 'foo', host: 'bar' }
291
293
  it { should_not match('/foo.foo@bar') }
292
294
  it { should_not match('/foo@bar.bar') }
293
295
 
@@ -318,12 +320,12 @@ describe Mustermann::Grape do
318
320
  end
319
321
 
320
322
  pattern '/10/:id' do
321
- it { should match('/10/test') .capturing id: 'test' }
323
+ it { should match('/10/test') .capturing id: 'test' }
322
324
  it { should_not match('/10/te.st') }
323
325
  end
324
326
 
325
327
  pattern '/10.1/:id' do
326
- it { should match('/10.1/test') .capturing id: 'test' }
328
+ it { should match('/10.1/test') .capturing id: 'test' }
327
329
  it { should_not match('/10.1/te.st') }
328
330
  end
329
331
 
@@ -435,34 +437,34 @@ describe Mustermann::Grape do
435
437
  it { should match('/foo/bar/baz').capturing foo: 'foo', bar: 'bar', baz: 'baz' }
436
438
  end
437
439
 
438
- pattern "/(foo|bar)" do
439
- it { should match("/foo") }
440
- it { should match("/bar") }
440
+ pattern '/(foo|bar)' do
441
+ it { should match('/foo') }
442
+ it { should match('/bar') }
441
443
  end
442
444
 
443
- pattern "/(foo\\|bar)" do
444
- it { should match "/foo%7Cbar" }
445
- it { should generate_template "/foo%7Cbar" }
445
+ pattern '/(foo\\|bar)' do
446
+ it { should match '/foo%7Cbar' }
447
+ it { should generate_template '/foo%7Cbar' }
446
448
 
447
- it { should_not match("/foo") }
448
- it { should_not match("/bar") }
449
+ it { should_not match('/foo') }
450
+ it { should_not match('/bar') }
449
451
 
450
452
  it { should_not generate_template('/foo') }
451
453
  it { should_not generate_template('/bar') }
452
454
  end
453
455
 
454
- pattern "/(:a/:b|:c)" do
455
- it { should match("/foo") .capturing c: 'foo' }
456
- it { should match("/foo/bar") .capturing a: 'foo', b: 'bar' }
456
+ pattern '/(:a/:b|:c)' do
457
+ it { should match('/foo') .capturing c: 'foo' }
458
+ it { should match('/foo/bar') .capturing a: 'foo', b: 'bar' }
457
459
 
458
460
  it { should expand(a: 'foo', b: 'bar') .to('/foo/bar') }
459
461
  it { should expand(c: 'foo') .to('/foo') }
460
462
  it { should_not expand(a: 'foo', b: 'bar', c: 'baz') }
461
463
  end
462
464
 
463
- pattern "/:a/:b|:c" do
464
- it { should match("foo") .capturing c: 'foo' }
465
- it { should match("/foo/bar") .capturing a: 'foo', b: 'bar' }
465
+ pattern '/:a/:b|:c' do
466
+ it { should match('foo') .capturing c: 'foo' }
467
+ it { should match('/foo/bar') .capturing a: 'foo', b: 'bar' }
466
468
 
467
469
  it { should generate_template('/{a}/{b}') }
468
470
  it { should generate_template('{c}') }
@@ -551,7 +553,7 @@ describe Mustermann::Grape do
551
553
  it { should_not match('/foo1') }
552
554
  end
553
555
 
554
- pattern '/:file(.:ext)?', capture: { ext: ['jpg', 'png'] } do
556
+ pattern '/:file(.:ext)?', capture: { ext: %w[jpg png] } do
555
557
  it { should match('/pony') .capturing file: 'pony', ext: nil }
556
558
  it { should match('/pony.jpg') .capturing file: 'pony', ext: 'jpg' }
557
559
  it { should match('/pony%2Ejpg') .capturing file: 'pony', ext: 'jpg' }
@@ -570,7 +572,7 @@ describe Mustermann::Grape do
570
572
  it { should match('/pony') .capturing file: 'pony', ext: nil }
571
573
  it { should match('/pony.jpg') .capturing file: 'pony', ext: '.jpg' }
572
574
  it { should match('/pony.png') .capturing file: 'pony', ext: '.png' }
573
- it { should match('/pony.tar.gz') .capturing file: 'pony', ext: '.tar.gz' }
575
+ it { should match('/pony.tar.gz') .capturing file: 'pony', ext: '.tar.gz' }
574
576
  it { should_not match('/pony.png.jpg') }
575
577
  it { should_not match('/pony.jpg.png') }
576
578
  it { should_not match('/pony.gif') }
@@ -618,14 +620,14 @@ describe Mustermann::Grape do
618
620
  it { should_not match('/foo%2fbar') }
619
621
  end
620
622
 
621
- pattern "/path with spaces", uri_decode: false do
623
+ pattern '/path with spaces', uri_decode: false do
622
624
  it { should match('/path with spaces') }
623
625
  it { should_not match('/path%20with%20spaces') }
624
626
  it { should_not match('/path%2Bwith%2Bspaces') }
625
627
  it { should_not match('/path+with+spaces') }
626
628
  end
627
629
 
628
- pattern "/path with spaces", space_matches_plus: false do
630
+ pattern '/path with spaces', space_matches_plus: false do
629
631
  it { should match('/path%20with%20spaces') }
630
632
  it { should_not match('/path%2Bwith%2Bspaces') }
631
633
  it { should_not match('/path+with+spaces') }
@@ -633,81 +635,81 @@ describe Mustermann::Grape do
633
635
 
634
636
  context 'invalid syntax' do
635
637
  example 'unexpected closing parenthesis' do
636
- expect { Mustermann::Grape.new('foo)bar') }.
637
- to raise_error(Mustermann::ParseError, 'unexpected ) while parsing "foo)bar"')
638
+ expect { Mustermann::Grape.new('foo)bar') }
639
+ .to raise_error(Mustermann::ParseError, 'unexpected ) while parsing "foo)bar"')
638
640
  end
639
641
 
640
642
  example 'missing closing parenthesis' do
641
- expect { Mustermann::Grape.new('foo(bar') }.
642
- to raise_error(Mustermann::ParseError, 'unexpected end of string while parsing "foo(bar"')
643
+ expect { Mustermann::Grape.new('foo(bar') }
644
+ .to raise_error(Mustermann::ParseError, 'unexpected end of string while parsing "foo(bar"')
643
645
  end
644
646
 
645
647
  example 'missing unescaped closing parenthesis' do
646
- expect { Mustermann::Grape.new('foo(bar\)') }.
647
- to raise_error(Mustermann::ParseError, 'unexpected end of string while parsing "foo(bar\\\\)"')
648
+ expect { Mustermann::Grape.new('foo(bar\)') }
649
+ .to raise_error(Mustermann::ParseError, 'unexpected end of string while parsing "foo(bar\\\\)"')
648
650
  end
649
651
 
650
652
  example '? at beginning of route' do
651
- expect { Mustermann::Grape.new('?foobar') }.
652
- to raise_error(Mustermann::ParseError, 'unexpected ? while parsing "?foobar"')
653
+ expect { Mustermann::Grape.new('?foobar') }
654
+ .to raise_error(Mustermann::ParseError, 'unexpected ? while parsing "?foobar"')
653
655
  end
654
656
 
655
657
  example 'double ?' do
656
- expect { Mustermann::Grape.new('foo??bar') }.
657
- to raise_error(Mustermann::ParseError, 'unexpected ? while parsing "foo??bar"')
658
+ expect { Mustermann::Grape.new('foo??bar') }
659
+ .to raise_error(Mustermann::ParseError, 'unexpected ? while parsing "foo??bar"')
658
660
  end
659
661
 
660
662
  example 'dangling escape' do
661
- expect { Mustermann::Grape.new('foo\\') }.
662
- to raise_error(Mustermann::ParseError, 'unexpected end of string while parsing "foo\\\\"')
663
+ expect { Mustermann::Grape.new('foo\\') }
664
+ .to raise_error(Mustermann::ParseError, 'unexpected end of string while parsing "foo\\\\"')
663
665
  end
664
666
  end
665
667
 
666
668
  context 'invalid capture names' do
667
669
  example 'empty name' do
668
- expect { Mustermann::Grape.new('/:/') }.
669
- to raise_error(Mustermann::CompileError, "capture name can't be empty: \"/:/\"")
670
+ expect { Mustermann::Grape.new('/:/') }
671
+ .to raise_error(Mustermann::CompileError, "capture name can't be empty: \"/:/\"")
670
672
  end
671
673
 
672
674
  example 'named splat' do
673
- expect { Mustermann::Grape.new('/:splat/') }.
674
- to raise_error(Mustermann::CompileError, "capture name can't be splat: \"/:splat/\"")
675
+ expect { Mustermann::Grape.new('/:splat/') }
676
+ .to raise_error(Mustermann::CompileError, "capture name can't be splat: \"/:splat/\"")
675
677
  end
676
678
 
677
679
  example 'named captures' do
678
- expect { Mustermann::Grape.new('/:captures/') }.
679
- to raise_error(Mustermann::CompileError, "capture name can't be captures: \"/:captures/\"")
680
+ expect { Mustermann::Grape.new('/:captures/') }
681
+ .to raise_error(Mustermann::CompileError, "capture name can't be captures: \"/:captures/\"")
680
682
  end
681
683
 
682
684
  example 'with capital letter' do
683
- expect { Mustermann::Grape.new('/:Foo/') }.
684
- to raise_error(Mustermann::CompileError, "capture name must start with underscore or lower case letter: \"/:Foo/\"")
685
+ expect { Mustermann::Grape.new('/:Foo/') }
686
+ .to raise_error(Mustermann::CompileError, 'capture name must start with underscore or lower case letter: "/:Foo/"')
685
687
  end
686
688
 
687
689
  example 'with integer' do
688
- expect { Mustermann::Grape.new('/:1a/') }.
689
- to raise_error(Mustermann::CompileError, "capture name must start with underscore or lower case letter: \"/:1a/\"")
690
+ expect { Mustermann::Grape.new('/:1a/') }
691
+ .to raise_error(Mustermann::CompileError, 'capture name must start with underscore or lower case letter: "/:1a/"')
690
692
  end
691
693
 
692
694
  example 'same name twice' do
693
- expect { Mustermann::Grape.new('/:foo(/:bar)?/:bar?') }.
694
- to raise_error(Mustermann::CompileError, "can't use the same capture name twice: \"/:foo(/:bar)?/:bar?\"")
695
+ expect { Mustermann::Grape.new('/:foo(/:bar)?/:bar?') }
696
+ .to raise_error(Mustermann::CompileError, "can't use the same capture name twice: \"/:foo(/:bar)?/:bar?\"")
695
697
  end
696
698
  end
697
699
 
698
700
  context 'Regexp compatibility' do
699
701
  describe :=== do
700
- example('non-matching') { Mustermann::Grape.new("/") .should_not be === '/foo' }
701
- example('matching') { Mustermann::Grape.new("/:foo") .should be === '/foo' }
702
+ example('non-matching') { Mustermann::Grape.new('/') .should_not be === '/foo' }
703
+ example('matching') { Mustermann::Grape.new('/:foo') .should be === '/foo' }
702
704
  end
703
705
 
704
706
  describe :=~ do
705
- example('non-matching') { Mustermann::Grape.new("/") .should_not be =~ '/foo' }
706
- example('matching') { Mustermann::Grape.new("/:foo") .should be =~ '/foo' }
707
+ example('non-matching') { Mustermann::Grape.new('/') .should_not be =~ '/foo' }
708
+ example('matching') { Mustermann::Grape.new('/:foo') .should be =~ '/foo' }
707
709
 
708
710
  context 'String#=~' do
709
- example('non-matching') { "/foo".should_not be =~ Mustermann::Grape.new("/") }
710
- example('matching') { "/foo".should be =~ Mustermann::Grape.new("/:foo") }
711
+ example('non-matching') { '/foo'.should_not be =~ Mustermann::Grape.new('/') }
712
+ example('matching') { '/foo'.should be =~ Mustermann::Grape.new('/:foo') }
711
713
  end
712
714
  end
713
715
 
@@ -722,31 +724,31 @@ describe Mustermann::Grape do
722
724
 
723
725
  context 'Proc compatibility' do
724
726
  describe :to_proc do
725
- example { Mustermann::Grape.new("/").to_proc.should be_a(Proc) }
726
- example('non-matching') { Mustermann::Grape.new("/") .to_proc.call('/foo').should be == false }
727
- example('matching') { Mustermann::Grape.new("/:foo") .to_proc.call('/foo').should be == true }
727
+ example { Mustermann::Grape.new('/').to_proc.should be_a(Proc) }
728
+ example('non-matching') { Mustermann::Grape.new('/') .to_proc.call('/foo').should be == false }
729
+ example('matching') { Mustermann::Grape.new('/:foo') .to_proc.call('/foo').should be == true }
728
730
  end
729
731
  end
730
732
 
731
- context "peeking" do
732
- subject(:pattern) { Mustermann::Grape.new(":name") }
733
+ context 'peeking' do
734
+ subject(:pattern) { Mustermann::Grape.new(':name') }
733
735
 
734
736
  describe :peek_size do
735
- example { pattern.peek_size("foo bar/blah") .should be == "foo bar".size }
736
- example { pattern.peek_size("foo%20bar/blah") .should be == "foo%20bar".size }
737
- example { pattern.peek_size("/foo bar") .should be_nil }
737
+ example { pattern.peek_size('foo bar/blah') .should be == 'foo bar'.size }
738
+ example { pattern.peek_size('foo%20bar/blah') .should be == 'foo%20bar'.size }
739
+ example { pattern.peek_size('/foo bar') .should be_nil }
738
740
  end
739
741
 
740
742
  describe :peek_match do
741
- example { pattern.peek_match("foo bar/blah") .to_s .should be == "foo bar" }
742
- example { pattern.peek_match("foo%20bar/blah") .to_s .should be == "foo%20bar" }
743
- example { pattern.peek_match("/foo bar") .should be_nil }
743
+ example { pattern.peek_match('foo bar/blah') .to_s .should be == 'foo bar' }
744
+ example { pattern.peek_match('foo%20bar/blah') .to_s .should be == 'foo%20bar' }
745
+ example { pattern.peek_match('/foo bar') .should be_nil }
744
746
  end
745
747
 
746
748
  describe :peek_params do
747
- example { pattern.peek_params("foo bar/blah") .should be == [{"name" => "foo bar"}, "foo bar".size] }
748
- example { pattern.peek_params("foo%20bar/blah") .should be == [{"name" => "foo bar"}, "foo%20bar".size] }
749
- example { pattern.peek_params("/foo bar") .should be_nil }
749
+ example { pattern.peek_params('foo bar/blah') .should be == [{ 'name' => 'foo bar' }, 'foo bar'.size] }
750
+ example { pattern.peek_params('foo%20bar/blah') .should be == [{ 'name' => 'foo bar' }, 'foo%20bar'.size] }
751
+ example { pattern.peek_params('/foo bar') .should be_nil }
750
752
  end
751
753
  end
752
754
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
4
+
5
+ require 'mustermann/grape'
metadata CHANGED
@@ -1,49 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mustermann-grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - namusyaka
8
8
  - Konstantin Haase
9
- autorequire:
9
+ - Daniel Doubrovkine
10
+ autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2017-02-01 00:00:00.000000000 Z
13
+ date: 2022-05-03 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: mustermann
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
18
- - - '='
19
+ - - ">="
19
20
  - !ruby/object:Gem::Version
20
- version: 1.0.0.beta2
21
+ version: 1.0.0
21
22
  type: :runtime
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
- - - '='
26
+ - - ">="
26
27
  - !ruby/object:Gem::Version
27
- version: 1.0.0.beta2
28
+ version: 1.0.0
28
29
  description: Adds Grape style patterns to Mustermman
29
30
  email: namusyaka@gmail.com
30
31
  executables: []
31
32
  extensions: []
32
33
  extra_rdoc_files: []
33
34
  files:
35
+ - ".github/workflows/tests.yml"
36
+ - ".gitignore"
34
37
  - Gemfile
35
- - Gemfile.lock
38
+ - LICENSE
36
39
  - README.md
37
40
  - Rakefile
38
41
  - lib/mustermann/grape.rb
39
42
  - lib/mustermann/grape/version.rb
40
43
  - mustermann-grape.gemspec
41
44
  - spec/grape_spec.rb
45
+ - spec/spec_helper.rb
42
46
  homepage: https://github.com/ruby-grape/mustermann-grape
43
47
  licenses:
44
48
  - MIT
45
49
  metadata: {}
46
- post_install_message:
50
+ post_install_message:
47
51
  rdoc_options: []
48
52
  require_paths:
49
53
  - lib
@@ -54,14 +58,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
58
  version: 2.1.0
55
59
  required_rubygems_version: !ruby/object:Gem::Requirement
56
60
  requirements:
57
- - - ">"
61
+ - - ">="
58
62
  - !ruby/object:Gem::Version
59
- version: 1.3.1
63
+ version: '0'
60
64
  requirements: []
61
- rubyforge_project:
62
- rubygems_version: 2.5.1
63
- signing_key:
65
+ rubygems_version: 3.1.3
66
+ signing_key:
64
67
  specification_version: 4
65
68
  summary: Grape syntax for Mustermann
66
69
  test_files:
67
70
  - spec/grape_spec.rb
71
+ - spec/spec_helper.rb
data/Gemfile.lock DELETED
@@ -1,88 +0,0 @@
1
- GIT
2
- remote: git@github.com:sinatra/mustermann.git
3
- revision: 4e7221d7fbcbc897e05fa088909caface9e7280e
4
- specs:
5
- support (0.0.1)
6
- addressable
7
- coveralls
8
- rack-test
9
- rake
10
- redcarpet
11
- rspec
12
- rspec-its
13
- simplecov
14
- sinatra (~> 1.4)
15
- tool (~> 0.2)
16
- yard
17
-
18
- PATH
19
- remote: .
20
- specs:
21
- mustermann-grape (1.0.0.beta2)
22
- mustermann (= 1.0.0.beta2)
23
-
24
- GEM
25
- remote: https://rubygems.org/
26
- specs:
27
- addressable (2.5.0)
28
- public_suffix (~> 2.0, >= 2.0.2)
29
- coveralls (0.8.15)
30
- json (>= 1.8, < 3)
31
- simplecov (~> 0.12.0)
32
- term-ansicolor (~> 1.3)
33
- thor (~> 0.19.1)
34
- tins (>= 1.6.0, < 2)
35
- diff-lcs (1.2.5)
36
- docile (1.1.5)
37
- json (2.0.2)
38
- mustermann (1.0.0.beta2)
39
- public_suffix (2.0.3)
40
- rack (1.6.4)
41
- rack-protection (1.5.3)
42
- rack
43
- rack-test (0.6.3)
44
- rack (>= 1.0)
45
- rake (11.3.0)
46
- redcarpet (3.3.4)
47
- rspec (3.5.0)
48
- rspec-core (~> 3.5.0)
49
- rspec-expectations (~> 3.5.0)
50
- rspec-mocks (~> 3.5.0)
51
- rspec-core (3.5.4)
52
- rspec-support (~> 3.5.0)
53
- rspec-expectations (3.5.0)
54
- diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.5.0)
56
- rspec-its (1.2.0)
57
- rspec-core (>= 3.0.0)
58
- rspec-expectations (>= 3.0.0)
59
- rspec-mocks (3.5.0)
60
- diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.5.0)
62
- rspec-support (3.5.0)
63
- simplecov (0.12.0)
64
- docile (~> 1.1.0)
65
- json (>= 1.8, < 3)
66
- simplecov-html (~> 0.10.0)
67
- simplecov-html (0.10.0)
68
- sinatra (1.4.7)
69
- rack (~> 1.5)
70
- rack-protection (~> 1.4)
71
- tilt (>= 1.3, < 3)
72
- term-ansicolor (1.4.0)
73
- tins (~> 1.0)
74
- thor (0.19.1)
75
- tilt (2.0.5)
76
- tins (1.12.0)
77
- tool (0.2.3)
78
- yard (0.9.5)
79
-
80
- PLATFORMS
81
- ruby
82
-
83
- DEPENDENCIES
84
- mustermann-grape!
85
- support!
86
-
87
- BUNDLED WITH
88
- 1.12.5