padrino-core 0.15.1 → 0.15.2

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: 34666b69f252023ab8f1a972e23b14c060e4219834ad088dd13f04987087c700
4
- data.tar.gz: dec853c3b9402dec32d39470da681522cc65245bf4e838c10893cd9a30b40310
3
+ metadata.gz: 936bbc8899b2e4f9d72e9bc438d3a645c7caa27d90a87a3076bf612ce2081266
4
+ data.tar.gz: 391dd038f7b3c928bb141bbdf583a5e01b9b9a08528c05cc957378369cb6cc35
5
5
  SHA512:
6
- metadata.gz: e71c9a7c41a7ed7b28c9668424dd6757fed139b39ec4b481b1403328664ffd57446912665c90f66a60cc4ca6b36a483346ef6d83137c5fb395f5aae319764a7a
7
- data.tar.gz: d7f454ef23ab20bfc18a4f041a8b7561ff6952da095549ff35919dcbb9395b0ab0a51e053af1d4bf533878c4c3ff0efcdc7408a8e6031795191a84510f3b4ed5
6
+ metadata.gz: 62a09f99b3330e75cf04caea5b69beae228fe9f65b7254ba292e3327c9620b6bf9806fd2a7ca1059890f53c4e653a76835ecc826e1a4dd9d185446686f8ad628
7
+ data.tar.gz: 6ea735209558b4f7579ebde9004437b980e61af0e77cc898bad8d331d13f31c93a477e3c18e54158dd3a447600b0cbd05deb769c22b6b2af911bc5e88e4183e4
@@ -29,13 +29,16 @@ module Padrino
29
29
  class << self
30
30
  def inherited(base)
31
31
  begun_at = Time.now
32
- CALLERS_TO_IGNORE.concat(PADRINO_IGNORE_CALLERS)
33
32
  super(base)
34
33
  base.prerequisites.replace(self.prerequisites.dup)
35
34
  base.default_configuration!
36
35
  logger.devel :setup, begun_at, base
37
36
  end
38
37
 
38
+ def callers_to_ignore
39
+ @callers_to_ignore ||= super + PADRINO_IGNORE_CALLERS
40
+ end
41
+
39
42
  ##
40
43
  # Reloads the application files from all defined load paths.
41
44
  #
@@ -58,8 +58,10 @@ module Padrino
58
58
  params = args.last.is_a?(Hash) ? args.pop : {}
59
59
  candidates = @routes.select { |route| route.name == name }
60
60
  fail InvalidRouteException if candidates.empty?
61
+ i = 0
61
62
  route = candidates.sort_by! { |candidate|
62
- (params.keys.map(&:to_s) - candidate.matcher.names).length }.shift
63
+ # Tries to find the route that matches more, but with fewer names, in stable order
64
+ [(params.keys.map(&:to_s) - candidate.matcher.names).length, candidate.matcher.names.size, i += 1] }.shift
63
65
  matcher = route.matcher
64
66
  params_for_expand = params.dup
65
67
  if !args.empty? && matcher.mustermann?
@@ -6,7 +6,7 @@
6
6
  #
7
7
  module Padrino
8
8
  # The version constant for the current version of Padrino.
9
- VERSION = '0.15.1' unless defined?(Padrino::VERSION)
9
+ VERSION = '0.15.2' unless defined?(Padrino::VERSION)
10
10
 
11
11
  #
12
12
  # The current Padrino version.
data/padrino-core.gemspec CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.rdoc_options = ["--charset=UTF-8"]
24
24
 
25
25
  s.add_dependency("padrino-support", Padrino.version)
26
- s.add_dependency("sinatra", ">= 2.0.0")
26
+ s.add_dependency("sinatra", ">= 2.2.4")
27
27
  s.add_dependency("thor", "~> 1.0")
28
28
  end
@@ -51,7 +51,7 @@ describe "Application" do
51
51
  end
52
52
 
53
53
  it 'should have shared sessions accessible in project' do
54
- Padrino.configure_apps { enable :sessions; set :session_secret, 'secret' }
54
+ Padrino.configure_apps { enable :sessions; set :session_secret, PadrinoTestApp2.session_secret }
55
55
  Padrino.mount("PadrinoTestApp").to("/write")
56
56
  Padrino.mount("PadrinoTestApp2").to("/read")
57
57
  PadrinoTestApp.send :default_configuration!
data/test/test_routing.rb CHANGED
@@ -96,6 +96,17 @@ describe "Routing" do
96
96
  assert_equal "/1234.json?baz=baz", @app.url_for(:index, :id => "1234", :format => "json", :baz => "baz")
97
97
  end
98
98
 
99
+ it 'should recognize route even if paths are duplicated, in reverse order' do
100
+ mock_app do
101
+ get(:index, :with => :id, :provides => :json) {}
102
+ get(:index, :with => :id) {}
103
+ get(:index) {}
104
+ end
105
+ assert_equal "/", @app.url_for(:index)
106
+ assert_equal "/1234", @app.url_for(:index, :id => "1234")
107
+ assert_equal "/1234.json?baz=baz", @app.url_for(:index, :id => "1234", :format => "json", :baz => "baz")
108
+ end
109
+
99
110
  it 'should fail with unrecognized route exception when not found' do
100
111
  mock_app do
101
112
  get(:index){ "okey" }
@@ -192,7 +203,7 @@ describe "Routing" do
192
203
  mock_app do
193
204
  get('/щч') { 'success!' }
194
205
  end
195
- get(URI.escape('/щч'))
206
+ get('/' + CGI.escape('щч'))
196
207
  assert_equal 'success!', body
197
208
  end
198
209
 
@@ -2122,7 +2133,7 @@ describe "Routing" do
2122
2133
  mock_app { set :environment, :development }
2123
2134
  get "/"
2124
2135
  assert_equal 404, status
2125
- assert_match %r{GET /}, body
2136
+ assert_match %r{Not Found}, body
2126
2137
  end
2127
2138
 
2128
2139
  it 'should render a custom NotFound page' do
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.15.1
4
+ version: 0.15.2
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: 2021-04-25 00:00:00.000000000 Z
14
+ date: 2022-12-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-support
@@ -19,28 +19,28 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.15.1
22
+ version: 0.15.2
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.15.1
29
+ version: 0.15.2
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
- version: 2.0.0
36
+ version: 2.2.4
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
- version: 2.0.0
43
+ version: 2.2.4
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: thor
46
46
  requirement: !ruby/object:Gem::Requirement