iso-639 0.2.5 → 0.2.6

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: 2c1644722c56e4a17a8fdcfa3bfcd4b8b48842e2
4
- data.tar.gz: ea8dbec6a423b9eaeaef0dcc262543568fe7ca1e
3
+ metadata.gz: 0263cfd7186c66c99ef204cae8d806be734572e4
4
+ data.tar.gz: 1a63d2d476333d43a3c33bd370bbfcb602a97eec
5
5
  SHA512:
6
- metadata.gz: 55341b7cb9629618bd6233a96bbf154437530765a67f0e62dad891efd358dad2b7b64beef8bf10dcefe8c7f1a57a0e22f1da4617061e69444b04a44d3f065d3d
7
- data.tar.gz: d9528fe3161762d4602b8bbc7c1a41196b9b5333d0182d6f0da8f80708209203db9d72a58ddb376823f8c8463ae263a35eaf9aa4dfd7906fb7c2fb809c6e89b9
6
+ metadata.gz: 654bb7a95891255fbdff11d2bb3c18972010f7f7db152868c562400c53df56f91f66529e744157bec811abcfcb1ab835658fc657cfd7927b47d2b6f0bd1ed976
7
+ data.tar.gz: 026f9abed71f92bfdaf89a73a4f930e26f755d5f29b07553b55dd732a6de71298fc68f3b22cef910a88095ef7eac7fa6225659292c09e22d089fce692d8a5e39
data/Gemfile CHANGED
@@ -6,9 +6,10 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development, :test do
9
- gem "minitest", "~> 4.7.5"
10
- gem "mocha", "~> 0.14.0"
11
- gem "rdoc", "~> 3.12"
12
- gem "shoulda", ">= 0"
9
+ gem "minitest"
10
+ gem "mocha"
13
11
  gem "rake"
12
+ gem "rdoc"
13
+ gem "rubocop"
14
+ gem "test-unit"
14
15
  end
@@ -1,32 +1,41 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (3.2.8)
5
- i18n (~> 0.6)
6
- multi_json (~> 1.0)
7
- i18n (0.6.1)
8
- json (1.7.5)
9
- metaclass (0.0.1)
10
- minitest (4.7.5)
11
- mocha (0.14.0)
4
+ ast (2.2.0)
5
+ json (1.8.3)
6
+ metaclass (0.0.4)
7
+ minitest (5.8.4)
8
+ mocha (1.1.0)
12
9
  metaclass (~> 0.0.1)
13
- multi_json (1.3.6)
14
- rake (0.9.2.2)
15
- rdoc (3.12)
10
+ parser (2.3.1.0)
11
+ ast (~> 2.2)
12
+ power_assert (0.3.0)
13
+ powerpack (0.1.1)
14
+ rainbow (2.1.0)
15
+ rake (11.1.2)
16
+ rdoc (4.2.2)
16
17
  json (~> 1.4)
17
- shoulda (3.3.2)
18
- shoulda-context (~> 1.0.1)
19
- shoulda-matchers (~> 1.4.1)
20
- shoulda-context (1.0.1)
21
- shoulda-matchers (1.4.1)
22
- activesupport (>= 3.0.0)
18
+ rubocop (0.40.0)
19
+ parser (>= 2.3.1.0, < 3.0)
20
+ powerpack (~> 0.1)
21
+ rainbow (>= 1.99.1, < 3.0)
22
+ ruby-progressbar (~> 1.7)
23
+ unicode-display_width (~> 1.0, >= 1.0.1)
24
+ ruby-progressbar (1.8.0)
25
+ test-unit (3.1.8)
26
+ power_assert
27
+ unicode-display_width (1.0.5)
23
28
 
24
29
  PLATFORMS
25
30
  ruby
26
31
 
27
32
  DEPENDENCIES
28
- minitest (~> 4.7.5)
29
- mocha (~> 0.14.0)
33
+ minitest
34
+ mocha
30
35
  rake
31
- rdoc (~> 3.12)
32
- shoulda
36
+ rdoc
37
+ rubocop
38
+ test-unit
39
+
40
+ BUNDLED WITH
41
+ 1.12.2
@@ -33,7 +33,7 @@ always returns an array of 0 or more results. For example:
33
33
  # => [["spa", "", "es", "Spanish; Castilian", "espagnol; castillan"]]
34
34
 
35
35
  Entries are arrays with convenience methods for accessing fields:
36
-
36
+
37
37
  @entry = ISO_639.find("slo")
