mustermann-contrib 3.1.0 → 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 +3 -3
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.1.
|
|
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.1.
|
|
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.1.
|
|
26
|
+
version: 3.1.1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: hansi
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|