padrino-core 0.13.1.beta1 → 0.13.1

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: af7cd163789baddaf975d9fba8d190c6ebc9ac3a
4
- data.tar.gz: 5436fc024ed5e7c1cdd605d82e8ca087366c72d3
3
+ metadata.gz: 3fc93251e3aa682cd94a019446ab096a31f4365d
4
+ data.tar.gz: b7c3653e92dc92655372e0359422307d84122b19
5
5
  SHA512:
6
- metadata.gz: 6796d2b316dc62d1007c71efc1f8513df379f8852f6633aca39d12daaa00535c7e107ea2cdc4c002dd01c83efe8c1b73dadcd3bb1bcc1bcf5d6df72f713a4af5
7
- data.tar.gz: 082b444f689877f4d5bcaa9c31ebbf100fa427458ca6c7900a9ec20998875eb04b3235746c37adc28e2808580fa0a2a8bb5cec865718a3a1ceaf421e6c71d3fb
6
+ metadata.gz: 54ff19551060bd54f259c55cf383ab8a39a737a4e31fa3ebd03dd44e2353a41dac726478ebfb42af22fc0a412abef9579e88e8d4adb240df6348fc943cba7f98
7
+ data.tar.gz: 54d8d4b3a35ffc91e16180b342fdcc8d04d043eb085f2e0e52bb88ee9b4ec3cbee00c9a016e6a972b29951abf772ac0ff6381e7abc7cd72ddf18484ff9abe1dd
@@ -38,7 +38,11 @@ module Padrino
38
38
  #
39
39
  def expand(params)
40
40
  params = params.merge(@default_values) if @default_values.is_a?(Hash)
41
+ params, query = params.each_with_object([{}, {}]) do |(key, val), parts|
42
+ parts[handler.names.include?(key.to_s) ? 0 : 1][key] = val
43
+ end
41
44
  expanded_path = handler.expand(:append, params)
45
+ expanded_path += ?? + Padrino::Utils.build_uri_query(query) unless query.empty?
42
46
  expanded_path
43
47
  end
44
48
 
@@ -11,12 +11,15 @@ module Padrino
11
11
  @app = app
12
12
  @cooldown = cooldown
13
13
  @last = (Time.now - cooldown)
14
+ @mutex = Mutex.new
14
15
  end
15
16
 
16
17
  # Invoked in order to perform the reload as part of the request stack.
17
18
  def call(env)
18
19
  if @cooldown && Time.now > @last + @cooldown
19
- Thread.list.size > 1 ? Thread.exclusive { Padrino.reload! } : Padrino.reload!
20
+ @mutex.synchronize do
21
+ Padrino.reload!
22
+ end
20
23
  @last = Time.now
21
24
  end
22
25
  @app.call(env)
@@ -221,7 +221,9 @@ module Padrino
221
221
  #
222
222
  def files_for_rotation
223
223
  files = Set.new
224
- files += Dir.glob("#{Padrino.root}/{lib,models,shared}/**/*.rb")
224
+ Padrino.dependency_paths.each do |path|
225
+ files += Dir.glob(path)
226
+ end
225
227
  reloadable_apps.each do |app|
226
228
  files << app.app_file
227
229
  files += Dir.glob(app.app_obj.prerequisites)
@@ -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.1.beta1' unless defined?(Padrino::VERSION)
9
+ VERSION = '0.13.1' unless defined?(Padrino::VERSION)
10
10
 
11
11
  #
12
12
  # The current Padrino version.
@@ -0,0 +1,11 @@
1
+ PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
2
+
3
+ class CustomDependencies < Padrino::Application
4
+ set :reload, true
5
+ end
6
+
7
+ CustomDependencies.controllers do
8
+ get "/" do
9
+ "foo"
10
+ end
11
+ end
@@ -149,11 +149,18 @@ describe "Application" do
149
149
  assert_equal 'custom error', body
150
150
  end
151
151
 