38
38
  # => ["slo", "slk", "sk", "Slovak", "slovaque"]
39
39
  @entry.alpha3_bibliographic
@@ -52,7 +52,7 @@ Entries are arrays with convenience methods for accessing fields:
52
52
  The full data set is available through the `ISO_639::ISO_639_1` and `ISO_639::ISO_639_2` constants.
53
53
 
54
54
  ## Note on Patches/Pull Requests
55
-
55
+
56
56
  * Fork the project.
57
57
  * Make your feature addition or bug fix.
58
58
  * Add tests for it. This is important so I don't break it in a
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ Rake::TestTask.new(:test) do |test|
18
18
  test.verbose = true
19
19
  end
20
20
 
21
- task :default => :test
21
+ task default: :test
22
22
 
23
23
  require 'rdoc/task'
24
24
  Rake::RDocTask.new do |rdoc|
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "iso-639"
8
- s.version = "0.2.5"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["William Melody"]
12
- s.date = "2014-07-20"
12
+ s.date = "2016-05-09"
13
13
  s.description = "ISO 639-1 and ISO 639-2 language code entries and convenience methods"
14
14
  s.email = "hi@williammelody.com"
15
15
  s.extra_rdoc_files = [
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  "iso-639.gemspec",
27
27
  "lib/iso-639.rb",
28
28
  "test/helper.rb",
29
- "test/test_ISO_639.rb"
29
+ "test/test_iso_639.rb"
30
30
  ]
31
31
  s.homepage = "http://github.com/alphabetum/iso-639"
32
32
  s.licenses = ["MIT"]
@@ -34,25 +34,27 @@ Gem::Specification.new do |s|
34
34
  s.rubygems_version = "1.8.24"
35
35
  s.summary = "ISO 639-1 and ISO 639-2 language code entries and convenience methods"
36
36
 
37
- if s.respond_to? :specification_version then
37
+ if s.respond_to? :specification_version
38
38
  s.specification_version = 3
39
39
 
40
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
- s.add_development_dependency(%q<minitest>, ["~> 4.7.5"])
42
- s.add_development_dependency(%q<mocha>, ["~> 0.14.0"])
43
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
44
- s.add_development_dependency(%q<shoulda>, [">= 0"])
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0')
41
+ s.add_development_dependency("minitest", [">= 0"])
42
+ s.add_development_dependency("mocha", [">= 0"])
43
+ s.add_development_dependency("rdoc", [">= 0"])
44
+ s.add_development_dependency("rubocop", [">= 0"])
45
+ s.add_development_dependency("test-unit", [">= 0"])
45
46
  else
46
- s.add_dependency(%q<minitest>, ["~> 4.7.5"])
47
- s.add_dependency(%q<mocha>, ["~> 0.14.0"])
48
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
49
- s.add_dependency(%q<shoulda>, [">= 0"])
47
+ s.add_dependency("minitest", [">= 0"])
48
+ s.add_dependency("mocha", [">= 0"])
49
+ s.add_dependency("rdoc", [">= 0"])
50
+ s.add_dependency("rubocop", [">= 0"])
51
+ s.add_dependency("test-unit", [">= 0"])
50
52
  end
51
53
  else
52
- s.add_dependency(%q<minitest>, ["~> 4.7.5"])
53
- s.add_dependency(%q<mocha>, ["~> 0.14.0"])
54
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
- s.add_dependency(%q<shoulda>, [">= 0"])
54
+ s.add_dependency("minitest", [">= 0"])
55
+ s.add_dependency("mocha", [">= 0"])
56
+ s.add_dependency("rdoc", [">= 0"])
57
+ s.add_dependency("rubocop", [">= 0"])
58
+ s.add_dependency("test-unit", [">= 0"])
56
59
  end
57
60
  end
58
-
@@ -2,7 +2,6 @@
2
2
  # http://www.loc.gov/standards/iso639-2/ascii_8bits.html
3
3
 
4
4
  class ISO_639 < Array
5
-
6
5
  # The ISO 639-2 dataset as an array of entries. Each entry is an array with
7
6
  # the following format:
8
7
  # * [0]: an alpha-3 (bibliographic) code
@@ -500,7 +499,7 @@ class ISO_639 < Array
500
499
 
501
500
  # An inverted index generated from the ISO_639_2 data. Used for searching
502
501
  # all words and codes in all fields.
