alexrabarts-iso_country_codes 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/History.txt +5 -0
- data/{README.txt → README.rdoc} +0 -0
- data/Rakefile +49 -12
- data/VERSION.yml +4 -0
- data/iso_country_codes.gemspec +38 -18
- data/lib/iso_country_codes/iso_3166_1.rb +6 -4
- data/rakelib/{iso_3116_1.rake → iso_3166_1.rake} +2 -2
- data/rakelib/iso_3166_1.rb +17 -10
- data/rakelib/iso_3166_1.rb.erb +2 -0
- data/test/{test_iso_country_codes.rb → iso_country_codes_test.rb} +0 -0
- metadata +22 -31
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/History.txt
CHANGED
data/{README.txt → README.rdoc}
RENAMED
File without changes
|
data/Rakefile
CHANGED
@@ -1,17 +1,54 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'hoe'
|
1
|
+
require 'rake'
|
5
2
|
require './lib/iso_country_codes.rb'
|
6
3
|
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |s|
|
7
|
+
s.name = 'iso_country_codes'
|
8
|
+
s.summary = %Q{
|
9
|
+
Provides ISO 3166-1 country codes/names and ISO 4217 currencies.
|
10
|
+
}
|
11
|
+
s.email = "alexrabarts@gmail.com"
|
12
|
+
s.homepage = "http://github.com/alexrabarts/iso_country_codes"
|
13
|
+
s.description = "ISO country code and currency library"
|
14
|
+
s.authors = ["alex"]
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/rdoctask'
|
21
|
+
Rake::RDocTask.new do |rdoc|
|
22
|
+
rdoc.rdoc_dir = 'rdoc'
|
23
|
+
rdoc.title = 'iso_country_codes'
|
24
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
25
|
+
rdoc.rdoc_files.include('README*')
|
26
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib' << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
require 'rcov/rcovtask'
|
38
|
+
Rcov::RcovTask.new do |t|
|
39
|
+
t.libs << 'test'
|
40
|
+
t.test_files = FileList['test/**/*_test.rb']
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
rescue LoadError
|
44
|
+
puts "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
10
45
|
end
|
11
46
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
47
|
+
begin
|
48
|
+
require 'cucumber/rake/task'
|
49
|
+
Cucumber::Rake::Task.new(:features)
|
50
|
+
rescue LoadError
|
51
|
+
puts "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
52
|
+
end
|
16
53
|
|
17
|
-
|
54
|
+
task :default => :test
|
data/VERSION.yml
ADDED
data/iso_country_codes.gemspec
CHANGED
@@ -1,32 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = %q{iso_country_codes}
|
3
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.2"
|
4
6
|
|
5
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
-
s.authors = ["
|
7
|
-
s.date = %q{
|
8
|
-
s.description = %q{
|
9
|
-
s.email =
|
10
|
-
s.extra_rdoc_files = [
|
11
|
-
|
12
|
-
|
13
|
-
s.
|
8
|
+
s.authors = ["alex"]
|
9
|
+
s.date = %q{2009-08-07}
|
10
|
+
s.description = %q{ISO country code and currency library}
|
11
|
+
s.email = %q{alexrabarts@gmail.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".gitignore",
|
17
|
+
"History.txt",
|
18
|
+
"Manifest.txt",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION.yml",
|
22
|
+
"iso_country_codes.gemspec",
|
23
|
+
"lib/iso_country_codes.rb",
|
24
|
+
"lib/iso_country_codes/code.rb",
|
25
|
+
"lib/iso_country_codes/iso_3166_1.rb",
|
26
|
+
"lib/iso_country_codes/iso_4217.rb",
|
27
|
+
"lib/iso_country_codes/iso_country_codes.rb",
|
28
|
+
"rakelib/cultivate.rake",
|
29
|
+
"rakelib/iso_3166_1.rake",
|
30
|
+
"rakelib/iso_3166_1.rb",
|
31
|
+
"rakelib/iso_3166_1.rb.erb",
|
32
|
+
"test/iso_country_codes_test.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/alexrabarts/iso_country_codes}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
14
36
|
s.require_paths = ["lib"]
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
|
37
|
+
s.rubygems_version = %q{1.3.4}
|
38
|
+
s.summary = %q{Provides ISO 3166-1 country codes/names and ISO 4217 currencies.}
|
39
|
+
s.test_files = [
|
40
|
+
"test/iso_country_codes_test.rb"
|
41
|
+
]
|
19
42
|
|
20
43
|
if s.respond_to? :specification_version then
|
21
44
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
22
|
-
s.specification_version =
|
45
|
+
s.specification_version = 3
|
23
46
|
|
24
|
-
if
|
25
|
-
s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
|
47
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
48
|
else
|
27
|
-
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
28
49
|
end
|
29
50
|
else
|
30
|
-
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
31
51
|
end
|
32
52
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
class IsoCountryCodes
|
2
4
|
class Code
|
3
5
|
class GBR < Code #:nodoc:
|
@@ -74,7 +76,7 @@ class IsoCountryCodes
|
|
74
76
|
end
|
75
77
|
class BOL < Code #:nodoc:
|
76
78
|
self.numeric = %q{068}
|
77
|
-
self.name = %q{Bolivia}
|
79
|
+
self.name = %q{Bolivia, Plurinational State of}
|
78
80
|
self.alpha2 = %q{BO}
|
79
81
|
self.alpha3 = %q{BOL}
|
80
82
|
end
|
@@ -464,7 +466,7 @@ class IsoCountryCodes
|
|
464
466
|
end
|
465
467
|
class COD < Code #:nodoc:
|
466
468
|
self.numeric = %q{180}
|
467
|
-
self.name = %q{Congo, Democratic Republic of the}
|
469
|
+
self.name = %q{Congo, the Democratic Republic of the}
|
468
470
|
self.alpha2 = %q{CD}
|
469
471
|
self.alpha3 = %q{COD}
|
470
472
|
end
|
@@ -476,7 +478,7 @@ class IsoCountryCodes
|
|
476
478
|
end
|
477
479
|
class MDA < Code #:nodoc:
|
478
480
|
self.numeric = %q{498}
|
479
|
-
self.name = %q{Moldova}
|
481
|
+
self.name = %q{Moldova, Republic of}
|
480
482
|
self.alpha2 = %q{MD}
|
481
483
|
self.alpha3 = %q{MDA}
|
482
484
|
end
|
@@ -644,7 +646,7 @@ class IsoCountryCodes
|
|
644
646
|
end
|
645
647
|
class VEN < Code #:nodoc:
|
646
648
|
self.numeric = %q{862}
|
647
|
-
self.name = %q{Venezuela}
|
649
|
+
self.name = %q{Venezuela, Bolivarian Republic of}
|
648
650
|
self.alpha2 = %q{VE}
|
649
651
|
self.alpha3 = %q{VEN}
|
650
652
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
namespace :
|
1
|
+
namespace :codes do
|
2
2
|
desc 'Create ISO 3166-1 code classes from Wikipedia ISO 3166-1 tables.'
|
3
|
-
task :
|
3
|
+
task :update do
|
4
4
|
dirname = File.dirname(__FILE__)
|
5
5
|
gen = File.join(dirname, %w{iso_3166_1.rb})
|
6
6
|
lib = File.expand_path(File.join(dirname, %w{.. lib iso_country_codes iso_3166_1.rb}))
|
data/rakelib/iso_3166_1.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'nokogiri'
|
2
2
|
require 'open-uri'
|
3
3
|
require 'erubis'
|
4
4
|
|
@@ -6,24 +6,31 @@ class IsoCountryCodes
|
|
6
6
|
module Task
|
7
7
|
module UpdateCodes
|
8
8
|
def self.get
|
9
|
-
doc
|
10
|
-
codes
|
9
|
+
doc = Nokogiri::HTML.parse(open('http://en.wikipedia.org/wiki/ISO_3166-1'))
|
10
|
+
codes = {}
|
11
11
|
td_map = {
|
12
|
-
:name =>
|
13
|
-
:
|
14
|
-
:alpha3 =>
|
15
|
-
:
|
12
|
+
:name => 1,
|
13
|
+
:alpha2 => 2,
|
14
|
+
:alpha3 => 3,
|
15
|
+
:numeric => 4
|
16
16
|
}
|
17
|
+
|
17
18
|
code_labels = td_map.keys
|
18
|
-
|
19
|
+
|
20
|
+
doc.search('table.wikitable.sortable tr').each do |row|
|
19
21
|
value_hash = {}
|
22
|
+
|
20
23
|
code_labels.each do |key|
|
21
24
|
selector = "td:nth-of-type(#{td_map[key]})"
|
22
25
|
selector << ' a' if key == :name
|
23
|
-
|
26
|
+
|
27
|
+
value = row.search(selector).text.strip
|
28
|
+
|
24
29
|
next if value == ''
|
30
|
+
|
25
31
|
value_hash[key] = value
|
26
|
-
|
32
|
+
|
33
|
+
if value_hash.length == code_labels.length - 1
|
27
34
|
value_hash.keys.each do |value_hash_key|
|
28
35
|
codes[value_hash[value_hash_key]] = value_hash if value_hash_key == :alpha3
|
29
36
|
end
|
data/rakelib/iso_3166_1.rb.erb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,42 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexrabarts-iso_country_codes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- alex
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-08-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
version_requirements: !ruby/object:Gem::Requirement
|
19
|
-
requirements:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.8.2
|
23
|
-
version:
|
24
|
-
description: Provides ISO codes, names and currencies for countries.
|
25
|
-
email:
|
26
|
-
- alexrabarts@gmail.com
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: ISO country code and currency library
|
17
|
+
email: alexrabarts@gmail.com
|
27
18
|
executables: []
|
28
19
|
|
29
20
|
extensions: []
|
30
21
|
|
31
22
|
extra_rdoc_files:
|
32
|
-
-
|
33
|
-
- Manifest.txt
|
34
|
-
- README.txt
|
23
|
+
- README.rdoc
|
35
24
|
files:
|
25
|
+
- .gitignore
|
36
26
|
- History.txt
|
37
27
|
- Manifest.txt
|
38
|
-
- README.
|
28
|
+
- README.rdoc
|
39
29
|
- Rakefile
|
30
|
+
- VERSION.yml
|
40
31
|
- iso_country_codes.gemspec
|
41
32
|
- lib/iso_country_codes.rb
|
42
33
|
- lib/iso_country_codes/code.rb
|
@@ -44,16 +35,16 @@ files:
|
|
44
35
|
- lib/iso_country_codes/iso_4217.rb
|
45
36
|
- lib/iso_country_codes/iso_country_codes.rb
|
46
37
|
- rakelib/cultivate.rake
|
47
|
-
- rakelib/
|
38
|
+
- rakelib/iso_3166_1.rake
|
48
39
|
- rakelib/iso_3166_1.rb
|
49
40
|
- rakelib/iso_3166_1.rb.erb
|
50
|
-
- test/
|
51
|
-
has_rdoc:
|
52
|
-
homepage:
|
41
|
+
- test/iso_country_codes_test.rb
|
42
|
+
has_rdoc: false
|
43
|
+
homepage: http://github.com/alexrabarts/iso_country_codes
|
44
|
+
licenses:
|
53
45
|
post_install_message:
|
54
46
|
rdoc_options:
|
55
|
-
- --
|
56
|
-
- README.txt
|
47
|
+
- --charset=UTF-8
|
57
48
|
require_paths:
|
58
49
|
- lib
|
59
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -70,10 +61,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
61
|
version:
|
71
62
|
requirements: []
|
72
63
|
|
73
|
-
rubyforge_project:
|
74
|
-
rubygems_version: 1.
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.3.5
|
75
66
|
signing_key:
|
76
|
-
specification_version:
|
77
|
-
summary: Provides ISO codes
|
67
|
+
specification_version: 3
|
68
|
+
summary: Provides ISO 3166-1 country codes/names and ISO 4217 currencies.
|
78
69
|
test_files:
|
79
|
-
- test/
|
70
|
+
- test/iso_country_codes_test.rb
|