mustermann-contrib 1.0.0.beta2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +23 -0
  3. data/README.md +11 -95
  4. data/lib/mustermann/cake.rb +1 -0
  5. data/lib/mustermann/express.rb +1 -0
  6. data/lib/mustermann/file_utils.rb +1 -0
  7. data/lib/mustermann/file_utils/glob_pattern.rb +1 -0
  8. data/lib/mustermann/flask.rb +1 -0
  9. data/lib/mustermann/pyramid.rb +1 -0
  10. data/lib/mustermann/rails.rb +1 -0
  11. data/lib/mustermann/shell.rb +1 -0
  12. data/lib/mustermann/simple.rb +1 -0
  13. data/lib/mustermann/string_scanner.rb +1 -0
  14. data/lib/mustermann/template.rb +1 -0
  15. data/lib/mustermann/versions.rb +2 -1
  16. data/lib/mustermann/visualizer.rb +5 -4
  17. data/lib/mustermann/visualizer/highlight.rb +9 -8
  18. data/lib/mustermann/visualizer/highlighter.rb +1 -0
  19. data/lib/mustermann/visualizer/highlighter/ad_hoc.rb +2 -1
  20. data/lib/mustermann/visualizer/highlighter/ast.rb +1 -0
  21. data/lib/mustermann/visualizer/highlighter/composite.rb +2 -1
  22. data/lib/mustermann/visualizer/highlighter/dummy.rb +2 -1
  23. data/lib/mustermann/visualizer/highlighter/regular.rb +2 -1
  24. data/lib/mustermann/visualizer/pattern_extension.rb +2 -1
  25. data/lib/mustermann/visualizer/renderer/ansi.rb +1 -0
  26. data/lib/mustermann/visualizer/renderer/generic.rb +1 -0
  27. data/lib/mustermann/visualizer/renderer/hansi_template.rb +1 -0
  28. data/lib/mustermann/visualizer/renderer/html.rb +1 -0
  29. data/lib/mustermann/visualizer/renderer/sexp.rb +1 -0
  30. data/lib/mustermann/visualizer/tree.rb +2 -1
  31. data/lib/mustermann/visualizer/tree_renderer.rb +2 -1
  32. data/mustermann-contrib.gemspec +1 -1
  33. data/spec/cake_spec.rb +1 -0
  34. data/spec/express_spec.rb +1 -0
  35. data/spec/file_utils_spec.rb +1 -0
  36. data/spec/flask_spec.rb +1 -0
  37. data/spec/flask_subclass_spec.rb +2 -1
  38. data/spec/pattern_extension_spec.rb +1 -0
  39. data/spec/pyramid_spec.rb +1 -0
  40. data/spec/rails_spec.rb +1 -0
  41. data/spec/shell_spec.rb +1 -0
  42. data/spec/simple_spec.rb +1 -0
  43. data/spec/string_scanner_spec.rb +1 -0
  44. data/spec/template_spec.rb +1 -0
  45. metadata +8 -10
  46. data/lib/mustermann/grape.rb +0 -35
  47. data/spec/grape_spec.rb +0 -747
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6ef2cc24604b7944b3b4e9a97fd7eacd331f4af
4
- data.tar.gz: d4d0031aff198de4a190cda57c5cf25a0bade3b5
3
+ metadata.gz: 99342e7d083221ed24c4a9357879b0a7473d26e0
4
+ data.tar.gz: 4f033729683186897e6dad66b394cfca6de74529
5
5
  SHA512:
6
- metadata.gz: 339f192ae2f720a0a5882d962c855c2d9f6285524db013b2fe56fb0e351cf88c13cbbff9c2d2cc84f42d740204f4c8ccf1ae965db577d5c11e8cd9211f5b279d
7
- data.tar.gz: 42293a657b0de5cda8d6a317108f59a138542fa2c88f0e317b02022d71e425ff7780e021dc42edd7e5df4ab6b3808a0841e8ab2239a90e3d0c1a48801b7dc267
6
+ metadata.gz: 242b9b216aa2418f988300c1bf351dd295947a85f2834541e84a3a972313303446865672b05d6b0f1292f6491e20f649679a2117d75f9162320c368070e511e2
7
+ data.tar.gz: 5769b306efcc6874caecb7ab7ce34074d35c59f2d851e8d5b98d2f56ee3d7a65524a4634f42e5729334cefd9f20ec20df8babb6d79b7e4fe1ad2182fd60328de
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2013-2017 Konstantin Haase
2
+ Copyright (c) 2016-2017 Zachary Scott
3
+
4
+ Permission is hereby granted, free of charge, to any person
5
+ obtaining a copy of this software and associated documentation
6
+ files (the "Software"), to deal in the Software without
7
+ restriction, including without limitation the rights to use,
8
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the
10
+ Software is furnished to do so, subject to the following
11
+ conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -24,21 +24,7 @@ github 'sinatra/mustermann' do
24
24
  end