503
- INVERTED_INDEX = lambda {
502
+ INVERTED_INDEX = lambda do
504
503
  index = {}
505
504
  ISO_639_2.each_with_index do |record, i|
506
505
  record.each do |field|
@@ -518,8 +517,8 @@ class ISO_639 < Array
518
517
  end
519
518
  end
520
519
  return index
521
- }.call
522
-
520
+ end.call
521
+
523
522
  # The ISO 639-1 dataset as an array of entries. Each entry is an array with
524
523
  # the following format:
525
524
  # * [0]: an ISO 369-2 alpha-3 (bibliographic) code
@@ -530,7 +529,7 @@ class ISO_639 < Array
530
529
  ISO_639_1 = ISO_639_2.collect do |entry|
531
530
  entry unless entry[2].empty?
532
531
  end.compact
533
-
532
+
534
533
  class << self
535
534
  # Returns the entry array for an alpha-2 or alpha-3 code
536
535
  def find_by_code(code)
@@ -547,14 +546,14 @@ class ISO_639 < Array
547
546
  end
548
547
  end
549
548
  alias_method :find, :find_by_code
550
-
549
+
551
550
  # Returns the entry array for a language specified by its English name.
552
551
  def find_by_english_name(name)
553
552
  ISO_639_2.detect do |entry|
554
553
  entry if entry.english_name == name
555
554
  end
556
555
  end
557
-
556
+
558
557
  # Returns the entry array for a language specified by its French name.
559
558
  def find_by_french_name(name)
560
559
  ISO_639_2.detect do |entry|
@@ -572,17 +571,30 @@ class ISO_639 < Array
572
571
  indexes ? ISO_639_2.values_at(*indexes).uniq : []
573
572
  end
574
573
  end
575
-
574
+
576
575
  # The entry's alpha-3 bibliotigraphic code.
577
- def alpha3_bibliographic; self[0] end
576
+ def alpha3_bibliographic
577
+ self[0]
578
+ end
578
579
  alias_method :alpha3, :alpha3_bibliographic
580
+
579
581
  # The entry's alpha-3 terminologic (when given)
580
- def alpha3_terminologic; self[1] end
582
+ def alpha3_terminologic
583
+ self[1]
584
+ end
585
+
581
586
  # The entry's alpha-2 code (when given)
582
- def alpha2; self[2] end
587
+ def alpha2
588
+ self[2]
589
+ end
590
+
583
591
  # The entry's english name.
584
- def english_name; self[3] end
592
+ def english_name
593
+ self[3]
594
+ end
595
+
585
596
  # The entry's french name.
586
- def french_name; self[4] end
587
-
597
+ def french_name
598
+ self[4]
599
+ end
588
600
  end
@@ -7,13 +7,10 @@ rescue Bundler::BundlerError => e
7
7
  $stderr.puts "Run `bundle install` to install missing gems"
8
8
  exit e.status_code
9
9
  end
10
- require 'test/unit'
11
- require 'shoulda'
10
+ require 'minitest/autorun'
11
+ require 'minitest/pride'
12
12
  require 'mocha/setup'
13
13
 
14
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
15
  $LOAD_PATH.unshift(File.dirname(__FILE__))
16
16
  require 'iso-639'
17
-
18
- class Test::Unit::TestCase
19
- end
@@ -1,71 +1,70 @@
1
1
  # encoding: UTF-8
2
2
  require 'helper'
3
3
 
4
- class TestISO639 < Test::Unit::TestCase
5
-
6
- should "have full code list in ISO_639_2" do
4
+ describe ISO_639 do
5
+ it "should have full code list in ISO_639_2" do
7
6
  assert_equal 485, ISO_639::ISO_639_2.length
8
7
  end
9
-
10
- should "have shorter code list in ISO_639_1" do
8
+
9
+ it "should have shorter code list in ISO_639_1" do
11
10
  assert_equal 184, ISO_639::ISO_639_1.length
12
11
  end
13
-
14
- should "return nil find_by_code when code does not exist or is invalid" do
12
+
13
+ it "should return nil find_by_code when code does not exist or is invalid" do
15
14
  assert ISO_639.find_by_code(nil).nil?, 'nil code'
16
15
  assert ISO_639.find_by_code('xxx').nil?, 'xxx alfa-3 not existing code'
17
16
  assert ISO_639.find_by_code('xx').nil?, 'xx alfa-2 not existing code'
18
17
  assert ISO_639.find_by_code('xxxx').nil?, 'xxxx lengthy code'
19
- assert ISO_639.find_by_code('').nil? ,'empty string code'
18
+ assert ISO_639.find_by_code('').nil?, 'empty string code'
20
19
  end
