padrino-core 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,7 +15,6 @@ begin
15
15
  gem.add_runtime_dependency "i18n", ">= 0.3.2"
16
16
  gem.add_runtime_dependency "usher", ">= 0.6.2"
17
17
  gem.add_runtime_dependency "thor", ">= 0.11.8"
18
- gem.add_development_dependency "haml", ">= 2.2.1"
19
18
  gem.add_runtime_dependency "bundler", ">= 0.5.0"
20
19
  gem.add_development_dependency "shoulda", ">= 0"
21
20
  gem.add_development_dependency "mocha", ">= 0.9.7"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -5,7 +5,8 @@ require 'sinatra/base'
5
5
  PADRINO_ENV = ENV["PADRINO_ENV"] ||= ENV["RACK_ENV"] ||= "development" unless defined?(PADRINO_ENV)
6
6
 
7
7
  module Padrino
8
- class ApplicationLoadError < RuntimeError; end
8
+ class ApplicationLoadError < RuntimeError #:nodoc:
9
+ end
9
10
 
10
11
  class << self
11
12
  ##
@@ -1,5 +1,6 @@
1
1
  module Padrino
2
- class ApplicationSetupError < RuntimeError; end
2
+ class ApplicationSetupError < RuntimeError #:nodoc:
3
+ end
3
4
  ##
4
5
  # Subclasses of this become independent Padrino applications (stemming from Sinatra::Application)
5
6
  # These subclassed applications can be easily mounted into other Padrino applications as well.
@@ -11,10 +12,12 @@ module Padrino
11
12
  CALLERS_TO_IGNORE.concat(PADRINO_IGNORE_CALLERS)
12
13
  subclass.default_configuration!
13
14
  Padrino.set_load_paths File.join(subclass.root, "/models")
15
+ Padrino.require_dependencies File.join(subclass.root, "/models.rb")
14
16
  Padrino.require_dependencies File.join(subclass.root, "/models/**/*.rb")
15
17
  super # Loading the subclass
16
18
  subclass.default_filters!
17
19
  subclass.default_routes!
20
+ subclass.default_errors!
18
21
  end
19
22
 
20
23
  ##
@@ -67,6 +70,11 @@ module Padrino
67
70
  ##
68
71
  # Usher router, for fatures and configurations see: http://github.com/joshbuddy/usher
69
72
  #
73
+ # Examples:
74
+ #
75
+ # router.add_route('/greedy/{!:greed,.*}')
76
+ # router.recognize_path('/simple')
77
+ #
70
78
  def router
