padrino-core 0.9.18 → 0.9.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,8 +64,8 @@ module Padrino
64
64
  app_obj.set :app_name, app_data.name
65
65
  app_obj.set :app_file, app_data.app_file unless ::File.exist?(app_obj.app_file)
66
66
  app_obj.set :root, app_data.app_root unless app_data.app_root.blank?
67
- app_obj.set :public, Padrino.root('public', app_data.uri_root)
68
- app_obj.set :static, File.exist?(app_obj.public)
67
+ app_obj.set :public, Padrino.root('public', app_data.uri_root) unless File.exists?(app_obj.public)
68
+ app_obj.set :static, File.exist?(app_obj.public) if app_obj.nil?
69
69
  app_obj.setup_application! # We need to initialize here the app.
70
70
  router.map(:to => app_obj, :path => app_data.uri_root, :host => app_data.app_host)
71
71
  end
@@ -70,7 +70,7 @@ module Padrino
70
70
 
71
71
  class UnrecognizedException < RuntimeError #:nodoc:
72
72
  end
73
-
73
+
74
74
  ##
75
75
  # Keeps information about parent scope.
76
76
  #
@@ -80,7 +80,7 @@ module Padrino
80
80
  attr_reader :options
81
81
 
82
82
  alias_method :optional?, :optional
83
-
83
+
84
84
  def initialize(value, options={})
85
85
  super(value.to_s)
86
86
  @map = options.delete(:map)
@@ -88,7 +88,7 @@ module Padrino
88
88
  @options = options
89
89
  end
90
90
  end
91
-
91
+
92
92
  ##
93
93
  # Main class that register this extension
94
94
  #
@@ -175,15 +175,13 @@ module Padrino
175
175
  @_defaults, original_defaults = options, @_defaults
176
176
 
177
177
  # Application defaults
178
- @before_filters, original_before_filters = [], @before_filters
179
- @after_filters, original_after_filters = [], @after_filters
180
- @layout, original_layout = nil, @layout
178
+ @filters, original_filters = { :before => [], :after => [] }, @filters
179
+ @layout, original_layout = nil, @layout
181
180
 
182
181
  instance_eval(&block)
183
182
 
184
183
  # Application defaults
185
- @before_filters = original_before_filters
186
- @after_filters = original_after_filters
184
+ @filters = original_filters
187
185
  @layout = original_layout
188
186
 
189
187
  # Controller defaults
@@ -196,10 +194,10 @@ module Padrino
196
194
  alias :controllers :controller
197
195
 
198
196
  ##
199
- # Provides many parents with shallowing.
197
+ # Provides many parents with shallowing.
200
198
  #
201
199
  # ==== Examples
202
- #
200
+ #
203
201
  # controllers :product do
204
202
  # parent :shop, :optional => true, :map => "/my/stand"
205
203
  # parent :category, :optional => true
@@ -212,7 +210,7 @@ module Padrino
212
210
  # # url_for(:product, :show, :shop_id => 5, :id => 10) => "/my/stand/5/product/show/10"
213
211
  # # url_for(:product, :show, :shop_id => 5, :category_id => 1, :id => 10) => "/my/stand/5/category/1/product/show/10"
214
212
  # end
215
- # end
213
+ # end
216
214
  #
217
215
  def parent(name, options={})
218
216
  defaults = { :optional => false, :map => name.to_s }
@@ -327,7 +325,7 @@ module Padrino
327
325
  else
328
326
  raise
329
327
  end
330
-
328
+
331
329
  # Do padrino parsing. We dup options so we can build HEAD request correctly
332
330
  route_options = options.dup
333
331
  route_options[:provides] = @_provides if @_provides
@@ -357,7 +355,7 @@ module Padrino
357
355
  route.host(options.delete(:host)) if options.key?(:host)
358
356
  route.condition(:user_agent => options.delete(:agent)) if options.key?(:agent)
359
357
  route.default_values = options.delete(:default_values)
360
- options.delete_if do |option, args|
358
+ options.delete_if do |option, args|
361
359
  if route.send(:significant_variable_names).include?(option)
362
360
  route.matching(option => Array(args).first)
363
361
  true
