mustermann-contrib 3.0.4 → 3.1.1
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 +4 -4
- data/README.md +0 -117
- data/lib/mustermann/visualizer/pattern_extension.rb +0 -14
- metadata +5 -26
- data/examples/highlighting.rb +0 -35
- data/highlighting.png +0 -0
- data/irb.png +0 -0
- data/lib/mustermann/rails.rb +0 -47
- data/lib/mustermann/versions.rb +0 -47
- data/mustermann-contrib.gemspec +0 -18
- data/spec/cake_spec.rb +0 -91
- data/spec/express_spec.rb +0 -210
- data/spec/file_utils_spec.rb +0 -120
- data/spec/flask_spec.rb +0 -362
- data/spec/flask_subclass_spec.rb +0 -369
- data/spec/pattern_extension_spec.rb +0 -52
- data/spec/pyramid_spec.rb +0 -102
- data/spec/rails_spec.rb +0 -648
- data/spec/shell_spec.rb +0 -148
- data/spec/simple_spec.rb +0 -269
- data/spec/string_scanner_spec.rb +0 -272
- data/spec/template_spec.rb +0 -842
- data/spec/visualizer_spec.rb +0 -199
- data/theme.png +0 -0
- data/tree.png +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4eef1534d55e9ec6be2c9bc3170114a40c2f0114b05102d4c0c4503daf97724a
|
|
4
|
+
data.tar.gz: 4d4b0f26fb7834945887ef7c9ce16292ca2090a9585cad9579d03f4fbe2769d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2cef5fe3354e2cf9c81a558138fb3ed563b6bc5fa3ec292c87dc8986e1ff55b970d1035824c3f8eb1ae322fde9a812051d3f49773dc8c2a49cda379700e3b09
|
|
7
|
+
data.tar.gz: f028d0897f58ec0cf68206c01d22a271fb8a03ce49ec431b5c51957a9777c6284d2d5943ae1c934059c3a84a5e529d213aeca97637d9efad48d7e0820166aab9
|
data/README.md
CHANGED
|
@@ -534,7 +534,6 @@ pattern.to_templates # => ['/{name}']
|
|
|
534
534
|
|
|
535
535
|
## Syntax
|
|
536
536
|
|
|
537
|
-
|
|
538
537
|
<table>
|
|
539
538
|
<thead>
|
|
540
539
|
<tr>
|
|
@@ -576,112 +575,6 @@ pattern.to_templates # => ['/{name}']
|
|
|
576
575
|
</tbody>
|
|
577
576
|
</table>
|
|
578
577
|
|
|
579
|
-
<a name="-mustermann-rails"></a>
|
|
580
|
-
# Rails Syntax for Mustermann
|
|
581
|
-
|
|
582
|
-
This gem implements the `rails` pattern type for Mustermann. It is compatible with [Ruby on Rails](http://rubyonrails.org/), [Journey](https://github.com/rails/journey), the [http_router gem](https://github.com/joshbuddy/http_router), [Lotus](http://lotusrb.org/) and [Scalatra](http://scalatra.org/) (if [configured](http://scalatra.org/2.3/guides/http/routes.html#toc_248))</td>
|
|
583
|
-
|
|
584
|
-
## Overview
|
|
585
|
-
|
|
586
|
-
**Supported options:**
|
|
587
|
-
`capture`, `except`, `greedy`, `space_matches_plus`, `uri_decode`, `version`, and `ignore_unknown_options`.
|
|
588
|
-
|
|
589
|
-
**External documentation:**
|
|
590
|
-
[Ruby on Rails Guides: Routing](http://guides.rubyonrails.org/routing.html).
|
|
591
|
-
|
|
592
|
-
``` ruby
|
|
593
|
-
require 'mustermann'
|
|
594
|
-
|
|
595
|
-
pattern = Mustermann.new('/:example', type: :rails)
|
|
596
|
-
pattern === "/foo.bar" # => true
|
|
597
|
-
pattern === "/foo/bar" # => false
|
|
598
|
-
pattern.params("/foo.bar") # => { "example" => "foo.bar" }
|
|
599
|
-
pattern.params("/foo/bar") # => nil
|
|
600
|
-
|
|
601
|
-
pattern = Mustermann.new('/:example(/:optional)', type: :rails)
|
|
602
|
-
pattern === "/foo.bar" # => true
|
|
603
|
-
pattern === "/foo/bar" # => true
|
|
604
|
-
pattern.params("/foo.bar") # => { "example" => "foo.bar", "optional" => nil }
|
|
605
|
-
pattern.params("/foo/bar") # => { "example" => "foo", "optional" => "bar" }
|
|
606
|
-
|
|
607
|
-
pattern = Mustermann.new('/*example', type: :rails)
|
|
608
|
-
pattern === "/foo.bar" # => true
|
|
609
|
-
pattern === "/foo/bar" # => true
|
|
610
|
-
pattern.params("/foo.bar") # => { "example" => "foo.bar" }
|
|
611
|
-
pattern.params("/foo/bar") # => { "example" => "foo/bar" }
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
## Rails Compatibility
|
|
615
|
-
|
|
616
|
-
Rails syntax changed over time. You can target different Ruby on Rails versions by setting the `version` option to the desired Rails version.
|
|
617
|
-
|
|
618
|
-
The default is `4.2`. Versions prior to `2.3` are not supported.
|
|
619
|
-
|
|
620
|
-
``` ruby
|
|
621
|
-
require 'mustermann'
|
|
622
|
-
Mustermann.new('/', type: :rails, version: "2.3")
|
|
623
|
-
Mustermann.new('/', type: :rails, version: "3.0.0")
|
|
624
|
-
|
|
625
|
-
require 'rails'
|
|
626
|
-
Mustermann.new('/', type: :rails, version: Rails::VERSION::STRING)
|
|
627
|
-
```
|
|
628
|
-
|
|
629
|
-
## Syntax
|
|
630
|
-
|
|
631
|
-
<table>
|
|
632
|
-
<thead>
|
|
633
|
-
<tr>
|
|
634
|
-
<th>Syntax Element</th>
|
|
635
|
-
<th>Description</th>
|
|
636
|
-
</tr>
|
|
637
|
-
</thead>
|
|
638
|
-
<tbody>
|
|
639
|
-
<tr>
|
|
640
|
-
<td><b>:</b><i>name</i></td>
|
|
641
|
-
<td>
|
|
642
|
-
Captures anything but a forward slash in a semi-greedy fashion. Capture is named <i>name</i>.
|
|
643
|
-
Capture behavior can be modified with tt>capture</tt> and <tt>greedy</tt> option.
|
|
644
|
-
</td>
|
|
645
|
-
</tr>
|
|
646
|
-
<tr>
|
|
647
|
-
<td><b>*</b><i>name</i></td>
|
|
648
|
-
<td>
|
|
649
|
-
Captures anything in a non-greedy fashion. Capture is named <i>name</i>.
|
|
650
|
-
</td>
|
|
651
|
-
</tr>
|
|
652
|
-
<tr>
|
|
653
|
-
<td><b>(</b><i>expression</i><b>)</b></td>
|
|
654
|
-
<td>Enclosed <i>expression</i> is optional. Not available in 2.3 compatibility mode.</td>
|
|
655
|
-
</tr>
|
|
656
|
-
<tr>
|
|
657
|
-
<td><b>/</b></td>
|
|
658
|
-
<td>
|
|
659
|
-
Matches forward slash. Does not match URI encoded version of forward slash.
|
|
660
|
-
</td>
|
|
661
|
-
</tr>
|
|
662
|
-
<tr>
|
|
663
|
-
<td><b>\</b><i>x</i></td>
|
|
664
|
-
<td>
|
|
665
|
-
In 3.x compatibility mode and starting with 4.2:
|
|
666
|
-
Matches <i>x</i> or URI encoded version of <i>x</i>. For instance <tt>\*</tt> matches <tt>*</tt>.<br>
|
|
667
|
-
In 4.0 or 4.1 compatibility mode:
|
|
668
|
-
<b>\</b> is ignored, <i>x</i> is parsed normally.<br>
|
|
669
|
-
</td>
|
|
670
|
-
</tr>
|
|
671
|
-
<tr>
|
|
672
|
-
<td><i>expression</i> <b>|</b> <i>expression</i></td>
|
|
673
|
-
<td>
|
|
674
|
-
3.2+ mode: This will raise a `Mustermann::ParseError`. While Ruby on Rails happily parses this character, it will result in broken routes due to a buggy implementation.<br>
|
|
675
|
-
5.0 mode: It will match if any of the nested expressions matches.
|
|
676
|
-
</td>
|
|
677
|
-
</tr>
|
|
678
|
-
<tr>
|
|
679
|
-
<td><i>any other character</i></td>
|
|
680
|
-
<td>Matches exactly that character or a URI encoded version of it.</td>
|
|
681
|
-
</tr>
|
|
682
|
-
</tbody>
|
|
683
|
-
</table>
|
|
684
|
-
|
|
685
578
|
<a name="-mustermann-shell"></a>
|
|
686
579
|
# Shell Syntax for Mustermann
|
|
687
580
|
|
|
@@ -1127,15 +1020,6 @@ The **s-expression like syntax** looks as follows:
|
|
|
1127
1020
|
* Full strings are Ruby strings enclosed by double quotes.
|
|
1128
1021
|
* Spaces before or after parens are optional.
|
|
1129
1022
|
|
|
1130
|
-
### IRB/Pry integration
|
|
1131
|
-
|
|
1132
|
-
When `mustermann` is being loaded from within an IRB or Pry session, it will automatically load `mustermann/visualizer` too, if possible.
|
|
1133
|
-
When displayed as result, it will be highlighted.
|
|
1134
|
-
|
|
1135
|
-

|
|
1136
|
-
|
|
1137
|
-
In Pry, this will even work when nested inside other objects (like as element on an array).
|
|
1138
|
-
|
|
1139
1023
|
## Tree Rendering
|
|
1140
1024
|
|
|
1141
1025
|

|
|
@@ -1152,4 +1036,3 @@ For patterns not based on an AST (shell, simple, regexp), it will print out a si
|
|
|
1152
1036
|
pattern (not AST based) "/example"
|
|
1153
1037
|
|
|
1154
1038
|
It will display a tree for identity patterns. While these are not based on an AST internally, Mustermann supports generating an AST for these patterns.
|
|
1155
|
-
|
|
@@ -44,26 +44,12 @@ module Mustermann
|
|
|
44
44
|
caller_locations.first.label == 'puts' ? to_ansi : super
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
# If invoked directly by IRB, same as {#color_inspect}, otherwise same as {Mustermann::Pattern#inspect}.
|
|
48
|
-
def inspect
|
|
49
|
-
caller_locations.first.base_label == '<module:IRB>' ? color_inspect : super
|
|
50
|
-
end
|
|
51
|
-
|
|
52
47
|
# @return [String] ANSI colorized version of {Mustermann::Pattern#inspect}
|
|
53
48
|
def color_inspect(base_color = nil, **theme)
|
|
54
49
|
base_color ||= Highlight::DEFAULT_THEME[:base01]
|
|
55
50
|
template = is_a?(Composite) ? "*#<%p:(*%s*)>*" : "*#<%p:*%s*>*"
|
|
56
51
|
Hansi.render(template, self.class, to_ansi(inspect: true, **theme), {"*" => base_color})
|
|
57
52
|
end
|
|
58
|
-
|
|
59
|
-
# If invoked directly by IRB, same as {#color_inspect}, otherwise same as Object#pretty_print.
|
|
60
|
-
def pretty_print(q)
|
|
61
|
-
if q.class.name.to_s[/[^:]+$/] == "ColorPrinter"
|
|
62
|
-
q.text(color_inspect, inspect.length)
|
|
63
|
-
else
|
|
64
|
-
super
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
53
|
end
|
|
68
54
|
end
|
|
69
55
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mustermann-contrib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Konstantin Haase
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - '='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 3.
|
|
19
|
+
version: 3.1.1
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - '='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 3.
|
|
26
|
+
version: 3.1.1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: hansi
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -46,9 +46,6 @@ extra_rdoc_files: []
|
|
|
46
46
|
files:
|
|
47
47
|
- LICENSE
|
|
48
48
|
- README.md
|
|
49
|
-
- examples/highlighting.rb
|
|
50
|
-
- highlighting.png
|
|
51
|
-
- irb.png
|
|
52
49
|
- lib/mustermann/cake.rb
|
|
53
50
|
- lib/mustermann/express.rb
|
|
54
51
|
- lib/mustermann/file_utils.rb
|
|
@@ -56,14 +53,12 @@ files:
|
|
|
56
53
|
- lib/mustermann/fileutils.rb
|
|
57
54
|
- lib/mustermann/flask.rb
|
|
58
55
|
- lib/mustermann/pyramid.rb
|
|
59
|
-
- lib/mustermann/rails.rb
|
|
60
56
|
- lib/mustermann/shell.rb
|
|
61
57
|
- lib/mustermann/simple.rb
|
|
62
58
|
- lib/mustermann/string_scanner.rb
|
|
63
59
|
- lib/mustermann/strscan.rb
|
|
64
60
|
- lib/mustermann/template.rb
|
|
65
61
|
- lib/mustermann/uri_template.rb
|
|
66
|
-
- lib/mustermann/versions.rb
|
|
67
62
|
- lib/mustermann/visualizer.rb
|
|
68
63
|
- lib/mustermann/visualizer/highlight.rb
|
|
69
64
|
- lib/mustermann/visualizer/highlighter.rb
|
|
@@ -80,22 +75,6 @@ files:
|
|
|
80
75
|
- lib/mustermann/visualizer/renderer/sexp.rb
|
|
81
76
|
- lib/mustermann/visualizer/tree.rb
|
|
82
77
|
- lib/mustermann/visualizer/tree_renderer.rb
|
|
83
|
-
- mustermann-contrib.gemspec
|
|
84
|
-
- spec/cake_spec.rb
|
|
85
|
-
- spec/express_spec.rb
|
|
86
|
-
- spec/file_utils_spec.rb
|
|
87
|
-
- spec/flask_spec.rb
|
|
88
|
-
- spec/flask_subclass_spec.rb
|
|
89
|
-
- spec/pattern_extension_spec.rb
|
|
90
|
-
- spec/pyramid_spec.rb
|
|
91
|
-
- spec/rails_spec.rb
|
|
92
|
-
- spec/shell_spec.rb
|
|
93
|
-
- spec/simple_spec.rb
|
|
94
|
-
- spec/string_scanner_spec.rb
|
|
95
|
-
- spec/template_spec.rb
|
|
96
|
-
- spec/visualizer_spec.rb
|
|
97
|
-
- theme.png
|
|
98
|
-
- tree.png
|
|
99
78
|
homepage: https://github.com/sinatra/mustermann
|
|
100
79
|
licenses:
|
|
101
80
|
- MIT
|
|
@@ -107,14 +86,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
107
86
|
requirements:
|
|
108
87
|
- - ">="
|
|
109
88
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 2.
|
|
89
|
+
version: 2.7.0
|
|
111
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
91
|
requirements:
|
|
113
92
|
- - ">="
|
|
114
93
|
- !ruby/object:Gem::Version
|
|
115
94
|
version: '0'
|
|
116
95
|
requirements: []
|
|
117
|
-
rubygems_version:
|
|
96
|
+
rubygems_version: 4.0.6
|
|
118
97
|
specification_version: 4
|
|
119
98
|
summary: Collection of extensions for Mustermann
|
|
120
99
|
test_files: []
|
data/examples/highlighting.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'bundler/setup'
|
|
2
|
-
require 'mustermann/visualizer'
|
|
3
|
-
|
|
4
|
-
Hansi.mode = ARGV[0].to_i if ARGV.any?
|
|
5
|
-
|
|
6
|
-
def self.example(type, *patterns)
|
|
7
|
-
print Hansi.render(:bold, " #{type}: ".ljust(14))
|
|
8
|
-
patterns.each do |pattern|
|
|
9
|
-
pattern = Mustermann.new(pattern, type: type)
|
|
10
|
-
space_after = pattern.to_s.size > 24 ? " " : " " * (25 - pattern.to_s.size)
|
|
11
|
-
highlight = Mustermann::Visualizer.highlight(pattern, inspect: true)
|
|
12
|
-
print highlight.to_ansi + space_after
|
|
13
|
-
end
|
|
14
|
-
puts
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
puts
|
|
18
|
-
example(:cake, '/:prefix/**')
|
|
19
|
-
example(:express, '/:prefix+/:id(\d+)', '/:page/:slug+')
|
|
20
|
-
example(:flask, '/<prefix>/<int:id>', '/user/<int(min=0):id>')
|
|
21
|
-
example(:identity, '/image.png')
|
|
22
|
-
example(:pyramid, '/{prefix:.*}/{id}', '/{page}/*slug')
|
|
23
|
-
example(:rails, '/:slug(.:ext)')
|
|
24
|
-
example(:regexp, '/(?<slug>[^/]+)', '/(?:page|user)/(\d+)')
|
|
25
|
-
example(:shell, '/**/*', '/\{a,b\}/{a,b}')
|
|
26
|
-
example(:simple, '/:page/*slug')
|
|
27
|
-
example(:sinatra, '/:page/*slug', '/users/{id}?')
|
|
28
|
-
example(:template, '/{+pre}/{page}{?q,p}', '/users/{id}?')
|
|
29
|
-
puts
|
|
30
|
-
|
|
31
|
-
example(:composition)
|
|
32
|
-
composite = Mustermann.new("/{a}", "/{b}/{c}")
|
|
33
|
-
puts " " + composite.to_ansi
|
|
34
|
-
puts " " + (Mustermann.new("/") ^ composite).to_ansi
|
|
35
|
-
puts
|
data/highlighting.png
DELETED
|
Binary file
|
data/irb.png
DELETED
|
Binary file
|
data/lib/mustermann/rails.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require 'mustermann'
|
|
3
|
-
require 'mustermann/ast/pattern'
|
|
4
|
-
require 'mustermann/versions'
|
|
5
|
-
|
|
6
|
-
module Mustermann
|
|
7
|
-
# Rails style pattern implementation.
|
|
8
|
-
#
|
|
9
|
-
# @example
|
|
10
|
-
# Mustermann.new('/:foo', type: :rails) === '/bar' # => true
|
|
11
|
-
#
|
|
12
|
-
# @see Mustermann::Pattern
|
|
13
|
-
# @see file:README.md#rails Syntax description in the README
|
|
14
|
-
class Rails < AST::Pattern
|
|
15
|
-
extend Versions
|
|
16
|
-
register :rails
|
|
17
|
-
|
|
18
|
-
# first parser, no optional parts
|
|
19
|
-
version('2.3') do
|
|
20
|
-
on(nil) { |c| unexpected(c) }
|
|
21
|
-
on(?*) { |c| node(:named_splat) { scan(/\w+/) } }
|
|
22
|
-
on(?:) { |c| node(:capture) { scan(/\w+/) } }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# rack-mount
|
|
26
|
-
version('3.0', '3.1') do
|
|
27
|
-
on(?)) { |c| unexpected(c) }
|
|
28
|
-
on(?() { |c| node(:optional, node(:group) { read unless scan(?)) }) }
|
|
29
|
-
on(?\\) { |c| node(:char, expect(/./)) }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# stand-alone journey
|
|
33
|
-
version('3.2') do
|
|
34
|
-
on(?|) { |c| raise ParseError, "the implementation of | is broken in ActionDispatch, cannot compile compatible pattern" }
|
|
35
|
-
on(?\\) { |c| node(:char, c) }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# embedded journey, broken (ignored) escapes
|
|
39
|
-
version('4.0', '4.1') { on(?\\) { |c| read } }
|
|
40
|
-
|
|
41
|
-
# escapes got fixed in 4.2
|
|
42
|
-
version('4.2') { on(?\\) { |c| node(:char, expect(/./)) } }
|
|
43
|
-
|
|
44
|
-
# Rails 5.0 fixes |
|
|
45
|
-
version('5.0') { on(?|) { |c| node(:or) }}
|
|
46
|
-
end
|
|
47
|
-
end
|
data/lib/mustermann/versions.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
module Mustermann
|
|
3
|
-
# Mixin that adds support for multiple versions of the same type.
|
|
4
|
-
# @see Mustermann::Rails
|
|
5
|
-
# @!visibility private
|
|
6
|
-
module Versions
|
|
7
|
-
# Checks if class has mulitple versions available and picks one that matches the version option.
|
|
8
|
-
# @!visibility private
|
|
9
|
-
def new(*args, version: nil, **options)
|
|
10
|
-
return super(*args, **options) unless versions.any?
|
|
11
|
-
self[version].new(*args, **options)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# @return [Hash] version to subclass mapping.
|
|
15
|
-
# @!visibility private
|
|
16
|
-
def versions
|
|
17
|
-
@versions ||= {}
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Defines a new version.
|
|
21
|
-
# @!visibility private
|
|
22
|
-
def version(*list, inherit_from: nil, &block)
|
|
23
|
-
superclass = self[inherit_from] || self
|
|
24
|
-
subclass = Class.new(superclass, &block)
|
|
25
|
-
list.each { |v| versions[v] = subclass }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Resolve a subclass for a given version string.
|
|
29
|
-
# @!visibility private
|
|
30
|
-
def [](version)
|
|
31
|
-
return versions.values.last unless version
|
|
32
|
-
detected = versions.detect { |v,_| version.start_with?(v) }
|
|
33
|
-
raise ArgumentError, 'unsupported version %p' % version unless detected
|
|
34
|
-
detected.last
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# @!visibility private
|
|
38
|
-
def name
|
|
39
|
-
super || superclass.name
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# @!visibility private
|
|
43
|
-
def inspect
|
|
44
|
-
name
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
data/mustermann-contrib.gemspec
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
$:.unshift File.expand_path("../../mustermann/lib", __FILE__)
|
|
2
|
-
require "mustermann/version"
|
|
3
|
-
|
|
4
|
-
Gem::Specification.new do |s|
|
|
5
|
-
s.name = "mustermann-contrib"
|
|
6
|
-
s.version = Mustermann::VERSION
|
|
7
|
-
s.authors = ["Konstantin Haase", "Zachary Scott"]
|
|
8
|
-
s.email = "sinatrarb@googlegroups.com"
|
|
9
|
-
s.homepage = "https://github.com/sinatra/mustermann"
|
|
10
|
-
s.summary = %q{Collection of extensions for Mustermann}
|
|
11
|
-
s.description = %q{Adds many plugins to Mustermann}
|
|
12
|
-
s.license = 'MIT'
|
|
13
|
-
s.required_ruby_version = '>= 2.6.0'
|
|
14
|
-
s.files = `git ls-files`.split("\n")
|
|
15
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
|
-
s.add_dependency 'mustermann', Mustermann::VERSION
|
|
17
|
-
s.add_dependency 'hansi', '~> 0.2.0'
|
|
18
|
-
end
|
data/spec/cake_spec.rb
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require 'support'
|
|
3
|
-
require 'mustermann/cake'
|
|
4
|
-
|
|
5
|
-
describe Mustermann::Cake do
|
|
6
|
-
extend Support::Pattern
|
|
7
|
-
|
|
8
|
-
pattern '' do
|
|
9
|
-
it { should match('') }
|
|
10
|
-
it { should_not match('/') }
|
|
11
|
-
|
|
12
|
-
it { should expand.to('') }
|
|
13
|
-
it { should_not expand(a: 1) }
|
|
14
|
-
|
|
15
|
-
it { should generate_template('') }
|
|
16
|
-
|
|
17
|
-
it { should respond_to(:expand) }
|
|
18
|
-
it { should respond_to(:to_templates) }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
pattern '/' do
|
|
22
|
-
it { should match('/') }
|
|
23
|
-
it { should_not match('/foo') }
|
|
24
|
-
|
|
25
|
-
it { should expand.to('/') }
|
|
26
|
-
it { should_not expand(a: 1) }
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
pattern '/foo' do
|
|
30
|
-
it { should match('/foo') }
|
|
31
|
-
it { should_not match('/bar') }
|
|
32
|
-
it { should_not match('/foo.bar') }
|
|
33
|
-
|
|
34
|
-
it { should expand.to('/foo') }
|
|
35
|
-
it { should_not expand(a: 1) }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
pattern '/foo/bar' do
|
|
39
|
-
it { should match('/foo/bar') }
|
|
40
|
-
it { should_not match('/foo%2Fbar') }
|
|
41
|
-
it { should_not match('/foo%2fbar') }
|
|
42
|
-
|
|
43
|
-
it { should expand.to('/foo/bar') }
|
|
44
|
-
it { should_not expand(a: 1) }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
pattern '/:foo' do
|
|
48
|
-
it { should match('/foo') .capturing foo: 'foo' }
|
|
49
|
-
it { should match('/bar') .capturing foo: 'bar' }
|
|
50
|
-
it { should match('/foo.bar') .capturing foo: 'foo.bar' }
|
|
51
|
-
it { should match('/%0Afoo') .capturing foo: '%0Afoo' }
|
|
52
|
-
it { should match('/foo%2Fbar') .capturing foo: 'foo%2Fbar' }
|
|
53
|
-
|
|
54
|
-
it { should_not match('/foo?') }
|
|
55
|
-
it { should_not match('/foo/bar') }
|
|
56
|
-
it { should_not match('/') }
|
|
57
|
-
it { should_not match('/foo/') }
|
|
58
|
-
|
|
59
|
-
example { pattern.params('/foo') .should be == {"foo" => "foo"} }
|
|
60
|
-
example { pattern.params('/f%20o') .should be == {"foo" => "f o"} }
|
|
61
|
-
example { pattern.params('').should be_nil }
|
|
62
|
-
|
|
63
|
-
it { should expand(foo: 'bar') .to('/bar') }
|
|
64
|
-
it { should expand(foo: 'b r') .to('/b%20r') }
|
|
65
|
-
it { should expand(foo: 'foo/bar') .to('/foo%2Fbar') }
|
|
66
|
-
|
|
67
|
-
it { should_not expand(foo: 'foo', bar: 'bar') }
|
|
68
|
-
it { should_not expand(bar: 'bar') }
|
|
69
|
-
it { should_not expand }
|
|
70
|
-
|
|
71
|
-
it { should generate_template('/{foo}') }
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
pattern '/*' do
|
|
75
|
-
it { should match('/') }
|
|
76
|
-
it { should match('/foo') }
|
|
77
|
-
it { should match('/foo/bar') }
|
|
78
|
-
|
|
79
|
-
example { pattern.params('/foo/bar') .should be == {"splat" => ["foo", "bar"]}}
|
|
80
|
-
it { should generate_template('/{+splat}') }
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
pattern '/**' do
|
|
84
|
-
it { should match('/') .capturing splat: '' }
|
|
85
|
-
it { should match('/foo') .capturing splat: 'foo' }
|
|
86
|
-
it { should match('/foo/bar') .capturing splat: 'foo/bar' }
|
|
87
|
-
|
|
88
|
-
example { pattern.params('/foo/bar') .should be == {"splat" => ["foo/bar"]} }
|
|
89
|
-
it { should generate_template('/{+splat}') }
|
|
90
|
-
end
|
|
91
|
-
end
|