iso 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ en:
2
+ name: English
3
+ fr:
4
+ name: French
5
+ de:
6
+ name: German
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe ISO::Language do
4
+ let(:language) { ISO::Language.new('de', name: 'German') }
5
+
6
+ it "is a ISO Subtag" do
7
+ language.should be_kind_of(ISO::Subtag)
8
+ end
9
+
10
+ it "has a code" do
11
+ language.code.should == 'de'
12
+ end
13
+
14
+ it "has a name" do
15
+ language.name.should == 'German'
16
+ end
17
+
18
+ describe "#plural_rule_names" do
19
+ it "defaults to %w(one other)" do
20
+ language.plural_rule_names.should == ISO::Language::DEFAULT_PLURAL_RULE_NAMES
21
+ end
22
+
23
+ it "is overwriteable" do
24
+ language = ISO::Language.new('ja', plural_rule_names: ['other'])
25
+ language.plural_rule_names.should == ['other']
26
+ end
27
+ end
28
+
29
+ describe "#direction" do
30
+ it "defaults to 'ltr'" do
31
+ language.direction.should == 'ltr'
32
+ end
33
+
34
+ it "is overwriteable" do
35
+ language = ISO::Language.new('ar', direction: :rtl)
36
+ language.direction.should == :rtl
37
+ end
38
+ end
39
+
40
+ describe ".identify(full_code)" do
41
+ it "identifies from 'de'" do
42
+ ISO::Language.identify('de').should == ISO::Language.new('de')
43
+ end
44
+
45
+ it "identifies from 'fr-CH'" do
46
+ ISO::Language.identify('fr-CH').should == ISO::Language.new('fr')
47
+ end
48
+
49
+ it "returns nil when it can't identify" do
50
+ ISO::Language.identify('csb').should be_nil
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe ISO::Region do
4
+ let(:region) { ISO::Region.new('FR', name: 'France') }
5
+
6
+ it "is a ISO Subtag" do
7
+ region.should be_kind_of(ISO::Subtag)
8
+ end
9
+
10
+ it "has a code" do
11
+ region.code.should == 'FR'
12
+ end
13
+
14
+ it "has a name" do
15
+ region.name.should == 'France'
16
+ end
17
+
18
+ describe ".identify(full_code)" do
19
+ it "identifies from 'fr-CH'" do
20
+ ISO::Region.identify('fr-CH').should == ISO::Region.find('CH')
21
+ end
22
+
23
+ it "identifies from 'es_MX" do
24
+ ISO::Region.identify('es_MX').should == ISO::Region.find('MX')
25
+ end
26
+
27
+ it "returns nil when it can't identify" do
28
+ ISO::Region.identify('gsw').should be_nil
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ class Subtag < ISO::Subtag
4
+ DEFINITIONS_FILE = "spec/fixtures/base.yml"
5
+ DEFAULT_CODE = "fr"
6
+ private
7
+ def i18n_scope
8
+ super << ".languages"
9
+ end
10
+ end
11
+
12
+ describe ISO::Subtag do
13
+ describe "#==(object)" do
14
+ it "returns true when both have the same code" do
15
+ ISO::Region.find('SY').should == ISO::Region.find('SY')
16
+ end
17
+
18
+ it "returns false when they have different codes" do
19
+ ISO::Region.find('FR').should_not == ISO::Region.find('GB')
20
+ end
21
+ end
22
+
23
+ describe "#full_name" do
24
+ it "is composed of the code and the name" do
25
+ full_name = Subtag.find('fr').full_name
26
+ full_name.should match(/fr/)
27
+ full_name.should match(/French/)
28
+ end
29
+ end
30
+
31
+ describe ".all" do
32
+ it "gets its definition from the DEFINITIONS_FILE" do
33
+ subtags = Subtag.all
34
+ subtags[0].should == Subtag.find('en')
35
+ subtags[1].should == Subtag.find('fr')
36
+ subtags[2].should == Subtag.find('de')
37
+ end
38
+ end
39
+
40
+ describe ".find(code)" do
41
+ it "finds a subtag by code" do
42
+ subtag = Subtag.find('de')
43
+ subtag.code.should == 'de'
44
+ subtag.name.should == 'German'
45
+ end
46
+
47
+ it "returns nil when no language can be found" do
48
+ Subtag.find('xxxx').should be_nil
49
+ end
50
+ end
51
+
52
+ describe ".default" do
53
+ it "finds from DEFAULT_CODE" do
54
+ Subtag.default.should == Subtag.find('fr')
55
+ end
56
+ end
57
+
58
+ describe ".codes" do
59
+ it "returns an array of all codes" do
60
+ Subtag.codes.should == %w(en fr de)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe ISO::Tag do
4
+ describe ".new(code)" do
5
+ it "returns a tag containing the language and region" do
6
+ tag = ISO::Tag.new('en-MX')
7
+ tag.language.code.should == 'en'
8
+ tag.region.code.should == 'MX'
9
+ end
10
+
11
+ it "returns a tag containing the language only" do
12
+ tag = ISO::Tag.new('en-XXXXXX')
13
+ tag.language.code.should == 'en'
14
+ tag.region.should be_nil
15
+ end
16
+
17
+ it "returns a tag containing the region only" do
18
+ tag = ISO::Tag.new('gsw-CH')
19
+ tag.language.should be_nil
20
+ tag.region.code.should == 'CH'
21
+ end
22
+
23
+ it "returns a tag containing no language or region" do
24
+ tag = ISO::Tag.new('csb-XXXXXX')
25
+ tag.language.should be_nil
26
+ tag.region.should be_nil
27
+ end
28
+ end
29
+
30
+ describe "#codes" do
31
+ it "returns an array containing each subtag's code" do
32
+ ISO::Tag.new('en-US').codes.should == %w(en US)
33
+ end
34
+ end
35
+
36
+ describe "#subtags" do
37
+ it "returns an array containing the language" do
38
+ tag = ISO::Tag.new('fr')
39
+ tag.subtags.size.should == 1
40
+ tag.subtags.first.should be_kind_of(ISO::Language)
41
+ tag.subtags.first.code.should == 'fr'
42
+ end
43
+
44
+ it "returns an array containing the language and the region" do
45
+ tag = ISO::Tag.new('fr-CH')
46
+ tag.subtags.size.should == 2
47
+
48
+ tag.subtags.first.should be_kind_of(ISO::Language)
49
+ tag.subtags.first.code.should == 'fr'
50
+
51
+ tag.subtags.last.should be_kind_of(ISO::Region)
52
+ tag.subtags.last.code.should == 'CH'
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-02 00:00:00.000000000 Z
12
+ date: 2012-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: i18n
16
+ requirement: &70269566174700 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70269566174700
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: rspec
16
- requirement: &70127719565080 !ruby/object:Gem::Requirement
27
+ requirement: &70269578659260 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
@@ -21,10 +32,10 @@ dependencies:
21
32
  version: 2.8.0