152
- it 'should raise NameError even if Kernel.require is extended' do
153
- assert_raises NameError do
152
+ it 'should pass Routing#parent to Module#parent' do
153
+ # see naming collision in issue #1814
154
+ begin
154
155
  ConstTest = Class.new(Padrino::Application)
155
- require 'active_support/dependencies'
156
- ConstTest::UninitializedConstant
156
+ class Module
157
+ def parent
158
+ :dirty
159
+ end
160
+ end
161
+ assert_equal :dirty, ConstTest.parent
162
+ ensure
163
+ Module.instance_eval{ undef :parent }
157
164
  end
158
165
  end
159
166
  end
@@ -1,5 +1,4 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/helper')
2
- require 'active_support/core_ext/hash/conversions'
3
2
 
4
3
  describe "Padrino::ParamsProtection" do
5
4
  before do
@@ -7,6 +6,7 @@ describe "Padrino::ParamsProtection" do
7
6
  @kim = { 'name' => 'Kim Bauer', 'position' => 'daughter', 'child' => @teri }
8
7
  @jack = { 'name' => 'Jack Bauer', 'position' => 'terrorist', 'child' => @kim }
9
8
  @family = { 'name' => 'Bauer', 'persons' => { 1 => @teri, 2 => @kim, 3 => @jack } }
9
+ @jack_query = Padrino::Utils.build_uri_query(@jack)
10
10
  end
11
11
 
12
12
  it 'should drop all parameters except allowed ones' do
@@ -17,7 +17,7 @@ describe "Padrino::ParamsProtection" do
17
17
  ''
18
18
  end
19
19
  end
20
- post '/basic?' + @jack.to_query
20
+ post '/basic?' + @jack_query
21
21
  assert_equal({ 'name' => @jack['name'] }, result)
22
22
  end
23
23
 
@@ -29,7 +29,7 @@ describe "Padrino::ParamsProtection" do
29
29
  ''
30
30
  end
31
31
  end
32
- post '/basic?' + @jack.to_query
32
+ post '/basic?' + @jack_query
33
33
  assert_equal(@jack, result)
34
34
  end
35
35
 
@@ -41,7 +41,7 @@ describe "Padrino::ParamsProtection" do
41
41
  ''
42
42
  end
43
43
  end