21
-
22
- should "return entry for alpha-2 code" do
20
+
21
+ it "should return entry for alpha-2 code" do
23
22
  assert_equal ["eng", "", "en", "English", "anglais"], ISO_639.find_by_code("en")
24
23
  assert_equal ["eng", "", "en", "English", "anglais"], ISO_639.find("en")
25
24
  end
26
25
 
27
- should "return entry for alpha-3 terminologic code" do
26
+ it "should return entry for alpha-3 terminologic code" do
28
27
  assert_equal ["ger", "deu", "de", "German", "allemand"], ISO_639.find("deu")
29
28
  end
30
-
31
- should "find by english name" do
29
+
30
+ it "should find by english name" do
32
31
  assert_equal ["eng", "", "en", "English", "anglais"], ISO_639.find_by_english_name("English")
33
32
  end
34
-
35
- should "find by french name" do
33
+
34
+ it "should find by french name" do
36
35
  assert_equal ["eng", "", "en", "English", "anglais"], ISO_639.find_by_french_name("anglais")
37
36
  end
38
-
39
- %w[
37
+
38
+ %w(
40
39
  alpha3_bibliographic
41
40
  alpha3
42
41
  alpha3_terminologic
43
42
  alpha2
44
43
  english_name
45
44
  french_name
46
- ].each_with_index do |m, i|
47
- should "respond to and return #{m}" do
45
+ ).each_with_index do |m, i|
46
+ it "should respond to and return #{m}" do
48
47
  @entry = ISO_639.find("en")
49
48
  assert @entry.respond_to?(m)
50
49
  assert_equal ["eng", "eng", "", "en", "English", "anglais"][i], @entry.send(m)
51
50
  end
52
51
  end
53
52
 
54
- should "return single record array by searching a unique code" do
53
+ it "should return single record array by searching a unique code" do
55
54
  assert_equal(
56
55
  [["spa", "", "es", "Spanish; Castilian", "espagnol; castillan"]],
57
56
  ISO_639.search("es")
58
57
  )
59
58
  end
60
59
 
61
- should "return single record array by searching a unique term" do
60
+ it "should return single record array by searching a unique term" do
62
61
  assert_equal(
63
62
  [["spa", "", "es", "Spanish; Castilian", "espagnol; castillan"]],
64
63
  ISO_639.search("spanish")
65
64
  )
66
65
  end
67
66
 
68
- should "return multiple record array by searching a common term" do
67
+ it "should return multiple record array by searching a common term" do
69
68
  assert_equal(
70
69
  [
71
70
  ["egy", "", "", "Egyptian (Ancient)", "égyptien"],
@@ -75,21 +74,20 @@ class TestISO639 < Test::Unit::TestCase
75
74
  )
76
75
  end
77
76
 
78
- should "return empty array when searching a non-existent term" do
77
+ it "should return empty array when searching a non-existent term" do
79
78
  assert_equal(
80
79
  [], ISO_639.search("bad term")
81
80
  )
82
81
  end
83
82
 
84
- should "return empty array when searching a nil term" do
83
+ it "should return empty array when searching a nil term" do
85
84
  assert_equal [], ISO_639.search(nil)
86
85
  end
87
86
 
88
- should "return single record array by searching a unique multi-word term" do
87
+ it "should return single record array by searching a unique multi-word term" do
89
88
  assert_equal(
90
89
  [["ypk", "", "", "Yupik languages", "yupik, langues"]],
91
90
  ISO_639.search("yupik, langues")
92
91
  )
93
92
  end
94
-
95
93
  end
metadata CHANGED
@@ -1,59 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso-639
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Melody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-20 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.7.5
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.7.5
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mocha
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.14.0
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.14.0
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.12'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.12'
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: shoulda
70
+ name: test-unit
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -83,7 +97,7 @@ files:
83
97
  - iso-639.gemspec
84
98
  - lib/iso-639.rb
85
99
  - test/helper.rb
86
- - test/test_ISO_639.rb
100
+ - test/test_iso_639.rb
87
101
  homepage: http://github.com/alphabetum/iso-639
88
102
  licenses:
89
103
  - MIT
@@ -104,8 +118,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
118
  version: '0'
105
119
  requirements: []
106
120
  rubyforge_project:
107
- rubygems_version: 2.2.1
121
+ rubygems_version: 2.5.1
108
122
  signing_key:
109
123
  specification_version: 3
110
124
  summary: ISO 639-1 and ISO 639-2 language code entries and convenience methods
111
125
  test_files: []
126
+ has_rdoc: