padrino-core 0.13.0 → 0.13.1.beta1

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
  SHA1:
3
- metadata.gz: df73d4a14b1d5ad90c0cee78699bfb08addd30f4
4
- data.tar.gz: 7307777a18f4d046f27bbc3296afcb26bab98757
3
+ metadata.gz: af7cd163789baddaf975d9fba8d190c6ebc9ac3a
4
+ data.tar.gz: 5436fc024ed5e7c1cdd605d82e8ca087366c72d3
5
5
  SHA512:
6
- metadata.gz: c951c3160d9354c1d0cef4c195f90cfc9e725661d235033ce930cc0fc2a3c47f34db0dda0dc02d9ee23fd6af7485f3c87e2389554f7330ac1df41572dbd21582
7
- data.tar.gz: bd1cd61aec6fd3de5c26c1f1e52695fb7dd4649f5d18a89a943f695b6b11f566483ec227362876800a987a7889f818fee8a74cd55bb0f3356735ae1b30b8fa9a
6
+ metadata.gz: 6796d2b316dc62d1007c71efc1f8513df379f8852f6633aca39d12daaa00535c7e107ea2cdc4c002dd01c83efe8c1b73dadcd3bb1bcc1bcf5d6df72f713a4af5
7
+ data.tar.gz: 082b444f689877f4d5bcaa9c31ebbf100fa427458ca6c7900a9ec20998875eb04b3235746c37adc28e2808580fa0a2a8bb5cec865718a3a1ceaf421e6c71d3fb
@@ -4,8 +4,7 @@ module Padrino
4
4
  # High performance engine for finding all routes which are matched with pattern
5
5
  #
6
6
  class Compiler
7
- # All regexps generated by recursive compiler
8
- attr_reader :regexps
7
+ attr_accessor :routes
9
8
 
10
9
  ##
11
10
  # Constructs an instance of Padrino::PathRouter::Compiler
@@ -19,11 +18,10 @@ module Padrino
19
18
  #
20
19
  def compile!
21
20
  return if compiled?
22
- @regexps = @routes.map.with_index do |route, index|
21
+ @routes.each_with_index do |route, index|
23
22
  route.index = index
