strict_geocoder 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/strict_geocoder.rb +19 -0
- data/lib/strict_geocoder/errors.rb +7 -0
- data/lib/strict_geocoder/stores/active_record.rb +41 -0
- data/lib/strict_geocoder/version.rb +3 -0
- data/strict_geocoder.gemspec +32 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a52a0db25ffcb3a6e99d9616fc02209482929637
|
4
|
+
data.tar.gz: 4b8256ff5a5a9991ee0e15c00b956661ff8a7ad6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e85d4927f1b7455f7402c34cdc55822a642daf65d9f8deb62595d1eb39fd58ddb825ced41f6fe65dc56e7493c6eb3727256eabbec7308ab4075e96762e094a6
|
7
|
+
data.tar.gz: 55430a57974db33538ab62f68f3507e03fdd83f72d5927f85775aacaa7ea24bb98c78a83a1f3b561bf303768d6a6ca01d6c896985e987d9e04890893304cc1c8
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Daniel P. Clark
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# StrictGeocoder
|
2
|
+
|
3
|
+
This gem will be versioned by the current releases of geocoder. Any new methods
|
4
|
+
will be available on the repo's master branch before version release.
|
5
|
+
|
6
|
+
The point of strict methods is to raise an error rather than query the database
|
7
|
+
with null values. For example you may use the `:near!` scope from an API and inform
|
8
|
+
the client/user of an invalid address based on geo lookup failures.
|
9
|
+
|
10
|
+
**Implemented for ActiveRecord**
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'strict_geocoder'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install strict_geocoder
|
27
|
+
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
32
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "strict_geocoder"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "strict_geocoder/version"
|
2
|
+
require "strict_geocoder/errors"
|
3
|
+
require "active_record"
|
4
|
+
require "geocoder/stores/active_record"
|
5
|
+
require "strict_geocoder/stores/active_record"
|
6
|
+
|
7
|
+
module StrictGeocoder
|
8
|
+
::ActiveRecord::Base.class_eval do
|
9
|
+
class << self
|
10
|
+
alias_method :_inherited_strict_geocoder, :inherited
|
11
|
+
def inherited(child)
|
12
|
+
child.extend Geocoder::Store::ActiveRecord::ClassMethods unless \
|
13
|
+
child.ancestors.include? Geocoder::Store::ActiveRecord
|
14
|
+
child.include StrictGeocoder::Store::ActiveRecord
|
15
|
+
_inherited_strict_geocoder(child)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'geocoder/sql'
|
3
|
+
require 'geocoder/stores/base'
|
4
|
+
|
5
|
+
##
|
6
|
+
# Add strict geocoding functionality to any ActiveRecord object.
|
7
|
+
#
|
8
|
+
module StrictGeocoder
|
9
|
+
module Store
|
10
|
+
module ActiveRecord
|
11
|
+
include Geocoder::Store::Base
|
12
|
+
|
13
|
+
##
|
14
|
+
# Implementation of 'included' hook method.
|
15
|
+
#
|
16
|
+
def self.included(base)
|
17
|
+
base.class_eval do
|
18
|
+
|
19
|
+
##
|
20
|
+
# Find all objects within a radius of the given location.
|
21
|
+
# Location may be either a string to geocode or an array of
|
22
|
+
# coordinates (<tt>[lat,lon]</tt>). Also takes an options hash
|
23
|
+
# (see Geocoder::Store::ActiveRecord::ClassMethods.near_scope_options
|
24
|
+
# for details).
|
25
|
+
#
|
26
|
+
scope :near!, lambda{ |location, *args|
|
27
|
+
point = Geocoder::Calculations.extract_coordinates(location)
|
28
|
+
raise StrictGeocoder::InvalidLocation, "The provided location didn't return as valid" \
|
29
|
+
and return if point == [
|
30
|
+
Geocoder::Calculations::NAN, Geocoder::Calculations::NAN
|
31
|
+
]
|
32
|
+
|
33
|
+
options = near_scope_options(*point, *args)
|
34
|
+
select(options[:select]).where(options[:conditions]).
|
35
|
+
order(options[:order])
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'strict_geocoder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "strict_geocoder"
|
8
|
+
spec.version = StrictGeocoder::VERSION
|
9
|
+
spec.authors = ["Daniel P. Clark"]
|
10
|
+
spec.email = ["6ftdan@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Add strict scopes for ActiveRecord}
|
13
|
+
spec.description = %q{Add strict scopes for ActiveRecord to Geocoder}
|
14
|
+
spec.homepage = "https://github.com/danielpclark/strict_geocoder"
|
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_runtime_dependency 'geocoder', '~> 1.3', '>= 1.3.1'
|
23
|
+
spec.add_runtime_dependency 'activerecord', '>= 3.2.22.2'
|
24
|
+
|
25
|
+
spec.add_development_dependency "sqlite3"
|
26
|
+
spec.add_development_dependency 'activerecord', '3.2.22.2'
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
28
|
+
spec.add_development_dependency "rake", "~> 11.1"
|
29
|
+
spec.add_development_dependency "minitest", "~> 5.8"
|
30
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.1"
|
31
|
+
spec.add_development_dependency "color_pound_spec_reporter", "~> 0.0.5"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: strict_geocoder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel P. Clark
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: geocoder
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.3.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.3.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activerecord
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 3.2.22.2
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.2.22.2
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sqlite3
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: activerecord
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 3.2.22.2
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 3.2.22.2
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: bundler
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.11'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.11'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '11.1'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '11.1'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: minitest
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '5.8'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '5.8'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: minitest-reporters
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1.1'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.1'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: color_pound_spec_reporter
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.0.5
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.0.5
|
145
|
+
description: Add strict scopes for ActiveRecord to Geocoder
|
146
|
+
email:
|
147
|
+
- 6ftdan@gmail.com
|
148
|
+
executables: []
|
149
|
+
extensions: []
|
150
|
+
extra_rdoc_files: []
|
151
|
+
files:
|
152
|
+
- ".gitignore"
|
153
|
+
- ".travis.yml"
|
154
|
+
- Gemfile
|
155
|
+
- LICENSE.txt
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- bin/console
|
159
|
+
- bin/setup
|
160
|
+
- lib/strict_geocoder.rb
|
161
|
+
- lib/strict_geocoder/errors.rb
|
162
|
+
- lib/strict_geocoder/stores/active_record.rb
|
163
|
+
- lib/strict_geocoder/version.rb
|
164
|
+
- strict_geocoder.gemspec
|
165
|
+
homepage: https://github.com/danielpclark/strict_geocoder
|
166
|
+
licenses:
|
167
|
+
- MIT
|
168
|
+
metadata: {}
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.5.1
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Add strict scopes for ActiveRecord
|
189
|
+
test_files: []
|