padrino-core 0.14.0.rc1 → 0.14.0.rc2
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/lib/padrino-core.rb +2 -2
- data/lib/padrino-core/application/flash.rb +2 -2
- data/lib/padrino-core/cli/adapter.rb +2 -0
- data/lib/padrino-core/cli/rake.rb +0 -9
- data/lib/padrino-core/loader.rb +0 -1
- data/lib/padrino-core/logger.rb +1 -1
- data/lib/padrino-core/module.rb +1 -1
- data/lib/padrino-core/mounter.rb +2 -0
- data/lib/padrino-core/path_router.rb +2 -2
- data/lib/padrino-core/path_router/matcher.rb +7 -7
- data/lib/padrino-core/server.rb +1 -1
- data/lib/padrino-core/version.rb +1 -1
- data/test/test_core.rb +1 -7
- data/test/test_filters.rb +2 -2
- data/test/test_flash.rb +2 -2
- data/test/test_router.rb +5 -5
- data/test/test_routing.rb +11 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8404b8357ac37d668e460e0d3c696917e6ff9856
|
4
|
+
data.tar.gz: 3db11b004865f9764c20d32c4e46593a6e72245b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fcac954da380e620eb81d654682c88c58b3a7693e2bc5b5826576588983a8e5fce2ea5a2315adaee44dc3c05640b6d95a234e5319cec9512aff2a132bbb0074
|
7
|
+
data.tar.gz: b733600e6602e99991f2a73dcac2cba57eb3e0fdfa7d4b03cb905b7f286f9f105e239aed3be9412df6d62b4546b5e62b4511eed9017d27dd772b1b583164b237
|
data/lib/padrino-core.rb
CHANGED
@@ -112,8 +112,8 @@ module Padrino
|
|
112
112
|
# @return [NilClass]
|
113
113
|
#
|
114
114
|
def set_encoding
|
115
|
-
|
116
|
-
|
115
|
+
# remove after 0.15
|
116
|
+
warn 'Warning! Padrino.set_encoding is deprecated. Padrino no longer manages ruby default encodings'
|
117
117
|
nil
|
118
118
|
end
|
119
119
|
|
@@ -185,11 +185,11 @@ module Padrino
|
|
185
185
|
#
|
186
186
|
# @overload redirect(url, status_code)
|
187
187
|
# @param [String] url
|
188
|
-
# @param [
|
188
|
+
# @param [Integer] status_code
|
189
189
|
#
|
190
190
|
# @overload redirect(url, status_code, flash_messages)
|
191
191
|
# @param [String] url
|
192
|
-
# @param [
|
192
|
+
# @param [Integer] status_code
|
193
193
|
# @param [Hash] flash_messages
|
194
194
|
#
|
195
195
|
# @overload redirect(url, flash_messages)
|
@@ -10,15 +10,6 @@ end
|
|
10
10
|
|
11
11
|
module PadrinoTasks
|
12
12
|
def self.init(init=false)
|
13
|
-
lib_path = File.expand_path("lib")
|
14
|
-
unless $LOAD_PATH.any?{ |path| File.expand_path(path) == lib_path }
|
15
|
-
warn <<-EOT
|
16
|
-
WARNING! In Padrino >= 0.14.0 cli command `padrino rake` will NOT add
|
17
|
-
'./lib' folder to $LOAD_PATH. Please alter your `require` calls accordingly
|
18
|
-
if you depend on this behavior.
|
19
|
-
EOT
|
20
|
-
$LOAD_PATH.unshift lib_path
|
21
|
-
end
|
22
13
|
Padrino::Tasks.files.flatten.uniq.each { |rakefile| Rake.application.add_import(rakefile) rescue puts "<= Failed load #{ext}" }
|
23
14
|
load(File.expand_path('../rake_tasks.rb', __FILE__))
|
24
15
|
Rake.application.load_imports
|
data/lib/padrino-core/loader.rb
CHANGED
data/lib/padrino-core/logger.rb
CHANGED
data/lib/padrino-core/module.rb
CHANGED
data/lib/padrino-core/mounter.rb
CHANGED
@@ -129,6 +129,8 @@ module Padrino
|
|
129
129
|
# Array of routes.
|
130
130
|
#
|
131
131
|
def named_routes
|
132
|
+
return [] unless app_obj.respond_to?(:routes)
|
133
|
+
|
132
134
|
app_obj.routes.map { |route|
|
133
135
|
request_method = route.request_methods.first
|
134
136
|
next if !route.name || request_method == 'HEAD'
|
@@ -58,8 +58,8 @@ 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
|
-
route = candidates.sort_by! { |
|
62
|
-
(params.keys.map(&:to_s) -
|
61
|
+
route = candidates.sort_by! { |candidate|
|
62
|
+
(params.keys.map(&:to_s) - candidate.matcher.names).length }.shift
|
63
63
|
matcher = route.matcher
|
64
64
|
params_for_expand = params.dup
|
65
65
|
if !args.empty? && matcher.mustermann?
|
@@ -14,7 +14,7 @@ module Padrino
|
|
14
14
|
@capture = options[:capture]
|
15
15
|
@default_values = options[:default_values]
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
##
|
19
19
|
# Matches a pattern with the route matcher.
|
20
20
|
#
|
@@ -32,12 +32,12 @@ module Padrino
|
|
32
32
|
def to_regexp
|
33
33
|
mustermann? ? handler.to_regexp : handler
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
##
|
37
37
|
# Expands the path by using parameters.
|
38
38
|
#
|
39
39
|
def expand(params)
|
40
|
-
params =
|
40
|
+
params = @default_values.merge(params) if @default_values.is_a?(Hash)
|
41
41
|
params, query = params.each_with_object([{}, {}]) do |(key, val), parts|
|
42
42
|
parts[handler.names.include?(key.to_s) ? 0 : 1][key] = val
|
43
43
|
end
|
@@ -45,7 +45,7 @@ module Padrino
|
|
45
45
|
expanded_path += ?? + Padrino::Utils.build_uri_query(query) unless query.empty?
|
46
46
|
expanded_path
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
##
|
50
50
|
# Returns true if handler is an instance of Mustermann.
|
51
51
|
#
|
@@ -72,7 +72,7 @@ module Padrino
|
|
72
72
|
end
|
73
73
|
params
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
##
|
77
77
|
# Returns the handler which is an instance of Mustermann or Regexp.
|
78
78
|
#
|
@@ -87,14 +87,14 @@ module Padrino
|
|
87
87
|
@path
|
88
88
|
end
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
##
|
92
92
|
# Converts the handler into string.
|
93
93
|
#
|
94
94
|
def to_s
|
95
95
|
handler.to_s
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
##
|
99
99
|
# Returns names of the handler.
|
100
100
|
# @see Regexp#names
|
data/lib/padrino-core/server.rb
CHANGED
@@ -104,7 +104,7 @@ module Padrino
|
|
104
104
|
#
|
105
105
|
def self.parse_server_options(options)
|
106
106
|
parsed_server_options = Array(options).flat_map{ |option| option.split('=', 2) }
|
107
|
-
Hash[*parsed_server_options]
|
107
|
+
Utils.symbolize_keys(Hash[*parsed_server_options])
|
108
108
|
end
|
109
109
|
|
110
110
|
# Detects Host and Port for Rack server.
|
data/lib/padrino-core/version.rb
CHANGED
data/test/test_core.rb
CHANGED
@@ -20,13 +20,7 @@ describe "Core" do
|
|
20
20
|
it 'should validate global helpers' do
|
21
21
|
assert_equal :test, Padrino.env
|
22
22
|
assert_match /\/test/, Padrino.root
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should set correct utf-8 encoding' do
|
27
|
-
Padrino.set_encoding
|
28
|
-
assert_equal Encoding.default_external, Encoding::UTF_8
|
29
|
-
assert_equal Encoding.default_internal, Encoding::UTF_8
|
23
|
+
assert Padrino.version
|
30
24
|
end
|
31
25
|
|
32
26
|
it 'should raise application error if I instantiate a new padrino application without mounted apps' do
|
data/test/test_filters.rb
CHANGED
@@ -337,7 +337,7 @@ describe "Filters" do
|
|
337
337
|
end
|
338
338
|
|
339
339
|
it 'should catch exceptions in before filters' do
|
340
|
-
doodle =
|
340
|
+
doodle = ''
|
341
341
|
mock_app do
|
342
342
|
after do
|
343
343
|
doodle = 'Been after'
|
@@ -355,7 +355,7 @@ describe "Filters" do
|
|
355
355
|
|
356
356
|
get '/'
|
357
357
|
assert_equal 'We broke before', body
|
358
|
-
assert_equal
|
358
|
+
assert_equal '', doodle
|
359
359
|
end
|
360
360
|
|
361
361
|
it 'should catch exceptions in after filters if no exceptions caught before' do
|
data/test/test_flash.rb
CHANGED
@@ -45,7 +45,7 @@ describe Padrino::Flash do
|
|
45
45
|
|
46
46
|
it 'should not know the values you set right away' do
|
47
47
|
@storage[:foo] = 'bar'
|
48
|
-
|
48
|
+
refute_includes @storage, :foo
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should knows the values you set next time' do
|
@@ -62,7 +62,7 @@ describe Padrino::Flash do
|
|
62
62
|
it 'should forgets values you set only for now next time' do
|
63
63
|
@storage.now[:foo] = 'bar'
|
64
64
|
@storage.sweep
|
65
|
-
|
65
|
+
refute_includes @storage, :foo
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
data/test/test_router.rb
CHANGED
@@ -94,13 +94,13 @@ describe "Router" do
|
|
94
94
|
|
95
95
|
res = Rack::MockRequest.new(map).get("/werewolf")
|
96
96
|
assert_equal 404, res.status
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
refute_includes res, "X-API"
|
98
|
+
refute_includes res, "X-ScriptName"
|
99
|
+
refute_includes res, "X-PathInfo"
|
100
100
|
|
101
101
|
res = Rack::MockRequest.new(map).get("/bar/mitzvah")
|
102
102
|
assert res.ok?
|
103
|
-
|
103
|
+
refute_includes res, "X-API"
|
104
104
|
assert_equal 'text/plain', res["Content-Type"]
|
105
105
|
assert_equal "/bar", res["X-ScriptName"]
|
106
106
|
assert_equal "/mitzvah", res["X-PathInfo"]
|
@@ -114,7 +114,7 @@ describe "Router" do
|
|
114
114
|
|
115
115
|
res = Rack::MockRequest.new(map).get("/bar/scary")
|
116
116
|
assert_equal 404, res.status
|
117
|
-
|
117
|
+
refute_includes res, "X-API"
|
118
118
|
assert_equal 'text/plain', res["Content-Type"]
|
119
119
|
assert_equal "/bar", res["X-ScriptName"]
|
120
120
|
assert_equal "/scary", res["X-PathInfo"]
|
data/test/test_routing.rb
CHANGED
@@ -1247,6 +1247,17 @@ describe "Routing" do
|
|
1247
1247
|
assert_equal "lang is en", body
|
1248
1248
|
end
|
1249
1249
|
|
1250
|
+
it 'should override default values when parameters are passed' do
|
1251
|
+
mock_app do
|
1252
|
+
controller lang: :it do
|
1253
|
+
get(:index, map: '/:lang') { "lang is #{params[:lang]}" }
|
1254
|
+
end
|
1255
|
+
end
|
1256
|
+
assert_equal '/pt', @app.url(:index, lang: 'pt')
|
1257
|
+
get '/pt'
|
1258
|
+
assert_equal 'lang is pt', body
|
1259
|
+
end
|
1260
|
+
|
1250
1261
|
it 'should transitions to the next matching route on pass' do
|
1251
1262
|
mock_app do
|
1252
1263
|
get '/:foo' 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.14.0.
|
4
|
+
version: 0.14.0.rc2
|
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:
|
14
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-support
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.14.0.
|
22
|
+
version: 0.14.0.rc2
|
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.14.0.
|
29
|
+
version: 0.14.0.rc2
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: sinatra
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|