24
- /(?<_#{index}>#{route.matcher.to_regexp})/
23
+ route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/
25
24
  end
26
- @regexps = recursive_compile(@regexps)
27
25
  @compiled = true
28
26
  end
29
27
 
@@ -39,7 +37,7 @@ module Padrino
39
37
  #
40
38
  def find_by(request_or_env)
41
39
  request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env
42
- pattern = encode_default_external(request.path_info)
40
+ pattern = decode_pattern(request.path_info)
43
41
  verb = request.request_method
44
42
  rotation { |offset| match?(offset, pattern) }.select { |route| route.verb == verb }
45
43
  end
@@ -49,7 +47,7 @@ module Padrino
49
47
  #
50
48
  def call_by_request(request)
51
49
  rotation do |offset|
52
- pattern = encode_default_external(request.path_info)
50
+ pattern = decode_pattern(request.path_info)
53
51
  if route = match?(offset, pattern)
54
52
  params = route.params_for(pattern, request.params)
55
53
  yield(route, params) if route.verb == request.request_method
@@ -62,7 +60,7 @@ module Padrino
62
60
  # Finds routes by using PATH_INFO.
63
61
  #
64
62
  def find_by_pattern(pattern)
65
- pattern = pattern.encode(Encoding.default_external)
63
+ pattern = decode_pattern(pattern)
66
64
  rotation { |offset| match?(offset, pattern) }
67
65
  end
68
66
 
@@ -72,9 +70,9 @@ module Padrino
72
70
  # Returns a instance of PathRouter::Route if path is matched with current regexp
73
71
  #
74
72
  def match?(offset, path)
75
- current_regexp = @regexps[offset]
76
- return unless current_regexp === path || (path.end_with?("/") && current_regexp === path[0..-2])
77
- @routes[offset..-1].detect{ |route| Regexp.last_match["_#{route.index}"] }
73
+ @routes[offset..-1].find do |route|
74
+ route.regexp === path || (path.end_with?("/") && route.regexp === path[0..-2])
75
+ end
78
76
  end
79
77
 
80
78
  ##
@@ -90,13 +88,10 @@ module Padrino
90
88
  end
91
89
 
92
90
  ##
93
- # Compiles routes into regexp recursively.
91
+ # Decode env["PATH_INFO"]
94
92
  #
95
- def recursive_compile(regexps, paths = [])
96
- return paths if regexps.length.zero?
97
- paths << Regexp.union(regexps)
98
- regexps.shift
99
- recursive_compile(regexps, paths)
93
+ def decode_pattern(pattern)
94
+ decode_uri(encode_default_external(pattern))
100
95
  end
101
96
 
102
97
  ##
@@ -105,6 +100,13 @@ module Padrino
105
100
  def encode_default_external(string)
106
101
  string.encode(Encoding.default_external)
107
102
  end
103
+
104
+ ##
105
+ # Decode uri escape sequences
106
+ #
107
+ def decode_uri(string)
108
+ string.split(/%2F|%2f/, -1).map { |part| Rack::Utils.unescape(part) }.join('%2F')
109
+ end
108
110
  end
109
111
  end
110
112
  end
@@ -76,7 +76,7 @@ module Padrino
76
76
  @handler ||=
77
77
  case @path
78
78
  when String
79
- Mustermann.new(@path, :capture => @capture)
79
+ Mustermann.new(@path, :capture => @capture, :uri_decode => false)
80
80
  when Regexp
81
81
  /^(?:#{@path})$/
82
82
  else
@@ -4,7 +4,7 @@ module Padrino
4
4
  ##
5
5
  # The accessors are useful to access from PathRouter::Router
6
6
  #
7
- attr_accessor :name, :capture, :order, :options, :index
7
+ attr_accessor :name, :capture, :order, :options, :index, :regexp
8
8
 
9
9
  ##
10
10
  # A reader for compile option
@@ -6,7 +6,7 @@
6
6
  #
7
7
  module Padrino
8
8
  # The version constant for the current version of Padrino.
9
- VERSION = '0.13.0' unless defined?(Padrino::VERSION)
9
+ VERSION = '0.13.1.beta1' unless defined?(Padrino::VERSION)
10
10
 
11
11
  #
12
12
  # The current Padrino version.
@@ -165,8 +165,8 @@ describe "Application" do
165
165
  assert_instance_of Padrino::PathRouter::Compiler, PrecompiledApp::SubApp.compiled_router.engine
166
166
  assert_equal true, PrecompiledApp::App.compiled_router.engine.compiled?
167
167
  assert_equal true, PrecompiledApp::SubApp.compiled_router.engine.compiled?
168
- assert_equal 20, PrecompiledApp::App.compiled_router.engine.regexps.length
169
- assert_equal 20, PrecompiledApp::SubApp.compiled_router.engine.regexps.length
168
+ assert_equal 20, PrecompiledApp::App.compiled_router.engine.routes.length
169
+ assert_equal 20, PrecompiledApp::SubApp.compiled_router.engine.routes.length
170
170
  end
171
171
  end
172
172
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-10-11 00:00:00.000000000 Z
14
+ date: 2015-10-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-support
@@ -19,82 +19,82 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.13.0
22
+ version: 0.13.1.beta1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.13.0
29
+ version: 0.13.1.beta1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: sinatra
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ~>
34
+ - - "~>"
35
35
  - !ruby/object:Gem::Version
36
36
  version: 1.4.6
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ~>
41
+ - - "~>"
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.4.6
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: mustermann19
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - '>='
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: thor
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ~>
62
+ - - "~>"
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0.18'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - ~>
69
+ - - "~>"
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0.18'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: activesupport
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '3.1'
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '3.1'
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: rack-protection
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: 1.5.0
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - '>='
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
99
  version: 1.5.0
100
100
  description: The Padrino core gem required for use of this framework
@@ -105,9 +105,9 @@ extensions: []
105
105
  extra_rdoc_files:
106
106
  - README.rdoc
107
107
  files:
108
- - .document
109
- - .gitignore
110
- - .yardopts
108
+ - ".document"
109
+ - ".gitignore"
110
+ - ".yardopts"
111
111
  - LICENSE.txt
112
112
  - README.rdoc
113
113
  - Rakefile
@@ -218,19 +218,19 @@ licenses:
218
218
  metadata: {}
219
219
  post_install_message:
220
220
  rdoc_options:
221
- - --charset=UTF-8
221
+ - "--charset=UTF-8"
222
222
  require_paths:
223
223
  - lib
224
224
  required_ruby_version: !ruby/object:Gem::Requirement
225
225
  requirements:
226
- - - '>='
226
+ - - ">="
227
227
  - !ruby/object:Gem::Version
228
228
  version: '0'
229
229
  required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  requirements:
231
- - - '>='
231
+ - - ">"
232
232
  - !ruby/object:Gem::Version
233
- version: 1.3.6
233
+ version: 1.3.1
234
234
  requirements: []
235
235
  rubyforge_project: padrino-core
236
236
  rubygems_version: 2.4.8