snail 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82917bd66c3458a46b14578bb04d693d3e0b809c
4
- data.tar.gz: a4275ea74487c843cbc408d3eecfbb5817486750
3
+ metadata.gz: 4a6c398f42c72d3b0f448888cca1b567fca39789
4
+ data.tar.gz: 149f4c658db6e2dc14411123bca065b3a804dd06
5
5
  SHA512:
6
- metadata.gz: 8d74b6bfeaab2d65d2ef62096dedb1bad4bef9bda84fff43ec80a1da1c4568c45391e94420a7fe385320750e42ddb00befcc0b8a9cfbbc5c7f3427707796ee0b
7
- data.tar.gz: 00ca018c1fbbb252965fb1fcdfb23b6355847f886f110e740c937d6eeca51743d9eac142929a284bab565cba2ea36002a883608d82dcec28a21f127fa69a69c3
6
+ metadata.gz: 5e09bf55453b4bcce32e2058029e3bdc90a22ab9c0c638d0a23939e959163047bd8ac7bdbefe5022979e90606bd9c409b1b9862261dec77eb1d6505b798f11c0
7
+ data.tar.gz: e1c26fea4f611844788801a68e679547f5da3fb7c0978865dfac223bff67b062e9eaede6259c9ecead73752f85ce631f05c82be697f05ec174390108b735c601
@@ -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
- # provide standardized USPS country names
28
- # provide basic formatting rules for the city line in major countries
29
- # provide basic country-specific validation logic
30
- # build a best-practice form field generator to collect appropriate address information
31
- # expand to other originating countries
32
- # continue fleshing out the formatting and validation
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 => "Australia"
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 => "Australia"
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 'rake'
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
- desc 'Test the snail plugin.'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
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
- desc 'Generate documentation for the snail plugin.'
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
@@ -61,7 +61,7 @@ class Snail
61
61
  end
62
62
 
63
63
  def self.lookup_country_iso(val)
64
- return nil if val.blank?
64
+ return nil if val.nil? || val.empty?
65
65
  val = val.upcase
66
66
  if ::Snail::Iso3166::ALPHA2[val]
67
67
  val
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  class Snail
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -1,15 +1,17 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
- class SnailTest < ActiveSupport::TestCase
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
  ##
@@ -1,8 +1,12 @@
1
1
  require 'rubygems'
2
- require 'active_support'
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.1.0
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: 2013-06-28 00:00:00.000000000 Z
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.0.0
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