padrino-core 0.10.0 → 0.10.1

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.
@@ -2,12 +2,7 @@ require 'http_router' unless defined?(HttpRouter)
2
2
  require 'padrino-core/support_lite' unless defined?(SupportLite)
3
3
 
4
4
  class Sinatra::Request #:nodoc:
5
- attr_accessor :route_obj, :runner
6
-
7
- def runner=(runner)
8
- @runner = runner
9
- env['padrino.instance'] = runner
10
- end
5
+ attr_accessor :route_obj
11
6
 
12
7
  def controller
13
8
  route_obj && route_obj.controller
@@ -19,7 +14,7 @@ class HttpRouter #:nodoc:
19
14
  def rewrite_path_info(env, request); end
20
15
 
21
16
  def process_destination_path(path, env)
22
- env['padrino.instance'].instance_eval do
17
+ Thread.current['padrino.instance'].instance_eval do
23
18
  request.route_obj = path.route
24
19
  @_response_buffer = nil
25
20
  @params ||= {}
@@ -95,10 +90,9 @@ module Padrino
95
90
  end
96
91
 
97
92
  def apply?(request)
98
- return true if @args.empty? && @options.empty?
99
93
  detect = @args.any? do |arg|
100
94
  case arg
101
- when Symbol then request.route_obj.named == arg or request.route_obj.named == [@scoped_controller, arg].flatten.join("_").to_sym
95
+ when Symbol then request.route_obj && (request.route_obj.named == arg or request.route_obj.named == [@scoped_controller, arg].flatten.join("_").to_sym)
102
96
  else arg === request.path_info
103
97
  end
