iso 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -44,6 +44,11 @@ The combination of a language and a region is called a Tag :
44
44
  @code="BR",
45
45
  @name="Brazil">>
46
46
 
47
+ You can check if a Tag is valid like so :
48
+
49
+ > ISO::Tag.new('pt-BR').valid? => true
50
+ > ISO::Tag.new('lolcat').valid? => false
51
+
47
52
  ## I18n
48
53
 
49
- Language and region names are internationalized - [contribute to the I18n project directly on Locale](http://www.localeapp.com/projects/1763) for any changes.
54
+ Language and region names are internationalized - [contribute to the I18n project directly on Locale](http://www.localeapp.com/projects/1763) for any changes.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{iso}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Christopher Dell}]
12
- s.date = %q{2012-09-03}
12
+ s.date = %q{2012-09-14}
13
13
  s.description = %q{A subset of the ISO spec implemented in ruby}
14
14
  s.email = %q{chris@tigrish.com}
15
15
  s.extra_rdoc_files = [
@@ -15,5 +15,10 @@ module ISO
15
15
  def subtags
16
16
  [language, region].compact
17
17
  end
18
+
19
+ def valid?
20
+ return false if @language.nil?
21
+ @code.split('-').size == subtags.size
22
+ end
18
23
  end
19
24
  end
@@ -52,4 +52,26 @@ describe ISO::Tag do
52
52
  tag.subtags.last.code.should == 'CH'
53
53
  end
54
54
  end
55
+
56
+ describe "#valid?" do
57
+ it "returns true when a valid language is supplied" do
58
+ ISO::Tag.new('da').should be_valid
59
+ end
60
+
61
+ it "returns true when a valid language and region are supplied" do
62
+ ISO::Tag.new('da-AT').should be_valid
63
+ end
64
+
65
+ it "returns false when no code is supplied" do
66
+ ISO::Tag.new('').should_not be_valid
67
+ end
68
+
69
+ it "returns false when supplied language is invalid" do
70
+ ISO::Tag.new('lol').should_not be_valid
71
+ end
72
+
73
+ it "returns false when supplied region is invalid" do
74
+ ISO::Tag.new('en-lol').should_not be_valid
75
+ end
76
+ end
55
77
  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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-03 00:00:00.000000000 Z
12
+ date: 2012-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
16
- requirement: &70188441598820 !ruby/object:Gem::Requirement
16
+ requirement: &70340463586180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70188441598820
24
+ version_requirements: *70340463586180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70188441598340 !ruby/object:Gem::Requirement
27
+ requirement: &70340463585700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70188441598340
35
+ version_requirements: *70340463585700
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdoc
38
- requirement: &70188441597860 !ruby/object:Gem::Requirement
38
+ requirement: &70340463585220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.12'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70188441597860
46
+ version_requirements: *70340463585220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70188441597380 !ruby/object:Gem::Requirement
49
+ requirement: &70340463584740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.2.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70188441597380
57
+ version_requirements: *70340463584740
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70188441596900 !ruby/object:Gem::Requirement
60
+ requirement: &70340463584260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.8.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70188441596900
68
+ version_requirements: *70340463584260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
- requirement: &70188441596420 !ruby/object:Gem::Requirement
71
+ requirement: &70340463583780 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70188441596420
79
+ version_requirements: *70340463583780
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: localeapp
82
- requirement: &70188441595940 !ruby/object:Gem::Requirement
82
+ requirement: &70340463583300 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70188441595940
90
+ version_requirements: *70340463583300
91
91
  description: A subset of the ISO spec implemented in ruby
92
92
  email: chris@tigrish.com
93
93
  executables: []
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  segments:
138
138
  - 0
139
- hash: 3390383372012130098
139
+ hash: 1679790692355639075
140
140
  required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements: