padrino-core 0.9.11 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -138,6 +138,8 @@ module Padrino
138
138
  # Padrino.mount_core(:app_file => "/path/to/file", :app_class => "Blog")
139
139
  #
140
140
  def mount_core(*args)
141
+ # TODO Remove this in 0.9.13 or before 1.0
142
+ warn "DEPRECATION! #{Padrino.first_caller}: Padrino.mount_core has been deprecated.\nUse Padrino.mount('AppName').to('/') instead"
141
143
  options = args.extract_options!
142
144
  app_class = args.size > 0 ? args.first.to_s.camelize : nil
143
145
  options.reverse_merge!(:app_class => app_class)
@@ -361,9 +361,8 @@ module Padrino
361
361
  # Allow paths for the given request head or request format
362
362
  #
363
363
  def provides(*types)
364
- mime_types = types.map { |t| mime_type(t) }
365
-
366
364
  condition do
365
+ mime_types = types.map { |t| mime_type(t) }
367
366
  accepts = request.accept.map { |a| a.split(";")[0].strip }
368
367
  matching_types = (accepts & mime_types)
369
368
  request.path_info =~ /\.([^\.\/]+)$/
@@ -378,7 +377,7 @@ module Padrino
378
377
  types.include?(accept_format) ||
379
378
  types.include?(url_format) ||
380
379
  accepts.any? { |a| a == "*/*" } ||
381
- (request.accept.empty? && types.include?(:html))
380
+ ((!url_format) && request.accept.empty? && types.include?(:html))
382
381
 
383
382
  if matched_format
384
383
  @_content_type = url_format || accept_format || :html
@@ -5,7 +5,7 @@
5
5
  # without include full padrino core.
6
6
  #
7
7
  module Padrino
8
- VERSION = '0.9.11' unless defined?(Padrino::VERSION)
8
+ VERSION = '0.9.12' unless defined?(Padrino::VERSION)
9
9
  ##
10
10
  # Return the current Padrino version
11
11
  #
@@ -24,7 +24,7 @@ end
24
24
 
25
25
  ## If you want use this as a standalone app uncomment:
26
26
  #
27
- # Padrino.mount_core("SimpleDemo")
27
+ # Padrino.mount("SimpleDemo").to("/")
28
28
  # Padrino.run! unless Padrino.loaded? # If you enable reloader prevent to re-run the app
29
29
  #
30
30
  # Then run it from your console: ruby -I"lib" test/fixtures/apps/simple.rb
@@ -34,14 +34,14 @@ class TestMounter < Test::Unit::TestCase
34
34
 
35
35
  should 'mount an app' do
36
36
  class ::AnApp < Padrino::Application; end
37
- Padrino.mount_core("an_app")
37
+ Padrino.mount("an_app").to("/")
38
38
  assert_equal AnApp, Padrino.mounted_apps.first.app_obj
39
- assert_equal ["core"], Padrino.mounted_apps.collect(&:name)
39
+ assert_equal ["an_app"], Padrino.mounted_apps.collect(&:name)
40
40
  end
41
41
 
42
42
  should 'mount a core' do
43
- mounter = Padrino.mount_core("test", :app_file => __FILE__)
44
- assert_equal "core", mounter.name
43
+ mounter = Padrino.mount("test", :app_file => __FILE__).to("/")
44
+ assert_equal "test", mounter.name
45
45
  assert_equal "Test", mounter.app_class
46
46
  assert_equal Test, mounter.app_obj
47
47
  assert_equal __FILE__, mounter.app_file
@@ -50,8 +50,8 @@ class TestMounter < Test::Unit::TestCase
50
50
  end
51
51
 
52
52
  should 'mount a core to url' do
53
- mounter = Padrino.mount_core("test", :app_file => __FILE__).to('/me')
54
- assert_equal "core", mounter.name
53
+ mounter = Padrino.mount("test", :app_file => __FILE__).to('/me')
54
+ assert_equal "test", mounter.name
55
55
  assert_equal "Test", mounter.app_class
56
56
  assert_equal Test, mounter.app_obj
57
57
  assert_equal __FILE__, mounter.app_file
@@ -46,8 +46,8 @@ class TestSimpleReloader < Test::Unit::TestCase
46
46
 
47
47
  should 'correctly instantiate SimpleDemo fixture' do
48
48
  Padrino.mounted_apps.clear
49
- Padrino.mount_core("simple_demo")
50
- assert_equal ["core"], Padrino.mounted_apps.collect(&:name)
49
+ Padrino.mount("simple_demo").to("/")
50
+ assert_equal ["simple_demo"], Padrino.mounted_apps.collect(&:name)
51
51
  assert SimpleDemo.reload?
52
52
  assert_match %r{fixtures/apps/simple.rb}, SimpleDemo.app_file
53
53
  end
@@ -302,7 +302,8 @@ class TestRendering < Test::Unit::TestCase
302
302
  get "/foo.js"
303
303
  assert_equal "Im Italian Js", body
304
304
  I18n.locale = :en
305
- assert_raise(RuntimeError) { get "/foo.pk" }
305
+ get "/foo.pk"
306
+ assert_equal 404, status
306
307
  end
307
308
 
308
309
  should 'resolve template content_type and locale with layout' do
@@ -343,7 +344,8 @@ class TestRendering < Test::Unit::TestCase
343
344
  I18n.locale = :en
344
345
  get "/bar.json"
345
346
  assert_equal "Im a json", body
346
- assert_raise(RuntimeError) { get "/bar.pk" }
347
+ get "/bar.pk"
348
+ assert_equal 404, status
347
349
  end
348
350
 
349
351
  should 'renders erb with blocks' do
@@ -105,8 +105,8 @@ class TestRouter < Test::Unit::TestCase
105
105
 
106
106
  should "works with padrino core applications" do
107
107
  Padrino.mounted_apps.clear
108
- Padrino.mount_core("simple_demo").host("padrino.org")
109
- assert_equal ["core"], Padrino.mounted_apps.collect(&:name)
108
+ Padrino.mount("simple_demo").host("padrino.org")
109
+ assert_equal ["simple_demo"], Padrino.mounted_apps.collect(&:name)
110
110
  assert_equal ["padrino.org"], Padrino.mounted_apps.collect(&:app_host)
111
111
 
112
112
  res = Rack::MockRequest.new(Padrino.application).get("/")
@@ -731,6 +731,38 @@ class TestRouting < Test::Unit::TestCase
731
731
  assert_equal "bar2", body
732
732
  end
733
733
 
734
+ should "parse two routes with the same path but different http verbs" do
735
+ mock_app do
736
+ get(:index) { "This is the get index" }
737
+ post(:index) { "This is the post index" }
738
+ end
739
+ get "/"
740
+ assert_equal "This is the get index", body
741
+ post "/"
742
+ assert_equal "This is the post index", body
743
+ end
744
+
745
+ should "parse two routes with the same path but different http verbs and provides" do
746
+ mock_app do
747
+ get(:index, :provides => [:html, :json]) { "This is the get index.#{content_type}" }
748
+ post(:index, :provides => [:html, :json]) { "This is the post index.#{content_type}" }
749
+ end
750
+ get "/"
751
+ assert_equal "This is the get index.html", body
752
+ post "/"
753
+ assert_equal "This is the post index.html", body
754
+ get "/.json"
755
+ assert_equal "This is the get index.json", body
756
+ get "/.js"
757
+ assert_equal 404, status
758
+ assert_match "Sinatra doesn't know this ditty", body
759
+ post "/.json"
760
+ assert_equal "This is the post index.json", body
761
+ post "/.js"
762
+ assert_match "Sinatra doesn't know this ditty", body
763
+ assert_equal 404, status
764
+ end
765
+
734
766
  should "work with params and parent options" do
735
767
  mock_app do
736
768
  controller :test2, :parent => :parent1, :parent1_id => 1 do
@@ -22,7 +22,7 @@ class ServerApp < Padrino::Application; end
22
22
 
23
23
  class ServerTest < Test::Unit::TestCase
24
24
  def setup
25
- Padrino.mount_core("server_app")
25
+ Padrino.mount("server_app").to("/")
26
26
  end
27
27
 
28
28
  context 'for server functionality' do
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-core
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 35
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 9
8
- - 11
9
- version: 0.9.11
9
+ - 12
10
+ version: 0.9.12
10
11
  platform: ruby
11
12
  authors:
12
13
  - Padrino Team
@@ -17,157 +18,167 @@ autorequire:
17
18
  bindir: bin
18
19
  cert_chain: []
19
20
 
20
- date: 2010-06-17 00:00:00 -07:00
21
+ date: 2010-06-19 00:00:00 +02:00
21
22
  default_executable: padrino
22
23
  dependencies:
23
24
  - !ruby/object:Gem::Dependency
24
- name: sinatra
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
+ hash: 23
30
31
  segments:
31
32
  - 1
32
33
  - 0
33
34
  - 0
34
35
  version: 1.0.0
35
36
  type: :runtime
37
+ name: sinatra
36
38
  prerelease: false
37
39
  version_requirements: *id001
38
40
  - !ruby/object:Gem::Dependency
39
- name: http_router
40
41
  requirement: &id002 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
43
44
  - - ">="
44
45
  - !ruby/object:Gem::Version
46
+ hash: 29
45
47
  segments:
46
48
  - 0
47
49
  - 2
48
- - 3
49
- version: 0.2.3
50
+ - 5
51
+ version: 0.2.5
50
52
  type: :runtime
53
+ name: http_router
51
54
  prerelease: false
52
55
  version_requirements: *id002
