snail 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/snail.rb +11 -5
- data/lib/snail/constants.rb +0 -101
- data/lib/snail/helpers.rb +112 -0
- data/lib/snail/version.rb +1 -1
- metadata +3 -3
- data/lib/snail_helpers.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82917bd66c3458a46b14578bb04d693d3e0b809c
|
4
|
+
data.tar.gz: a4275ea74487c843cbc408d3eecfbb5817486750
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d74b6bfeaab2d65d2ef62096dedb1bad4bef9bda84fff43ec80a1da1c4568c45391e94420a7fe385320750e42ddb00befcc0b8a9cfbbc5c7f3427707796ee0b
|
7
|
+
data.tar.gz: 00ca018c1fbbb252965fb1fcdfb23b6355847f886f110e740c937d6eeca51743d9eac142929a284bab565cba2ea36002a883608d82dcec28a21f127fa69a69c3
|
data/lib/snail.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'snail/initializable'
|
3
3
|
require 'snail/constants'
|
4
|
-
require '
|
4
|
+
require 'snail/helpers'
|
5
5
|
|
6
6
|
require 'cgi'
|
7
7
|
require 'active_support/core_ext/string/output_safety'
|
8
8
|
|
9
|
-
if defined? ActionView
|
10
|
-
ActionView::Base.class_eval { include SnailHelpers }
|
11
|
-
end
|
12
|
-
|
13
9
|
class Snail
|
14
10
|
include Snail::Initializable
|
15
11
|
|
@@ -46,6 +42,16 @@ class Snail
|
|
46
42
|
alias_method "#{new}=", "#{existing}="
|
47
43
|
end
|
48
44
|
|
45
|
+
# Load the SnailHelpers module into ActionView::Base. Previously this was done
|
46
|
+
# automatically, but going forward it must be included explicitly by calling
|
47
|
+
# Snail.load_helpers.
|
48
|
+
def self.load_helpers
|
49
|
+
if defined? ActionView
|
50
|
+
warn '[DEPRECATION] Snail::Helpers will be removed in a future release.'
|
51
|
+
ActionView::Base.class_eval { include Snail::Helpers }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
49
55
|
def self.home_country
|
50
56
|
@home_country ||= "US"
|
51
57
|
end
|
data/lib/snail/constants.rb
CHANGED
@@ -3,107 +3,6 @@
|
|
3
3
|
# TODO: carmen
|
4
4
|
class Snail
|
5
5
|
|
6
|
-
REGIONS = {
|
7
|
-
# see http://en.wikipedia.org/wiki/Postcodes_in_Australia#Australia_States_and_territories
|
8
|
-
:au => {
|
9
|
-
"Australian Capital Territory" => "ACT",
|
10
|
-
"New South Wales" => "NSW",
|
11
|
-
"Victoria" => "VIC",
|
12
|
-
"Queensland" => "QLD",
|
13
|
-
"South Australia" => "SA",
|
14
|
-
"Western Australia" => "WA",
|
15
|
-
"Tasmania" => "TAS",
|
16
|
-
"Northern Territory" => "NT"
|
17
|
-
},
|
18
|
-
# see http://en.wikipedia.org/wiki/Canadian_subnational_postal_abbreviations
|
19
|
-
:ca => {
|
20
|
-
"Alberta" => "AB",
|
21
|
-
"British Columbia" => "BC",
|
22
|
-
"Manitoba" => "MB",
|
23
|
-
"New Brunswick" => "NB",
|
24
|
-
"Newfoundland and Labrador" => "NL",
|
25
|
-
"Nova Scotia" => "NS",
|
26
|
-
"Northwest Territories" => "NT",
|
27
|
-
"Nunavut" => "NU",
|
28
|
-
"Ontario" => "ON",
|
29
|
-
"Prince Edward Island" => "PE",
|
30
|
-
"Quebec" => "QC",
|
31
|
-
"Saskatchewan" => "SK",
|
32
|
-
"Yukon" => "YT"
|
33
|
-
},
|
34
|
-
# see http://www.columbia.edu/kermit/postal.html#usa
|
35
|
-
# and http://www.usps.com/ncsc/lookups/usps_abbreviations.html
|
36
|
-
:us => {
|
37
|
-
"Alabama" => "AL",
|
38
|
-
"Alaska" => "AK",
|
39
|
-
"Arizona" => "AZ",
|
40
|
-
"Arkansas" => "AR",
|
41
|
-
"California" => "CA",
|
42
|
-
"Colorado" => "CO",
|
43
|
-
"Connecticut" => "CT",
|
44
|
-
"Delaware" => "DE",
|
45
|
-
"District Of Columbia" => "DC",
|
46
|
-
"Florida" => "FL",
|
47
|
-
"Georgia" => "GA",
|
48
|
-
"Hawaii" => "HI",
|
49
|
-
"Idaho" => "ID",
|
50
|
-
"Illinois" => "IL",
|
51
|
-
"Indiana" => "IN",
|
52
|
-
"Iowa" => "IA",
|
53
|
-
"Kansas" => "KS",
|
54
|
-
"Kentucky" => "KY",
|
55
|
-
"Louisiana" => "LA",
|
56
|
-
"Maine" => "ME",
|
57
|
-
"Maryland" => "MD",
|
58
|
-
"Massachusetts" => "MA",
|
59
|
-
"Michigan" => "MI",
|
60
|
-
"Minnesota" => "MN",
|
61
|
-
"Mississippi" => "MS",
|
62
|
-
"Missouri" => "MO",
|
63
|
-
"Montana" => "MT",
|
64
|
-
"Nebraska" => "NE",
|
65
|
-
"Nevada" => "NV",
|
66
|
-
"New Hampshire" => "NH",
|
67
|
-
"New Jersey" => "NJ",
|
68
|
-
"New Mexico" => "NM",
|
69
|
-
"New York" => "NY",
|
70
|
-
"North Carolina" => "NC",
|
71
|
-
"North Dakota" => "ND",
|
72
|
-
"Ohio" => "OH",
|
73
|
-
"Oklahoma" => "OK",
|
74
|
-
"Oregon" => "OR",
|
75
|
-
"Pennsylvania" => "PA",
|
76
|
-
"Rhode Island" => "RI",
|
77
|
-
"South Carolina" => "SC",
|
78
|
-
"South Dakota" => "SD",
|
79
|
-
"Tennessee" => "TN",
|
80
|
-
"Texas" => "TX",
|
81
|
-
"Utah" => "UT",
|
82
|
-
"Vermont" => "VT",
|
83
|
-
"Virginia" => "VA",
|
84
|
-
"Washington" => "WA",
|
85
|
-
"West Virginia" => "WV",
|
86
|
-
"Wisconsin" => "WI",
|
87
|
-
"Wyoming" => "WY",
|
88
|
-
|
89
|
-
# These are not states exactly, but they are addressed as states through USA
|
90
|
-
"American Samoa" => "AS",
|
91
|
-
"Federated States Of Micronesia" => "FM",
|
92
|
-
"Guam" => "GU",
|
93
|
-
"Marshall Islands" => "MH",
|
94
|
-
"Northern Mariana Islands" => "MP",
|
95
|
-
"Palau" => "PW",
|
96
|
-
"Puerto Rico" => "PR",
|
97
|
-
"Virgin Islands" => "VI",
|
98
|
-
"Armed Forces Africa" => "AE",
|
99
|
-
"Armed Forces Americas (Except Canada)" => "AA",
|
100
|
-
"Armed Forces Canada" => "AE",
|
101
|
-
"Armed Forces Europe" => "AE",
|
102
|
-
"Armed Forces Middle East" => "AE",
|
103
|
-
"Armed Forces Pacific" => "AP",
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
6
|
module Iso3166
|
108
7
|
# as of January 28, 2013
|
109
8
|
# pulled http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
@@ -0,0 +1,112 @@
|
|
1
|
+
class Snail
|
2
|
+
|
3
|
+
REGIONS = {
|
4
|
+
# see http://en.wikipedia.org/wiki/Postcodes_in_Australia#Australia_States_and_territories
|
5
|
+
:au => {
|
6
|
+
'Australian Capital Territory' => 'ACT',
|
7
|
+
'New South Wales' => 'NSW',
|
8
|
+
'Victoria' => 'VIC',
|
9
|
+
'Queensland' => 'QLD',
|
10
|
+
'South Australia' => 'SA',
|
11
|
+
'Western Australia' => 'WA',
|
12
|
+
'Tasmania' => 'TAS',
|
13
|
+
'Northern Territory' => 'NT'
|
14
|
+
},
|
15
|
+
# see http://en.wikipedia.org/wiki/Canadian_subnational_postal_abbreviations
|
16
|
+
:ca => {
|
17
|
+
'Alberta' => 'AB',
|
18
|
+
'British Columbia' => 'BC',
|
19
|
+
'Manitoba' => 'MB',
|
20
|
+
'New Brunswick' => 'NB',
|
21
|
+
'Newfoundland and Labrador' => 'NL',
|
22
|
+
'Nova Scotia' => 'NS',
|
23
|
+
'Northwest Territories' => 'NT',
|
24
|
+
'Nunavut' => 'NU',
|
25
|
+
'Ontario' => 'ON',
|
26
|
+
'Prince Edward Island' => 'PE',
|
27
|
+
'Quebec' => 'QC',
|
28
|
+
'Saskatchewan' => 'SK',
|
29
|
+
'Yukon' => 'YT'
|
30
|
+
},
|
31
|
+
# see http://www.columbia.edu/kermit/postal.html#usa
|
32
|
+
# and http://www.usps.com/ncsc/lookups/usps_abbreviations.html
|
33
|
+
:us => {
|
34
|
+
'Alabama' => 'AL',
|
35
|
+
'Alaska' => 'AK',
|
36
|
+
'Arizona' => 'AZ',
|
37
|
+
'Arkansas' => 'AR',
|
38
|
+
'California' => 'CA',
|
39
|
+
'Colorado' => 'CO',
|
40
|
+
'Connecticut' => 'CT',
|
41
|
+
'Delaware' => 'DE',
|
42
|
+
'District Of Columbia' => 'DC',
|
43
|
+
'Florida' => 'FL',
|
44
|
+
'Georgia' => 'GA',
|
45
|
+
'Hawaii' => 'HI',
|
46
|
+
'Idaho' => 'ID',
|
47
|
+
'Illinois' => 'IL',
|
48
|
+
'Indiana' => 'IN',
|
49
|
+
'Iowa' => 'IA',
|
50
|
+
'Kansas' => 'KS',
|
51
|
+
'Kentucky' => 'KY',
|
52
|
+
'Louisiana' => 'LA',
|
53
|
+
'Maine' => 'ME',
|
54
|
+
'Maryland' => 'MD',
|
55
|
+
'Massachusetts' => 'MA',
|
56
|
+
'Michigan' => 'MI',
|
57
|
+
'Minnesota' => 'MN',
|
58
|
+
'Mississippi' => 'MS',
|
59
|
+
'Missouri' => 'MO',
|
60
|
+
'Montana' => 'MT',
|
61
|
+
'Nebraska' => 'NE',
|
62
|
+
'Nevada' => 'NV',
|
63
|
+
'New Hampshire' => 'NH',
|
64
|
+
'New Jersey' => 'NJ',
|
65
|
+
'New Mexico' => 'NM',
|
66
|
+
'New York' => 'NY',
|
67
|
+
'North Carolina' => 'NC',
|
68
|
+
'North Dakota' => 'ND',
|
69
|
+
'Ohio' => 'OH',
|
70
|
+
'Oklahoma' => 'OK',
|
71
|
+
'Oregon' => 'OR',
|
72
|
+
'Pennsylvania' => 'PA',
|
73
|
+
'Rhode Island' => 'RI',
|
74
|
+
'South Carolina' => 'SC',
|
75
|
+
'South Dakota' => 'SD',
|
76
|
+
'Tennessee' => 'TN',
|
77
|
+
'Texas' => 'TX',
|
78
|
+
'Utah' => 'UT',
|
79
|
+
'Vermont' => 'VT',
|
80
|
+
'Virginia' => 'VA',
|
81
|
+
'Washington' => 'WA',
|
82
|
+
'West Virginia' => 'WV',
|
83
|
+
'Wisconsin' => 'WI',
|
84
|
+
'Wyoming' => 'WY',
|
85
|
+
|
86
|
+
# These are not states exactly, but they are addressed as states through USA
|
87
|
+
'American Samoa' => 'AS',
|
88
|
+
'Federated States Of Micronesia' => 'FM',
|
89
|
+
'Guam' => 'GU',
|
90
|
+
'Marshall Islands' => 'MH',
|
91
|
+
'Northern Mariana Islands' => 'MP',
|
92
|
+
'Palau' => 'PW',
|
93
|
+
'Puerto Rico' => 'PR',
|
94
|
+
'Virgin Islands' => 'VI',
|
95
|
+
'Armed Forces Africa' => 'AE',
|
96
|
+
'Armed Forces Americas (Except Canada)' => 'AA',
|
97
|
+
'Armed Forces Canada' => 'AE',
|
98
|
+
'Armed Forces Europe' => 'AE',
|
99
|
+
'Armed Forces Middle East' => 'AE',
|
100
|
+
'Armed Forces Pacific' => 'AP',
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
module Helpers
|
105
|
+
|
106
|
+
def region_options_for_select(country = :us, selected = nil)
|
107
|
+
options_for_select(REGIONS[country], selected)
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
data/lib/snail/version.rb
CHANGED
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.0
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2013-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -37,9 +37,9 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- lib/snail.rb
|
39
39
|
- lib/snail/constants.rb
|
40
|
+
- lib/snail/helpers.rb
|
40
41
|
- lib/snail/initializable.rb
|
41
42
|
- lib/snail/version.rb
|
42
|
-
- lib/snail_helpers.rb
|
43
43
|
- snail.gemspec
|
44
44
|
- test/snail_test.rb
|
45
45
|
- test/test_helper.rb
|