104
98
  end || @options.any? { |name, val|
@@ -111,10 +105,12 @@ module Padrino
111
105
  end
112
106
 
113
107
  def to_proc
114
- filter = self
115
- proc {
116
- instance_eval(&filter.block) if filter.apply?(request)
117
- }
108
+ if @args.empty? && @options.empty?
109
+ block
110
+ else
111
+ filter = self
112
+ proc { instance_eval(&filter.block) if filter.apply?(request) }
113
+ end
118
114
  end
119
115
  end
120
116
 
@@ -618,7 +614,7 @@ module Padrino
618
614
  def process_path_for_parent_params(path, parent_params)
619
615
  parent_prefix = parent_params.flatten.compact.uniq.map do |param|
620
616
  map = (param.respond_to?(:map) && param.map ? param.map : param.to_s)
621
- part = "#{map}/:#{param}_id/"
617
+ part = "#{map}/:#{param.to_s.singularize}_id/"
622
618
  part = "(#{part})" if param.respond_to?(:optional) && param.optional?
623
619
  part
624
620
  end
@@ -665,7 +661,7 @@ module Padrino
665
661
  condition do
666
662
  mime_types = types.map { |t| mime_type(t) }
667
663
  request.path_info =~ /\.([^\.\/]+)$/
668
- url_format = $1.to_sym if $1
664
+ url_format = params[:format].to_sym if params[:format]
669
665
  accepts = request.accept.map { |a| a.split(";")[0].strip }
670
666
 
671
667
  # per rfc2616-sec14:
@@ -673,9 +669,7 @@ module Padrino
673
669
  catch_all = (accepts.delete "*/*" || accepts.empty?)
674
670
  matching_types = accepts.empty? ? mime_types.slice(0,1) : (accepts & mime_types)
675
671
 
676
- if params[:format]
677
- accept_format = params[:format]
678
- elsif !url_format && matching_types.first
672
+ if !url_format && matching_types.first
679
673
  type = ::Rack::Mime::MIME_TYPES.find { |k, v| v == matching_types.first }[0].sub(/\./,'').to_sym
680
674
  accept_format = CONTENT_TYPE_ALIASES[type] || type
681
675
  elsif catch_all
@@ -784,16 +778,18 @@ module Padrino
784
778
  static! if settings.static? && (request.get? || request.head?)
785
779
  route!
786
780
  rescue Sinatra::NotFound => boom
781
+ filter! :before
787
782
  handle_not_found!(boom)
788
783
  rescue ::Exception => boom
784
+ filter! :before
789
785
  handle_exception!(boom)
790
786
  ensure
791
787
  @_pending_after_filters.each { |filter| instance_eval(&filter)} if @_pending_after_filters
792
788
  end
793
789
 
794
790
  def route!(base=self.class, pass_block=nil)
795
- @request.env['padrino.instance'] = self
796
- if base.compiled_router and match = base.router.call(@request.env)
791
+ Thread.current['padrino.instance'] = self
792
+ if base.compiled_router and match = base.compiled_router.call(@request.env)
797
793
  if match.respond_to?(:each)
798
794
  route_eval do
799
795
  match[1].each {|k,v| response[k] = v}
@@ -818,4 +814,4 @@ module Padrino
818
814
  end
819
815
  end # InstanceMethods
820
816
  end # Routing
821
- end # Padrino
817
+ end # Padrino
@@ -3,16 +3,17 @@ module Padrino
3
3
  # This module extend Sinatra::ShowExceptions adding Padrino as "Framework"
4
4
  #
5
5
  class ShowExceptions < Sinatra::ShowExceptions
6
- def frame_class(frame)
7
- if frame.filename =~ /lib\/sinatra.*\.rb|lib\/padrino.*\.rb/
8
- "framework"
9
- elsif (defined?(Gem) && frame.filename.include?(Gem.dir)) ||
10
- frame.filename =~ /\/bin\/(\w+)$/ ||
11
- frame.filename =~ /Ruby\/Gems/
12
- "system"
13
- else
14
- "app"
6
+ private
7
+ def frame_class(frame)
8
+ if frame.filename =~ /lib\/sinatra.*\.rb|lib\/padrino.*\.rb/
9
+ "framework"
10
+ elsif (defined?(Gem) && frame.filename.include?(Gem.dir)) ||
11
+ frame.filename =~ /\/bin\/(\w+)$/ ||
12
+ frame.filename =~ /Ruby\/Gems/
13
+ "system"
14
+ else
15
+ "app"
16
+ end
15
17
  end
16
- end
17
18
  end # ShowExceptions
18
- end # Padrino
19
+ end # Padrino
@@ -186,7 +186,7 @@ module Padrino
186
186
  #
187
187
  def default_routes!
188
188
  configure :development do
189
- get '/__sinatra__/:image.png' do
189
+ get '*__sinatra__/:image.png' do
190
190
  content_type :png
191
191
  filename = File.dirname(__FILE__) + "/images/#{params[:image]}.png"
192
192
  send_file filename
@@ -16,8 +16,8 @@ module Padrino
16
16
  #
17
17
  def self.ruby_command
18
18
  @ruby_command ||= begin
19
- ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
20
- ruby << Config::CONFIG['EXEEXT']
19
+ ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
20
+ ruby << RbConfig::CONFIG['EXEEXT']
21
21
 
22
22
  # escape string in case path to ruby executable contain spaces.
23
23
  ruby.sub!(/.*\s.*/m, '"\&"')
@@ -1,4 +1,4 @@
1
- cz:
1
+ cs:
2
2
  date:
3
3
  formats:
4
4
  # Use the strftime parameters for formats.
@@ -7,6 +7,7 @@ cz:
7
7
  default: "%d. %m. %Y"
8
8
  short: "%d %b"
9
9
  long: "%d. %B %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Neděle, Pondělí, Úterý, Středa, Čtvrtek, Pátek, Sobota]
12
13
  abbr_day_names: [Ne, Po, Út, St, Čt, Pá, So]
@@ -7,6 +7,7 @@ da:
7
7
  default: "%d.%m.%Y"
8
8
  short: "%e. %b %Y"
9
9
  long: "%e. %B %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [søndag, mandag, tirsdag, onsdag, torsdag, fredag, lørdag]
12
13
  abbr_day_names: [sø, ma, ti, 'on', to, fr, lø]
@@ -27,4 +28,4 @@ da:
27
28
  array:
28
29
  words_connector: ", "
29
30
  two_words_connector: " og "
30
- last_word_connector: " og "
31
+ last_word_connector: " og "
@@ -7,6 +7,7 @@ de:
7
7
  default: "&d.&m.%Y"
8
8
  short: "%b %d"
9
9
  long: "%B %d, %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Sonntag, Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag]
12
13
  abbr_day_names: [So, Mo, Di, Mi, Do, Fr, Sa]
@@ -27,4 +28,4 @@ de:
27
28
  array:
28
29
  words_connector: ", "
29
30
  two_words_connector: " und "
30
- last_word_connector: ", und "
31
+ last_word_connector: ", und "
@@ -7,6 +7,7 @@ en:
7
7
  default: "%Y-%m-%d"
8
8
  short: "%b %d"
9
9
  long: "%B %d, %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
12
13
  abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
@@ -27,4 +28,4 @@ en:
27
28
  array:
28
29
  words_connector: ", "
29
30
  two_words_connector: " and "
30
- last_word_connector: ", and "
31
+ last_word_connector: ", and "
@@ -7,6 +7,7 @@ es:
7
7
  default: "%d-%m-%Y"
8
8
  short: "%b %d"
9
9
  long: "%B %d, %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Domingo, Lunes, Martes, Miércoles, Jueves, Viernes, Sábado]
12
13
  abbr_day_names: [Dom, Lun, Mar, Mie, Jue, Vie, Sab]
@@ -27,4 +28,4 @@ es:
27
28
  array:
28
29
  words_connector: ", "
29
30
  two_words_connector: " y "
30
- last_word_connector: ", y "
31
+ last_word_connector: ", y "
@@ -7,6 +7,7 @@ fr:
7
7
  default: "%d-%m-%Y"
8
8
  short: "%b %d"
9
9
  long: "%B %d, %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Dimanche, Lundi, Mardi, Mercredi, Jeudi, Vendredi, Samedi]
12
13
  abbr_day_names: [Lun, Mar, Mer, Jeu, Ven, Sam, Dim]
@@ -27,4 +28,4 @@ fr:
27
28
  array:
28
29
  words_connector: ", "
29
30
  two_words_connector: " et "
30
- last_word_connector: ", et "
31
+ last_word_connector: ", et "
@@ -7,6 +7,7 @@ hu:
7
7
  default: "%Y-%m-%d"
8
8
  short: "%b. %d."
9
9
  long: "%Y. %B %d."
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [vasárnap, hétfő, kedd, szerda, csütörtök, péntek, szombat]
12
13
  abbr_day_names: [vas, hét, kedd, sze, csüt, pén, szo]
@@ -27,4 +28,4 @@ hu:
27
28
  array:
28
29
  words_connector: ", "
29
30
  two_words_connector: " és "
30
- last_word_connector: " és "
31
+ last_word_connector: " és "
@@ -7,6 +7,7 @@ ja:
7
7
  default: "%Y/%m/%d"
8
8
  short: "%m/%d"
9
9
  long: "%Y年%m月%d日"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [日曜日, 月曜日, 火曜日, 水曜日, 木曜日, 金曜日, 土曜日]
12
13
  abbr_day_names: [日, 月, 火, 水, 木, 金, 土]
@@ -7,6 +7,7 @@ nl:
7
7
  default: "%d-%m-%Y"
8
8
  short: "%d %b"
9
9
  long: "%d %B %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [zondag, maandag, dinsdag, woensdag, donderdag, vrijdag, zaterdag]
12
13
  abbr_day_names: [zo, ma, di, wo, do, vr, za]
@@ -27,4 +28,4 @@ nl:
27
28
  array:
28
29
  words_connector: ", "
29
30
  two_words_connector: " en "
30
- last_word_connector: " en "
31
+ last_word_connector: " en "
@@ -7,6 +7,7 @@
7
7
  default: "%d.%m.%Y"
8
8
  short: "%e. %b %Y"
9
9
  long: "%e. %B %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [søndag, mandag, tirsdag, onsdag, torsdag, fredag, lørdag]
12
13
  abbr_day_names: [sø, ma, ti, 'on', to, fr, lø]
@@ -7,6 +7,7 @@ pl:
7
7
  default: "%Y-%m-%d"
8
8
  short: "%d %b"
9
9
  long: "%d %B %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Niedziela, Poniedziałek, Wtorek, Środa, Czwartek, Piątek, Sobota]
12
13
  abbr_day_names: [nie, pon, wto, śro, czw, pia, sob]
@@ -1,4 +1,4 @@
1
- it:
1
+ pt_br:
2
2
  date:
3
3
  formats:
4
4
  # Use the strftime parameters for formats.
@@ -7,11 +7,12 @@ ru:
7
7
  default: "%d.%m.%Y"
8
8
  short: "%d %b"
9
9
  long: "%e %B, %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Воскресенье, Понедельник, Вторник, Среда, Четверг, Пятница, Суббота]
12
13
  abbr_day_names: [Вс, Пн, Вт, Ср, Чт, Пт, Сб]
13
14
  month_names: [~, Январь, Февраль, Март, Апрель, Май, Июнь, Июль, Август, Сентябрь, Октябрь, Ноябрь, Декабрь]
14
- abbr_month_names: [~, Янв, Феб, Мар, Апр, Май, Июн, Июл, Авг, Сен, Окт, Нов, Дек]
15
+ abbr_month_names: [~, Янв, Феб, Мар, Апр, Май, Июн, Июл, Авг, Сен, Окт, Ноя, Дек]
15
16
  order: [ :year, :month, :day ]
16
17
 
17
18
  time:
@@ -20,11 +21,12 @@ ru:
20
21
  short: "%d %b %H:%M"
21
22
  long: "%e %B, %Y %H:%M"
22
23
  am: "д.п."
23
- pm: "п.п"
24
+ pm: "п.п."
24
25
 
25
26
  # Used in array.to_sentence.
26
27
  support:
27
28
  array:
28
29
  words_connector: ", "
29
30
  two_words_connector: " и "
30
- last_word_connector: ", и "
31
+ last_word_connector: " и "
32
+
@@ -7,6 +7,7 @@ tr:
7
7
  default: "%d/%m/%Y"
8
8
  short: "%d %b"
9
9
  long: "%d %B %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Pazar, Pazartesi, Salı, Çarşamba, Perşembe, Cuma, Cumartesi]
12
13
  abbr_day_names: [Paz, Pts, Sal, Çar, Per, Cum, Cts]
@@ -7,6 +7,7 @@ uk:
7
7
  default: "%d.%m.%Y"
8
8
  short: "%d %b"
9
9
  long: "%e %B, %Y"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [Неділя, Понеділок, Вівторок, Середа, Четвер, Пятница, Субота]
12
13
  abbr_day_names: [Нд, Пн, Вт, Ср, Чт, Пт, Сб]
@@ -7,6 +7,7 @@ zh_cn:
7
7
  default: "%Y-%m-%d"
8
8
  short: "%b%d日"
9
9
  long: "%Y年%b%d日"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [星期日, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六]
12
13
  abbr_day_names: [日, 一, 二, 三, 四, 五, 六]
@@ -7,6 +7,7 @@ zh_tw:
7
7
  default: "%Y-%m-%d"
8
8
  short: "%b%d日"
9
9
  long: "%Y年%b%d日"
10
+ only_day: "%e"
10
11
 
11
12
  day_names: [星期日, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六]
12
13
  abbr_day_names: [日, 一, 二, 三, 四, 五, 六]
@@ -1,5 +1,6 @@
1
- # Defines our PADRINO_LOG_LEVEL
1
+ # Defines our PADRINO_LOGGER constants
2
2
  PADRINO_LOG_LEVEL = ENV['PADRINO_LOG_LEVEL'] unless defined?(PADRINO_LOG_LEVEL)
3
+ PADRINO_LOGGER = ENV['PADRINO_LOGGER'] unless defined?(PADRINO_LOGGER)
3
4
 
4
5
  module Padrino
5
6
 
@@ -66,7 +67,7 @@ module Padrino
66
67
  # :log_level:: Once of [:fatal, :error, :warn, :info, :debug]
67
68
  # :stream:: Once of [:to_file, :null, :stdout, :stderr] our your custom stream
68
69
  # :log_level::
69
- # The log level from, e.g. :fatal or :info. Defaults to :debug in the
70
+ # The log level from, e.g. :fatal or :info. Defaults to :warn in the
70
71
  # production environment and :debug otherwise.
71
72
  # :auto_flush::
72
73
  # Whether the log should automatically flush after new messages are
@@ -89,11 +90,17 @@ module Padrino
89
90
  # :development => { :log_level => :debug, :stream => :stdout }
90
91
  # :test => { :log_level => :fatal, :stream => :null }
91
92
  #
93
+ # In some cases, configuring the loggers before loading the framework is necessary.
94
+ # You can do so by setting PADRINO_LOGGER:
95
+ #
96
+ # PADRINO_LOGGER = { :staging => { :log_level => :debug, :stream => :to_file }}
97
+ #
92
98
  Config = {
93
99
  :production => { :log_level => :warn, :stream => :to_file },
94
100
  :development => { :log_level => :debug, :stream => :stdout },
95
101
  :test => { :log_level => :debug, :stream => :null }
96
102
  }
103
+ Config.merge!(PADRINO_LOGGER) if PADRINO_LOGGER
97
104
 
98
105
  # Embed in a String to clear all previous ANSI sequences.
99
106
  CLEAR = "\e[0m"
@@ -132,6 +139,12 @@ module Padrino
132
139
  def self.setup!
133
140
  config_level = (PADRINO_LOG_LEVEL || Padrino.env || :test).to_sym # need this for PADRINO_LOG_LEVEL
134
141
  config = Config[config_level]
142
+
143
+ unless config
144
+ warn("No logging configuration for :#{config_level} found, falling back to :production")
145
+ config = Config[:production]
146
+ end
147
+
135
148
  stream = case config[:stream]
136
149
  when :to_file
137
150
  FileUtils.mkdir_p(Padrino.root("log")) unless File.exists?(Padrino.root("log"))
@@ -341,4 +354,4 @@ module Kernel #:nodoc:
341
354
  def logger
342
355
  Padrino.logger
343
356
  end
344
- end # Kernel
357
+ end # Kernel
@@ -32,6 +32,18 @@ class String
32
32
  ActiveSupport::Inflector.pluralize(self)
33
33
  end
34
34
 
35
+ # Returns the singular form of the word in the string.
36
+ #
37
+ # "posts".singularize # => "post"
38
+ # "octopi".singularize # => "octopus"
39
+ # "sheep".singularize # => "sheep"
40
+ # "words".singularize # => "word"
41
+ # "the blue mailmen".singularize # => "the blue mailman"
42
+ # "CamelOctopi".singularize # => "CamelOctopus"
43
+ def singularize
44
+ ActiveSupport::Inflector.singularize(self)
45
+ end
46
+
35
47
  # +constantize+ tries to find a declared constant with the name specified
36
48
  # in the string. It raises a NameError when the name is not in CamelCase
37
49
  # or is not initialized.
@@ -5,7 +5,7 @@
5
5
  # without include full padrino core.
6
6
  #
7
7
  module Padrino
8
- VERSION = '0.10.0' unless defined?(Padrino::VERSION)
8
+ VERSION = '0.10.1' unless defined?(Padrino::VERSION)
9
9
  ##
10
10
  # Return the current Padrino version
11
11
  #
data/padrino-core.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
 
33
33
  s.add_dependency("tilt", "~> 1.3.0")
34
34
  s.add_dependency("sinatra", "~> 1.2.6")
35
- s.add_dependency("http_router", "~> 0.8.10")
35
+ s.add_dependency("http_router", "~> 0.9.4")
36
36
  s.add_dependency("thor", "~> 0.14.3")
37
37
  s.add_dependency("activesupport", "~> 3.0.0")
38
38
  end
data/test/test_filters.rb CHANGED
@@ -263,4 +263,15 @@ class TestFilters < Test::Unit::TestCase
263
263
  get '/bar/main'
264
264
  assert_equal 'also before', body
265
265
  end
266
+
267
+ should "call before filters even if there was no match" do
268
+ test = nil
269
+ mock_app do
270
+ before(:index, '/foo') { test = 'before' }
271
+ get :index do
272
+ end
273
+ end
274
+ get '/foo'
275
+ assert_equal 'before', test
276
+ end
266
277
  end
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/helper')
2
+
3
+ class TestLocales < Test::Unit::TestCase
4
+ Dir[File.expand_path("../../lib/padrino-core/locale/*.yml", __FILE__)].each do |file|
5
+ base_original = YAML.load_file(file)
6
+ name = File.basename(file, '.yml')
7
+ should "should have correct locale for #{name}" do
8
+ base = base_original[name]['date']['formats']
9
+ assert base['default'].present?
10
+ assert base['short'].present?
11
+ assert base['long'].present?
12
+ assert base['only_day'].present?
13
+ base = base_original[name]['date']
14
+ assert base['day_names'].present?
15
+ assert base['abbr_day_names'].present?
16
+ assert base['month_names'].present?
17
+ assert base['abbr_month_names'].present?
18
+ assert base['order'].present?
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/helper')
2
+
3
+ class TestRouting < Test::Unit::TestCase
4
+ should 'perform restul routing' do
5
+ mock_app do
6
+ controller :parent => :parents do
7
+ get :index do
8
+ "#{url_for(:index, params[:parent_id])} get"
9
+ end
10
+
11
+ put :index, :with => :asset_id do
12
+ "#{url_for(:index, params[:parent_id], :asset_id => params[:asset_id])} put"
13
+ end
14
+
15
+ post :index, :with => :asset_id do
16
+ "#{url_for(:index, :parent_id => params[:parent_id], :asset_id => params[:asset_id])} post"
17
+ end
18
+
19
+ delete :index, :with => :asset_id do
20
+ "#{url_for(:index, params[:parent_id], :asset_id => params[:asset_id])} delete"
21
+ end
22
+ end
23
+ end
24
+ get "/parents/1"
25
+ assert_equal "/parents/1 get", body
26
+ put "/parents/1/hi"
27
+ assert_equal "/parents/1/hi put", body
28
+ post "/parents/1/hi"
29
+ assert_equal "/parents/1/hi post", body
30
+ delete "/parents/1/hi"
31
+ assert_equal "/parents/1/hi delete", body
32
+ end
33
+ end
data/test/test_routing.rb CHANGED
@@ -348,17 +348,48 @@ class TestRouting < Test::Unit::TestCase
348
348
  should "preserve the format if you set it manually" do
349
349
  mock_app do
350
350
  before do
351
- params[:format] = :json
351
+ params[:format] = "json"
352
352
  end
353
353
 
354
354
  get "test", :provides => [:html, :json] do
355
- params[:format].inspect
355
+ content_type.inspect
356
356
  end
357
357
  end
358
358
  get "/test"
359
359
  assert_equal ":json", body
360
360
  get "/test.html"
361
361
  assert_equal ":json", body
362
+ get "/test.php"
363
+ assert_equal ":json", body
364
+ end
365
+
366
+ should "correctly accept '.' in the route" do
367
+ mock_app do
368
+ get "test.php", :provides => [:html, :json] do
369
+ content_type.inspect
370
+ end
371
+ end
372
+ get "/test.php"
373
+ assert_equal ":html", body
374
+ get "/test.php.json"
375
+ assert_equal ":json", body
376
+ end
377
+
378
+ should "correctly accept priority of format" do
379
+ mock_app do
380
+ get "test.php", :provides => [:html, :json, :xml] do
381
+ content_type.inspect
382
+ end
383
+ end
384
+
385
+ get "/test.php"
386
+ assert_equal ":html", body
387
+ get "/test.php", {}, { 'HTTP_ACCEPT' => 'application/xml' }
388
+ assert_equal ":xml", body
389
+ get "/test.php?format=json", { 'HTTP_ACCEPT' => 'application/xml' }
390
+ assert_equal ":json", body
391
+ get "/test.php.json?format=html", { 'HTTP_ACCEPT' => 'application/xml' }
392
+ assert_equal ":json", body
362
393
  end
363
394
 
364
395
  should "generate routes for format with controller" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: padrino-core
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.10.0
5
+ version: 0.10.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Padrino Team
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-07-07 00:00:00 -07:00
16
+ date: 2011-08-01 00:00:00 -07:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ~>
48
48
  - !ruby/object:Gem::Version
49
- version: 0.8.10
49
+ version: 0.9.4
50
50
  type: :runtime
51
51
  version_requirements: *id003
52
52
  - !ruby/object:Gem::Dependency
@@ -101,7 +101,7 @@ files:
101
101
  - lib/padrino-core/images/404.png
102
102
  - lib/padrino-core/images/500.png
103
103
  - lib/padrino-core/loader.rb
104
- - lib/padrino-core/locale/cz.yml
104
+ - lib/padrino-core/locale/cs.yml
105
105
  - lib/padrino-core/locale/da.yml
106
106
  - lib/padrino-core/locale/de.yml
107
107
  - lib/padrino-core/locale/en.yml
@@ -144,11 +144,13 @@ files:
144
144
  - test/test_core.rb
145
145
  - test/test_dependencies.rb
146
146
  - test/test_filters.rb
147
+ - test/test_locale.rb
147
148
  - test/test_logger.rb
148
149
  - test/test_mounter.rb
149
150
  - test/test_reloader_complex.rb
150
151
  - test/test_reloader_simple.rb
151
152
  - test/test_rendering.rb
153
+ - test/test_restful_routing.rb
152
154
  - test/test_router.rb
153
155
  - test/test_routing.rb
154
156
  has_rdoc: true
@@ -200,10 +202,12 @@ test_files:
200
202
  - test/test_core.rb
201
203
  - test/test_dependencies.rb
202
204
  - test/test_filters.rb
205
+ - test/test_locale.rb
203
206
  - test/test_logger.rb
204
207
  - test/test_mounter.rb
205
208
  - test/test_reloader_complex.rb
206
209
  - test/test_reloader_simple.rb
207
210
  - test/test_rendering.rb
211
+ - test/test_restful_routing.rb
208
212
  - test/test_router.rb
209
213
  - test/test_routing.rb