53
56
  - !ruby/object:Gem::Dependency
54
- name: thor
55
57
  requirement: &id003 !ruby/object:Gem::Requirement
56
58
  none: false
57
59
  requirements:
58
60
  - - ">="
59
61
  - !ruby/object:Gem::Version
62
+ hash: 43
60
63
  segments:
61
64
  - 0
62
65
  - 13
63
66
  - 0
64
67
  version: 0.13.0
65
68
  type: :runtime
69
+ name: thor
66
70
  prerelease: false
67
71
  version_requirements: *id003
68
72
  - !ruby/object:Gem::Dependency
69
- name: activesupport
70
73
  requirement: &id004 !ruby/object:Gem::Requirement
71
74
  none: false
72
75
  requirements:
73
76
  - - ">="
74
77
  - !ruby/object:Gem::Version
78
+ hash: 19
75
79
  segments:
76
80
  - 2
77
81
  - 3
78
82
  - 8
79
83
  version: 2.3.8
80
84
  type: :runtime
85
+ name: activesupport
81
86
  prerelease: false
82
87
  version_requirements: *id004
83
88
  - !ruby/object:Gem::Dependency
84
- name: rake
85
89
  requirement: &id005 !ruby/object:Gem::Requirement
86
90
  none: false
87
91
  requirements:
88
92
  - - ">="
89
93
  - !ruby/object:Gem::Version
94
+ hash: 49
90
95
  segments:
91
96
  - 0
92
97
  - 8
93
98
  - 7
94
99
  version: 0.8.7
95
100
  type: :development
101
+ name: rake
96
102
  prerelease: false
97
103
  version_requirements: *id005
98
104
  - !ruby/object:Gem::Dependency
99
- name: mocha
100
105
  requirement: &id006 !ruby/object:Gem::Requirement
101
106
  none: false
102
107
  requirements:
103
108
  - - ">="
104
109
  - !ruby/object:Gem::Version
110
+ hash: 43
105
111
  segments:
106
112
  - 0
107
113
  - 9
108
114
  - 8
109
115
  version: 0.9.8
110
116
  type: :development
117
+ name: mocha
111
118
  prerelease: false
112
119
  version_requirements: *id006
113
120
  - !ruby/object:Gem::Dependency
114
- name: rack-test
115
121
  requirement: &id007 !ruby/object:Gem::Requirement
116
122
  none: false
117
123
  requirements:
118
124
  - - ">="
119
125
  - !ruby/object:Gem::Version
126
+ hash: 11
120
127
  segments:
121
128
  - 0
122
129
  - 5
123
130
  - 0
124
131
  version: 0.5.0
125
132
  type: :development
133
+ name: rack-test
126
134
  prerelease: false
127
135
  version_requirements: *id007
128
136
  - !ruby/object:Gem::Dependency
129
- name: webrat
130
137
  requirement: &id008 !ruby/object:Gem::Requirement
131
138
  none: false
132
139
  requirements:
133
140
  - - ">="
134
141
  - !ruby/object:Gem::Version
142
+ hash: 9
135
143
  segments:
136
144
  - 0
137
145
  - 5
138
146
  - 1
139
147
  version: 0.5.1
140
148
  type: :development
149
+ name: webrat
141
150
  prerelease: false
142
151
  version_requirements: *id008
143
152
  - !ruby/object:Gem::Dependency
144
- name: haml
145
153
  requirement: &id009 !ruby/object:Gem::Requirement
146
154
  none: false
147
155
  requirements:
148
156
  - - ">="
149
157
  - !ruby/object:Gem::Version
158
+ hash: 43
150
159
  segments:
151
160
  - 2
152
161
  - 2
153
162
  - 22
154
163
  version: 2.2.22
155
164
  type: :development
165
+ name: haml
156
166
  prerelease: false
157
167
  version_requirements: *id009
158
168
  - !ruby/object:Gem::Dependency
159
- name: shoulda
160
169
  requirement: &id010 !ruby/object:Gem::Requirement
161
170
  none: false
162
171
  requirements:
163
172
  - - ">="
164
173
  - !ruby/object:Gem::Version
174
+ hash: 33
165
175
  segments:
166
176
  - 2
167
177
  - 10
168
178
  - 3
169
179
  version: 2.10.3
170
180
  type: :development
181
+ name: shoulda
171
182
  prerelease: false
172
183
  version_requirements: *id010
173
184
  description: The Padrino core gem required for use of this framework
@@ -250,6 +261,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
250
261
  requirements:
251
262
  - - ">="
252
263
  - !ruby/object:Gem::Version
264
+ hash: 3
253
265
  segments:
254
266
  - 0
255
267
  version: "0"
@@ -258,6 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
270
  requirements:
259
271
  - - ">="
260
272
  - !ruby/object:Gem::Version
273
+ hash: 23
261
274
  segments:
262
275
  - 1
263
276
  - 3