snail 1.2.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +65 -0
  3. data/assets/AD.yml +249 -0
  4. data/assets/AE.yml +249 -0
  5. data/assets/AF.yml +63 -0
  6. data/assets/AG.yml +249 -0
  7. data/assets/AI.yml +249 -0
  8. data/assets/AL.yml +249 -0
  9. data/assets/AM.yml +249 -0
  10. data/assets/AO.yml +249 -0
  11. data/assets/AQ.yml +249 -0
  12. data/assets/AR.yml +249 -0
  13. data/assets/AS.yml +249 -0
  14. data/assets/AT.yml +249 -0
  15. data/assets/AU.yml +249 -0
  16. data/assets/AW.yml +249 -0
  17. data/assets/AX.yml +249 -0
  18. data/assets/AZ.yml +249 -0
  19. data/assets/BA.yml +249 -0
  20. data/assets/BB.yml +249 -0
  21. data/assets/BD.yml +249 -0
  22. data/assets/BE.yml +249 -0
  23. data/assets/BF.yml +249 -0
  24. data/assets/BG.yml +249 -0
  25. data/assets/BH.yml +249 -0
  26. data/assets/BI.yml +249 -0
  27. data/assets/BJ.yml +249 -0
  28. data/assets/BL.yml +249 -0
  29. data/assets/BM.yml +249 -0
  30. data/assets/BN.yml +249 -0
  31. data/assets/BO.yml +249 -0
  32. data/assets/BQ.yml +249 -0
  33. data/assets/BR.yml +249 -0
  34. data/assets/BS.yml +249 -0
  35. data/assets/BT.yml +249 -0
  36. data/assets/BV.yml +249 -0
  37. data/assets/BW.yml +249 -0
  38. data/assets/BY.yml +249 -0
  39. data/assets/BZ.yml +249 -0
  40. data/assets/CA.yml +249 -0
  41. data/assets/CC.yml +249 -0
  42. data/assets/CD.yml +249 -0
  43. data/assets/CF.yml +249 -0
  44. data/assets/CG.yml +249 -0
  45. data/assets/CH.yml +249 -0
  46. data/assets/CI.yml +249 -0
  47. data/assets/CK.yml +249 -0
  48. data/assets/CL.yml +249 -0
  49. data/assets/CM.yml +249 -0
  50. data/assets/CN.yml +249 -0
  51. data/assets/CO.yml +249 -0
  52. data/assets/CR.yml +249 -0
  53. data/assets/CU.yml +249 -0
  54. data/assets/CV.yml +249 -0
  55. data/assets/CW.yml +249 -0
  56. data/assets/CX.yml +249 -0
  57. data/assets/CY.yml +249 -0
  58. data/assets/CZ.yml +249 -0
  59. data/assets/DE.yml +249 -0
  60. data/assets/DJ.yml +249 -0
  61. data/assets/DK.yml +249 -0
  62. data/assets/DM.yml +249 -0
  63. data/assets/DO.yml +249 -0
  64. data/assets/DZ.yml +249 -0
  65. data/assets/EC.yml +249 -0
  66. data/assets/EE.yml +249 -0
  67. data/assets/EG.yml +249 -0
  68. data/assets/EH.yml +249 -0
  69. data/assets/ER.yml +249 -0
  70. data/assets/ES.yml +249 -0
  71. data/assets/ET.yml +249 -0
  72. data/assets/FI.yml +249 -0
  73. data/assets/FJ.yml +249 -0
  74. data/assets/FK.yml +249 -0
  75. data/assets/FM.yml +249 -0
  76. data/assets/FO.yml +249 -0
  77. data/assets/FR.yml +249 -0
  78. data/assets/GA.yml +249 -0
  79. data/assets/GB.yml +249 -0
  80. data/assets/GD.yml +249 -0
  81. data/assets/GE.yml +249 -0
  82. data/assets/GF.yml +249 -0
  83. data/assets/GG.yml +249 -0
  84. data/assets/GH.yml +249 -0
  85. data/assets/GI.yml +249 -0
  86. data/assets/GL.yml +218 -0
  87. data/assets/GM.yml +249 -0
  88. data/assets/GN.yml +249 -0
  89. data/assets/GP.yml +249 -0
  90. data/assets/GQ.yml +249 -0
  91. data/assets/GR.yml +249 -0
  92. data/assets/GS.yml +249 -0
  93. data/assets/GT.yml +249 -0
  94. data/assets/GU.yml +249 -0
  95. data/assets/GW.yml +249 -0
  96. data/assets/GY.yml +249 -0
  97. data/assets/HK.yml +249 -0
  98. data/assets/HM.yml +249 -0
  99. data/assets/HN.yml +249 -0
  100. data/assets/HR.yml +249 -0
  101. data/assets/HT.yml +249 -0
  102. data/assets/HU.yml +249 -0
  103. data/assets/ID.yml +249 -0
  104. data/assets/IE.yml +249 -0
  105. data/assets/IL.yml +249 -0
  106. data/assets/IM.yml +249 -0
  107. data/assets/IN.yml +249 -0
  108. data/assets/IO.yml +249 -0
  109. data/assets/IQ.yml +249 -0
  110. data/assets/IR.yml +249 -0
  111. data/assets/IS.yml +249 -0
  112. data/assets/IT.yml +249 -0
  113. data/assets/JE.yml +249 -0
  114. data/assets/JM.yml +249 -0
  115. data/assets/JO.yml +249 -0
  116. data/assets/JP.yml +249 -0
  117. data/assets/KE.yml +249 -0
  118. data/assets/KG.yml +249 -0
  119. data/assets/KH.yml +249 -0
  120. data/assets/KI.yml +249 -0
  121. data/assets/KM.yml +249 -0
  122. data/assets/KN.yml +249 -0
  123. data/assets/KP.yml +249 -0
  124. data/assets/KR.yml +249 -0
  125. data/assets/KW.yml +249 -0
  126. data/assets/KY.yml +249 -0
  127. data/assets/KZ.yml +249 -0
  128. data/assets/LA.yml +249 -0
  129. data/assets/LB.yml +249 -0
  130. data/assets/LC.yml +249 -0
  131. data/assets/LI.yml +249 -0
  132. data/assets/LK.yml +249 -0
  133. data/assets/LR.yml +249 -0
  134. data/assets/LS.yml +249 -0
  135. data/assets/LT.yml +249 -0
  136. data/assets/LU.yml +249 -0
  137. data/assets/LV.yml +249 -0
  138. data/assets/LY.yml +249 -0
  139. data/assets/MA.yml +249 -0
  140. data/assets/MC.yml +249 -0
  141. data/assets/MD.yml +249 -0
  142. data/assets/ME.yml +249 -0
  143. data/assets/MF.yml +249 -0
  144. data/assets/MG.yml +249 -0
  145. data/assets/MH.yml +249 -0
  146. data/assets/MK.yml +249 -0
  147. data/assets/ML.yml +249 -0
  148. data/assets/MM.yml +249 -0
  149. data/assets/MN.yml +249 -0
  150. data/assets/MO.yml +249 -0
  151. data/assets/MP.yml +249 -0
  152. data/assets/MQ.yml +249 -0
  153. data/assets/MR.yml +249 -0
  154. data/assets/MS.yml +249 -0
  155. data/assets/MT.yml +239 -0
  156. data/assets/MU.yml +249 -0
  157. data/assets/MV.yml +249 -0
  158. data/assets/MW.yml +249 -0
  159. data/assets/MX.yml +249 -0
  160. data/assets/MY.yml +249 -0
  161. data/assets/MZ.yml +249 -0
  162. data/assets/NA.yml +249 -0
  163. data/assets/NC.yml +249 -0
  164. data/assets/NE.yml +249 -0
  165. data/assets/NF.yml +249 -0
  166. data/assets/NG.yml +249 -0
  167. data/assets/NI.yml +249 -0
  168. data/assets/NL.yml +249 -0
  169. data/assets/NO.yml +249 -0
  170. data/assets/NP.yml +249 -0
  171. data/assets/NR.yml +249 -0
  172. data/assets/NU.yml +249 -0
  173. data/assets/NZ.yml +249 -0
  174. data/assets/OM.yml +249 -0
  175. data/assets/PA.yml +249 -0
  176. data/assets/PE.yml +249 -0
  177. data/assets/PF.yml +249 -0
  178. data/assets/PG.yml +249 -0
  179. data/assets/PH.yml +249 -0
  180. data/assets/PK.yml +249 -0
  181. data/assets/PL.yml +249 -0
  182. data/assets/PM.yml +249 -0
  183. data/assets/PN.yml +249 -0
  184. data/assets/PR.yml +249 -0
  185. data/assets/PS.yml +249 -0
  186. data/assets/PT.yml +249 -0
  187. data/assets/PW.yml +249 -0
  188. data/assets/PY.yml +249 -0
  189. data/assets/QA.yml +249 -0
  190. data/assets/RE.yml +249 -0
  191. data/assets/RO.yml +249 -0
  192. data/assets/RS.yml +249 -0
  193. data/assets/RU.yml +249 -0
  194. data/assets/RW.yml +2 -0
  195. data/assets/SA.yml +249 -0
  196. data/assets/SB.yml +249 -0
  197. data/assets/SC.yml +249 -0
  198. data/assets/SD.yml +249 -0
  199. data/assets/SE.yml +249 -0
  200. data/assets/SG.yml +249 -0
  201. data/assets/SH.yml +249 -0
  202. data/assets/SI.yml +249 -0
  203. data/assets/SJ.yml +249 -0
  204. data/assets/SK.yml +249 -0
  205. data/assets/SL.yml +249 -0
  206. data/assets/SM.yml +249 -0
  207. data/assets/SN.yml +249 -0
  208. data/assets/SO.yml +225 -0
  209. data/assets/SR.yml +249 -0
  210. data/assets/SS.yml +249 -0
  211. data/assets/ST.yml +249 -0
  212. data/assets/SV.yml +249 -0
  213. data/assets/SX.yml +249 -0
  214. data/assets/SY.yml +249 -0
  215. data/assets/SZ.yml +249 -0
  216. data/assets/TC.yml +249 -0
  217. data/assets/TD.yml +249 -0
  218. data/assets/TF.yml +249 -0
  219. data/assets/TG.yml +249 -0
  220. data/assets/TH.yml +249 -0
  221. data/assets/TJ.yml +249 -0
  222. data/assets/TK.yml +249 -0
  223. data/assets/TL.yml +249 -0
  224. data/assets/TM.yml +17 -0
  225. data/assets/TN.yml +249 -0
  226. data/assets/TO.yml +249 -0
  227. data/assets/TR.yml +249 -0
  228. data/assets/TT.yml +249 -0
  229. data/assets/TV.yml +249 -0
  230. data/assets/TW.yml +249 -0
  231. data/assets/TZ.yml +249 -0
  232. data/assets/UA.yml +249 -0
  233. data/assets/UG.yml +249 -0
  234. data/assets/UM.yml +249 -0
  235. data/assets/US.yml +249 -0
  236. data/assets/UY.yml +249 -0
  237. data/assets/UZ.yml +249 -0
  238. data/assets/VA.yml +249 -0
  239. data/assets/VC.yml +249 -0
  240. data/assets/VE.yml +249 -0
  241. data/assets/VG.yml +249 -0
  242. data/assets/VI.yml +249 -0
  243. data/assets/VN.yml +249 -0
  244. data/assets/VU.yml +249 -0
  245. data/assets/WF.yml +249 -0
  246. data/assets/WS.yml +249 -0
  247. data/assets/YE.yml +249 -0
  248. data/assets/YT.yml +249 -0
  249. data/assets/ZA.yml +249 -0
  250. data/assets/ZM.yml +249 -0
  251. data/assets/ZW.yml +249 -0
  252. data/lib/snail.rb +16 -9
  253. data/lib/snail/version.rb +1 -1
  254. data/test/snail_test.rb +8 -1
  255. metadata +253 -4
  256. data/README.rdoc +0 -68