22
33
  type: :development
23
34
  prerelease: false
24
- version_requirements: *70127719565080
35
+ version_requirements: *70269578659260
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: rdoc
27
- requirement: &70127719564080 !ruby/object:Gem::Requirement
38
+ requirement: &70269578658780 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ~>
@@ -32,10 +43,10 @@ dependencies:
32
43
  version: '3.12'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *70127719564080
46
+ version_requirements: *70269578658780
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: bundler
38
- requirement: &70127719562500 !ruby/object:Gem::Requirement
49
+ requirement: &70269578658300 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ~>
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: 1.2.0
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *70127719562500
57
+ version_requirements: *70269578658300
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: jeweler
49
- requirement: &70127719560760 !ruby/object:Gem::Requirement
60
+ requirement: &70269578657820 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ~>
@@ -54,27 +65,60 @@ dependencies:
54
65
  version: 1.8.4
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70127719560760
58
- description: A ruby implementation of ISO languages and regions and they're translation
59
- data (such as language direction, pluralization rules).
68
+ version_requirements: *70269578657820
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: &70269578657340 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70269578657340
80
+ - !ruby/object:Gem::Dependency
81
+ name: localeapp
82
+ requirement: &70269578656860 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70269578656860
91
+ description: A subset of the ISO spec implemented in ruby
60
92
  email: chris@tigrish.com
61
93
  executables: []
62
94
  extensions: []
63
95
  extra_rdoc_files:
64
96
  - LICENSE.txt
65
- - README.rdoc
97
+ - README.md
66
98
  files:
67
99
  - .document
68
100
  - .rspec
69
101
  - Gemfile
70
102
  - Gemfile.lock
103
+ - Guardfile
71
104
  - LICENSE.txt
72
- - README.rdoc
105
+ - README.md
73
106
  - Rakefile
74
107
  - VERSION
108
+ - data/iso-3166-1.yml
109
+ - data/iso-639-1.yml
75
110
  - iso.gemspec
76
111
  - lib/iso.rb
77
- - spec/iso_spec.rb
112
+ - lib/iso/language.rb
113
+ - lib/iso/region.rb
114
+ - lib/iso/subtag.rb
115
+ - lib/iso/tag.rb
116
+ - locales/en.yml
117
+ - spec/fixtures/base.yml
118
+ - spec/lib/iso/language_spec.rb
119
+ - spec/lib/iso/region_spec.rb
120
+ - spec/lib/iso/subtag_spec.rb
121
+ - spec/lib/iso/tag_spec.rb
78
122
  - spec/spec_helper.rb
79
123
  homepage: http://github.com/tigrish/iso
80
124
  licenses:
@@ -91,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
135
  version: '0'
92
136
  segments:
93
137
  - 0
94
- hash: -2036970180345028082
138
+ hash: -1936047706480761074
95
139
  required_rubygems_version: !ruby/object:Gem::Requirement
96
140
  none: false
97
141
  requirements:
@@ -103,6 +147,5 @@ rubyforge_project:
103
147
  rubygems_version: 1.8.6
104
148
  signing_key:
105
149
  specification_version: 3
106
- summary: A ruby implementation of ISO languages and regions and they're translation
107
- data.
150
+ summary: A ruby implementation of ISO
108
151
  test_files: []
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = iso
2
-
3
- Description goes here.
4
-
5
- == Contributing to iso
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2012 Christopher Dell. See LICENSE.txt for
18
- further details.
19
-
data/spec/iso_spec.rb DELETED
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Iso" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end