iso_country_codes 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,4 +5,5 @@ gem 'rdoc'
5
5
 
6
6
  group :development do
7
7
  gem 'jeweler'
8
+ gem 'nokogiri'
8
9
  end
data/Gemfile.lock CHANGED
@@ -7,8 +7,8 @@ GEM
7
7
  git (>= 1.2.5)
8
8
  rake
9
9
  json (1.6.1)
10
+ nokogiri (1.5.2)
10
11
  rake (0.9.2.2)
11
- rcov (0.9.11)
12
12
  rdoc (3.11)
13
13
  json (~> 1.4)
14
14
 
@@ -17,6 +17,6 @@ PLATFORMS
17
17
 
18
18
  DEPENDENCIES
19
19
  jeweler
20
+ nokogiri
20
21
  rake
21
- rcov
22
22
  rdoc
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.2.4 / 2012-03-13
2
+
3
+ * Added IsoCountryCodes.for_select convenience method
4
+ * Updated with the latest country names from Wikipedia
5
+
1
6
  === 0.2.3 / 2011-10-27
2
7
 
3
8
  * Updated with the latest data from Wikipedia
data/README.rdoc CHANGED
@@ -31,6 +31,9 @@ Provides ISO codes, names and currencies for countries.
31
31
  # Fetch a country's local currency
32
32
  IsoCountryCodes.find('aus').currency # => "AUD"
33
33
 
34
+ # Output an Array of countries and their codes for use form helper methods
35
+ IsoCountryCodes.for_select # => Array
36
+
34
37
  == INSTALL:
35
38
 
36
39
  gem install iso_country_codes
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 3
3
- :major: 0
4
2
  :build:
5
- :minor: 2
3
+ :minor: 3
4
+ :patch: 0
5
+ :major: 0
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "iso_country_codes"
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["alex"]
12
+ s.date = "2012-03-13"
13
+ s.description = "ISO country code and currency library"
14
+ s.email = "alexrabarts@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "History.txt",
22
+ "Manifest.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION.yml",
26
+ "iso_country_codes.gemspec",
27
+ "lib/iso_country_codes.rb",
28
+ "lib/iso_country_codes/code.rb",
29
+ "lib/iso_country_codes/iso_3166_1.rb",
30
+ "lib/iso_country_codes/iso_4217.rb",
31
+ "lib/iso_country_codes/iso_country_codes.rb",
32
+ "rakelib/cultivate.rake",
33
+ "rakelib/iso_3166_1.rake",
34
+ "rakelib/iso_3166_1.rb",
35
+ "rakelib/iso_3166_1.rb.erb",
36
+ "test/iso_country_codes_test.rb"
37
+ ]
38
+ s.homepage = "http://github.com/alexrabarts/iso_country_codes"
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.10"
41
+ s.summary = "Provides ISO 3166-1 country codes/names and ISO 4217 currencies."
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
48
+ s.add_runtime_dependency(%q<rdoc>, [">= 0"])
49
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
50
+ s.add_development_dependency(%q<nokogiri>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<rake>, [">= 0"])
53
+ s.add_dependency(%q<rdoc>, [">= 0"])
54
+ s.add_dependency(%q<jeweler>, [">= 0"])
55
+ s.add_dependency(%q<nokogiri>, [">= 0"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<rake>, [">= 0"])
59
+ s.add_dependency(%q<rdoc>, [">= 0"])
60
+ s.add_dependency(%q<jeweler>, [">= 0"])
61
+ s.add_dependency(%q<nokogiri>, [">= 0"])
62
+ end
63
+ end
64
+
@@ -47,6 +47,10 @@ class IsoCountryCodes
47
47
  @@codes.uniq
48
48
  end
49
49
 
50
+ def for_select(type = :alpha2)
51
+ all.map { |country| [country.name, country.send(type)] }
52
+ end
53
+
50
54
  def currencies
51
55
  if defined? @currencies
52
56
  return @currencies
@@ -1360,7 +1360,7 @@ class IsoCountryCodes
1360
1360
  end
1361
1361
  class LBY < Code #:nodoc:
1362
1362
  self.numeric = %q{434}
1363
- self.name = %q{Libyan Arab Jamahiriya}
1363
+ self.name = %q{Libya}
1364
1364
  self.alpha2 = %q{LY}
1365
1365
  self.alpha3 = %q{LBY}
1366
1366
  end
@@ -2,6 +2,11 @@ class IsoCountryCodes # :nodoc:
2
2
  class UnknownCodeError < StandardError; end
3
3
 
4
4
  class << self
5
+
6
+ def for_select(*args)
7
+ Code.for_select(*args)
8
+ end
9
+
5
10
  def all
6
11
  Code.all
7
12
  end
@@ -77,12 +77,21 @@ class TestIsoCountryCodes < Test::Unit::TestCase
77
77
  assert_equal 'AUS', IsoCountryCodes::Code::AUS.alpha3
78
78
  assert_equal 'AUS', IsoCountryCodes::Code::AUS.instance.alpha3
79
79
  end
80
-
80
+
81
81
  def test_get_name
82
82
  assert_equal 'Australia', IsoCountryCodes::Code::AUS.name
83
83
  assert_equal 'Australia', IsoCountryCodes::Code::AUS.instance.name
84
84
  end
85
85
 
86
+ def test_for_select
87
+ assert IsoCountryCodes::Code.for_select.is_a?(Array)
88
+ assert_equal IsoCountryCodes::Code.for_select.length, IsoCountryCodes::Code.all.length
89
+ end
90
+
91
+ def test_for_select_value_attribute
92
+ assert_equal IsoCountryCodes::Code.for_select(:alpha3)[0][1].length, 3
93
+ end
94
+
86
95
  def test_unknown_iso_code
87
96
  assert_raises IsoCountryCodes::UnknownCodeError do
88
97
  IsoCountryCodes.find('FOO')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso_country_codes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
8
  - 3
10
- version: 0.2.3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - alex
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-27 00:00:00 +01:00
19
- default_executable:
18
+ date: 2012-03-13 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rake
@@ -60,6 +59,20 @@ dependencies:
60
59
  version: "0"
61
60
  type: :development
62
61
  version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: nokogiri
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :development
75
+ version_requirements: *id004
63
76
  description: ISO country code and currency library
64
77
  email: alexrabarts@gmail.com
65
78
  executables: []
@@ -76,6 +89,7 @@ files:
76
89
  - README.rdoc
77
90
  - Rakefile
78
91
  - VERSION.yml
92
+ - iso_country_codes.gemspec
79
93
  - lib/iso_country_codes.rb
80
94
  - lib/iso_country_codes/code.rb
81
95
  - lib/iso_country_codes/iso_3166_1.rb
@@ -86,7 +100,6 @@ files:
86
100
  - rakelib/iso_3166_1.rb
87
101
  - rakelib/iso_3166_1.rb.erb
88
102
  - test/iso_country_codes_test.rb
89
- has_rdoc: true
90
103
  homepage: http://github.com/alexrabarts/iso_country_codes
91
104
  licenses: []
92
105
 
@@ -116,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
129
  requirements: []
117
130
 
118
131
  rubyforge_project:
119
- rubygems_version: 1.4.2
132
+ rubygems_version: 1.8.10
120
133
  signing_key:
121
134
  specification_version: 3
122
135
  summary: Provides ISO 3166-1 country codes/names and ISO 4217 currencies.