padrino-core 0.12.0.rc3 → 0.12.0
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/application.rb +3 -7
- data/lib/padrino-core/application/authenticity_token.rb +1 -1
- data/lib/padrino-core/application/routing.rb +5 -5
- data/lib/padrino-core/locale/nl.yml +1 -1
- data/lib/padrino-core/reloader.rb +6 -2
- data/lib/padrino-core/support_lite.rb +2 -2
- data/lib/padrino-core/version.rb +1 -1
- data/test/fixtures/apps/static.rb +10 -0
- data/test/test_csrf_protection.rb +15 -0
- data/test/test_reloader_system.rb +13 -1
- data/test/test_routing.rb +8 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef4204b99783ae0f813af61c5ae43a5edb5b9c99
|
4
|
+
data.tar.gz: 9752a0075e390a6fd24c7b56f60b76f1719d3bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f716e4b5e8f068047a87ae18d19dbf2abcdf0ff4bcce8c538a4e05dd7933ac0c3374e80174340d74f80f9d4862da4de097d8d328e4d703e24281dde03aac722
|
7
|
+
data.tar.gz: 3917aed536dedd954528f03e4e650830bc721235b68c8ae07fccb546bef08d7c77a382c95d35ad05a868181d0babf6486ee79474415f53d71c12e5c74bfe7bea
|
@@ -344,13 +344,9 @@ module Padrino
|
|
344
344
|
check_csrf_protection_dependency
|
345
345
|
|
346
346
|
if protect_from_csrf?
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
else
|
351
|
-
builder.use(Rack::Protection::AuthenticityToken,
|
352
|
-
options_for_csrf_protection_setup)
|
353
|
-
end
|
347
|
+
options = options_for_csrf_protection_setup
|
348
|
+
options.merge!(protect_from_csrf) if protect_from_csrf.kind_of?(Hash)
|
349
|
+
builder.use(options[:except] ? Padrino::AuthenticityToken : Rack::Protection::AuthenticityToken, options)
|
354
350
|
end
|
355
351
|
end
|
356
352
|
|
@@ -580,7 +580,7 @@ module Padrino
|
|
580
580
|
name = names[0, 2].join(" ").to_sym # route name is concatenated with underscores
|
581
581
|
if params.is_a?(Hash)
|
582
582
|
params[:format] = params[:format].to_s unless params[:format].nil?
|
583
|
-
params = value_to_param(params)
|
583
|
+
params = value_to_param(params.symbolize_keys)
|
584
584
|
end
|
585
585
|
url =
|
586
586
|
if params_array.empty?
|
@@ -884,10 +884,10 @@ module Padrino
|
|
884
884
|
def provides(*types)
|
885
885
|
@_use_format = true
|
886
886
|
condition do
|
887
|
-
mime_types
|
888
|
-
url_format
|
889
|
-
accepts
|
890
|
-
accepts
|
887
|
+
mime_types = types.map { |t| mime_type(t) }.compact
|
888
|
+
url_format = params[:format].to_sym if params[:format]
|
889
|
+
accepts = request.accept.map(&:to_str)
|
890
|
+
accepts.clear if accepts == ["*/*"]
|
891
891
|
|
892
892
|
# Per rfc2616-sec14:
|
893
893
|
# Assume */* if no ACCEPT header is given.
|
@@ -11,7 +11,7 @@ nl:
|
|
11
11
|
|
12
12
|
day_names: [zondag, maandag, dinsdag, woensdag, donderdag, vrijdag, zaterdag]
|
13
13
|
abbr_day_names: [zo, ma, di, wo, do, vr, za]
|
14
|
-
month_names: [~, januari, februari, maart, april, mei, juni, juli, augustus, september, oktober, november]
|
14
|
+
month_names: [~, januari, februari, maart, april, mei, juni, juli, augustus, september, oktober, november, december]
|
15
15
|
abbr_month_names: [~, jan, feb, maa, apr, mei, jun, jul, aug, sep, okt, nov, dec]
|
16
16
|
order:
|
17
17
|
- day
|
@@ -168,7 +168,7 @@ module Padrino
|
|
168
168
|
update_modification_time(file)
|
169
169
|
else
|
170
170
|
safe_load(file)
|
171
|
-
|
171
|
+
reloadable_apps.each do |app|
|
172
172
|
app.app_obj.reload! if app.app_obj.dependencies.include?(file)
|
173
173
|
end
|
174
174
|
end
|
@@ -222,7 +222,7 @@ module Padrino
|
|
222
222
|
def files_for_rotation
|
223
223
|
files = Set.new
|
224
224
|
Padrino.load_paths.each{ |path| files += Dir.glob("#{path}/**/*.rb") }
|
225
|
-
|
225
|
+
reloadable_apps.each do |app|
|
226
226
|
files << app.app_file
|
227
227
|
files += app.app_obj.dependencies
|
228
228
|
end
|
@@ -233,6 +233,10 @@ module Padrino
|
|
233
233
|
(exclude_constants - include_constants).any?{ |c| const._orig_klass_name.start_with?(c) }
|
234
234
|
end
|
235
235
|
|
236
|
+
def reloadable_apps
|
237
|
+
Padrino.mounted_apps.select{ |app| app.app_obj.respond_to?(:reload) && app.app_obj.reload? }
|
238
|
+
end
|
239
|
+
|
236
240
|
##
|
237
241
|
# Disables output, yields block, switches output back.
|
238
242
|
#
|
@@ -2,9 +2,9 @@
|
|
2
2
|
# This file loads certain extensions required by Padrino from ActiveSupport.
|
3
3
|
#
|
4
4
|
require 'active_support/core_ext/module/aliasing' # alias_method_chain
|
5
|
-
require 'active_support/core_ext/hash/keys' # symbolize_keys
|
6
5
|
require 'active_support/core_ext/hash/reverse_merge' # reverse_merge
|
7
|
-
require 'active_support/core_ext/hash/
|
6
|
+
require 'active_support/core_ext/hash/keys' # symbolize_keys
|
7
|
+
require 'active_support/core_ext/hash/indifferent_access' # params[:foo]
|
8
8
|
require 'active_support/core_ext/hash/slice' # slice
|
9
9
|
require 'active_support/core_ext/object/blank' # present?
|
10
10
|
require 'active_support/core_ext/array/extract_options' # extract_options
|
data/lib/padrino-core/version.rb
CHANGED
@@ -119,6 +119,21 @@ describe "Application" do
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
+
context "with custom protection options" do
|
123
|
+
before do
|
124
|
+
mock_app do
|
125
|
+
enable :sessions
|
126
|
+
set :protect_from_csrf, :authenticity_param => 'foobar'
|
127
|
+
post("/a") { "a" }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
should "allow configuring protection options" do
|
132
|
+
post "/a", {"foobar" => "a"}, 'rack.session' => {:csrf => "a"}
|
133
|
+
assert_equal 200, status
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
122
137
|
context "with middleware" do
|
123
138
|
before do
|
124
139
|
class Middleware < Sinatra::Base
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/kiq')
|
2
3
|
require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/system')
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/static')
|
3
5
|
|
4
6
|
describe "SystemReloader" do
|
5
7
|
context 'for wierd and difficult reload events' do
|
@@ -39,7 +41,7 @@ describe "SystemReloader" do
|
|
39
41
|
File.open(parent_file, "w") { |f| f.write(backup) }
|
40
42
|
end
|
41
43
|
end
|
42
|
-
|
44
|
+
|
43
45
|
should 'tamper with LOAD_PATH' do
|
44
46
|
SystemDemo.load_paths.each do |lib_dir|
|
45
47
|
assert_includes $LOAD_PATH, lib_dir
|
@@ -48,5 +50,15 @@ describe "SystemReloader" do
|
|
48
50
|
assert_includes $LOAD_PATH, lib_dir
|
49
51
|
end
|
50
52
|
end
|
53
|
+
|
54
|
+
should 'not fail horribly on reload event with non-padrino apps' do
|
55
|
+
Padrino.mount("kiq").to("/")
|
56
|
+
Padrino.reload!
|
57
|
+
end
|
58
|
+
|
59
|
+
should 'not reload apps with disabled reload' do
|
60
|
+
Padrino.mount(StaticDemo).to("/")
|
61
|
+
Padrino.reload!
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
data/test/test_routing.rb
CHANGED
@@ -284,6 +284,14 @@ describe "Routing" do
|
|
284
284
|
assert_equal "https://example.org/hash/1", body
|
285
285
|
end
|
286
286
|
|
287
|
+
should 'generate absolute urls from stringified keys' do
|
288
|
+
mock_app do
|
289
|
+
get(:hash, with: :id) { absolute_url(:hash, "id" => 1) }
|
290
|
+
end
|
291
|
+
get "/hash/2"
|
292
|
+
assert_equal "http://example.org/hash/1", body
|
293
|
+
end
|
294
|
+
|
287
295
|
should 'generate proper absolute urls for mounted apps' do
|
288
296
|
class Test < Padrino::Application
|
289
297
|
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.12.0
|
4
|
+
version: 0.12.0
|
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: 2014-
|
14
|
+
date: 2014-02-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: tilt
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- test/fixtures/apps/models/parent.rb
|
182
182
|
- test/fixtures/apps/render.rb
|
183
183
|
- test/fixtures/apps/simple.rb
|
184
|
+
- test/fixtures/apps/static.rb
|
184
185
|
- test/fixtures/apps/system.rb
|
185
186
|
- test/fixtures/apps/views/blog/post.erb
|
186
187
|
- test/fixtures/dependencies/a.rb
|
@@ -227,9 +228,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
227
228
|
version: '0'
|
228
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
230
|
requirements:
|
230
|
-
- - '
|
231
|
+
- - '>='
|
231
232
|
- !ruby/object:Gem::Version
|
232
|
-
version: 1.3.
|
233
|
+
version: 1.3.6
|
233
234
|
requirements: []
|
234
235
|
rubyforge_project: padrino-core
|
235
236
|
rubygems_version: 2.0.6
|
@@ -253,6 +254,7 @@ test_files:
|
|
253
254
|
- test/fixtures/apps/models/parent.rb
|
254
255
|
- test/fixtures/apps/render.rb
|
255
256
|
- test/fixtures/apps/simple.rb
|
257
|
+
- test/fixtures/apps/static.rb
|
256
258
|
- test/fixtures/apps/system.rb
|
257
259
|
- test/fixtures/apps/views/blog/post.erb
|
258
260
|
- test/fixtures/dependencies/a.rb
|