@@ -373,13 +371,13 @@ module Padrino
373
371
 
374
372
  # Add Application defaults
375
373
  if @_controller
376
- route.before_filters = @before_filters
377
- route.after_filters = @after_filters
374
+ route.before_filters = @filters[:before]
375
+ route.after_filters = @filters[:after]
378
376
  route.use_layout = @layout
379
377
  route.controller = Array(@_controller).first.to_s
380
378
  else
381
- route.before_filters = @before_filters || []
382
- route.after_filters = @after_filters || []
379
+ route.before_filters = @filters[:before] || []
380
+ route.after_filters = @filters[:after] || []
383
381
  end
384
382
 
385
383
  route.to(block)
@@ -0,0 +1,31 @@
1
+ "no":
2
+ date:
3
+ formats:
4
+ # Use the strftime parameters for formats.
5
+ # When no format has been given, it uses default.
6
+ # You can provide other formats here if you like!
7
+ default: "%d.%m.%Y"
8
+ short: "%e. %b %Y"
9
+ long: "%e. %B %Y"
10
+
11
+ day_names: [søndag, mandag, tirsdag, onsdag, torsdag, fredag, lørdag]
12
+ abbr_day_names: [sø, ma, ti, 'on', to, fr, lø]
13
+ month_names: [~, januar, februar, mars, april, mai, juni, juli, august, september, oktober, november, desember]
14
+ abbr_month_names: [~, jan, feb, mar, apr, maj, jun, jul, aug, sep, okt, nov, des]
15
+ order: [ :day, :month, :year ]
16
+
17
+ time:
18
+ formats:
19
+ default: "%e. %B %Y, %H:%M"
20
+ short: "%e. %b %Y, %H:%M"
21
+ long: "%A, %e. %B %Y, %H:%M"
22
+ am: ""
23
+ pm: ""
24
+
25
+ # Used in array.to_sentence.
26
+ support:
27
+ array:
28
+ words_connector: ", "
29
+ two_words_connector: " og "
30
+ last_word_connector: " og "
31
+
@@ -49,7 +49,11 @@ module Padrino
49
49
  end
50
50
  rescue RuntimeError => e
51
51
  if e.message =~ /no acceptor/
52
- puts "=> Someone is already performing on port #{port}!"
52
+ if port < 1024 && RUBY_PLATFORM !~ /mswin|win|mingw/ && Process.uid != 0
53
+ puts "=> Only root may open a priviledged port #{port}!"
54
+ else
55
+ puts "=> Someone is already performing on port #{port}!"
56
+ end
53
57
  else
54
58
  raise e
55
59
  end
@@ -67,4 +71,4 @@ module Padrino
67
71
  raise LoadError, "Server handler (#{servers.join(',')}) not found."
68
72
  end
69
73
  end # Server
70
- end # Padrino
74
+ end # Padrino
@@ -5,7 +5,7 @@
5
5
  # without include full padrino core.
6
6
  #
7
7
  module Padrino
8
- VERSION = '0.9.18' unless defined?(Padrino::VERSION)
8
+ VERSION = '0.9.19' unless defined?(Padrino::VERSION)
9
9
  ##
10
10
  # Return the current Padrino version
11
11
  #
data/padrino-core.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.files = %w(.document .gitignore LICENSE README.rdoc Rakefile padrino-core.gemspec) + Dir.glob("{bin,lib,test}/**/*")
18
18
  s.rdoc_options = ["--charset=UTF-8"]
19
19
  s.require_path = "lib"
20
- s.add_dependency("sinatra", ">= 1.0.0")
20
+ s.add_dependency("sinatra", ">= 1.1.0")
21
21
  s.add_dependency("http_router", "~> 0.4.0")
22
22
  s.add_dependency("thor", ">=0.14.3")
23
23
  s.add_dependency("activesupport", ">= 3.0.0")
data/test/test_mounter.rb CHANGED
@@ -146,5 +146,17 @@ class TestMounter < Test::Unit::TestCase
146
146
  get '/demo_2'
147
147
  assert_equal "Im Demo 2", body
148
148
  end
