otto 0.4.0 → 0.4.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.
Files changed (5) hide show
  1. data/CHANGES.txt +4 -2
  2. data/VERSION.yml +1 -1
  3. data/lib/otto.rb +13 -9
  4. data/otto.gemspec +2 -2
  5. metadata +2 -2
@@ -1,15 +1,17 @@
1
1
  OTTO, CHANGES
2
2
 
3
+ #### 0.4.1 (2015-04-07) ###############################
4
+
5
+ * FIXED: Resolved error when ACCEPT-LANGUAGES header doesn't exist
6
+
3
7
  #### 0.4.0 (2015-04-06) ###############################
4
8
 
5
9
  * ADDED: Locale support via env['rack.locale']
6
10
 
7
-
8
11
  #### 0.3.2 (2013-01-27) ###############################
9
12
 
10
13
  * CHANGE: send_cookie doesn't set domain
11
14
 
12
-
13
15
  #### 0.3.1 (2012-12-17) ###############################
14
16
 
15
17
  * ADDED: Otto.debug (set w/ Otto.debug= or env variable OTTO_DEBUG)
@@ -1,3 +1,3 @@
1
1
  :MAJOR: 0
2
2
  :MINOR: 4
3
- :PATCH: 0
3
+ :PATCH: 1
@@ -86,7 +86,7 @@ class Otto
86
86
 
87
87
  def call env
88
88
  locale = determine_locale env
89
- env['rack.locale'] = locale || self.option[:locale]
89
+ env['rack.locale'] = locale
90
90
  if option[:public] && safe_dir?(option[:public])
91
91
  @static_route ||= Rack::File.new(option[:public])
92
92
  end
@@ -187,14 +187,18 @@ class Otto
187
187
 
188
188
  def determine_locale env
189
189
  accept_langs = env['HTTP_ACCEPT_LANGUAGE']
190
- locales = accept_langs.split(',').map { |l|
191
- l += ';q=1.0' unless l =~ /;q=\d+(?:\.\d+)?$/
192
- l.split(';q=')
193
- }.sort_by { |locale, qvalue|
194
- qvalue.to_f
195
- }.collect { |locale, qvalue|
196
- locale
197
- }.reverse
190
+ accept_langs = self.option[:locale] if accept_langs.to_s.empty?
191
+ locales = []
192
+ unless accept_langs.empty?
193
+ locales = accept_langs.split(',').map { |l|
194
+ l += ';q=1.0' unless l =~ /;q=\d+(?:\.\d+)?$/
195
+ l.split(';q=')
196
+ }.sort_by { |locale, qvalue|
197
+ qvalue.to_f
198
+ }.collect { |locale, qvalue|
199
+ locale
200
+ }.reverse
201
+ end
198
202
  STDERR.puts "locale: #{locales} (#{accept_langs})" if Otto.debug
199
203
  locales.empty? ? nil : locales
200
204
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "otto"
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Delano Mandelbaum"]
12
- s.date = "2015-04-06"
12
+ s.date = "2015-04-07"
13
13
  s.description = "Auto-define your rack-apps in plaintext."
14
14
  s.email = "delano@solutious.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: otto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-06 00:00:00.000000000 Z
12
+ date: 2015-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack