lola 0.1.2 → 0.1.3

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.
@@ -5,4 +5,7 @@
5
5
  * Fix problem with helpers
6
6
 
7
7
  ### 0.1.2
8
- * Fix problema with Norwegian ISO code
8
+ * Fix problema with Norwegian ISO code
9
+
10
+ ### 0.1.3
11
+ * Use English as default locale
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -14,11 +14,12 @@ module Lola
14
14
 
15
15
  # Raised when attemting to switch to a locale which does not exist
16
16
  class UnavailableLocale < RuntimeError; end
17
-
17
+
18
18
  # Returns a list of all languages
19
19
  def self.languages(options={})
20
20
  # Use specified locale or fall back to default locale
21
- locale = (options.delete(:locale) || @default_locale).to_s
21
+ locale = options.delete(:locale) || @default_locale
22
+ locale = available_locales.include?(locale) ? locale.to_s : @default_locale.to_s
22
23
 
23
24
  # Load the country list for the specified locale
24
25
  @languages ||= {}
@@ -65,6 +66,14 @@ module Lola
65
66
  end
66
67
 
67
68
  protected
69
+ def self.available_locales
70
+ locales = Array.new
71
+ Dir.glob("#{@data_path}/*.yml") do |filename|
72
+ locales << File.basename(filename, '.yml').to_sym
73
+ end
74
+ locales
75
+ end
76
+
68
77
  def self.search_collection(collection, value, index_to_match, index_to_retrieve)
69
78
  return nil if collection.nil? || value.nil? || value.empty?
70
79
  collection.each do |m|
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "lola"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Carlos Hernandez"]
@@ -38,7 +38,7 @@ class TestLola < Test::Unit::TestCase
38
38
  Lola.default_locale = :es
39
39
  assert_equal 'Griego', Lola.language_name('EL')
40
40
  end
41
-
41
+
42
42
  def test_language_code
43
43
  assert_equal 'ES', Lola.language_code('Spanish')
44
44
  assert_equal 'ES', Lola.language_code('spanish')
@@ -84,9 +84,7 @@ class TestLola < Test::Unit::TestCase
84
84
  end
85
85
 
86
86
  def test_unsupported_locale
87
- assert_raises Lola::UnavailableLocale do
88
- Lola.languages(:locale => :latin)
89
- end
87
+ assert_equal 'English', Lola.language_name('EN', :locale => :latin)
90
88
  end
91
89
 
92
90
  def test_special_characters_dont_rails_an_exception
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lola
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  segments:
116
116
  - 0
117
- hash: -2359747171660169643
117
+ hash: -205451062462248237
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements: