iso639 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +1 -0
- data/Gemfile +0 -1
- data/LICENSE.txt +2 -2
- data/README.md +1 -1
- data/iso639.gemspec +1 -0
- data/lib/iso639/insensitive_hash.rb +8 -2
- data/lib/iso639/version.rb +1 -1
- data/test/insensitive_hash_test.rb +24 -4
- data/test/iso639_test.rb +7 -0
- metadata +11 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 578e3c4f186ee6ce7be47626269bd9b4e0939d3d
|
4
|
+
data.tar.gz: c3716f2cad4b92f1c6f2b50d4447a8c621e658e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d75b6b0d94a7ebe9f3bfbfbb7bbc032d1a6d8ec4a3f3c3920cc1a67400106115ba7447fbcc10150318b8051e6216a1e95011aa55c1e6951e8ecb3eda139b92b
|
7
|
+
data.tar.gz: effba8a1517835e0578196b56b13f2f8514b33b542df689b1032c9ff17b27236a7e23e1fa7c3fab4e56f24572b50573b5dec0ae9cdb860d8ace180efb9c02d74
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2012 Ryan McGeary
|
1
|
+
Copyright (c) 2012-2013 Ryan McGeary
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# iso639 [![Build Status](https://travis-ci.org/rmm5t/iso639.png?branch=master)](https://travis-ci.org/rmm5t/iso639)
|
1
|
+
# iso639 [![Gem Version](https://badge.fury.io/rb/iso639.png)](http://badge.fury.io/rb/iso639) [![Build Status](https://travis-ci.org/rmm5t/iso639.png?branch=master)](https://travis-ci.org/rmm5t/iso639) [![Code Climate](https://codeclimate.com/github/rmm5t/iso639.png)](https://codeclimate.com/github/rmm5t/iso639)
|
2
2
|
|
3
3
|
The iso639 gem provides convenience methods for looking up ISO-639-1 or
|
4
4
|
ISO-639-2 language codes by their english name, 2-char, or 3-char counterpart
|
data/iso639.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.description = %q{ISO 639-1 and ISO 639-2 lookups by name, alpha-2 code, or alpha-3 code}
|
12
12
|
gem.summary = gem.description
|
13
13
|
gem.homepage = "https://github.com/rmm5t/iso639"
|
14
|
+
gem.license = "MIT"
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Iso639
|
2
2
|
class InsensitiveHash < Hash # :nodoc:
|
3
3
|
def [](key)
|
4
|
-
super(key
|
4
|
+
super normalize(key)
|
5
5
|
end
|
6
6
|
|
7
7
|
def []=(key, value)
|
8
|
-
super(key
|
8
|
+
super normalize(key), value
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def normalize(key)
|
14
|
+
key.to_s.downcase.strip.split("_").first
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
data/lib/iso639/version.rb
CHANGED
@@ -1,14 +1,34 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Iso639::InsensitiveHash do
|
4
|
-
it "should
|
4
|
+
it "should return results ignoring case" do
|
5
5
|
hash = Iso639::InsensitiveHash.new
|
6
6
|
hash["foo"] = "one thing"
|
7
7
|
hash["Bar"] = "another thing"
|
8
8
|
hash["BAZ"] = "last thing"
|
9
9
|
|
10
|
-
assert_equal
|
11
|
-
assert_equal
|
12
|
-
assert_equal
|
10
|
+
assert_equal "one thing", hash["FOO"]
|
11
|
+
assert_equal "another thing", hash["bar"]
|
12
|
+
assert_equal "last thing", hash["baz"]
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return results ignoring whitespace" do
|
16
|
+
hash = Iso639::InsensitiveHash.new
|
17
|
+
hash[" foo \t"] = "one thing"
|
18
|
+
hash["Bar"] = "another thing"
|
19
|
+
hash["\tBAZ\n"] = "last thing"
|
20
|
+
|
21
|
+
assert_equal "one thing", hash["FOO"]
|
22
|
+
assert_equal "another thing", hash[" bar \t"]
|
23
|
+
assert_equal "last thing", hash["baz"]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return results ignoring regional designators" do
|
27
|
+
hash = Iso639::InsensitiveHash.new
|
28
|
+
hash["en_GB"] = "english"
|
29
|
+
hash["fr_CA"] = "french"
|
30
|
+
|
31
|
+
assert_equal "english", hash["en_US"]
|
32
|
+
assert_equal "french", hash["fr_FR"]
|
13
33
|
end
|
14
34
|
end
|
data/test/iso639_test.rb
CHANGED
@@ -101,4 +101,11 @@ describe Iso639 do
|
|
101
101
|
assert_equal "fr", Iso639[" fra "].alpha2
|
102
102
|
assert_equal "fr", Iso639[" french\t"].alpha2
|
103
103
|
end
|
104
|
+
|
105
|
+
it "should ignore regional designations" do
|
106
|
+
assert_equal "en", Iso639["en_US"].alpha2
|
107
|
+
assert_equal "en", Iso639["en_GB"].alpha2
|
108
|
+
assert_equal "fr", Iso639["fr_CA"].alpha2
|
109
|
+
assert_equal "fr", Iso639["fr_FR"].alpha2
|
110
|
+
end
|
104
111
|
end
|
metadata
CHANGED
@@ -1,44 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso639
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 1.1.0
|
4
|
+
version: 1.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ryan McGeary
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: minitest
|
16
|
-
type: :development
|
17
15
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
16
|
requirements:
|
20
17
|
- - ~>
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '4.3'
|
20
|
+
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '4.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
|
-
type: :development
|
33
29
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
30
|
requirements:
|
36
31
|
- - ~>
|
37
32
|
- !ruby/object:Gem::Version
|
38
33
|
version: '10.0'
|
34
|
+
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -67,28 +62,28 @@ files:
|
|
67
62
|
- test/language_test.rb
|
68
63
|
- test/test_helper.rb
|
69
64
|
homepage: https://github.com/rmm5t/iso639
|
70
|
-
licenses:
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
71
68
|
post_install_message:
|
72
69
|
rdoc_options: []
|
73
70
|
require_paths:
|
74
71
|
- lib
|
75
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
73
|
requirements:
|
78
|
-
- -
|
74
|
+
- - '>='
|
79
75
|
- !ruby/object:Gem::Version
|
80
76
|
version: '0'
|
81
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
78
|
requirements:
|
84
|
-
- -
|
79
|
+
- - '>='
|
85
80
|
- !ruby/object:Gem::Version
|
86
81
|
version: '0'
|
87
82
|
requirements: []
|
88
83
|
rubyforge_project:
|
89
|
-
rubygems_version:
|
84
|
+
rubygems_version: 2.0.3
|
90
85
|
signing_key:
|
91
|
-
specification_version:
|
86
|
+
specification_version: 4
|
92
87
|
summary: ISO 639-1 and ISO 639-2 lookups by name, alpha-2 code, or alpha-3 code
|
93
88
|
test_files:
|
94
89
|
- test/insensitive_hash_test.rb
|