44
- post '/basic?' + @jack.to_query
44
+ post '/basic?' + @jack_query
45
45
  assert_equal(
46
46
  [
47
47
  { 'name' => @jack['name'], 'child' => { 'name' => @kim['name'], 'child' => { 'name' => @teri['name'] } } },
@@ -59,7 +59,7 @@ describe "Padrino::ParamsProtection" do
59
59
  ''
60
60
  end
61
61
  end
62
- post '/basic?' + @jack.to_query
62
+ post '/basic?' + @jack_query
63
63
  assert_equal({ 'name' => @jack['name'], 'position' => 'anti-terrorist' }, result)
64
64
  end
65
65
 
@@ -71,7 +71,7 @@ describe "Padrino::ParamsProtection" do
71
71
  ''
72
72
  end
73
73
  end
74
- post '/basic/24/42?' + @jack.to_query
74
+ post '/basic/24/42?' + @jack_query
75
75
  assert_equal({ 'name' => @jack['name'], 'id' => '24', 'tag' => '42' }, result)
76
76
  end
77
77
 
@@ -83,7 +83,7 @@ describe "Padrino::ParamsProtection" do
83
83
  ''
84
84
  end
85
85
  end
86
- post '/basic/24?' + @jack.to_query
86
+ post '/basic/24?' + @jack_query
87
87
  assert_equal({ 'id' => '24' }, result)
88
88
  end
89
89
 
@@ -99,9 +99,9 @@ describe "Padrino::ParamsProtection" do
99
99
  ''
100
100
  end
101
101
  end
102
- get '/hide/1?' + @jack.to_query
102
+ get '/hide/1?' + @jack_query
103
103
  assert_equal({"id"=>"1"}, result)
104
- get '/show/1?' + @jack.to_query
104
+ get '/show/1?' + @jack_query
105
105
  assert_equal({"id"=>"1"}.merge(@jack), result)
106
106
  end
107
107
 
@@ -133,13 +133,13 @@ describe "Padrino::ParamsProtection" do
133
133
  end
134
134
  end
135
135
  end
136
- post '/persons/create?' + @jack.to_query
136
+ post '/persons/create?' + @jack_query
137
137
  assert_equal({ 'name' => @jack['name'], 'position' => 'terrorist' }, result)
138
138
  post '/persons/update/1?name=Chloe+O\'Brian&position=hacker'
139
139
  assert_equal({ 'id' => '1', 'name' => 'Chloe O\'Brian' }, result)
140
- post '/persons/delete?' + @jack.to_query
140
+ post '/persons/delete?' + @jack_query
141
141
  assert_equal(@jack, result)
142
- post '/persons/destroy/1?' + @jack.to_query
142
+ post '/persons/destroy/1?' + @jack_query
143
143
  assert_equal({"id"=>"1"}, result)
144
144
  get '/noparam?a=1;b=2'
145
145
  assert_equal({}, result)
@@ -153,7 +153,7 @@ describe "Padrino::ParamsProtection" do
153
153
  ''
154
154
  end
155
155
  end
156
- post '/family?' + @family.to_query
156
+ post '/family?' + Padrino::Utils.build_uri_query(@family)
157
157
  assert_equal({"persons" => {"3" => {"name" => @jack["name"]}, "2" => {"name" => @kim["name"]}, "1" => {"name" => @teri["name"]}}}, result)
158
158
  end
159
159
 
@@ -165,7 +165,7 @@ describe "Padrino::ParamsProtection" do
165
165
  ''
166
166
  end
167
167
  end
168
- post '/family?' + { :names => %w{Jack Kim Teri} }.to_query
168
+ post '/family?' + Padrino::Utils.build_uri_query(:names => %w{Jack Kim Teri})
169
169
  assert_equal({"names" => %w[Jack Kim Teri]}, result)
170
170
  end
171
171
 
@@ -177,7 +177,7 @@ describe "Padrino::ParamsProtection" do
177
177
  ''
178
178
  end
179
179
  end
180
- post '/i?' + { :gotta => { :what => 'go', :who => 'self' } }.to_query
180
+ post '/i?' + Padrino::Utils.build_uri_query(:gotta => { :what => 'go', :who => 'self' })
181
181
  assert_equal({"gotta" => {"what" => "go"}}, result)
182
182
  end
183
183
 
@@ -2,6 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/helper')
2
2
  require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/kiq')
3
3
  require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/system')
4
4
  require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/static')
5
+ require File.expand_path(File.dirname(__FILE__) + '/fixtures/apps/custom_dependencies/custom_dependencies')
5
6
 
6
7
  describe "SystemReloader" do
7
8
  describe 'for wierd and difficult reload events' do
@@ -120,4 +121,23 @@ describe "SystemReloader" do
120
121
  Padrino.reload!
121
122
  end
122
123
  end
124
+
125
+ describe 'reloading custom dependencies' do
126
+ let(:custom_dependency_path) { File.dirname(__FILE__) + '/fixtures/apps/custom_dependencies/my_dependencies' }
127
+ let(:custom_dependency) { File.join(custom_dependency_path, 'my_dependency.rb') }
128
+
129
+ before do
130
+ @app = CustomDependencies
131
+ Padrino.clear!
132
+ Padrino.mount(CustomDependencies).to("/")
133
+ Padrino.dependency_paths << custom_dependency_path + '/*.rb'
134
+ Padrino.load!
135
+ get '/'
136
+ end
137
+
138
+ it 'should discover changed dependencies' do
139
+ FileUtils.touch(custom_dependency)
140
+ assert Padrino::Reloader.changed?, 'Change to custom dependency has not been recognised'
141
+ end
142
+ end
123
143
  end
data/test/test_routing.rb CHANGED
@@ -259,6 +259,7 @@ describe "Routing" do
259
259
  get(:anchor) { url(:anchor, :anchor => 'comments') }
260
260
  get(:fragment) { url(:anchor, :fragment => 'comments') }
261
261
  get(:fragment2) { url(:anchor, :fragment => :comments) }
262
+ get(:gangsta) { url(:gangsta, :foo => { :bar => :baz }, :hoge => :fuga) }
262
263
  get([:hash, :id]){ url(:hash, :id => 1) }
263
264
  get(:array, :with => :id){ url(:array, 23) }
264
265
  get([:array, :id]){ url(:array, 23) }
@@ -307,6 +308,8 @@ describe "Routing" do
307
308
  assert_equal "/drugs/123/destroy", body
308
309
  delete "/123/destroy"
309
310
  assert_equal "/123/destroy", body
311
+ get "/gangsta"
312
+ assert_equal "/gangsta?foo%5Bbar%5D=baz&hoge=fuga", body
310
313
  get "/splatter/123/456"
311
314
  assert_equal "/splatter/123/456", body
312
315
  end
@@ -2077,7 +2080,7 @@ describe "Routing" do
2077
2080
  mock_app do
2078
2081
  get(:index) { "%s %s" % [params[:account][:name], params[:account][:surname]] }
2079
2082
  end
2080
- get "/?" + { :account => { :name => 'foo', :surname => 'bar' } }.to_query
2083
+ get "/?" + Padrino::Utils.build_uri_query(:account => { :name => 'foo', :surname => 'bar' })
2081
2084
  assert_equal 'foo bar', body
2082
2085
  get @app.url(:index, "account[name]" => "foo", "account[surname]" => "bar")
2083
2086
  assert_equal 'foo bar', body
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.1.beta1
4
+ version: 0.13.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: 2015-10-18 00:00:00.000000000 Z
14
+ date: 2016-01-17 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.1.beta1
22
+ version: 0.13.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.1.beta1
29
+ version: 0.13.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
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
@@ -157,6 +157,8 @@ files:
157
157
  - test/fixtures/app_gem/lib/app_gem.rb
158
158
  - test/fixtures/app_gem/lib/app_gem/version.rb
159
159
  - test/fixtures/apps/complex.rb
160
+ - test/fixtures/apps/custom_dependencies/custom_dependencies.rb
161
+ - test/fixtures/apps/custom_dependencies/my_dependencies/my_dependency.rb
160
162
  - test/fixtures/apps/demo_app.rb
161
163
  - test/fixtures/apps/demo_demo.rb
162
164
  - test/fixtures/apps/demo_project/api/app.rb
@@ -218,19 +220,19 @@ licenses:
218
220
  metadata: {}
219
221
  post_install_message:
220
222
  rdoc_options:
221
- - "--charset=UTF-8"
223
+ - --charset=UTF-8
222
224
  require_paths:
223
225
  - lib
224
226
  required_ruby_version: !ruby/object:Gem::Requirement
225
227
  requirements:
226
- - - ">="
228
+ - - '>='
227
229
  - !ruby/object:Gem::Version
228
230
  version: '0'
229
231
  required_rubygems_version: !ruby/object:Gem::Requirement
230
232
  requirements:
231
- - - ">"
233
+ - - '>='
232
234
  - !ruby/object:Gem::Version
233
- version: 1.3.1
235
+ version: 1.3.6
234
236
  requirements: []
235
237
  rubyforge_project: padrino-core
236
238
  rubygems_version: 2.4.8
@@ -244,6 +246,8 @@ test_files:
244
246
  - test/fixtures/app_gem/lib/app_gem.rb
245
247
  - test/fixtures/app_gem/lib/app_gem/version.rb
246
248
  - test/fixtures/apps/complex.rb
249
+ - test/fixtures/apps/custom_dependencies/custom_dependencies.rb
250
+ - test/fixtures/apps/custom_dependencies/my_dependencies/my_dependency.rb
247
251
  - test/fixtures/apps/demo_app.rb
248
252
  - test/fixtures/apps/demo_demo.rb
249
253
  - test/fixtures/apps/demo_project/api/app.rb