language_list 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '068bbf4dc0c63ec1a2f51b7f88d04359d6343c3c'
4
- data.tar.gz: 72465669955bcd970f4bb8caff0ed2d0a5bfff7f
3
+ metadata.gz: 2ef342ceed57bb2b45b98248a642712249f73e82
4
+ data.tar.gz: c368362516768dcc4ccd7498e9526d3551229637
5
5
  SHA512:
6
- metadata.gz: 6c29043d299c748cf72a34b00be615aa8faa787f54558a73321f4461c2a6747aeba62eddc855b9d52edb0ea35a758660761e7be5c2a94eaf001ca521e3a5329e
7
- data.tar.gz: 7f685621ee567bde0a23d14b89a74422423545f66a0b60ede9aada402f7d60d50f338c776c57de57a7fc92c409676561e3fb295ea8d6dbdd24e117201ee46f26
6
+ metadata.gz: c7a7c2a5107270bd092e89dd3ccbc8571898992115e858b915348513ae71202f1904fa63052ae523f261feb18d88082fcd8cd9cf7a0e8fb7a851e060fac7a446
7
+ data.tar.gz: 2b7c76e838504587f01b923168493527e2036b5e0d9e66aeeda33d44229d1fd466234bafb4b93d7b648459f6e22e2e4837ce31a089e29f20ca9e340e5935bf54
@@ -58,11 +58,15 @@ module LanguageList
58
58
  end
59
59
 
60
60
  def self.find_by_name(name)
61
+ return if name.nil?
62
+
61
63
  LanguageList::BY_NAME[name.downcase]
62
64
  end
63
65
 
64
66
  def self.find(code)
65
- code.downcase!
67
+ return if code.nil?
68
+
69
+ code = code.downcase
66
70
  find_by_iso_639_1(code) ||
67
71
  find_by_iso_639_3(code) ||
68
72
  find_by_iso_639_2b(code) ||
@@ -1,3 +1,3 @@
1
1
  module LanguageList
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -25,6 +25,23 @@ class LanguageListTest < Minitest::Test
25
25
  assert_equal 'English', english.name
26
26
  end
27
27
 
28
+ def test_find_by_iso_639_1_with_nil
29
+ result = LanguageList::LanguageInfo.find_by_iso_639_1(nil)
30
+ assert_equal nil, result
31
+ end
32
+
33
+ def test_find_by_iso_639_1_with_empty_string
34
+ result = LanguageList::LanguageInfo.find_by_iso_639_1('')
35
+ assert_equal nil, result
36
+ end
37
+
38
+ def test_find_by_iso_639_1_with_frozen_string
39
+ english = LanguageList::LanguageInfo.find_by_iso_639_1('en'.freeze)
40
+ assert_equal 'en', english.iso_639_1
41
+ assert_equal 'eng', english.iso_639_3
42
+ assert_equal 'English', english.name
43
+ end
44
+
28
45
  def test_find_by_iso_639_3
29
46
  english = LanguageList::LanguageInfo.find_by_iso_639_3('eng')
30
47
  assert_equal 'en', english.iso_639_1
@@ -32,6 +49,42 @@ class LanguageListTest < Minitest::Test
32
49
  assert_equal 'English', english.name
33
50
  end
34
51
 
52
+ def test_find_by_iso_639_3_with_nil
53
+ result = LanguageList::LanguageInfo.find_by_iso_639_3(nil)
54
+ assert_equal nil, result
55
+ end
56
+
57
+ def test_find_by_iso_639_3_with_empty_string
58
+ result = LanguageList::LanguageInfo.find_by_iso_639_3('')
59
+ assert_equal nil, result
60
+ end
61
+
62
+ def test_find_by_iso_639_3_with_frozen_string
63
+ english = LanguageList::LanguageInfo.find_by_iso_639_3('eng'.freeze)
64
+ assert_equal 'en', english.iso_639_1
65
+ assert_equal 'eng', english.iso_639_3
66
+ assert_equal 'English', english.name
67
+ end
68
+
69
+ def test_find_by_name_with_nil
70
+ result = LanguageList::LanguageInfo.find_by_name(nil)
71
+ assert_equal nil, result
72
+ end
73
+
74
+ def test_find_by_name_with_empty_string
75
+ result = LanguageList::LanguageInfo.find_by_name('')
76
+ assert_equal nil, result
77
+ end
78
+
79
+ def test_find_by_name_with_frozen_string
80
+ english = LanguageList::LanguageInfo.find_by_name('English'.freeze)
81
+ assert_equal 'en', english.iso_639_1
82
+ assert_equal 'eng', english.iso_639_3
83
+ assert_equal 'eng', english.iso_639_2b
84
+ assert_equal 'eng', english.iso_639_2t
85
+ assert_equal 'English', english.name
86
+ end
87
+
35
88
  def test_find_by_name
36
89
  english = LanguageList::LanguageInfo.find_by_name('English')
37
90
  assert_equal 'en', english.iso_639_1
@@ -48,6 +101,23 @@ class LanguageListTest < Minitest::Test
48
101
  assert_equal 'English', english.name
49
102
  end
50
103
 
104
+ def test_find_with_nil
105
+ result = LanguageList::LanguageInfo.find(nil)
106
+ assert_equal nil, result
107
+ end
108
+
109
+ def test_find_with_empty_string
110
+ result = LanguageList::LanguageInfo.find('')
111
+ assert_equal nil, result
112
+ end
113
+
114
+ def test_find_with_frozen_string
115
+ english = LanguageList::LanguageInfo.find('EN'.freeze)
116
+ assert_equal 'en', english.iso_639_1
117
+ assert_equal 'eng', english.iso_639_3
118
+ assert_equal 'English', english.name
119
+ end
120
+
51
121
  def test_find_with_iso_639_1_code
52
122
  english = LanguageList::LanguageInfo.find('en')
53
123
  assert_equal 'en', english.iso_639_1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: language_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-15 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project: language_list
81
- rubygems_version: 2.5.2
81
+ rubygems_version: 2.6.8
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: A list of languages and methods to find and work with these languages.