mainstreet 0.1.0 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +29 -0
- data/LICENSE.txt +1 -1
- data/README.md +129 -52
- data/lib/mainstreet/address_verifier.rb +82 -0
- data/lib/mainstreet/model.rb +35 -0
- data/lib/mainstreet/version.rb +2 -2
- data/lib/mainstreet.rb +20 -83
- metadata +16 -132
- data/.gitignore +0 -10
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/lib/generators/mainstreet/address_generator.rb +0 -10
- data/mainstreet.gemspec +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '08e1a7061a00946e499902c0eab2b4a9ab51971a69ab722626b89047aa4c1eca'
|
4
|
+
data.tar.gz: e7696455f9372bdb90b889fb8193a499f992a6ecc3b1a6c51fc2c1cf732ca0ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9a5c7b6147226624d4492df51bde93d1ae3c35f3da48a3f2e5730f8e649011e1108e13bdf2469e32feae23e722140721907a029d9343c3d8d52f9aef653cc3f
|
7
|
+
data.tar.gz: 52038f683d0fa478446c4a04d1a74aa545bac6f75b54d9bc98a5827855374ca88383e9deb32ae3479269e742765bb06b75dca6249f7dad786ce601cb69f480ed
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
## 0.2.3 (2022-02-08)
|
2
|
+
|
3
|
+
- Added `lookup` option
|
4
|
+
- Fixed duplicate API calls for invalid addresses
|
5
|
+
|
6
|
+
## 0.2.2 (2020-04-16)
|
7
|
+
|
8
|
+
- Fixed bug with SmartyStreets and ZIP code only addresses
|
9
|
+
|
10
|
+
## 0.2.1 (2019-10-04)
|
11
|
+
|
12
|
+
- Added support for i18n
|
13
|
+
- Added support for more validation options like `if` and `on`
|
14
|
+
- Specified minimum Geocoder version
|
15
|
+
|
16
|
+
## 0.2.0 (2018-11-30)
|
17
|
+
|
18
|
+
- Added `AddressVerifier`
|
19
|
+
- Added `validates_address` method
|
20
|
+
- Removed `acts_as_address` method
|
21
|
+
|
22
|
+
## 0.1.0 (2017-05-01)
|
23
|
+
|
24
|
+
- Added more validation
|
25
|
+
- Fixed model generator for Rails 5
|
26
|
+
|
27
|
+
## 0.0.1 (2015-03-14)
|
28
|
+
|
29
|
+
- First release
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,95 +1,163 @@
|
|
1
1
|
# MainStreet
|
2
2
|
|
3
|
-
|
3
|
+
Address verification for Ruby and Rails
|
4
4
|
|
5
|
-
|
5
|
+
:earth_americas: Supports international addresses
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
[![Build Status](https://github.com/ankane/mainstreet/workflows/build/badge.svg?branch=master)](https://github.com/ankane/mainstreet/actions)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application’s Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "mainstreet"
|
15
|
+
```
|
10
16
|
|
11
17
|
## How It Works
|
12
18
|
|
19
|
+
MainStreet uses [Geocoder](https://github.com/alexreisner/geocoder) for address verification, which has a number of [3rd party services](https://github.com/alexreisner/geocoder/blob/master/README_API_GUIDE.md#global-street-address-lookups) you can use. If you adhere to GDPR, be sure to add the service to your subprocessor list.
|
20
|
+
|
21
|
+
With some services, bad street numbers, units, and postal codes may pass verification. For full verification, get an account with [SmartyStreets](https://smartystreets.com). The free plan supports 250 lookups per month for US addresses, and plans for international addresses start at $7. To use it, set:
|
22
|
+
|
13
23
|
```ruby
|
14
|
-
|
24
|
+
ENV["SMARTY_STREETS_AUTH_ID"] = "auth-id"
|
25
|
+
ENV["SMARTY_STREETS_AUTH_TOKEN"] = "auth-token"
|
15
26
|
```
|
16
27
|
|
17
|
-
|
28
|
+
## How to Use
|
18
29
|
|
19
|
-
|
20
|
-
- city - `Cupertino`
|
21
|
-
- state - `CA`
|
22
|
-
- zip_code - `95014`
|
23
|
-
- latitude - `37.33053`
|
24
|
-
- longitude - `-122.02887`
|
25
|
-
- original_attributes - `{"street"=>"1 infinite loop", "street2"=>nil, "city"=>nil, "state"=>nil, "zip_code"=>"95014"}`
|
26
|
-
- verification_info
|
30
|
+
Check an address with:
|
27
31
|
|
28
|
-
|
32
|
+
```ruby
|
33
|
+
address = "1600 Pennsylvania Ave NW, Washington DC 20500"
|
34
|
+
verifier = MainStreet::AddressVerifier.new(address)
|
35
|
+
verifier.success?
|
36
|
+
```
|
29
37
|
|
30
|
-
|
38
|
+
If verification fails, get the failure message with:
|
31
39
|
|
32
40
|
```ruby
|
33
|
-
|
34
|
-
address.valid?
|
35
|
-
# false
|
36
|
-
address.errors.full_messages
|
37
|
-
# ["Did you mean 95014?"]
|
41
|
+
verifier.failure_message
|
38
42
|
```
|
39
43
|
|
40
|
-
|
44
|
+
Get details about the result with:
|
41
45
|
|
42
|
-
|
46
|
+
```ruby
|
47
|
+
verifier.result
|
48
|
+
```
|
43
49
|
|
44
|
-
|
50
|
+
Get the latitude and longitude with:
|
45
51
|
|
46
52
|
```ruby
|
47
|
-
|
53
|
+
verifier.latitude
|
54
|
+
verifier.longitude
|
48
55
|
```
|
49
56
|
|
50
|
-
|
57
|
+
## Active Record
|
51
58
|
|
52
|
-
|
53
|
-
|
59
|
+
For Active Record models, use:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
class User < ApplicationRecord
|
63
|
+
validates_address fields: [:street, :street2, :city, :state, :postal_code]
|
64
|
+
end
|
54
65
|
```
|
55
66
|
|
56
|
-
|
67
|
+
The order should be the same as if you were to write the address out.
|
68
|
+
|
69
|
+
For performance, the address is only verified if at least one of the fields changes. Set your own condition with:
|
57
70
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
- latitude
|
64
|
-
- longitude
|
65
|
-
- original_attributes
|
66
|
-
- verification_info
|
71
|
+
```ruby
|
72
|
+
class User < ApplicationRecord
|
73
|
+
validates_address if: -> { something_changed? }, ...
|
74
|
+
end
|
75
|
+
```
|
67
76
|
|
68
|
-
|
77
|
+
Geocode the address with:
|
69
78
|
|
70
|
-
|
71
|
-
|
72
|
-
|
79
|
+
```ruby
|
80
|
+
class User < ApplicationRecord
|
81
|
+
validates_address geocode: true, ...
|
82
|
+
end
|
83
|
+
```
|
73
84
|
|
74
|
-
|
85
|
+
The `latitude` and `longitude` fields are used by default. Specify the fields with:
|
75
86
|
|
76
|
-
|
87
|
+
```ruby
|
88
|
+
class User < ApplicationRecord
|
89
|
+
validates_address geocode: {latitude: :lat, longitude: :lon}, ...
|
90
|
+
end
|
91
|
+
```
|
77
92
|
|
78
|
-
|
93
|
+
Empty addresses are not verified. To require an address, add your own validation.
|
79
94
|
|
80
95
|
```ruby
|
81
|
-
|
82
|
-
|
96
|
+
class User < ApplicationRecord
|
97
|
+
validates :street, presence: true
|
98
|
+
end
|
83
99
|
```
|
84
100
|
|
85
|
-
|
101
|
+
## SmartyStreets
|
102
|
+
|
103
|
+
With SmartyStreets, you must pass the country for non-US addresses.
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
MainStreet::AddressVerifier.new(address, country: "France")
|
107
|
+
```
|
108
|
+
|
109
|
+
Here’s the list of [supported countries](https://smartystreets.com/docs/cloud/international-street-api#countries). You can pass the name, ISO-3, ISO-2, or ISO-N code (like `France`, `FRA`, `FR`, or `250`).
|
110
|
+
|
111
|
+
For Active Record, use:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
class User < ApplicationRecord
|
115
|
+
validates_address country: "France", ...
|
116
|
+
end
|
117
|
+
```
|
118
|
+
|
119
|
+
Or use a proc to make it dynamic
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
class User < ApplicationRecord
|
123
|
+
validates_address country: -> { country }, ...
|
124
|
+
end
|
125
|
+
```
|
126
|
+
|
127
|
+
## Internationalization (i18n)
|
128
|
+
|
129
|
+
You can customize error messages with the [i18n](https://github.com/ruby-i18n/i18n) gem. In Rails, add to the appropriate `config/locales` file:
|
130
|
+
|
131
|
+
```yml
|
132
|
+
en:
|
133
|
+
mainstreet:
|
134
|
+
errors:
|
135
|
+
messages:
|
136
|
+
unconfirmed: Address can't be confirmed
|
137
|
+
apt_unconfirmed: Apartment or suite can't be confirmed
|
138
|
+
apt_missing: Apartment or suite is missing
|
139
|
+
```
|
140
|
+
|
141
|
+
## Data Protection
|
142
|
+
|
143
|
+
We recommend encrypting street information and postal code (at the very least) for user addresses. [Lockbox](https://github.com/ankane/lockbox) is great for this. Check out [this article](https://ankane.org/sensitive-data-rails) for more details.
|
86
144
|
|
87
145
|
```ruby
|
88
|
-
|
89
|
-
|
90
|
-
|
146
|
+
class User < ApplicationRecord
|
147
|
+
encrypts :street, :postal_code
|
148
|
+
end
|
91
149
|
```
|
92
150
|
|
151
|
+
## Upgrading
|
152
|
+
|
153
|
+
### 0.2.0
|
154
|
+
|
155
|
+
See the [upgrade guide](docs/0-2-Upgrade.md)
|
156
|
+
|
157
|
+
## History
|
158
|
+
|
159
|
+
View the [changelog](https://github.com/ankane/mainstreet/blob/master/CHANGELOG.md)
|
160
|
+
|
93
161
|
## Contributing
|
94
162
|
|
95
163
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
@@ -98,3 +166,12 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
98
166
|
- Fix bugs and [submit pull requests](https://github.com/ankane/mainstreet/pulls)
|
99
167
|
- Write, clarify, or fix documentation
|
100
168
|
- Suggest or add new features
|
169
|
+
|
170
|
+
To get started with development:
|
171
|
+
|
172
|
+
```sh
|
173
|
+
git clone https://github.com/ankane/mainstreet.git
|
174
|
+
cd mainstreet
|
175
|
+
bundle install
|
176
|
+
bundle exec rake test
|
177
|
+
```
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module MainStreet
|
2
|
+
class AddressVerifier
|
3
|
+
def initialize(address, country: nil, locale: nil)
|
4
|
+
@address = address
|
5
|
+
@country = country
|
6
|
+
@locale = locale
|
7
|
+
end
|
8
|
+
|
9
|
+
def success?
|
10
|
+
failure_message.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def failure_message
|
14
|
+
if !result
|
15
|
+
message :unconfirmed, "Address can't be confirmed"
|
16
|
+
elsif result.respond_to?(:analysis)
|
17
|
+
analysis = result.analysis
|
18
|
+
|
19
|
+
if analysis["verification_status"]
|
20
|
+
case analysis["verification_status"]
|
21
|
+
when "Verified"
|
22
|
+
nil # success!!
|
23
|
+
when "Ambiguous", "Partial", "None"
|
24
|
+
message :unconfirmed, "Address can't be confirmed"
|
25
|
+
else
|
26
|
+
raise "Unknown verification_status"
|
27
|
+
end
|
28
|
+
elsif analysis["dpv_match_code"]
|
29
|
+
case analysis["dpv_match_code"]
|
30
|
+
when "Y"
|
31
|
+
nil # success!!
|
32
|
+
when "N"
|
33
|
+
message :unconfirmed, "Address can't be confirmed"
|
34
|
+
when "S"
|
35
|
+
message :apt_unconfirmed, "Apartment or suite can't be confirmed"
|
36
|
+
when "D"
|
37
|
+
message :apt_missing, "Apartment or suite is missing"
|
38
|
+
else
|
39
|
+
raise "Unknown dpv_match_code"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def result
|
46
|
+
return @result if defined?(@result)
|
47
|
+
|
48
|
+
@result = begin
|
49
|
+
options = {lookup: MainStreet.lookup}
|
50
|
+
options[:country] = @country if @country && !usa?
|
51
|
+
# don't use smarty streets zipcode only API
|
52
|
+
# keep mirrored with geocoder gem, including \Z
|
53
|
+
# \Z is the same as \z when strip is used
|
54
|
+
if @address.to_s.strip !~ /\A\d{5}(-\d{4})?\Z/
|
55
|
+
Geocoder.search(@address, options).first
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def latitude
|
61
|
+
result && result.latitude
|
62
|
+
end
|
63
|
+
|
64
|
+
def longitude
|
65
|
+
result && result.longitude
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def usa?
|
71
|
+
["United States", "USA", "US", "840"].include?(@country.to_s)
|
72
|
+
end
|
73
|
+
|
74
|
+
def message(key, default)
|
75
|
+
if defined?(I18n)
|
76
|
+
I18n.t(key, scope: [:mainstreet, :errors, :messages], locale: @locale, default: default)
|
77
|
+
else
|
78
|
+
default
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module MainStreet
|
2
|
+
module Model
|
3
|
+
def validates_address(fields:, geocode: false, country: nil, **options)
|
4
|
+
fields = Array(fields.map(&:to_s))
|
5
|
+
geocode_options = {latitude: :latitude, longitude: :longitude}
|
6
|
+
geocode_options = geocode_options.merge(geocode) if geocode.is_a?(Hash)
|
7
|
+
options[:if] ||= -> { fields.any? { |f| changes.key?(f.to_s) } } unless options[:unless]
|
8
|
+
|
9
|
+
class_eval do
|
10
|
+
validate :verify_address, **options
|
11
|
+
|
12
|
+
define_method :verify_address do
|
13
|
+
address = fields.map { |v| send(v).presence }.compact.join(", ")
|
14
|
+
|
15
|
+
if address.present?
|
16
|
+
# must use a different variable than country
|
17
|
+
record_country = instance_exec(&country) if country.respond_to?(:call)
|
18
|
+
verifier = MainStreet::AddressVerifier.new(address, country: record_country)
|
19
|
+
if verifier.success?
|
20
|
+
if geocode
|
21
|
+
self.send("#{geocode_options[:latitude]}=", verifier.latitude)
|
22
|
+
self.send("#{geocode_options[:longitude]}=", verifier.longitude)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
errors.add(:base, verifier.failure_message)
|
26
|
+
end
|
27
|
+
|
28
|
+
# legacy - for standardize_address method
|
29
|
+
@address_verification_result = verifier.result
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/mainstreet/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.
|
1
|
+
module MainStreet
|
2
|
+
VERSION = "0.2.3"
|
3
3
|
end
|
data/lib/mainstreet.rb
CHANGED
@@ -1,95 +1,32 @@
|
|
1
|
-
|
1
|
+
# dependencies
|
2
2
|
require "geocoder"
|
3
3
|
|
4
|
-
|
4
|
+
# modules
|
5
|
+
require "mainstreet/address_verifier"
|
6
|
+
require "mainstreet/version"
|
7
|
+
|
8
|
+
module MainStreet
|
5
9
|
class << self
|
6
10
|
attr_writer :lookup
|
7
11
|
|
8
12
|
def lookup
|
9
|
-
@lookup ||=
|
10
|
-
if ENV["SMARTY_STREETS_AUTH_ID"] && ENV["SMARTY_STREETS_AUTH_TOKEN"]
|
11
|
-
Geocoder.config[:smarty_streets] ||= {api_key: [ENV["SMARTY_STREETS_AUTH_ID"], ENV["SMARTY_STREETS_AUTH_TOKEN"]]}
|
12
|
-
end
|
13
|
-
Geocoder.config[:smarty_streets] ? :smarty_streets : nil
|
14
|
-
end
|
13
|
+
@lookup ||= ENV["SMARTY_STREETS_AUTH_ID"] ? :smarty_streets : nil
|
15
14
|
end
|
16
15
|
end
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
before_save :standardize_address, if: -> { address_fields_changed? }
|
27
|
-
|
28
|
-
def verify_address
|
29
|
-
if zip_code.blank? && (city.blank? || state.blank?)
|
30
|
-
errors.add(:base, "Address can't be confirmed")
|
31
|
-
end
|
32
|
-
if errors.empty?
|
33
|
-
@verification_result = fetch_verification_info
|
34
|
-
if @verification_result
|
35
|
-
if @verification_result.respond_to?(:analysis)
|
36
|
-
case @verification_result.analysis["dpv_match_code"]
|
37
|
-
when "N"
|
38
|
-
errors.add(:base, "Address can't be confirmed")
|
39
|
-
when "S"
|
40
|
-
errors.add(:base, "Apartment or suite can't be confirmed")
|
41
|
-
when "D"
|
42
|
-
errors.add(:base, "Apartment or suite is missing")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
correct_zip_code = @verification_result.postal_code
|
47
|
-
if zip_code != correct_zip_code
|
48
|
-
errors.add(:base, "Did you mean #{correct_zip_code}?")
|
49
|
-
end
|
50
|
-
else
|
51
|
-
errors.add(:base, "Address can't be confirmed")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
errors.full_messages
|
55
|
-
end
|
56
|
-
|
57
|
-
def standardize_address
|
58
|
-
result = @verification_result
|
59
|
-
if result
|
60
|
-
info = result.data
|
61
|
-
self.original_attributes = attributes.slice(*address_fields)
|
62
|
-
self.verification_info = result.data.to_hash
|
63
|
-
self.street =
|
64
|
-
if result.respond_to?(:delivery_line_1)
|
65
|
-
result.delivery_line_1
|
66
|
-
else
|
67
|
-
result.formatted_address.split(",").first
|
68
|
-
end
|
69
|
-
self.street2 = nil
|
70
|
-
self.city = result.city
|
71
|
-
self.state = result.state_code
|
72
|
-
self.zip_code = result.postal_code
|
73
|
-
self.latitude = result.latitude
|
74
|
-
self.longitude = result.longitude
|
75
|
-
end
|
76
|
-
true
|
77
|
-
end
|
78
|
-
|
79
|
-
def fetch_verification_info
|
80
|
-
Geocoder.search("#{street} #{street2} #{city}, #{state} #{zip_code}", lookup: Mainstreet.lookup).first
|
81
|
-
end
|
82
|
-
|
83
|
-
def address_fields_changed?
|
84
|
-
address_fields.any? { |f| send("#{f}_changed?") }
|
85
|
-
end
|
18
|
+
if ENV["SMARTY_STREETS_AUTH_ID"]
|
19
|
+
Geocoder.config[:smarty_streets] ||= {
|
20
|
+
api_key: [
|
21
|
+
ENV["SMARTY_STREETS_AUTH_ID"],
|
22
|
+
ENV["SMARTY_STREETS_AUTH_TOKEN"]
|
23
|
+
]
|
24
|
+
}
|
25
|
+
end
|
86
26
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
27
|
+
if defined?(ActiveSupport.on_load)
|
28
|
+
ActiveSupport.on_load(:active_record) do
|
29
|
+
require "mainstreet/model"
|
30
|
+
extend MainStreet::Model
|
92
31
|
end
|
93
32
|
end
|
94
|
-
|
95
|
-
ActiveRecord::Base.send(:extend, Mainstreet::Model) if defined?(ActiveRecord)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mainstreet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: geocoder
|
@@ -16,147 +16,32 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.5.1
|
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
|
-
version:
|
27
|
-
|
28
|
-
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.8'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.8'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '10.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: activerecord
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: sqlite3
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: smartystreets
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: vcr
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: webmock
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
description: A standard US address model for Rails
|
140
|
-
email:
|
141
|
-
- andrew@chartkick.com
|
26
|
+
version: 1.5.1
|
27
|
+
description:
|
28
|
+
email: andrew@ankane.org
|
142
29
|
executables: []
|
143
30
|
extensions: []
|
144
31
|
extra_rdoc_files: []
|
145
32
|
files:
|
146
|
-
-
|
147
|
-
- Gemfile
|
33
|
+
- CHANGELOG.md
|
148
34
|
- LICENSE.txt
|
149
35
|
- README.md
|
150
|
-
- Rakefile
|
151
|
-
- lib/generators/mainstreet/address_generator.rb
|
152
36
|
- lib/mainstreet.rb
|
37
|
+
- lib/mainstreet/address_verifier.rb
|
38
|
+
- lib/mainstreet/model.rb
|
153
39
|
- lib/mainstreet/version.rb
|
154
|
-
- mainstreet.gemspec
|
155
40
|
homepage: https://github.com/ankane/mainstreet
|
156
41
|
licenses:
|
157
42
|
- MIT
|
158
43
|
metadata: {}
|
159
|
-
post_install_message:
|
44
|
+
post_install_message:
|
160
45
|
rdoc_options: []
|
161
46
|
require_paths:
|
162
47
|
- lib
|
@@ -164,16 +49,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
49
|
requirements:
|
165
50
|
- - ">="
|
166
51
|
- !ruby/object:Gem::Version
|
167
|
-
version: '
|
52
|
+
version: '2.2'
|
168
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
54
|
requirements:
|
170
55
|
- - ">="
|
171
56
|
- !ruby/object:Gem::Version
|
172
57
|
version: '0'
|
173
58
|
requirements: []
|
174
|
-
|
175
|
-
|
176
|
-
signing_key:
|
59
|
+
rubygems_version: 3.3.3
|
60
|
+
signing_key:
|
177
61
|
specification_version: 4
|
178
|
-
summary:
|
62
|
+
summary: Address verification for Ruby and Rails
|
179
63
|
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Mainstreet
|
4
|
-
class AddressGenerator < Rails::Generators::Base
|
5
|
-
def boom
|
6
|
-
invoke "model", ["Address", "street:string", "street2:string", "city:string", "state:string", "zip_code:string", "latitude:decimal{15.10}", "longitude:decimal{15.10}", "verification_info:text", "original_attributes:text"], options
|
7
|
-
insert_into_file "app/models/address.rb", " acts_as_address\n", after: "ApplicationRecord\n"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
data/mainstreet.gemspec
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "mainstreet/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "mainstreet"
|
8
|
-
spec.version = Mainstreet::VERSION
|
9
|
-
spec.authors = ["Andrew Kane"]
|
10
|
-
spec.email = ["andrew@chartkick.com"]
|
11
|
-
|
12
|
-
spec.summary = "A standard US address model for Rails"
|
13
|
-
spec.description = "A standard US address model for Rails"
|
14
|
-
spec.homepage = "https://github.com/ankane/mainstreet"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = "exe"
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_dependency "geocoder"
|
23
|
-
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.8"
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.add_development_dependency "minitest"
|
27
|
-
spec.add_development_dependency "activerecord"
|
28
|
-
spec.add_development_dependency "sqlite3"
|
29
|
-
spec.add_development_dependency "smartystreets"
|
30
|
-
spec.add_development_dependency "vcr"
|
31
|
-
spec.add_development_dependency "webmock"
|
32
|
-
end
|