71
79
  @router ||= Usher.new(:request_methods => [:request_method, :host, :port, :scheme],
72
80
  :ignore_trailing_delimiters => true,
@@ -153,6 +161,7 @@ module Padrino
153
161
  set :raise_errors, true if development?
154
162
  set :logging, false # !test?
155
163
  set :sessions, true
164
+ set :public, Proc.new { Padrino.root('public', self.uri_root) }
156
165
  # Padrino specific
157
166
  set :uri_root, "/"
158
167
  set :reload, development?
@@ -185,10 +194,23 @@ module Padrino
185
194
  #
186
195
  def default_filters!
187
196
  before do
188
- unless options.static? && options.public? && (request.get? || request.head?) && static_file?(request.path_info)
189
- request.path_info =~ /\.([^\.\/]+)$/
190
- @_content_type = ($1 || :html).to_sym
191
- content_type(@_content_type, :charset => 'utf-8') rescue content_type('application/octet-stream')
197
+ request.path_info =~ /\.([^\.\/]+)$/
198
+ @_content_type = ($1 || :html).to_sym
199
+ content_type(@_content_type, :charset => 'utf-8') rescue content_type('application/octet-stream')
200
+ end
201
+ end
202
+
203
+ ##
204
+ # This log errors for production environments
205
+ #
206
+ def default_errors!
207
+ configure :production do
208
+ error ::Exception do
209
+ boom = env['sinatra.error']
210
+ logger.error ["#{boom.class} - #{boom.message}:", *boom.backtrace].join("\n ")
211
+ response.status = 500
212
+ content_type 'text/html'
213
+ '<h1>Internal Server Error</h1>'
192
214
  end
193
215
  end
194
216
  end
@@ -227,7 +249,7 @@ module Padrino
227
249
  # Returns the load_paths for the application (relative to the application root)
228
250
  #
229
251
  def load_paths
230
- @load_paths ||= ["urls.rb", "config/urls.rb", "mailers/*.rb", "controllers/**/*.rb", "helpers/*.rb"]
252
+ @load_paths ||= ["urls.rb", "config/urls.rb", "mailers/*.rb", "controllers/**/*.rb", "controllers.rb", "helpers/*.rb"]
231
253
  end
232
254
 
233
255
  ##
@@ -482,7 +504,8 @@ module Padrino
482
504
  if (options[:layout].nil? || options[:layout] == true) && !self.class.templates.has_key?(:layout)
483
505
  layout = self.class.instance_variable_defined?(:@_layout) ? self.class.instance_variable_get(:@_layout) : :application
484
506
  if layout
485
- options[:layout] = Dir["#{self.options.views}/#{layout}.*"].size == 0 ? File.join('layouts', layout.to_s).to_sym : layout.to_sym
507
+ # We look first for views/layout_name.ext then then for views/layouts/layout_name.ext
508
+ options[:layout] = Dir["#{self.options.views}/#{layout}.*"].present? ? layout.to_sym : File.join('layouts', layout.to_s).to_sym
486
509
  logger.debug "Rendering layout #{options[:layout]}"
487
510
  end
488
511
  end
@@ -234,7 +234,7 @@ module Padrino
234
234
  now = Time.now
235
235
  length = extract_content_length(header)
236
236
 
237
- logger.warn FORMAT % [
237
+ logger.debug FORMAT % [
238
238
  env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
239
239
  env["REMOTE_USER"] || "-",
240
240
  env["REQUEST_METHOD"],
@@ -257,7 +257,7 @@ module Padrino
257
257
  end # Logger
258
258
  end # Padrino
259
259
 
260
- module Kernel
260
+ module Kernel #:nodoc:
261
261
 
262
262
  ##
263
263
  # Define a logger available every where in our app
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-core}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
- s.date = %q{2010-01-31}
12
+ s.date = %q{2010-02-03}
13
13
  s.default_executable = %q{padrino}
14
14
  s.description = %q{The Padrino core gem required for use of this framework}
15
15
  s.email = %q{nesquena@gmail.com}
@@ -81,7 +81,6 @@ Gem::Specification.new do |s|
81
81
  s.add_runtime_dependency(%q<i18n>, [">= 0.3.2"])
82
82
  s.add_runtime_dependency(%q<usher>, [">= 0.6.2"])
83
83
  s.add_runtime_dependency(%q<thor>, [">= 0.11.8"])
84
- s.add_development_dependency(%q<haml>, [">= 2.2.1"])
85
84
  s.add_runtime_dependency(%q<bundler>, [">= 0.5.0"])
86
85
  s.add_development_dependency(%q<shoulda>, [">= 0"])
87
86
  s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
@@ -92,7 +91,6 @@ Gem::Specification.new do |s|
92
91
  s.add_dependency(%q<i18n>, [">= 0.3.2"])
93
92
  s.add_dependency(%q<usher>, [">= 0.6.2"])
94
93
  s.add_dependency(%q<thor>, [">= 0.11.8"])
95
- s.add_dependency(%q<haml>, [">= 2.2.1"])
96
94
  s.add_dependency(%q<bundler>, [">= 0.5.0"])
97
95
  s.add_dependency(%q<shoulda>, [">= 0"])
98
96
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -104,7 +102,6 @@ Gem::Specification.new do |s|
104
102
  s.add_dependency(%q<i18n>, [">= 0.3.2"])
105
103
  s.add_dependency(%q<usher>, [">= 0.6.2"])
106
104
  s.add_dependency(%q<thor>, [">= 0.11.8"])
107
- s.add_dependency(%q<haml>, [">= 2.2.1"])
108
105
  s.add_dependency(%q<bundler>, [">= 0.5.0"])
109
106
  s.add_dependency(%q<shoulda>, [">= 0"])
110
107
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -144,16 +144,16 @@ class TestRouting < Test::Unit::TestCase
144
144
  end
145
145
  get "/a.js"
146
146
  assert_equal "js", body
147
- assert_equal 'application/javascript', response["Content-Type"]
147
+ assert_equal 'application/javascript;charset=utf-8', response["Content-Type"]
148
148
  get "/a.json"
149
149
  assert_equal "json", body
150
- assert_equal 'application/json', response["Content-Type"]
150
+ assert_equal 'application/json;charset=utf-8', response["Content-Type"]
151
151
  get "/a.foo"
152
152
  assert_equal "foo", body
153
153
  assert_equal 'application/octet-stream', response["Content-Type"]
154
154
  get "/a"
155
155
  assert_equal "html", body
156
- assert_equal 'text/html', response["Content-Type"]
156
+ assert_equal 'text/html;charset=utf-8', response["Content-Type"]
157
157
  end
158
158
 
159
159
  should 'use controllers' 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.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2010-01-31 00:00:00 +01:00
15
+ date: 2010-02-03 00:00:00 +01:00
16
16
  default_executable: padrino
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -55,16 +55,6 @@ dependencies:
55
55
  - !ruby/object:Gem::Version
56
56
  version: 0.11.8
57
57
  version:
58
- - !ruby/object:Gem::Dependency
59
- name: haml
60
- type: :development
61
- version_requirement:
62
- version_requirements: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 2.2.1
67
- version:
68
58
  - !ruby/object:Gem::Dependency
69
59
  name: bundler
70
60
  type: :runtime