snail 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +8 -8
- data/Rakefile +6 -19
- data/lib/snail.rb +1 -1
- data/lib/snail/helpers.rb +29 -0
- data/lib/snail/version.rb +1 -1
- data/test/snail_test.rb +3 -1
- data/test/test_helper.rb +8 -4
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a6c398f42c72d3b0f448888cca1b567fca39789
|
4
|
+
data.tar.gz: 149f4c658db6e2dc14411123bca065b3a804dd06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e09bf55453b4bcce32e2058029e3bdc90a22ab9c0c638d0a23939e959163047bd8ac7bdbefe5022979e90606bd9c409b1b9862261dec77eb1d6505b798f11c0
|
7
|
+
data.tar.gz: e1c26fea4f611844788801a68e679547f5da3fb7c0978865dfac223bff67b062e9eaede6259c9ecead73752f85ce631f05c82be697f05ec174390108b735c601
|
data/README.rdoc
CHANGED
@@ -24,12 +24,12 @@ And then there's Great Britain, which Frank's Compulsive Guide describes as "whe
|
|
24
24
|
|
25
25
|
I hope to tackle this plugin in stages, with help from the open source community:
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
1. Provide standardized USPS country names
|
28
|
+
2. Provide basic formatting rules for the city line in major countries
|
29
|
+
3. Provide basic country-specific validation logic
|
30
|
+
4. Build a best-practice form field generator to collect appropriate address information
|
31
|
+
5. Expand to other originating countries
|
32
|
+
6. Continue fleshing out the formatting and validation
|
33
33
|
|
34
34
|
== Example
|
35
35
|
|
@@ -42,7 +42,7 @@ Taking regular data and formatting it into an internationally mailable address:
|
|
42
42
|
:city => "Bentley",
|
43
43
|
:region => "WA",
|
44
44
|
:postal_code => "6102",
|
45
|
-
:country => "
|
45
|
+
:country => "AU"
|
46
46
|
).to_s
|
47
47
|
|
48
48
|
=> "Jon Doe\n12345 Somewhere Ln\nBENTLEY WA 6102\nAUSTRALIA"
|
@@ -58,7 +58,7 @@ be left off any output. To change the home country:
|
|
58
58
|
:city => "Bentley",
|
59
59
|
:region => "WA",
|
60
60
|
:postal_code => "6102",
|
61
|
-
:country => "
|
61
|
+
:country => "AU"
|
62
62
|
).to_s
|
63
63
|
|
64
64
|
=> "Jon Doe\n12345 Somewhere Ln\nBENTLEY WA 6102"
|
data/Rakefile
CHANGED
@@ -1,23 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rdoc/task'
|
4
|
-
|
5
|
-
desc 'Default: run unit tests.'
|
6
|
-
task :default => :test
|
1
|
+
require "bundler/gem_tasks"
|
7
2
|
|
8
|
-
|
9
|
-
Rake::TestTask.new
|
10
|
-
t.libs <<
|
11
|
-
t.
|
12
|
-
t.pattern = 'test/**/*_test.rb'
|
3
|
+
require 'rake/testtask'
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.test_files = FileList['test/*test.rb']
|
13
7
|
t.verbose = true
|
14
8
|
end
|
15
9
|
|
16
|
-
|
17
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
-
rdoc.rdoc_dir = 'rdoc'
|
19
|
-
rdoc.title = 'Snail'
|
20
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
-
rdoc.rdoc_files.include('README')
|
22
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
-
end
|
10
|
+
task :default => :test
|
data/lib/snail.rb
CHANGED
data/lib/snail/helpers.rb
CHANGED
@@ -98,6 +98,35 @@ class Snail
|
|
98
98
|
'Armed Forces Europe' => 'AE',
|
99
99
|
'Armed Forces Middle East' => 'AE',
|
100
100
|
'Armed Forces Pacific' => 'AP',
|
101
|
+
},
|
102
|
+
# http://en.wikipedia.org/wiki/Counties_of_Ireland
|
103
|
+
# NB: only includes Replublic of Ireland, also no abbreviations
|
104
|
+
:ie => {
|
105
|
+
'Carlows' => 'Carlows',
|
106
|
+
"Cavan" => 'Cavan',
|
107
|
+
'Clare' => 'Clare',
|
108
|
+
'Cork' => 'Cork',
|
109
|
+
'Donegal' => 'Donegal',
|
110
|
+
'Galway' => 'Galway',
|
111
|
+
'Kerry' => 'Kerry',
|
112
|
+
'Kildare' => 'Kildare',
|
113
|
+
'Kilkenny' => 'Kilkenny',
|
114
|
+
'Laois' => 'Laois',
|
115
|
+
'Leitrim' => 'Leitrim',
|
116
|
+
'Limerick' => 'Limerick',
|
117
|
+
'Longford' => 'Longford',
|
118
|
+
'Louth' => 'Louth',
|
119
|
+
'Mayo' => 'Mayo',
|
120
|
+
'Meath' => 'Meath',
|
121
|
+
'Monaghan' => 'Monaghan',
|
122
|
+
'Offaly' => 'Offaly',
|
123
|
+
'Roscommon' => 'Roscommon',
|
124
|
+
'Sligo' => 'Sligo',
|
125
|
+
'Tipperary' => 'Tipperary',
|
126
|
+
'Waterford' => 'Waterford',
|
127
|
+
'Westmeath' => 'Westmeath',
|
128
|
+
'Wexford' => 'Wexford',
|
129
|
+
'Wicklow' => 'Wicklow',
|
101
130
|
}
|
102
131
|
}
|
103
132
|
|
data/lib/snail/version.rb
CHANGED
data/test/snail_test.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
|
-
class SnailTest <
|
3
|
+
class SnailTest < Snail::TestCase
|
4
4
|
def setup
|
5
5
|
@us = {:name => "John Doe", :line_1 => "12345 5th St", :city => "Somewheres", :state => "NY", :zip => "12345", :country => 'USA'}
|
6
6
|
@ca = {:name => "John Doe", :line_1 => "12345 5th St", :city => "Somewheres", :state => "NY", :zip => "12345", :country => 'CAN'}
|
7
|
+
@ie = {:name => "John Doe", :line_1 => "12345 5th St", :city => "Somewheres", :region => "Dublin", :zip => "12345", :country => 'IE'}
|
7
8
|
end
|
8
9
|
|
9
10
|
test "provides region codes via 2-digit iso country code" do
|
10
11
|
assert_equal "WA", Snail::REGIONS[:us]["Washington"]
|
11
12
|
assert_equal "WA", Snail::REGIONS[:au]["Western Australia"]
|
12
13
|
assert_equal "BC", Snail::REGIONS[:ca]["British Columbia"]
|
14
|
+
assert_equal "Cork", Snail::REGIONS[:ie]["Cork"]
|
13
15
|
end
|
14
16
|
|
15
17
|
##
|
data/test/test_helper.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
3
|
-
require 'active_support/test_case'
|
4
|
-
require 'test/unit'
|
2
|
+
require 'minitest/autorun'
|
5
3
|
|
6
4
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
7
|
-
|
8
5
|
require 'snail'
|
6
|
+
|
7
|
+
class Snail::TestCase < Minitest::Test
|
8
|
+
def self.test(str, &block)
|
9
|
+
name = "test_" + str.gsub(/[^a-z_]/, '_').gsub(/_{2,}/, '_')
|
10
|
+
define_method name, &block
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lance Ivy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: International snail mail addressing is a pain. This begins to make it
|
@@ -52,17 +52,17 @@ require_paths:
|
|
52
52
|
- lib
|
53
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
64
|
rubyforge_project:
|
65
|
-
rubygems_version: 2.
|
65
|
+
rubygems_version: 2.2.2
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: Easily format snail mail addresses for international delivery
|