padrino-core 0.13.3 → 0.13.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/padrino-core.rb +2 -2
- data/lib/padrino-core/application/routing.rb +10 -9
- data/lib/padrino-core/cli/adapter.rb +2 -2
- data/lib/padrino-core/cli/rake_tasks.rb +1 -1
- data/lib/padrino-core/mounter.rb +2 -2
- data/lib/padrino-core/server.rb +3 -3
- data/lib/padrino-core/version.rb +1 -1
- data/padrino-core.gemspec +1 -5
- data/test/test_csrf_protection.rb +7 -6
- data/test/test_locale.rb +9 -9
- data/test/test_routing.rb +8 -8
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33124fc7a2cac824324138a48c0fda3a890aae3f
|
4
|
+
data.tar.gz: d051bf2e1b63df26a05aa63cdc6d77e97429c51a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00d7e8413a335c6b8faa73c114f93ecf8bc73174b25f508c71c0f2f939c591029b608a7251ae0944a9378df0c22bf9a26d4c5dba09d3793f8ee06af38400681c
|
7
|
+
data.tar.gz: c874f43d918e9d8f819b69ddeb0e404c0659cc5de995da64774d3f73578fb0b103d66c217d360fc5400dbc99e841f88ae8b60e8c16fae098ab7e83986e22601b
|
data/lib/padrino-core.rb
CHANGED
@@ -68,10 +68,10 @@ module Padrino
|
|
68
68
|
# No applications were mounted.
|
69
69
|
#
|
70
70
|
def application
|
71
|
-
warn 'WARNING! No apps are mounted. Please, mount apps in `config/apps.rb`'
|
71
|
+
warn 'WARNING! No apps are mounted. Please, mount apps in `config/apps.rb`' if Padrino.mounted_apps.empty?
|
72
72
|
router = Padrino::Router.new
|
73
73
|
Padrino.mounted_apps.each { |app| app.map_onto(router) }
|
74
|
-
middleware.
|
74
|
+
middleware.empty? ? router : add_middleware(router)
|
75
75
|
end
|
76
76
|
|
77
77
|
##
|
@@ -340,7 +340,7 @@ module Padrino
|
|
340
340
|
def url(*args)
|
341
341
|
params = args.last.is_a?(Hash) ? args.pop : {}
|
342
342
|
fragment = params.delete(:fragment) || params.delete(:anchor)
|
343
|
-
path = make_path_with_params(args, value_to_param(params
|
343
|
+
path = make_path_with_params(args, value_to_param(params))
|
344
344
|
rebase_url(fragment ? path << '#' << fragment.to_s : path)
|
345
345
|
end
|
346
346
|
alias :url_for :url
|
@@ -377,7 +377,7 @@ module Padrino
|
|
377
377
|
new_url << conform_uri(uri_root) if defined?(uri_root)
|
378
378
|
new_url << url
|
379
379
|
else
|
380
|
-
url.
|
380
|
+
url.empty? ? '/' : url
|
381
381
|
end
|
382
382
|
end
|
383
383
|
|
@@ -398,6 +398,7 @@ module Padrino
|
|
398
398
|
|
399
399
|
private
|
400
400
|
|
401
|
+
# temporary variables named @_parent, @_provides, @_use_format, @_cache, @_expires, @_map, @_conditions, @_accepts, @_params
|
401
402
|
CONTROLLER_OPTIONS = [ :parent, :provides, :use_format, :cache, :expires, :map, :conditions, :accepts, :params ].freeze
|
402
403
|
|
403
404
|
# Saves controller options, yields the block, restores controller options.
|
@@ -624,7 +625,7 @@ module Padrino
|
|
624
625
|
|
625
626
|
unless controller.empty?
|
626
627
|
# Now we need to add our controller path only if not mapped directly
|
627
|
-
if map
|
628
|
+
if !map && !absolute_map
|
628
629
|
controller_path = controller.join("/")
|
629
630
|
path.gsub!(%r{^\(/\)|/\?}, "")
|
630
631
|
path = File.join(controller_path, path) unless @_map
|
@@ -638,7 +639,7 @@ module Padrino
|
|
638
639
|
end
|
639
640
|
|
640
641
|
# Add any controller level map to the front of the path.
|
641
|
-
path = "#{@_map}/#{path}".squeeze('/') unless absolute_map
|
642
|
+
path = "#{@_map}/#{path}".squeeze('/') unless absolute_map || !@_map
|
642
643
|
|
643
644
|
# Small reformats
|
644
645
|
path.gsub!(%r{/\?$}, '(/)') # Remove index path
|
@@ -655,7 +656,7 @@ module Padrino
|
|
655
656
|
name = options.delete(:name) if name.nil? && options.key?(:name)
|
656
657
|
if name
|
657
658
|
controller_name = controller.join("_")
|
658
|
-
name = "#{controller_name} #{name}".to_sym unless controller_name.
|
659
|
+
name = "#{controller_name} #{name}".to_sym unless controller_name.empty?
|
659
660
|
end
|
660
661
|
|
661
662
|
options[:default_values] = @_defaults unless options.has_key?(:default_values)
|
@@ -832,12 +833,12 @@ module Padrino
|
|
832
833
|
#
|
833
834
|
def current_path(*path_params)
|
834
835
|
if path_params.last.is_a?(Hash)
|
835
|
-
path_params[-1] = params.merge(path_params[-1]
|
836
|
+
path_params[-1] = params.merge(path_params[-1])
|
836
837
|
else
|
837
838
|
path_params << params
|
838
839
|
end
|
839
840
|
|
840
|
-
path_params[-1] = path_params[-1]
|
841
|
+
path_params[-1] = Utils.symbolize_keys(path_params[-1])
|
841
842
|
@route.path(*path_params)
|
842
843
|
end
|
843
844
|
|
@@ -960,7 +961,7 @@ module Padrino
|
|
960
961
|
@params, @layout = original_params, parent_layout
|
961
962
|
end
|
962
963
|
|
963
|
-
|
964
|
+
unless routes.empty?
|
964
965
|
verb = request.request_method
|
965
966
|
candidacies, allows = routes.partition{|route| route.verb == verb }
|
966
967
|
if candidacies.empty?
|
@@ -1008,7 +1009,7 @@ module Padrino
|
|
1008
1009
|
end
|
1009
1010
|
|
1010
1011
|
def captures_from_params(params)
|
1011
|
-
if params[:captures].instance_of?(Array) && params[:captures].
|
1012
|
+
if params[:captures].instance_of?(Array) && !params[:captures].empty?
|
1012
1013
|
params.delete(:captures)
|
1013
1014
|
else
|
1014
1015
|
params.values_at(*route.matcher.names).flatten
|
@@ -4,12 +4,12 @@ module Padrino
|
|
4
4
|
class << self
|
5
5
|
# Start for the given options a rackup handler
|
6
6
|
def start(options)
|
7
|
-
Padrino.run!(
|
7
|
+
Padrino.run!(Utils.symbolize_keys(options))
|
8
8
|
end
|
9
9
|
|
10
10
|
# Method that stop (if exist) a running Padrino.application
|
11
11
|
def stop(options)
|
12
|
-
options.symbolize_keys
|
12
|
+
options = Utils.symbolize_keys(options)
|
13
13
|
if File.exist?(options[:pid])
|
14
14
|
pid = File.read(options[:pid]).to_i
|
15
15
|
puts "=> Sending INT to process with pid #{pid}"
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
|
23
23
|
def list_app_routes(app, args)
|
24
24
|
app_routes = app.named_routes
|
25
|
-
app_routes.reject! { |r| r.identifier.to_s !~ /#{args.query}/ } if args.query.
|
25
|
+
app_routes.reject! { |r| r.identifier.to_s !~ /#{args.query}/ } if args.query && !args.query.empty?
|
26
26
|
app_routes.map! { |r| [r.verb, r.name, r.path] }
|
27
27
|
return if app_routes.empty?
|
28
28
|
shell.say "\nApplication: #{app.app_class}", :yellow
|
data/lib/padrino-core/mounter.rb
CHANGED
@@ -130,6 +130,8 @@ module Padrino
|
|
130
130
|
#
|
131
131
|
def named_routes
|
132
132
|
app_obj.routes.map { |route|
|
133
|
+
request_method = route.request_methods.first
|
134
|
+
next if !route.name || request_method == 'HEAD'
|
133
135
|
route_name = route.name.to_s
|
134
136
|
route_name =
|
135
137
|
if route.controller
|
@@ -138,8 +140,6 @@ module Padrino
|
|
138
140
|
":#{route_name}"
|
139
141
|
end
|
140
142
|
name_array = "(#{route_name})"
|
141
|
-
request_method = route.request_methods.first
|
142
|
-
next if route.name.blank? || request_method == 'HEAD'
|
143
143
|
original_path = route.original_path.is_a?(Regexp) ? route.original_path.inspect : route.original_path
|
144
144
|
full_path = File.join(uri_root, original_path)
|
145
145
|
OpenStruct.new(:verb => request_method, :identifier => route.name, :name => name_array, :path => full_path)
|
data/lib/padrino-core/server.rb
CHANGED
@@ -39,11 +39,11 @@ module Padrino
|
|
39
39
|
|
40
40
|
# Starts the application on the available server with specified options.
|
41
41
|
def self.start(app, options={})
|
42
|
-
options = options.to_hash
|
42
|
+
options = Utils.symbolize_keys(options.to_hash)
|
43
43
|
options.update(parse_server_options(options.delete(:options)))
|
44
44
|
options.update(detect_address(options))
|
45
45
|
options[:pid] = prepare_pid(options[:pid]) if options[:daemonize]
|
46
|
-
options[:server]
|
46
|
+
options[:server] ||= detect_rack_handler
|
47
47
|
# disable Webrick AccessLog
|
48
48
|
options[:AccessLog] = []
|
49
49
|
new(options, app).start
|
@@ -95,7 +95,7 @@ module Padrino
|
|
95
95
|
# Prepares a directory for pid file.
|
96
96
|
#
|
97
97
|
def self.prepare_pid(pid)
|
98
|
-
pid
|
98
|
+
pid ||= 'tmp/pids/server.pid'
|
99
99
|
FileUtils.mkdir_p(File.dirname(pid))
|
100
100
|
File.expand_path(pid)
|
101
101
|
end
|
data/lib/padrino-core/version.rb
CHANGED
data/padrino-core.gemspec
CHANGED
@@ -24,11 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.rdoc_options = ["--charset=UTF-8"]
|
25
25
|
|
26
26
|
s.add_dependency("padrino-support", Padrino.version)
|
27
|
-
|
28
|
-
s.add_dependency("sinatra")
|
29
|
-
else
|
30
|
-
s.add_dependency("sinatra", "~> 1.4.6")
|
31
|
-
end
|
27
|
+
s.add_dependency("sinatra", ">= 1.4.6")
|
32
28
|
s.add_dependency("mustermann19")
|
33
29
|
s.add_dependency("thor", "~> 0.18")
|
34
30
|
s.add_dependency("activesupport", ">= 3.1")
|
@@ -6,6 +6,7 @@ describe "Application" do
|
|
6
6
|
describe 'CSRF protection' do
|
7
7
|
describe "with CSRF protection on" do
|
8
8
|
before do
|
9
|
+
@token = Rack::Protection::AuthenticityToken.random_token rescue "a_token"
|
9
10
|
mock_app do
|
10
11
|
enable :sessions
|
11
12
|
enable :protect_from_csrf
|
@@ -19,25 +20,24 @@ describe "Application" do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'should allow requests with correct tokens' do
|
22
|
-
post "/", {"authenticity_token" =>
|
23
|
+
post "/", {"authenticity_token" => @token}, 'rack.session' => {:csrf => @token}
|
23
24
|
assert_equal 200, status
|
24
25
|
end
|
25
26
|
|
26
27
|
it 'should not allow requests with incorrect tokens' do
|
27
|
-
post "/", {"authenticity_token" => "
|
28
|
+
post "/", {"authenticity_token" => "b"}, 'rack.session' => {:csrf => @token}
|
28
29
|
assert_equal 403, status
|
29
30
|
end
|
30
31
|
|
31
32
|
it 'should allow requests with correct X-CSRF-TOKEN' do
|
32
|
-
post "/", {}, 'rack.session' => {:csrf =>
|
33
|
+
post "/", {}, 'rack.session' => {:csrf => @token}, 'HTTP_X_CSRF_TOKEN' => @token
|
33
34
|
assert_equal 200, status
|
34
35
|
end
|
35
36
|
|
36
37
|
it 'should not allow requests with incorrect X-CSRF-TOKEN' do
|
37
|
-
post "/", {}, 'rack.session' => {:csrf =>
|
38
|
+
post "/", {}, 'rack.session' => {:csrf => @token}, 'HTTP_X_CSRF_TOKEN' => "b"
|
38
39
|
assert_equal 403, status
|
39
40
|
end
|
40
|
-
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "without CSRF protection on" do
|
@@ -142,6 +142,7 @@ describe "Application" do
|
|
142
142
|
|
143
143
|
describe "with custom protection options" do
|
144
144
|
before do
|
145
|
+
@token = Rack::Protection::AuthenticityToken.random_token rescue "a_token"
|
145
146
|
mock_app do
|
146
147
|
enable :sessions
|
147
148
|
set :protect_from_csrf, :authenticity_param => 'foobar', :message => 'sucker!'
|
@@ -150,7 +151,7 @@ describe "Application" do
|
|
150
151
|
end
|
151
152
|
|
152
153
|
it 'should allow configuring protection options' do
|
153
|
-
post "/a", {"foobar" =>
|
154
|
+
post "/a", {"foobar" => @token}, 'rack.session' => {:csrf => @token}
|
154
155
|
assert_equal 200, status
|
155
156
|
end
|
156
157
|
|
data/test/test_locale.rb
CHANGED
@@ -6,16 +6,16 @@ describe "Locales" do
|
|
6
6
|
name = File.basename(file, '.yml')
|
7
7
|
it "should should have correct locale for #{name}" do
|
8
8
|
base = base_original[name]['date']['formats']
|
9
|
-
assert base['default']
|
10
|
-
assert base['short']
|
11
|
-
assert base['long']
|
12
|
-
assert base['only_day']
|
9
|
+
assert base['default']
|
10
|
+
assert base['short']
|
11
|
+
assert base['long']
|
12
|
+
assert base['only_day']
|
13
13
|
base = base_original[name]['date']
|
14
|
-
assert base['day_names']
|
15
|
-
assert base['abbr_day_names']
|
16
|
-
assert base['month_names']
|
17
|
-
assert base['abbr_month_names']
|
18
|
-
assert base['order']
|
14
|
+
assert base['day_names']
|
15
|
+
assert base['abbr_day_names']
|
16
|
+
assert base['month_names']
|
17
|
+
assert base['abbr_month_names']
|
18
|
+
assert base['order']
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/test/test_routing.rb
CHANGED
@@ -2149,14 +2149,14 @@ describe "Routing" do
|
|
2149
2149
|
get(:simple, :map => "/simple/:id") { }
|
2150
2150
|
get(:with_format, :with => :id, :provides => :js) { }
|
2151
2151
|
end
|
2152
|
-
assert_equal [:"foo bar", {
|
2153
|
-
assert_equal [:"foo bar", {
|
2154
|
-
assert_equal [:simple, {
|
2155
|
-
assert_equal [:simple, {
|
2156
|
-
assert_equal [:simple, {
|
2157
|
-
assert_equal [:with_format, {
|
2158
|
-
assert_equal [:with_format, {
|
2159
|
-
assert_equal [:with_format, {
|
2152
|
+
assert_equal [:"foo bar", { "id" => "fantastic" }], @app.recognize_path(@app.url(:foo, :bar, :id => :fantastic))
|
2153
|
+
assert_equal [:"foo bar", { "id" => "18" }], @app.recognize_path(@app.url(:foo, :bar, :id => 18))
|
2154
|
+
assert_equal [:simple, { "id" => "bar" }], @app.recognize_path(@app.url(:simple, :id => "bar"))
|
2155
|
+
assert_equal [:simple, { "id" => "true" }], @app.recognize_path(@app.url(:simple, :id => true))
|
2156
|
+
assert_equal [:simple, { "id" => "9" }], @app.recognize_path(@app.url(:simple, :id => 9))
|
2157
|
+
assert_equal [:with_format, { "id" => "bar", "format" => "js" }], @app.recognize_path(@app.url(:with_format, :id => "bar", :format => :js))
|
2158
|
+
assert_equal [:with_format, { "id" => "true", "format" => "js" }], @app.recognize_path(@app.url(:with_format, :id => true, :format => "js"))
|
2159
|
+
assert_equal [:with_format, { "id" => "9", "format" => "js" }], @app.recognize_path(@app.url(:with_format, :id => 9, :format => :js))
|
2160
2160
|
end
|
2161
2161
|
|
2162
2162
|
it 'should have current_path' 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.13.3
|
4
|
+
version: 0.13.3.1
|
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: 2016-08-
|
14
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-support
|
@@ -19,26 +19,26 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.13.3
|
22
|
+
version: 0.13.3.1
|
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.3
|
29
|
+
version: 0.13.3.1
|
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
|
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
238
|
version: 1.3.6
|
239
239
|
requirements: []
|
240
240
|
rubyforge_project: padrino-core
|
241
|
-
rubygems_version: 2.
|
241
|
+
rubygems_version: 2.5.1
|
242
242
|
signing_key:
|
243
243
|
specification_version: 4
|
244
244
|
summary: The required Padrino core gem
|