@@ -5,6 +5,7 @@ require 'snail/helpers'
5
5
 
6
6
  require 'cgi'
7
7
  require 'active_support/core_ext/string/output_safety'
8
+ require 'yaml'
8
9
 
9
10
  class Snail
10
11
  include Snail::Initializable
@@ -21,7 +22,12 @@ class Snail
21
22
  attr_accessor :city
22
23
  attr_accessor :region
23
24
  attr_accessor :postal_code
24
- attr_accessor :country
25
+ attr_reader :country
26
+
27
+ # Store country as ISO-3166 Alpha 2
28
+ def country=(val)
29
+ @country = Snail.lookup_country_iso(val)
30
+ end
25
31
 
26
32
  # Aliases for easier assignment compatibility
27
33
  {
@@ -84,11 +90,6 @@ class Snail
84
90
  @origin ||= Snail.home_country
85
91
  end
86
92
 
87
- # Store country as ISO-3166 Alpha 2
88
- def country=(val)
89
- @country = Snail.lookup_country_iso(val)
90
- end
91
-
92
93
  def to_s
93
94
  [name, line_1, line_2, city_line, country_line].select{|line| !(line.nil? or line.empty?)}.join("\n")
94
95
  end
@@ -113,7 +114,7 @@ class Snail
113
114
  "#{postal_code} #{city}-(#{region})"
114
115
  when 'US', 'CA', 'AU', nil, ""
115
116
  "#{city} #{region} #{postal_code}"
116
- when 'IL', 'DK', 'FI', 'FR', 'DE', 'GR', 'IT', 'NO', 'ES', 'SE', 'TR', 'CY', 'PT', 'MK', 'BA'
117
+ when 'IL', 'DK', 'FI', 'FR', 'DE', 'GR', 'NO', 'ES', 'SE', 'TR', 'CY', 'PT', 'MK', 'BA'
117
118
  "#{postal_code} #{city}"
118
119
  when 'KW', 'SY', 'OM', 'EE', 'LU', 'BE', 'IS', 'CH', 'AT', 'MD', 'ME', 'RS', 'BG', 'GE', 'PL', 'AM', 'HR', 'RO', 'AZ'
119
120
  "#{postal_code} #{city}"
@@ -149,8 +150,14 @@ class Snail
149
150
  end
150
151
  end
151
152
 
152
- # TODO localize to the origin country
153
153
  def country_line
154
- ::Snail::Iso3166::ALPHA2[country].first if country and self.origin != country
154
+ if country and self.origin != country
155
+ (translated_country(self.origin, country) || translated_country("US", country))
156
+ end
157
+ end
158
+
159
+ def translated_country(origin, country)
160
+ path = File.join(File.dirname(File.expand_path(__FILE__)), "../assets/#{origin}.yml")
161
+ File.read(path).match(/^#{country}: (.*)$/)[1]
155
162
  end
156
163
  end
@@ -1,3 +1,3 @@
1
1
  class Snail
2
- VERSION = '1.2.3'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -69,7 +69,7 @@ class SnailTest < Snail::TestCase
69
69
 
70
70
  test "includes two spaces between region and zip for domestic mail" do
71
71
  s = Snail.new(@us)
72
- assert /NY 12345/, s.city_line
72
+ assert s.city_line.match(/NY 12345/)
73
73
  end
74
74
 
75
75
  test "does not include country name for domestic addresses" do
@@ -86,6 +86,13 @@ class SnailTest < Snail::TestCase
86
86
  assert s.to_s.match(/Canada/i)
87
87
  end
88
88
 
89
+ test "includes translated country name for international addresses" do
90
+ s = Snail.new(@us.merge(:origin => 'FR'))
91
+ assert s.to_s.match(/ÉTATS-UNIS/i)
92
+ s = Snail.new(@ca.merge(:origin => 'EC'))
93
+ assert s.to_s.match(/CANADÁ/i)
94
+ end
95
+
89
96
  test "includes first country name for countries with many commonly used names" do
90
97
  s = Snail.new(@ca.merge(:country => 'UK'))
91
98
  assert s.to_s.match(/United Kingdom\Z/i), s.to_s
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snail
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 2.0.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: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2016-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -33,8 +33,257 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - MIT-LICENSE
36
- - README.rdoc
36
+ - README.md
37
37
  - Rakefile
38
+ - assets/AD.yml
39
+ - assets/AE.yml
40
+ - assets/AF.yml
41
+ - assets/AG.yml
42
+ - assets/AI.yml
43
+ - assets/AL.yml
44
+ - assets/AM.yml
45
+ - assets/AO.yml
46
+ - assets/AQ.yml
47
+ - assets/AR.yml
48
+ - assets/AS.yml
49
+ - assets/AT.yml
50
+ - assets/AU.yml
51
+ - assets/AW.yml
52
+ - assets/AX.yml
53
+ - assets/AZ.yml
54
+ - assets/BA.yml
55
+ - assets/BB.yml
56
+ - assets/BD.yml
57
+ - assets/BE.yml
58
+ - assets/BF.yml
59
+ - assets/BG.yml
60
+ - assets/BH.yml
61
+ - assets/BI.yml
62
+ - assets/BJ.yml
63
+ - assets/BL.yml
64
+ - assets/BM.yml
65
+ - assets/BN.yml
66
+ - assets/BO.yml
67
+ - assets/BQ.yml
68
+ - assets/BR.yml
69
+ - assets/BS.yml
70
+ - assets/BT.yml
71
+ - assets/BV.yml
72
+ - assets/BW.yml
73
+ - assets/BY.yml
74
+ - assets/BZ.yml
75
+ - assets/CA.yml
76
+ - assets/CC.yml
77
+ - assets/CD.yml
78
+ - assets/CF.yml
79
+ - assets/CG.yml
80
+ - assets/CH.yml
81
+ - assets/CI.yml
82
+ - assets/CK.yml
83
+ - assets/CL.yml
84
+ - assets/CM.yml
85
+ - assets/CN.yml
86
+ - assets/CO.yml
87
+ - assets/CR.yml
88
+ - assets/CU.yml
89
+ - assets/CV.yml
90
+ - assets/CW.yml
91
+ - assets/CX.yml
92
+ - assets/CY.yml
93
+ - assets/CZ.yml
94
+ - assets/DE.yml
95
+ - assets/DJ.yml
96
+ - assets/DK.yml
97
+ - assets/DM.yml
98
+ - assets/DO.yml
99
+ - assets/DZ.yml
100
+ - assets/EC.yml
101
+ - assets/EE.yml
102
+ - assets/EG.yml
103
+ - assets/EH.yml
104
+ - assets/ER.yml
105
+ - assets/ES.yml
106
+ - assets/ET.yml
107
+ - assets/FI.yml
108
+ - assets/FJ.yml
109
+ - assets/FK.yml
110
+ - assets/FM.yml
111
+ - assets/FO.yml
112
+ - assets/FR.yml
113
+ - assets/GA.yml
114
+ - assets/GB.yml
115
+ - assets/GD.yml
116
+ - assets/GE.yml
117
+ - assets/GF.yml
118
+ - assets/GG.yml
119
+ - assets/GH.yml
120
+ - assets/GI.yml
121
+ - assets/GL.yml
122
+ - assets/GM.yml
123
+ - assets/GN.yml
124
+ - assets/GP.yml
125
+ - assets/GQ.yml
126
+ - assets/GR.yml
127
+ - assets/GS.yml
128
+ - assets/GT.yml
129
+ - assets/GU.yml
130
+ - assets/GW.yml
131
+ - assets/GY.yml
132
+ - assets/HK.yml
133
+ - assets/HM.yml
134
+ - assets/HN.yml
135
+ - assets/HR.yml
136
+ - assets/HT.yml
137
+ - assets/HU.yml
138
+ - assets/ID.yml
139
+ - assets/IE.yml
140
+ - assets/IL.yml
141
+ - assets/IM.yml
142
+ - assets/IN.yml
143
+ - assets/IO.yml
144
+ - assets/IQ.yml
145
+ - assets/IR.yml
146
+ - assets/IS.yml
147
+ - assets/IT.yml
148
+ - assets/JE.yml
149
+ - assets/JM.yml
150
+ - assets/JO.yml
151
+ - assets/JP.yml
152
+ - assets/KE.yml
153
+ - assets/KG.yml
154
+ - assets/KH.yml
155
+ - assets/KI.yml
156
+ - assets/KM.yml
157
+ - assets/KN.yml
158
+ - assets/KP.yml
159
+ - assets/KR.yml
160
+ - assets/KW.yml
161
+ - assets/KY.yml
162
+ - assets/KZ.yml
163
+ - assets/LA.yml
164
+ - assets/LB.yml
165
+ - assets/LC.yml
166
+ - assets/LI.yml
167
+ - assets/LK.yml
168
+ - assets/LR.yml
169
+ - assets/LS.yml
170
+ - assets/LT.yml
171
+ - assets/LU.yml
172
+ - assets/LV.yml
173
+ - assets/LY.yml
174
+ - assets/MA.yml
175
+ - assets/MC.yml
176
+ - assets/MD.yml
177
+ - assets/ME.yml
178
+ - assets/MF.yml
179
+ - assets/MG.yml
180
+ - assets/MH.yml
181
+ - assets/MK.yml
182
+ - assets/ML.yml
183
+ - assets/MM.yml
184
+ - assets/MN.yml
185
+ - assets/MO.yml
186
+ - assets/MP.yml
187
+ - assets/MQ.yml
188
+ - assets/MR.yml
189
+ - assets/MS.yml
190
+ - assets/MT.yml
191
+ - assets/MU.yml
192
+ - assets/MV.yml
193
+ - assets/MW.yml
194
+ - assets/MX.yml
195
+ - assets/MY.yml
196
+ - assets/MZ.yml
197
+ - assets/NA.yml
198
+ - assets/NC.yml
199
+ - assets/NE.yml
200
+ - assets/NF.yml
201
+ - assets/NG.yml
202
+ - assets/NI.yml
203
+ - assets/NL.yml
204
+ - assets/NO.yml
205
+ - assets/NP.yml
206
+ - assets/NR.yml
207
+ - assets/NU.yml
208
+ - assets/NZ.yml
209
+ - assets/OM.yml
210
+ - assets/PA.yml
211
+ - assets/PE.yml
212
+ - assets/PF.yml
213
+ - assets/PG.yml
214
+ - assets/PH.yml
215
+ - assets/PK.yml
216
+ - assets/PL.yml
217
+ - assets/PM.yml
218
+ - assets/PN.yml
219
+ - assets/PR.yml
220
+ - assets/PS.yml
221
+ - assets/PT.yml
222
+ - assets/PW.yml
223
+ - assets/PY.yml
224
+ - assets/QA.yml
225
+ - assets/RE.yml
226
+ - assets/RO.yml
227
+ - assets/RS.yml
228
+ - assets/RU.yml
229
+ - assets/RW.yml
230
+ - assets/SA.yml
231
+ - assets/SB.yml
232
+ - assets/SC.yml
233
+ - assets/SD.yml
234
+ - assets/SE.yml
235
+ - assets/SG.yml
236
+ - assets/SH.yml
237
+ - assets/SI.yml
238
+ - assets/SJ.yml
239
+ - assets/SK.yml
240
+ - assets/SL.yml
241
+ - assets/SM.yml
242
+ - assets/SN.yml
243
+ - assets/SO.yml
244
+ - assets/SR.yml
245
+ - assets/SS.yml
246
+ - assets/ST.yml
247
+ - assets/SV.yml
248
+ - assets/SX.yml
249
+ - assets/SY.yml
250
+ - assets/SZ.yml
251
+ - assets/TC.yml
252
+ - assets/TD.yml
253
+ - assets/TF.yml
254
+ - assets/TG.yml
255
+ - assets/TH.yml
256
+ - assets/TJ.yml
257
+ - assets/TK.yml
258
+ - assets/TL.yml
259
+ - assets/TM.yml
260
+ - assets/TN.yml
261
+ - assets/TO.yml
262
+ - assets/TR.yml
263
+ - assets/TT.yml
264
+ - assets/TV.yml
265
+ - assets/TW.yml
266
+ - assets/TZ.yml
267
+ - assets/UA.yml
268
+ - assets/UG.yml
269
+ - assets/UM.yml
270
+ - assets/US.yml
271
+ - assets/UY.yml
272
+ - assets/UZ.yml
273
+ - assets/VA.yml
274
+ - assets/VC.yml
275
+ - assets/VE.yml
276
+ - assets/VG.yml
277
+ - assets/VI.yml
278
+ - assets/VN.yml
279
+ - assets/VU.yml
280
+ - assets/WF.yml
281
+ - assets/WS.yml
282
+ - assets/YE.yml
283
+ - assets/YT.yml
284
+ - assets/ZA.yml
285
+ - assets/ZM.yml
286
+ - assets/ZW.yml
38
287
  - lib/snail.rb
39
288
  - lib/snail/constants.rb
40
289
  - lib/snail/helpers.rb
@@ -62,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
311
  version: '0'
63
312
  requirements: []
64
313
  rubyforge_project:
65
- rubygems_version: 2.2.2
314
+ rubygems_version: 2.4.5
66
315
  signing_key:
67
316
  specification_version: 4
68
317
  summary: Easily format snail mail addresses for international delivery
@@ -1,68 +0,0 @@
1
- = Snail
2
-
3
- International snail mail addressing is a pain. This plugin begins to make it easier.
4
-
5
- == How?
6
-
7
- The basic idea is that mailing addresses need first and foremost to make it OUT of the originating country. It's beyond the scope of my current work to consider any originating country besides the United States, so that's where I am beginning. I will leave other countries of origination to the open source community.
8
-
9
- Given the United States as a point of origin, my effort here is based on Frank's Compulsive Guide to Postal Addresses, available from http://www.columbia.edu/kermit/postal.html as of July 2009, and the USPS International Mail Manual (IMM), available from http://pe.usps.gov/text/imm/immidx.htm.
10
-
11
- The United States Postal Service (USPS) requires (strongly prefers?) a few things:
12
-
13
- * That the address be 5 lines long or less.
14
- * That the last address line be a country name recognized by the USPS, in all uppercase.
15
- * That the city line (comprising the city, state, and postal code as appropriate) immediately precede the country line.
16
-
17
- The rest of the address should be formatted according to the rules of the receiving country.
18
-
19
- Nearly all of the variation in formatting rules applies to the city line. Depending on the receiving country, the three component pieces (e.g. city, state, postal code) have different names, are pieced together in different order with different punctuation, and may or may not be required.
20
-
21
- And then there's Great Britain, which Frank's Compulsive Guide describes as "where to find the most confusing addresses on earth" (a description confirmed and further confused by a source from within Royal Mail).
22
-
23
- == The Future
24
-
25
- I hope to tackle this plugin in stages, with help from the open source community:
26
-
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
-
34
- == Example
35
-
36
- Taking regular data and formatting it into an internationally mailable address:
37
-
38
- Snail.new(
39
- :name => "Jon Doe",
40
- :line_1 => "12345 Somewhere Ln",
41
- :line_2 => nil,
42
- :city => "Bentley",
43
- :region => "WA",
44
- :postal_code => "6102",
45
- :country => "AU"
46
- ).to_s
47
-
48
- => "Jon Doe\n12345 Somewhere Ln\nBENTLEY WA 6102\nAUSTRALIA"
49
-
50
- By default addresses with a country of USA are considered domestic and the country will
51
- be left off any output. To change the home country:
52
-
53
- Snail.home_country = "Australia"
54
- Snail.new(
55
- :name => "Jon Doe",
56
- :line_1 => "12345 Somewhere Ln",
57
- :line_2 => nil,
58
- :city => "Bentley",
59
- :region => "WA",
60
- :postal_code => "6102",
61
- :country => "AU"
62
- ).to_s
63
-
64
- => "Jon Doe\n12345 Somewhere Ln\nBENTLEY WA 6102"
65
-
66
- See the test cases for more.
67
-
68
- Copyright (c) 2009 Lance Ivy, released under the MIT license