mustermann 3.0.1 → 3.0.3

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
2
  SHA256:
3
- metadata.gz: f75d6f364025d8f0de627e954e2fabe7ab1e9bd965bba6d0b2d250ccec5b9e31
4
- data.tar.gz: f47314d7ee8ebba68ed527bffca2865c1b1a6472132e3fd2cf0f1083b424299a
3
+ metadata.gz: 6eab7afe8e103bc21ee7dbf141e56ec0a086f3225f3ecfd1031afe7e0ed6425e
4
+ data.tar.gz: 4e7fdee86cb855b82741ed15aac5464611f683b7bd4eca83326dfb08e708f816
5
5
  SHA512:
6
- metadata.gz: ca91716b6e3b8e7ec9040ae2d9f58f27cd697bdb2c0d86b46a3eb18d74fb664c45e1c87a9d2b8aa22997c471833316ce591ec702f491937104d61c8e264d58bb
7
- data.tar.gz: f533a4c49cc4c6f7bf8c3d98d94681536b89138f18aac3117a70f450f50ed512d59f2d4f2157068d21b58c1012f65ac01da819fe20b88f5d172db89a329c1aa1
6
+ metadata.gz: 12dd15e15b97f1d399d7ccecdc343e741aded6aa095b7c69a174e34b64db15075b106bd23179e0d2023f8f1efd817379322afe7036b94fbb76d35d5b7c33348d
7
+ data.tar.gz: 21362bc9a0145ed898156c2f0793b9092a76c49ca2fd3d0760b309507cfff61fb324363babd34759d46b67462ea66dc686a18aff1324ad5de20bee9c09b0e43f
@@ -0,0 +1,16 @@
1
+ require "objspace"
2
+ require "uri"
3
+ require_relative "../lib/mustermann/ast/translator"
4
+
5
+ translator = Mustermann::AST::Translator.new
6
+ translator.escape("foo")
7
+
8
+ h1 = ObjectSpace.each_object.inject(Hash.new 0) { |h, o| h[o.class] += 1; h }
9
+
10
+ 100.times do
11
+ translator.escape("foo")
12
+ end
13
+
14
+ h2 = ObjectSpace.each_object.inject(Hash.new 0) { |h, o| h[o.class] += 1; h }
15
+
16
+ raise if (h2[URI::RFC2396_Parser] - h1[URI::RFC2396_Parser] != 0)
@@ -11,6 +11,9 @@ module Mustermann
11
11
  # @abstract
12
12
  # @!visibility private
13
13
  class Translator
14
+
15
+ URI_PARSER = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::RFC2396_Parser.new
16
+
14
17
  # Encapsulates a single node translation
15
18
  # @!visibility private
16
19
  class NodeTranslator < DelegateClass(Node)
@@ -118,7 +121,7 @@ module Mustermann
118
121
 
119
122
  # @return [String] escaped character
120
123
  # @!visibility private
121
- def escape(char, parser: URI::DEFAULT_PARSER, escape: URI::RFC2396_Parser.new.regexp[:UNSAFE], also_escape: nil)
124
+ def escape(char, parser: URI_PARSER, escape: URI_PARSER.regexp[:UNSAFE], also_escape: nil)
122
125
  escape = Regexp.union(also_escape, escape) if also_escape
123
126
  char.to_s =~ escape ? parser.escape(char, Regexp.union(*escape)) : char
124
127
  end
@@ -9,7 +9,7 @@ module Mustermann
9
9
  # @abstract
10
10
  class Pattern
11
11
  include Mustermann
12
- @@uri ||= URI::Parser.new
12
+ @@uri ||= URI::RFC2396_Parser.new
13
13
 
14
14
  # List of supported options.
15
15
  #
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Mustermann
3
- VERSION ||= '3.0.1'
3
+ VERSION ||= '3.0.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mustermann
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-07-31 00:00:00.000000000 Z
12
+ date: 2024-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby2_keywords
@@ -37,6 +37,7 @@ files:
37
37
  - bench/regexp.rb
38
38
  - bench/simple_vs_sinatra.rb
39
39
  - bench/template_vs_addressable.rb
40
+ - bench/uri_parser_object.rb
40
41
  - lib/mustermann.rb
41
42
  - lib/mustermann/ast/boundaries.rb
42
43
  - lib/mustermann/ast/compiler.rb