mustermann-grape 1.0.0 → 1.0.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
- SHA1:
3
- metadata.gz: 1fce8b4d0f2db37faa5e51a263f1eceed77de4a9
4
- data.tar.gz: 2103833f2437678cbd24b299096561b131b977fb
2
+ SHA256:
3
+ metadata.gz: 55697b38c24285593dccd82d84d78475a68e9f85c097215dd34361755a532c0d
4
+ data.tar.gz: 10c154f103a904e122a996423225981f3f00e3ec831737b7c34ef9db85ed8d23
5
5
  SHA512:
6
- metadata.gz: 35157330709f5da67f28e40bfcbe2e0bb2d29fa20fbb893e306a377c57140c0f9880efb8002f8b60f534d00ffa88b8d6a23205cc84508810f4165fbbd34e7606
7
- data.tar.gz: 9405df771d0d3074d58d25b474f099e252909025b3c27685808f196443b98c6f35ca70a62d204158a72f7c720be855a84e58b8fe33be106861db3b8fad16fadf
6
+ metadata.gz: f62d87d318ea717f8da907fd77be82b80ec4332c8912f4a6b28ac771b9c83fe35a2f70503c99c224a5e661d6e5ca8d5bd3b8b2d5ce2d74e028bafef220089d81
7
+ data.tar.gz: 72de2d4f7012efa3f5054065d1585f5aca004c60f7567353959bb0d380f8f4f2fb11a25f02155eb6cec247d10bc9253e9050aba66602af76d1d8df0c1d2c02cb
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.5
5
+ - 2.6
6
+ - 2.7
7
+
8
+ cache: bundler
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'
@@ -1,7 +1,9 @@
1
1
  GIT
2
- remote: git@github.com:sinatra/mustermann.git
3
- revision: 4e7221d7fbcbc897e05fa088909caface9e7280e
2
+ remote: https://github.com/sinatra/mustermann.git
3
+ revision: db86e25f786c717dbe937d862a5ba0d35a58797b
4
4
  specs:
5
+ mustermann (1.1.0)
6
+ ruby2_keywords (~> 0.0.1)
5
7
  support (0.0.1)
6
8
  addressable
7
9
  coveralls
@@ -18,71 +20,79 @@ GIT
18
20
  PATH
19
21
  remote: .
20
22
  specs:
21
- mustermann-grape (1.0.0)
22
- mustermann (~> 1.0.0)
23
+ mustermann-grape (1.0.1)
24
+ mustermann (>= 1.0.0)
23
25
 
24
26
  GEM
25
27
  remote: https://rubygems.org/
26
28
  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)
39
- public_suffix (2.0.3)
40
- rack (1.6.4)
41
- rack-protection (1.5.3)
29
+ addressable (2.7.0)
30
+ public_suffix (>= 2.0.2, < 5.0)
31
+ coveralls (0.7.2)
32
+ multi_json (~> 1.3)
33
+ rest-client (= 1.6.7)
34
+ simplecov (>= 0.7)
35
+ term-ansicolor (= 1.2.2)
36
+ thor (= 0.18.1)
37
+ diff-lcs (1.3)
38
+ docile (1.3.2)
39
+ json (2.3.0)
40
+ mime-types (3.3.1)
41
+ mime-types-data (~> 3.2015)
42
+ mime-types-data (3.2019.1009)
43
+ multi_json (1.14.1)
44
+ public_suffix (4.0.2)
45
+ rack (1.6.12)
46
+ rack-protection (1.5.5)
42
47
  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)
48
+ rack-test (1.1.0)
49
+ rack (>= 1.0, < 3)
50
+ rake (13.0.1)
51
+ redcarpet (3.5.0)
52
+ rest-client (1.6.7)
53
+ mime-types (>= 1.16)
54
+ rspec (3.9.0)
55
+ rspec-core (~> 3.9.0)
56
+ rspec-expectations (~> 3.9.0)
57
+ rspec-mocks (~> 3.9.0)
58
+ rspec-core (3.9.1)
59
+ rspec-support (~> 3.9.1)
60
+ rspec-expectations (3.9.0)
54
61
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.5.0)
56
- rspec-its (1.2.0)
62
+ rspec-support (~> 3.9.0)
63
+ rspec-its (1.3.0)
57
64
  rspec-core (>= 3.0.0)
58
65
  rspec-expectations (>= 3.0.0)
59
- rspec-mocks (3.5.0)
66
+ rspec-mocks (3.9.0)
60
67
  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)
68
+ rspec-support (~> 3.9.0)
69
+ rspec-support (3.9.2)
70
+ ruby2_keywords (0.0.1)
71
+ simplecov (0.17.1)
72
+ docile (~> 1.1)
65
73
  json (>= 1.8, < 3)
66
74
  simplecov-html (~> 0.10.0)
67
- simplecov-html (0.10.0)
68
- sinatra (1.4.7)
75
+ simplecov-html (0.10.2)
76
+ sinatra (1.4.8)
69
77
  rack (~> 1.5)
70
78
  rack-protection (~> 1.4)
71
79
  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)
80
+ term-ansicolor (1.2.2)
81
+ tins (~> 0.8)
82
+ thor (0.18.1)
83
+ tilt (2.0.10)
84
+ tins (0.13.2)
77
85
  tool (0.2.3)
78
- yard (0.9.5)
86
+ yard (0.9.20)
79
87
 
80
88
  PLATFORMS
81
89
  ruby
82
90
 
83
91
  DEPENDENCIES
84
92
  mustermann-grape!
93
+ rake
94
+ rspec-core
85
95
  support!
86
96
 
87
97
  BUNDLED WITH
88
- 1.14.3
98
+ 2.1.2
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This gem implements the `grape` pattern type for Mustermann.
4
4
 
5
+ [![Build Status](https://travis-ci.org/ruby-grape/mustermann-grape.svg?branch=master)](https://travis-ci.org/ruby-grape/mustermann-grape)
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,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,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'
6
- end
3
+ module MustermannGrape
4
+ VERSION = '1.0.1'
7
5
  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'
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
@@ -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,28 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mustermann-grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - namusyaka
8
8
  - Konstantin Haase
9
+ - Daniel Doubrovkine
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2017-03-04 00:00:00.000000000 Z
13
+ date: 2020-01-09 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
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
28
  version: 1.0.0
28
29
  description: Adds Grape style patterns to Mustermman
@@ -31,6 +32,7 @@ executables: []
31
32
  extensions: []
32
33
  extra_rdoc_files: []
33
34
  files:
35
+ - ".travis.yml"
34
36
  - Gemfile
35
37
  - Gemfile.lock
36
38
  - README.md
@@ -39,6 +41,7 @@ files:
39
41
  - lib/mustermann/grape/version.rb
40
42
  - mustermann-grape.gemspec
41
43
  - spec/grape_spec.rb
44
+ - spec/spec_helper.rb
42
45
  homepage: https://github.com/ruby-grape/mustermann-grape
43
46
  licenses:
44
47
  - MIT
@@ -58,10 +61,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
61
  - !ruby/object:Gem::Version
59
62
  version: '0'
60
63
  requirements: []
61
- rubyforge_project:
62
- rubygems_version: 2.6.8
64
+ rubygems_version: 3.0.4
63
65
  signing_key:
64
66
  specification_version: 4
65
67
  summary: Grape syntax for Mustermann
66
68
  test_files:
67
69
  - spec/grape_spec.rb
70
+ - spec/spec_helper.rb