25
25
  ```
26
26
 
27
- Below is the documentation for all extensions, including:
28
-
29
- * mustermann-cake
30
- * mustermann-express
31
- * mustermann-fileutils
32
- * mustermann-flask
33
- * mustermann-grape
34
- * mustermann-pyramid
35
- * mustermann-rails
36
- * mustermann-shell
37
- * mustermann-simple
38
- * mustermann-strscan
39
- * mustermann-uri-template
40
- * mustermann-visualizer
41
-
27
+ <a name="-mustermann-cake"></a>
42
28
  # CakePHP Syntax for Mustermann
43
29
 
44
30
  This gem implements the `cake` pattern type for Mustermann. It is compatible with [CakePHP](http://cakephp.org/) 2.x and 3.x.
@@ -115,6 +101,7 @@ pattern.to_templates # => ['/{name}']
115
101
  </table>
116
102
 
117
103
 
104
+ <a name="-mustermann-express"></a>
118
105
  # Express Syntax for Mustermann
119
106
 
120
107
  This gem implements the `express` pattern type for Mustermann. It is compatible with [Express](http://expressjs.com/) and [pillar.js](https://pillarjs.github.io/).
@@ -212,6 +199,7 @@ pattern.to_templates # => ['/{name}']
212
199
  </tbody>
213
200
  </table>
214
201
 
202
+ <a name="-mustermann-fileutils"></a>
215
203
  # FileUtils for Mustermann
216
204
 
217
205
  This gem implements efficient file system operations for Mustermann patterns.
@@ -270,6 +258,7 @@ Mustermann::FileUtils.cp_r(':base.:ext' => ':base.bak.:ext')
270
258
  Mustermann::FileUtils.ln_s('lib/:name.rb' => 'bin/:name')
271
259
  ```
272
260
 
261
+ <a name="-mustermann-flask"></a>
273
262
  # Flask Syntax for Mustermann
274
263
 