149
+
150
+ should "not clobber the public setting when mounting an app" do
151
+ class ::PublicApp < Padrino::Application
152
+ set :root, "/root"
153
+ set :public, File.expand_path(File.dirname(__FILE__))
154
+ end
155
+
156
+ Padrino.mount("public_app").to("/public")
157
+ res = Rack::MockRequest.new(Padrino.application).get("/public/test_mounter.rb")
158
+ assert res.ok?
159
+ assert_equal File.read(__FILE__), res.body
160
+ end
149
161
  end
150
- end
162
+ end
@@ -32,13 +32,13 @@ class TestSimpleReloader < Test::Unit::TestCase
32
32
  assert_equal 200, status
33
33
  get "/__sinatra__/404.png"
34
34
  assert_equal 200, status
35
- assert_equal "image/png", response["Content-Type"]
35
+ assert_equal "image/png;charset=utf-8", response["Content-Type"]
36
36
  @app.reset_routes!
37
37
  get "/"
38
38
  assert_equal 404, status
39
39
  get "/__sinatra__/404.png"
40
40
  assert_equal 200, status
41
- assert_equal "image/png", response["Content-Type"]
41
+ assert_equal "image/png;charset=utf-8", response["Content-Type"]
42
42
  end
43
43
  end
44
44
 
@@ -74,9 +74,9 @@ class TestSimpleReloader < Test::Unit::TestCase
74
74
  get "/rand"
75
75
  assert ok?
76
76
  last_body = body
77
- assert_equal 2, @app.before_filters.size # one is ours the other is default_filter for content type
77
+ assert_equal 2, @app.filters[:before].size # one is ours the other is default_filter for content type
78
78
  assert_equal 1, @app.errors.size
79
- assert_equal 1, @app.after_filters.size
79
+ assert_equal 1, @app.filters[:after].size
80
80
  assert_equal 2, @app.middleware.size # [Padrino::Logger::Rack, Padrino::Reloader::Rack]
81
81
  assert_equal 4, @app.routes.size # GET+HEAD of "/" + GET+HEAD of "/rand" = 4
82
82
  assert_equal 2, @app.extensions.size # [Padrino::Routing, Padrino::Rendering]
@@ -84,13 +84,13 @@ class TestSimpleReloader < Test::Unit::TestCase
84
84
  @app.reload!
85
85
  get "/rand"
86
86
  assert_not_equal last_body, body
87
- assert_equal 2, @app.before_filters.size # one is ours the other is default_filter for content type
87
+ assert_equal 2, @app.filters[:before].size # one is ours the other is default_filter for content type
88
88
  assert_equal 1, @app.errors.size
89
- assert_equal 1, @app.after_filters.size
89
+ assert_equal 1, @app.filters[:after].size
90
90
  assert_equal 2, @app.middleware.size # only logger Padrino::Logger::Rack
91
91
  assert_equal 4, @app.routes.size # GET+HEAD of "/" = 2
92
92
  assert_equal 2, @app.extensions.size # [Padrino::Routing, Padrino::Rendering]
93
93
  assert_equal 0, @app.templates.size
94
94
  end
95
95
  end
96
- end
96
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 18
10
- version: 0.9.18
9
+ - 19
10
+ version: 0.9.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Padrino Team
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-10-05 00:00:00 -07:00
21
+ date: 2010-11-17 00:00:00 +01:00
22
22
  default_executable: padrino
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -29,12 +29,12 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- hash: 23
32
+ hash: 19
33
33
  segments:
34
34
  - 1
35
+ - 1
35
36
  - 0
36
- - 0
37
- version: 1.0.0
37
+ version: 1.1.0
38
38
  type: :runtime
39
39
  version_requirements: *id001
40
40
  - !ruby/object:Gem::Dependency
@@ -137,6 +137,7 @@ files:
137
137
  - lib/padrino-core/locale/fr.yml
138
138
  - lib/padrino-core/locale/it.yml
139
139
  - lib/padrino-core/locale/nl.yml
140
+ - lib/padrino-core/locale/no.yml
140
141
  - lib/padrino-core/locale/pl.yml
141
142
  - lib/padrino-core/locale/pt_br.yml
142
143
  - lib/padrino-core/locale/ru.yml