iso 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +4 -4
- data/Gemfile.lock +122 -47
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/data/iso-639-1.yml +1 -0
- data/iso.gemspec +34 -34
- data/lib/iso.rb +5 -5
- data/spec/lib/iso/language_spec.rb +10 -10
- data/spec/lib/iso/region_spec.rb +6 -6
- data/spec/lib/iso/subtag_spec.rb +16 -16
- data/spec/lib/iso/tag_spec.rb +28 -28
- data/spec/lib/iso/un/region_spec.rb +7 -7
- metadata +30 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 73ac639564aea0ff8452e12700723542ab0680976c594a8a4def9428cc8272e1
|
4
|
+
data.tar.gz: 94221235e9d9b87c784b206c3567d3a4cd1d90704ebadadd39fdb67ab68c29c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d2ebc1de12710b1bb3f7ed9e899e007a62fea609cd0d998b112ca32450b9932f6d1c56c4647e9bc37de02d2074fc8da88a67ddc104972ff88982e2b4bef2c50
|
7
|
+
data.tar.gz: 60fa2d39c8a44039dc3291d5ac6772b29cbc611ad95b7dbfa4f051cbabed04a9aa0d5530a48502c620d961933e47dcbed9d011e1d3094aa24bded9ee2b9c824f
|
data/Gemfile
CHANGED
@@ -3,10 +3,10 @@ source "http://rubygems.org"
|
|
3
3
|
gem "i18n"
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem "rspec", "~>
|
7
|
-
gem "rdoc", "~>
|
8
|
-
gem "bundler", "~>
|
9
|
-
gem "jeweler", "~>
|
6
|
+
gem "rspec", "~> 3.9"
|
7
|
+
gem "rdoc", "~> 6.2"
|
8
|
+
gem "bundler", "~> 2.0"
|
9
|
+
gem "jeweler", "~> 2.3"
|
10
10
|
gem "guard-rspec"
|
11
11
|
gem "localeapp"
|
12
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,62 +1,137 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
addressable (2.4.0)
|
5
|
+
builder (3.2.3)
|
6
|
+
coderay (1.1.2)
|
7
|
+
concurrent-ruby (1.1.5)
|
8
|
+
descendants_tracker (0.0.4)
|
9
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
domain_name (0.5.20190701)
|
12
|
+
unf (>= 0.0.5, < 1.0.0)
|
13
|
+
faraday (0.9.2)
|
14
|
+
multipart-post (>= 1.2, < 3)
|
15
|
+
ffi (1.11.3)
|
16
|
+
formatador (0.2.5)
|
17
|
+
git (1.5.0)
|
18
|
+
github_api (0.16.0)
|
19
|
+
addressable (~> 2.4.0)
|
20
|
+
descendants_tracker (~> 0.0.4)
|
21
|
+
faraday (~> 0.8, < 0.10)
|
22
|
+
hashie (>= 3.4)
|
23
|
+
mime-types (>= 1.16, < 3.0)
|
24
|
+
oauth2 (~> 1.0)
|
25
|
+
gli (2.19.0)
|
26
|
+
guard (2.16.1)
|
27
|
+
formatador (>= 0.2.4)
|
28
|
+
listen (>= 2.7, < 4.0)
|
29
|
+
lumberjack (>= 1.0.12, < 2.0)
|
30
|
+
nenv (~> 0.1)
|
31
|
+
notiffany (~> 0.0)
|
32
|
+
pry (>= 0.9.12)
|
33
|
+
shellany (~> 0.0)
|
34
|
+
thor (>= 0.18.1)
|
35
|
+
guard-compat (1.2.1)
|
36
|
+
guard-rspec (4.7.3)
|
37
|
+
guard (~> 2.1)
|
38
|
+
guard-compat (~> 1.1)
|
39
|
+
rspec (>= 2.99.0, < 4.0)
|
40
|
+
hashie (4.0.0)
|
41
|
+
highline (2.0.3)
|
42
|
+
http-accept (1.7.0)
|
43
|
+
http-cookie (1.0.3)
|
44
|
+
domain_name (~> 0.5)
|
45
|
+
i18n (1.7.0)
|
46
|
+
concurrent-ruby (~> 1.0)
|
47
|
+
jeweler (2.3.9)
|
48
|
+
builder
|
49
|
+
bundler
|
16
50
|
git (>= 1.2.5)
|
51
|
+
github_api (~> 0.16.0)
|
52
|
+
highline (>= 1.6.15)
|
53
|
+
nokogiri (>= 1.5.10)
|
54
|
+
psych
|
17
55
|
rake
|
18
56
|
rdoc
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
rb-
|
24
|
-
|
57
|
+
semver2
|
58
|
+
json (2.2.0)
|
59
|
+
jwt (2.2.1)
|
60
|
+
listen (3.2.0)
|
61
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
62
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
63
|
+
localeapp (3.1.2)
|
25
64
|
gli
|
26
|
-
i18n
|
27
|
-
json
|
28
|
-
rest-client
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
65
|
+
i18n (>= 0.7, < 2)
|
66
|
+
json (>= 1.7.7)
|
67
|
+
rest-client (>= 1.8.0)
|
68
|
+
lumberjack (1.0.13)
|
69
|
+
method_source (0.9.2)
|
70
|
+
mime-types (2.99.3)
|
71
|
+
mini_portile2 (2.4.0)
|
72
|
+
multi_json (1.14.1)
|
73
|
+
multi_xml (0.6.0)
|
74
|
+
multipart-post (2.1.1)
|
75
|
+
nenv (0.3.0)
|
76
|
+
netrc (0.11.0)
|
77
|
+
nokogiri (1.10.6)
|
78
|
+
mini_portile2 (~> 2.4.0)
|
79
|
+
notiffany (0.1.3)
|
80
|
+
nenv (~> 0.1)
|
81
|
+
shellany (~> 0.0)
|
82
|
+
oauth2 (1.4.2)
|
83
|
+
faraday (>= 0.8, < 2.0)
|
84
|
+
jwt (>= 1.0, < 3.0)
|
85
|
+
multi_json (~> 1.3)
|
86
|
+
multi_xml (~> 0.5)
|
87
|
+
rack (>= 1.2, < 3)
|
88
|
+
pry (0.12.2)
|
89
|
+
coderay (~> 1.1.0)
|
90
|
+
method_source (~> 0.9.0)
|
91
|
+
psych (3.1.0)
|
92
|
+
rack (2.0.7)
|
93
|
+
rake (13.0.1)
|
94
|
+
rb-fsevent (0.10.3)
|
95
|
+
rb-inotify (0.10.0)
|
96
|
+
ffi (~> 1.0)
|
97
|
+
rdoc (6.2.0)
|
98
|
+
rest-client (2.1.0)
|
99
|
+
http-accept (>= 1.7.0, < 2.0)
|
100
|
+
http-cookie (>= 1.0.2, < 2.0)
|
101
|
+
mime-types (>= 1.16, < 4.0)
|
102
|
+
netrc (~> 0.8)
|
103
|
+
rspec (3.9.0)
|
104
|
+
rspec-core (~> 3.9.0)
|
105
|
+
rspec-expectations (~> 3.9.0)
|
106
|
+
rspec-mocks (~> 3.9.0)
|
107
|
+
rspec-core (3.9.0)
|
108
|
+
rspec-support (~> 3.9.0)
|
109
|
+
rspec-expectations (3.9.0)
|
110
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
111
|
+
rspec-support (~> 3.9.0)
|
112
|
+
rspec-mocks (3.9.0)
|
113
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
114
|
+
rspec-support (~> 3.9.0)
|
115
|
+
rspec-support (3.9.0)
|
116
|
+
semver2 (3.4.2)
|
117
|
+
shellany (0.0.1)
|
118
|
+
thor (0.20.3)
|
119
|
+
thread_safe (0.3.6)
|
120
|
+
unf (0.1.4)
|
121
|
+
unf_ext
|
122
|
+
unf_ext (0.0.7.6)
|
51
123
|
|
52
124
|
PLATFORMS
|
53
125
|
ruby
|
54
126
|
|
55
127
|
DEPENDENCIES
|
56
|
-
bundler (~>
|
128
|
+
bundler (~> 2.0)
|
57
129
|
guard-rspec
|
58
130
|
i18n
|
59
|
-
jeweler (~>
|
131
|
+
jeweler (~> 2.3)
|
60
132
|
localeapp
|
61
|
-
rdoc (~>
|
62
|
-
rspec (~>
|
133
|
+
rdoc (~> 6.2)
|
134
|
+
rspec (~> 3.9)
|
135
|
+
|
136
|
+
BUNDLED WITH
|
137
|
+
2.0.2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# iso
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://travis-ci.org/Locale/iso.svg?branch=master)](https://travis-ci.org/Locale/iso)
|
4
4
|
|
5
5
|
This project is a ruby implementation of ISO 639-1 alpha2 and ISO 3166-1. It includes definitions of all two letter language and region codes.
|
6
6
|
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
|
|
20
20
|
gem.summary = %Q{A ruby implementation of ISO}
|
21
21
|
gem.description = %Q{A subset of the ISO spec implemented in ruby}
|
22
22
|
gem.email = "chris@tigrish.com"
|
23
|
-
gem.authors = ["Christopher Dell"]
|
23
|
+
gem.authors = ["Christopher Dell", "Thibault Dalban"]
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/data/iso-639-1.yml
CHANGED
data/iso.gemspec
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: iso 0.
|
5
|
+
# stub: iso 0.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name = "iso"
|
9
|
-
s.version = "0.
|
8
|
+
s.name = "iso".freeze
|
9
|
+
s.version = "0.3.0"
|
10
10
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Christopher Dell"]
|
14
|
-
s.date = "
|
15
|
-
s.description = "A subset of the ISO spec implemented in ruby"
|
16
|
-
s.email = "chris@tigrish.com"
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Christopher Dell".freeze, "Thibault Dalban".freeze]
|
14
|
+
s.date = "2019-12-04"
|
15
|
+
s.description = "A subset of the ISO spec implemented in ruby".freeze
|
16
|
+
s.email = "chris@tigrish.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE.txt",
|
19
19
|
"README.md"
|
@@ -48,39 +48,39 @@ Gem::Specification.new do |s|
|
|
48
48
|
"spec/lib/iso/un/region_spec.rb",
|
49
49
|
"spec/spec_helper.rb"
|
50
50
|
]
|
51
|
-
s.homepage = "http://github.com/tigrish/iso"
|
52
|
-
s.licenses = ["MIT"]
|
53
|
-
s.rubygems_version = "
|
54
|
-
s.summary = "A ruby implementation of ISO"
|
51
|
+
s.homepage = "http://github.com/tigrish/iso".freeze
|
52
|
+
s.licenses = ["MIT".freeze]
|
53
|
+
s.rubygems_version = "3.0.6".freeze
|
54
|
+
s.summary = "A ruby implementation of ISO".freeze
|
55
55
|
|
56
56
|
if s.respond_to? :specification_version then
|
57
57
|
s.specification_version = 4
|
58
58
|
|
59
59
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
-
s.add_runtime_dependency(%q<i18n
|
61
|
-
s.add_development_dependency(%q<rspec
|
62
|
-
s.add_development_dependency(%q<rdoc
|
63
|
-
s.add_development_dependency(%q<bundler
|
64
|
-
s.add_development_dependency(%q<jeweler
|
65
|
-
s.add_development_dependency(%q<guard-rspec
|
66
|
-
s.add_development_dependency(%q<localeapp
|
60
|
+
s.add_runtime_dependency(%q<i18n>.freeze, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.9"])
|
62
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 6.2"])
|
63
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 2.0"])
|
64
|
+
s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
65
|
+
s.add_development_dependency(%q<guard-rspec>.freeze, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<localeapp>.freeze, [">= 0"])
|
67
67
|
else
|
68
|
-
s.add_dependency(%q<i18n
|
69
|
-
s.add_dependency(%q<rspec
|
70
|
-
s.add_dependency(%q<rdoc
|
71
|
-
s.add_dependency(%q<bundler
|
72
|
-
s.add_dependency(%q<jeweler
|
73
|
-
s.add_dependency(%q<guard-rspec
|
74
|
-
s.add_dependency(%q<localeapp
|
68
|
+
s.add_dependency(%q<i18n>.freeze, [">= 0"])
|
69
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.9"])
|
70
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 6.2"])
|
71
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 2.0"])
|
72
|
+
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
73
|
+
s.add_dependency(%q<guard-rspec>.freeze, [">= 0"])
|
74
|
+
s.add_dependency(%q<localeapp>.freeze, [">= 0"])
|
75
75
|
end
|
76
76
|
else
|
77
|
-
s.add_dependency(%q<i18n
|
78
|
-
s.add_dependency(%q<rspec
|
79
|
-
s.add_dependency(%q<rdoc
|
80
|
-
s.add_dependency(%q<bundler
|
81
|
-
s.add_dependency(%q<jeweler
|
82
|
-
s.add_dependency(%q<guard-rspec
|
83
|
-
s.add_dependency(%q<localeapp
|
77
|
+
s.add_dependency(%q<i18n>.freeze, [">= 0"])
|
78
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.9"])
|
79
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 6.2"])
|
80
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 2.0"])
|
81
|
+
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
82
|
+
s.add_dependency(%q<guard-rspec>.freeze, [">= 0"])
|
83
|
+
s.add_dependency(%q<localeapp>.freeze, [">= 0"])
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
data/lib/iso.rb
CHANGED
@@ -2,8 +2,8 @@ require 'i18n'
|
|
2
2
|
I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + '/../locales'), '*.yml')]
|
3
3
|
I18n.load_path.flatten!
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
require_relative 'iso/tag'
|
6
|
+
require_relative 'iso/subtag'
|
7
|
+
require_relative 'iso/language'
|
8
|
+
require_relative 'iso/region'
|
9
|
+
require_relative 'iso/un/region'
|
@@ -4,50 +4,50 @@ describe ISO::Language do
|
|
4
4
|
let(:language) { ISO::Language.new('de', name: 'German') }
|
5
5
|
|
6
6
|
it "is a ISO Subtag" do
|
7
|
-
language.
|
7
|
+
expect(language).to be_kind_of(ISO::Subtag)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "has a code" do
|
11
|
-
language.code.
|
11
|
+
expect(language.code).to eq 'de'
|
12
12
|
end
|
13
13
|
|
14
14
|
it "has a name" do
|
15
|
-
language.name.
|
15
|
+
expect(language.name).to eq 'German'
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#plural_rule_names" do
|
19
19
|
it "defaults to %w(one other)" do
|
20
|
-
language.plural_rule_names.
|
20
|
+
expect(language.plural_rule_names).to eq ISO::Language::DEFAULT_PLURAL_RULE_NAMES
|
21
21
|
end
|
22
22
|
|
23
23
|
it "is overwriteable" do
|
24
24
|
language = ISO::Language.new('ja', plural_rule_names: ['other'])
|
25
|
-
language.plural_rule_names.
|
25
|
+
expect(language.plural_rule_names).to eq ['other']
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "#direction" do
|
30
30
|
it "defaults to 'ltr'" do
|
31
|
-
language.direction.
|
31
|
+
expect(language.direction).to eq 'ltr'
|
32
32
|
end
|
33
33
|
|
34
34
|
it "is overwriteable" do
|
35
35
|
language = ISO::Language.new('ar', direction: :rtl)
|
36
|
-
language.direction.
|
36
|
+
expect(language.direction).to eq :rtl
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe ".identify(full_code)" do
|
41
41
|
it "identifies from 'de'" do
|
42
|
-
ISO::Language.identify('de').
|
42
|
+
expect(ISO::Language.identify('de')).to eq ISO::Language.new('de')
|
43
43
|
end
|
44
44
|
|
45
45
|
it "identifies from 'fr-CH'" do
|
46
|
-
ISO::Language.identify('fr-CH').
|
46
|
+
expect(ISO::Language.identify('fr-CH')).to eq ISO::Language.new('fr')
|
47
47
|
end
|
48
48
|
|
49
49
|
it "returns nil when it can't identify" do
|
50
|
-
ISO::Language.identify('csb').
|
50
|
+
expect(ISO::Language.identify('csb')).to be_nil
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/spec/lib/iso/region_spec.rb
CHANGED
@@ -4,28 +4,28 @@ describe ISO::Region do
|
|
4
4
|
let(:region) { ISO::Region.new('FR', name: 'France') }
|
5
5
|
|
6
6
|
it "is a ISO Subtag" do
|
7
|
-
region.
|
7
|
+
expect(region).to be_kind_of(ISO::Subtag)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "has a code" do
|
11
|
-
region.code.
|
11
|
+
expect(region.code).to eq 'FR'
|
12
12
|
end
|
13
13
|
|
14
14
|
it "has a name" do
|
15
|
-
region.name.
|
15
|
+
expect(region.name).to eq 'France'
|
16
16
|
end
|
17
17
|
|
18
18
|
describe ".identify(full_code)" do
|
19
19
|
it "identifies from 'fr-CH'" do
|
20
|
-
ISO::Region.identify('fr-CH').
|
20
|
+
expect(ISO::Region.identify('fr-CH')).to eq ISO::Region.find('CH')
|
21
21
|
end
|
22
22
|
|
23
23
|
it "identifies from 'es_MX" do
|
24
|
-
ISO::Region.identify('es_MX').
|
24
|
+
expect(ISO::Region.identify('es_MX')).to eq ISO::Region.find('MX')
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns nil when it can't identify" do
|
28
|
-
ISO::Region.identify('gsw').
|
28
|
+
expect(ISO::Region.identify('gsw')).to be_nil
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/spec/lib/iso/subtag_spec.rb
CHANGED
@@ -12,11 +12,11 @@ end
|
|
12
12
|
describe ISO::Subtag do
|
13
13
|
describe "#==(object)" do
|
14
14
|
it "returns true when both have the same code" do
|
15
|
-
ISO::Region.find('SY').
|
15
|
+
expect(ISO::Region.find('SY')).to eq ISO::Region.find('SY')
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns false when they have different codes" do
|
19
|
-
ISO::Region.find('FR').
|
19
|
+
expect(ISO::Region.find('FR')).to_not eq ISO::Region.find('GB')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -25,13 +25,13 @@ describe ISO::Subtag do
|
|
25
25
|
let(:mars) { ISO::Subtag.new('MRS') }
|
26
26
|
|
27
27
|
it 'will accept a name option' do
|
28
|
-
I18n.
|
29
|
-
fake_region.name.
|
28
|
+
expect(I18n).to_not receive(:t)
|
29
|
+
expect(fake_region.name).to eq 'This is a lie'
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'falls back to the translation' do
|
33
|
-
I18n.
|
34
|
-
mars.name.
|
33
|
+
expect(I18n).to receive(:t).with('MRS', scope: 'vendor.iso').and_return('Mars')
|
34
|
+
expect(mars.name).to eq 'Mars'
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -39,41 +39,41 @@ describe ISO::Subtag do
|
|
39
39
|
describe "#full_name" do
|
40
40
|
it "is composed of the code and the name" do
|
41
41
|
full_name = Subtag.find('fr').full_name
|
42
|
-
full_name.
|
43
|
-
full_name.
|
42
|
+
expect(full_name).to match(/fr/)
|
43
|
+
expect(full_name).to match(/French/)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe ".all" do
|
48
48
|
it "gets its definition from the DEFINITIONS_FILE" do
|
49
49
|
subtags = Subtag.all
|
50
|
-
subtags[0].
|
51
|
-
subtags[1].
|
52
|
-
subtags[2].
|
50
|
+
expect(subtags[0]).to eq Subtag.find('en')
|
51
|
+
expect(subtags[1]).to eq Subtag.find('fr')
|
52
|
+
expect(subtags[2]).to eq Subtag.find('de')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe ".find(code)" do
|
57
57
|
it "finds a subtag by code" do
|
58
58
|
subtag = Subtag.find('de')
|
59
|
-
subtag.code.
|
60
|
-
subtag.name.
|
59
|
+
expect(subtag.code).to eq 'de'
|
60
|
+
expect(subtag.name).to eq 'German'
|
61
61
|
end
|
62
62
|
|
63
63
|
it "returns nil when no language can be found" do
|
64
|
-
Subtag.find('xxxx').
|
64
|
+
expect(Subtag.find('xxxx')).to be_nil
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
describe ".default" do
|
69
69
|
it "finds from DEFAULT_CODE" do
|
70
|
-
Subtag.default.
|
70
|
+
expect(Subtag.default).to eq Subtag.find('fr')
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe ".codes" do
|
75
75
|
it "returns an array of all codes" do
|
76
|
-
Subtag.codes.
|
76
|
+
expect(Subtag.codes).to eq %w(en fr de)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/spec/lib/iso/tag_spec.rb
CHANGED
@@ -4,90 +4,90 @@ describe ISO::Tag do
|
|
4
4
|
describe ".new(code)" do
|
5
5
|
it "returns a tag containing the language and region" do
|
6
6
|
tag = ISO::Tag.new('en-MX')
|
7
|
-
tag.language.code.
|
8
|
-
tag.region.code.
|
7
|
+
expect(tag.language.code).to eq 'en'
|
8
|
+
expect(tag.region.code).to eq 'MX'
|
9
9
|
end
|
10
10
|
|
11
11
|
it "returns a tag containing the language and UN region" do
|
12
12
|
tag = ISO::Tag.new('en-419')
|
13
|
-
tag.language.code.
|
14
|
-
tag.region.code.
|
13
|
+
expect(tag.language.code).to eq 'en'
|
14
|
+
expect(tag.region.code).to eq '419'
|
15
15
|
end
|
16
16
|
|
17
17
|
it "returns a tag containing the language only" do
|
18
18
|
tag = ISO::Tag.new('en-XXXXXX')
|
19
|
-
tag.language.code.
|
20
|
-
tag.region.
|
19
|
+
expect(tag.language.code).to eq 'en'
|
20
|
+
expect(tag.region).to be_nil
|
21
21
|
end
|
22
22
|
|
23
23
|
it "returns a tag containing the region only" do
|
24
24
|
tag = ISO::Tag.new('gsw-CH')
|
25
|
-
tag.language.
|
26
|
-
tag.region.code.
|
25
|
+
expect(tag.language).to be_nil
|
26
|
+
expect(tag.region.code).to eq 'CH'
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "returns a tag containing the UN region only" do
|
30
30
|
tag = ISO::Tag.new('gsw-419')
|
31
|
-
tag.language.
|
32
|
-
tag.region.code.
|
31
|
+
expect(tag.language).to be_nil
|
32
|
+
expect(tag.region.code).to eq '419'
|
33
33
|
end
|
34
34
|
|
35
35
|
it "returns a tag containing no language or region" do
|
36
36
|
tag = ISO::Tag.new('csb-XXXXXX')
|
37
|
-
tag.language.
|
38
|
-
tag.region.
|
37
|
+
expect(tag.language).to be_nil
|
38
|
+
expect(tag.region).to be_nil
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "#codes" do
|
43
43
|
it "returns an array containing each subtag's code" do
|
44
|
-
ISO::Tag.new('en-US').codes.
|
44
|
+
expect(ISO::Tag.new('en-US').codes).to eq %w(en US)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "#subtags" do
|
49
49
|
it "returns an array containing the language" do
|
50
50
|
tag = ISO::Tag.new('fr')
|
51
|
-
tag.subtags.size.
|
52
|
-
tag.subtags.first.
|
53
|
-
tag.subtags.first.code.
|
51
|
+
expect(tag.subtags.size).to eq 1
|
52
|
+
expect(tag.subtags.first).to be_kind_of(ISO::Language)
|
53
|
+
expect(tag.subtags.first.code).to eq 'fr'
|
54
54
|
end
|
55
55
|
|
56
56
|
it "returns an array containing the language and the region" do
|
57
57
|
tag = ISO::Tag.new('fr-CH')
|
58
|
-
tag.subtags.size.
|
58
|
+
expect(tag.subtags.size).to eq 2
|
59
59
|
|
60
|
-
tag.subtags.first.
|
61
|
-
tag.subtags.first.code.
|
60
|
+
expect(tag.subtags.first).to be_kind_of(ISO::Language)
|
61
|
+
expect(tag.subtags.first.code).to eq 'fr'
|
62
62
|
|
63
|
-
tag.subtags.last.
|
64
|
-
tag.subtags.last.code.
|
63
|
+
expect(tag.subtags.last).to be_kind_of(ISO::Region)
|
64
|
+
expect(tag.subtags.last.code).to eq 'CH'
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
describe "#valid?" do
|
69
69
|
it "returns true when a valid language is supplied" do
|
70
|
-
ISO::Tag.new('da').
|
70
|
+
expect(ISO::Tag.new('da')).to be_valid
|
71
71
|
end
|
72
72
|
|
73
73
|
it "returns true when a valid language and region are supplied" do
|
74
|
-
ISO::Tag.new('da-AT').
|
74
|
+
expect(ISO::Tag.new('da-AT')).to be_valid
|
75
75
|
end
|
76
76
|
|
77
77
|
it "returns true when a valid language an UN region are supplied" do
|
78
|
-
ISO::Tag.new('es-419').
|
78
|
+
expect(ISO::Tag.new('es-419')).to be_valid
|
79
79
|
end
|
80
80
|
|
81
81
|
it "returns false when no code is supplied" do
|
82
|
-
ISO::Tag.new('').
|
82
|
+
expect(ISO::Tag.new('')).to_not be_valid
|
83
83
|
end
|
84
84
|
|
85
85
|
it "returns false when supplied language is invalid" do
|
86
|
-
ISO::Tag.new('lol').
|
86
|
+
expect(ISO::Tag.new('lol')).to_not be_valid
|
87
87
|
end
|
88
88
|
|
89
89
|
it "returns false when supplied region is invalid" do
|
90
|
-
ISO::Tag.new('en-lol').
|
90
|
+
expect(ISO::Tag.new('en-lol')).to_not be_valid
|
91
91
|
end
|
92
92
|
|
93
93
|
end
|
@@ -6,33 +6,33 @@ describe ISO::UN::Region do
|
|
6
6
|
|
7
7
|
describe "#iso_code" do
|
8
8
|
it "returns the corresponding iso code" do
|
9
|
-
has_iso.iso_code.
|
9
|
+
expect(has_iso.iso_code).to eq 'AF'
|
10
10
|
end
|
11
11
|
|
12
12
|
it "returns nil when there is no corresponding iso code" do
|
13
|
-
no_iso.iso_code.
|
13
|
+
expect(no_iso.iso_code).to be_nil
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "#name" do
|
18
18
|
it "uses the correct scope when there is an iso code" do
|
19
|
-
has_iso.name.
|
19
|
+
expect(has_iso.name).to eq 'Afghanistan'
|
20
20
|
end
|
21
21
|
|
22
22
|
it "uses the correct scope when there is no iso code" do
|
23
|
-
no_iso.name.
|
23
|
+
expect(no_iso.name).to eq 'Africa'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe ".identify(full_code)" do
|
28
28
|
it "identifies from 'es-419'" do
|
29
29
|
region = ISO::UN::Region.identify('es-419')
|
30
|
-
region.
|
31
|
-
region.
|
30
|
+
expect(region).to_not be_nil
|
31
|
+
expect(region).to eq ISO::UN::Region.find('419')
|
32
32
|
end
|
33
33
|
|
34
34
|
it "returns nil when it can't identify" do
|
35
|
-
ISO::UN::Region.identify('gsw').
|
35
|
+
expect(ISO::UN::Region.identify('gsw')).to be_nil
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,111 +1,112 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Dell
|
8
|
+
- Thibault Dalban
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: i18n
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- -
|
18
|
+
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '0'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- -
|
25
|
+
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '0'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rspec
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- - ~>
|
32
|
+
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
+
version: '3.9'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- - ~>
|
39
|
+
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
+
version: '3.9'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: rdoc
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- - ~>
|
46
|
+
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
+
version: '6.2'
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- - ~>
|
53
|
+
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
+
version: '6.2'
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
57
|
name: bundler
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
|
-
- - ~>
|
60
|
+
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
+
version: '2.0'
|
62
63
|
type: :development
|
63
64
|
prerelease: false
|
64
65
|
version_requirements: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
|
-
- - ~>
|
67
|
+
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
+
version: '2.0'
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
71
|
name: jeweler
|
71
72
|
requirement: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
|
-
- - ~>
|
74
|
+
- - "~>"
|
74
75
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
76
|
+
version: '2.3'
|
76
77
|
type: :development
|
77
78
|
prerelease: false
|
78
79
|
version_requirements: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
80
|
-
- - ~>
|
81
|
+
- - "~>"
|
81
82
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
+
version: '2.3'
|
83
84
|
- !ruby/object:Gem::Dependency
|
84
85
|
name: guard-rspec
|
85
86
|
requirement: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
|
-
- -
|
88
|
+
- - ">="
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '0'
|
90
91
|
type: :development
|
91
92
|
prerelease: false
|
92
93
|
version_requirements: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
|
-
- -
|
95
|
+
- - ">="
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '0'
|
97
98
|
- !ruby/object:Gem::Dependency
|
98
99
|
name: localeapp
|
99
100
|
requirement: !ruby/object:Gem::Requirement
|
100
101
|
requirements:
|
101
|
-
- -
|
102
|
+
- - ">="
|
102
103
|
- !ruby/object:Gem::Version
|
103
104
|
version: '0'
|
104
105
|
type: :development
|
105
106
|
prerelease: false
|
106
107
|
version_requirements: !ruby/object:Gem::Requirement
|
107
108
|
requirements:
|
108
|
-
- -
|
109
|
+
- - ">="
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: '0'
|
111
112
|
description: A subset of the ISO spec implemented in ruby
|
@@ -116,8 +117,8 @@ extra_rdoc_files:
|
|
116
117
|
- LICENSE.txt
|
117
118
|
- README.md
|
118
119
|
files:
|
119
|
-
- .document
|
120
|
-
- .rspec
|
120
|
+
- ".document"
|
121
|
+
- ".rspec"
|
121
122
|
- Gemfile
|
122
123
|
- Gemfile.lock
|
123
124
|
- Guardfile
|
@@ -154,17 +155,16 @@ require_paths:
|
|
154
155
|
- lib
|
155
156
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
157
|
requirements:
|
157
|
-
- -
|
158
|
+
- - ">="
|
158
159
|
- !ruby/object:Gem::Version
|
159
160
|
version: '0'
|
160
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
162
|
requirements:
|
162
|
-
- -
|
163
|
+
- - ">="
|
163
164
|
- !ruby/object:Gem::Version
|
164
165
|
version: '0'
|
165
166
|
requirements: []
|
166
|
-
|
167
|
-
rubygems_version: 2.4.6
|
167
|
+
rubygems_version: 3.0.6
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: A ruby implementation of ISO
|