275
264
  This gem implements the `flask` pattern type for Mustermann. It is compatible with [Flask](http://flask.pocoo.org/) and [Werkzeug](http://werkzeug.pocoo.org/).
@@ -517,85 +506,7 @@ pattern = Mustermann.new('/<id:id>/<num(base=8):oct>/<num(base=16):hex>', type:
517
506
  pattern.params('/10/12/f1') # => {"id"=>10, "oct"=>10, "hex"=>241}
518
507
  ```
519
508
 
520
- # Grape Syntax for Mustermann
521
-
522
- This gem implements the `grape` pattern type for Mustermann.
523
-
524
- ## Overview
525
-
526
- **Supported options:**
527
- `capture`, `except`, `greedy`, `space_matches_plus`, `uri_decode`, `converters` and `ignore_unknown_options`
528
-
529
- ``` ruby
530
- require 'mustermann/grape'
531
-
532
- Mustermann.new('/:id', type: :grape).params('/foo') # => { id: 'foo' }
533
- ```
534
-
535
- ## Syntax
536
-
537
- <table>
538
- <thead>
539
- <tr>
540
- <th>Syntax Element</th>
541
- <th>Description</th>
542
- </tr>
543
- </thead>
544
- <tbody>
545
- <tr>
546
- <td><b>:</b><i>name</i> <i><b>or</b></i> <b>&#123;</b><i>name</i><b>&#125;</b></td>
547
- <td>
548
- Captures anything but a forward slash in a semi-greedy fashion. Capture is named <i>name</i>.
549
- Capture behavior can be modified with <tt>capture</tt> and <tt>greedy</tt> option.
550
- </td>
551
- </tr>
552
- <tr>
553
- <td><b>*</b><i>name</i> <i><b>or</b></i> <b>&#123;+</b><i>name</i><b>&#125;</b></td>
554
- <td>
555
- Captures anything in a non-greedy fashion. Capture is named <i>name</i>.
556
- </td>
557
- </tr>
558
- <tr>
559
- <td><b>*</b> <i><b>or</b></i> <b>&#123;+splat&#125;</b></td>
560
- <td>
561
- Captures anything in a non-greedy fashion. Capture is named splat.
562
- It is always an array of captures, as you can use it more than once in a pattern.
563
- </td>
564
- </tr>
565
- <tr>
566
- <td><b>(</b><i>expression</i><b>)</b></td>
567
- <td>
568
- Enclosed <i>expression</i> is optional.
569
- </td>
570
- </tr>
571
- <tr>
572
- <td><i>expression</i><b>|</b><i>expression</i><b>|</b><i>...</i></td>
573
- <td>
574
- Will match anything matching the nested expressions. May contain any other syntax element, including captures.
575
- </td>
576
- </tr>
577
- <tr>
578
- <td><i>x</i><b>?</b></td>
579
- <td>Makes <i>x</i> optional. For instance, <tt>(foo)?</tt> matches <tt>foo</tt> or an empty string.</td>
580
- </tr>
581
- <tr>
582
- <td><b>/</b></td>
583
- <td>
584
- Matches forward slash. Does not match URI encoded version of forward slash.
585
- </td>
586
- </tr>
587
- <tr>
588
- <td><b>\</b><i>x</i></td>
589
- <td>Matches <i>x</i> or URI encoded version of <i>x</i>. For instance <tt>\*</tt> matches <tt>*</tt>.</td>
590
- </tr>
591
- <tr>
592
- <td><i>any other character</i></td>
593
- <td>Matches exactly that character or a URI encoded version of it.</td>
594
- </tr>
595
- </tbody>
596
- </table>
597
-
598
-
509
+ <a name="-mustermann-pyramid"></a>
599
510
  # Pyramid Syntax for Mustermann
600
511
 
601
512
  This gem implements the `pyramid` pattern type for Mustermann. It is compatible with [Pyramid](http://www.pylonsproject.org/projects/pyramid/about) and [Pylons](http://www.pylonsproject.org/projects/pylons-framework/about).
@@ -665,7 +576,7 @@ pattern.to_templates # => ['/{name}']
665
576
  </tbody>
666
577
  </table>
667
578
 
668
-
579
+ <a name="-mustermann-rails"></a>
669
580
  # Rails Syntax for Mustermann
670
581
 
671
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://www.scalatra.org/) (if [configured](http://www.scalatra.org/2.3/guides/http/routes.html#toc_248))</td>
@@ -771,6 +682,7 @@ Mustermann.new('/', type: :rails, version: Rails::VERSION::STRING)
771
682
  </tbody>
772
683
  </table>
773
684
 
685
+ <a name="-mustermann-shell"></a>
774
686
  # Shell Syntax for Mustermann
775
687
 
776
688
  This gem implements the `rails` pattern type for Mustermann. It is compatible with common Unix shells (like bash or zsh).
@@ -836,6 +748,7 @@ pattern === "/baz" # => false
836
748
  </table>
837
749
 
838
750
 
751
+ <a name="-mustermann-simple"></a>
839
752
  # Simple Syntax for Mustermann
840
753
 
841
754
  This gem implements the `simple` pattern type for Mustermann. It is compatible with [Sinatra](http://www.sinatrarb.com/) (1.x), [Scalatra](http://www.scalatra.org/) and [Dancer](http://perldancer.org/).
@@ -913,6 +826,7 @@ pattern.params("/foo/bar") # => { "splat" => ["foo/bar"] }
913
826
  </tbody>
914
827
  </table>
915
828
 
829
+ <a name="-mustermann-strscan"></a>
916
830
  # String Scanner for Mustermann
917
831
 
918
832
  This gem implements `Mustermann::StringScanner`, a tool inspired by Ruby's [`StringScanner`]() class.
@@ -952,6 +866,7 @@ You can also pass in default options for ad hoc patterns when creating the scann
952
866
  scanner = Mustermann::StringScanner.new(input, type: :shell)
953
867
  ```
954
868
 
869
+ <a name="-mustermann-uri-template"></a>
955
870
  # URI Template Syntax for Mustermann
956
871
 
957
872
  This gem implements the `uri-template` (or `template`) pattern type for Mustermann. It is compatible with [RFC 6570](https://tools.ietf.org/html/rfc6570) (level 4), [JSON API](http://jsonapi.org/), [JSON Home Documents](http://tools.ietf.org/html/draft-nottingham-json-home-02) and [many more](https://code.google.com/p/uri-templates/wiki/Implementations)
@@ -1038,6 +953,7 @@ If you reuse the exact same templates and expose them via an external API meant
1038
953
  you should set `uri_decode` to `false` in order to conform with the specification.
1039
954
 
1040
955
 
956
+ <a name="-mustermann-visualizer"></a>
1041
957
  # Mustermann Pattern Visualizer
1042
958
 
1043
959
  With this gem, you can visualize the internal structure of a Mustermann pattern:
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/ast/pattern'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/ast/pattern'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/file_utils/glob_pattern'
3
4
  require 'mustermann/mapper'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann/ast/translator'
2
3
 
3
4
  module Mustermann
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/ast/pattern'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/ast/pattern'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/ast/pattern'
3
4
  require 'mustermann/versions'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/pattern'
3
4
  require 'mustermann/simple_match'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/regexp_based'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/pattern_cache'
3
4
  require 'delegate'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/ast/pattern'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Mustermann
2
3
  # Mixin that adds support for multiple versions of the same type.
3
4
  # @see Mustermann::Rails
@@ -43,4 +44,4 @@ module Mustermann
43
44
  name
44
45
  end
45
46
  end
46
- end
47
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann'
2
3
  require 'mustermann/visualizer/highlight'
3
4
  require 'mustermann/visualizer/tree_renderer'
@@ -10,10 +11,10 @@ module Mustermann
10
11
 
11
12
  # @example creating a highlight object
12
13
  # require 'mustermann/visualizer'
13
- #
14
+ #
14
15
  # pattern = Mustermann.new('/:name')
15
16
  # highlight = Mustermann::Visualizer.highlight(pattern)
16
- #
17
+ #
17
18
  # puts highlight.to_ansi
18
19
  #
19
20
  # @return [Mustermann::Visualizer::Highlight] highlight object for given pattern
@@ -24,10 +25,10 @@ module Mustermann
24
25
 
25
26
  # @example creating a tree object
26
27
  # require 'mustermann/visualizer'
27
- #
28
+ #
28
29
  # pattern = Mustermann.new('/:name')
29
30
  # tree = Mustermann::Visualizer.tree(pattern)
30
- #
31
+ #
31
32
  # puts highlight.to_s
32
33
  #
33
34
  # @return [Mustermann::Visualizer::Tree] tree object for given pattern
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'hansi'
2
3
  require 'mustermann'
3
4
  require 'mustermann/visualizer/highlighter'
@@ -57,10 +58,10 @@ module Mustermann
57
58
 
58
59
  # @example
59
60
  # require 'mustermann/visualizer'
60
- #
61
+ #
61
62
  # pattern = Mustermann.new('/:name')
62
63
  # highlight = Mustermann::Visualizer.highlight(pattern)
63
- #
64
+ #
64
65
  # puts highlight.to_hansi_template
65
66
  #
66
67
  # @return [String] Hansi template representation of the pattern
@@ -70,10 +71,10 @@ module Mustermann
70
71
 
71
72
  # @example
72
73
  # require 'mustermann/visualizer'
73
- #
74
+ #
74
75
  # pattern = Mustermann.new('/:name')
75
76
  # highlight = Mustermann::Visualizer.highlight(pattern)
76
- #
77
+ #
77
78
  # puts highlight.to_ansi
78
79
  #
79
80
  # @return [String] ANSI colorized version of the pattern
@@ -83,10 +84,10 @@ module Mustermann
83
84
 
84
85
  # @example
85
86
  # require 'mustermann/visualizer'
86
- #
87
+ #
87
88
  # pattern = Mustermann.new('/:name')
88
89
  # highlight = Mustermann::Visualizer.highlight(pattern)
89
- #
90
+ #
90
91
  # puts highlight.to_html
91
92
  #
92
93
  # @return [String] HTML rendering of the pattern
@@ -96,10 +97,10 @@ module Mustermann
96
97
 
97
98
  # @example
98
99
  # require 'mustermann/visualizer'
99
- #
100
+ #
100
101
  # pattern = Mustermann.new('/:name')
101
102
  # highlight = Mustermann::Visualizer.highlight(pattern)
102
- #
103
+ #
103
104
  # puts highlight.to_sexp
104
105
  #
105
106
  # @return [String] s-expression like representation of the pattern
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann/visualizer/highlighter/ast'
2
3
  require 'mustermann/visualizer/highlighter/ad_hoc'
3
4
  require 'mustermann/visualizer/highlighter/composite'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'strscan'
2
3
 
3
4
  module Mustermann
@@ -33,7 +34,7 @@ module Mustermann
33
34
  def initialize(pattern, renderer)
34
35
  @pattern = pattern
35
36
  @renderer = renderer
36
- @output = ""
37
+ @output = String.new
37
38
  @rules = self.class.rules
38
39
  @scanner = ::StringScanner.new(pattern.to_s)
39
40
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'mustermann/ast/translator'
2
3
 
3
4
  module Mustermann
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Mustermann
2
3
  module Visualizer
3
4
  # @!visibility private
@@ -42,4 +43,4 @@ module Mustermann
42
43
  end
43
44
  end
44
45
  end
45
- end
46
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Mustermann
2
3
  module Visualizer
3
4
  # @!visibility private
@@ -7,7 +8,7 @@ module Mustermann
7
8
  module Dummy
8
9
  # @!visibility private
9
10
  def self.highlight(pattern, renderer)
10
- output = ""
11
+ output = String.new
11
12
  output << renderer.pre(:root) << renderer.pre(:unknown)
12
13
  output << renderer.escape(pattern.to_s)
13
14
  output << renderer.post(:unknown) << renderer.post(:root)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'strscan'
2
3
 
3
4
  module Mustermann
@@ -27,7 +28,7 @@ module Mustermann
27
28
  # @!visibility private
28
29
  def initialize(renderer)
29
30
  @renderer = renderer
30
- @output = ""
31
+ @output = String.new
31
32
  end
32
33
 
33
34
  # @!visibility private