geocode_records 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97c3fbf26bb7ebaec1fac57e9212476b1a3ddf64
4
- data.tar.gz: b98b65636292d3b74f53f6045aaacfac99784b07
3
+ metadata.gz: 2cec9b1bf42ae7aa40359d9a4d84f0ab30273358
4
+ data.tar.gz: 6aa1c9fab15253fd0f16b7ba5ba12a3d73390d1e
5
5
  SHA512:
6
- metadata.gz: 1ca4fdc59c870dab258bd10de6c8bcdc10ba7120b6bfa5f620cb7f67249cffd47b8936116326991c09df85cc870479a4d8c4e74d37df9935ed8bf02e7f899cb2
7
- data.tar.gz: 47723ada9b16c31654080114a01de9899e7457e4e5022f71510525515322632e78fd9620dacf56adb489012cf2fd98eeae5de1fbc9fe5b42d4023cbc033ef513
6
+ metadata.gz: 805f6cf61202f52be4078e6df883ddefc8eee9cb559742ee912fd9f5b1469f2c06de840218030f8ab1b682254dca515eaec2a5f57b66dc76b5fea00b9eeb8112
7
+ data.tar.gz: 17fbb907970b4bc2608250598366159dd5501f14568bb649c3070f5b67b27314fe8e16d1e1013de21e2539c3466a85825664e62078d9cafb2745994ed154290a
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 0.1.0 / 2016-02-01
2
+
3
+ * Enhancements
4
+
5
+ * Don't preemptively chop off postcode after 5 chars
6
+ * include_invalid: option
7
+ * Requires latest smartystreets
8
+
1
9
  0.0.5 / 2015-07-16
2
10
 
3
11
  * Enhancements
data/bin/geocode_records CHANGED
@@ -6,12 +6,6 @@ require 'geocode_records'
6
6
 
7
7
  ActiveRecord::Base.establish_connection ENV.fetch('DATABASE_URL')
8
8
 
9
- # http://gray.fm/2013/09/17/unknown-oid-with-rails-and-postgresql/
10
- require 'active_record/connection_adapters/postgresql/oid'
11
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.tap do |klass|
12
- klass::OID.register_type('geometry', klass::OID::Identity.new)
13
- end
14
-
15
9
  logger = Logger.new($stderr)
16
10
  logger.level = Logger::WARN
17
11
  ActiveRecord::Base.logger = logger
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency 'activerecord', '~>4.1.9'
22
+ spec.add_runtime_dependency 'activesupport'
22
23
  spec.add_runtime_dependency 'pg'
23
24
  spec.add_runtime_dependency 'attr_extras'
24
25
  spec.add_runtime_dependency 'zaru'
@@ -10,11 +10,13 @@ require 'geocode_records/smarty_streets'
10
10
  class GeocodeRecords
11
11
  class GeocodeCsv
12
12
  attr_reader :glob
13
+ attr_reader :include_invalid
13
14
 
14
15
  def initialize(input_path, options = {})
15
16
  @input_path = input_path
16
17
  options ||= {}
17
18
  @glob = options[:glob]
19
+ @include_invalid = options[:include_invalid]
18
20
  @mutex = Mutex.new
19
21
  end
20
22
 
@@ -53,6 +55,9 @@ class GeocodeRecords
53
55
  '--auth-id', ENV.fetch('SMARTY_STREETS_AUTH_ID'),
54
56
  '--auth-token', ENV.fetch('SMARTY_STREETS_AUTH_TOKEN')
55
57
  ]
58
+ if include_invalid
59
+ args += [ '--include-invalid' ]
60
+ end
56
61
  input_map.each do |ss, local|
57
62
  args += [ "--#{ss}-col", local.to_s ]
58
63
  end
@@ -2,7 +2,7 @@ class GeocodeRecords
2
2
 
3
3
  module SmartyStreets
4
4
 
5
- VERSION = '1.6.2'
5
+ VERSION = '1.7.2'
6
6
 
7
7
  def self.bin_path
8
8
  @bin_path ||= if File.exist?('node_modules/.bin/smartystreets')
@@ -1,3 +1,3 @@
1
1
  class GeocodeRecords
2
- VERSION = '0.0.5'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require 'active_record'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
2
4
  require 'attr_extras'
3
5
  require 'pasqual'
4
6
 
@@ -14,7 +16,7 @@ class GeocodeRecords
14
16
  attr_reader :options
15
17
  def initialize(records, options = {})
16
18
  records.is_a?(ActiveRecord::Relation) or raise(ArgumentError, "expected AR::Relation, got #{records.class}")
17
- @options = options || {}
19
+ @options = (options || {}).symbolize_keys
18
20
  @records = records
19
21
  end
20
22
 
@@ -51,7 +53,7 @@ class GeocodeRecords
51
53
  if glob
52
54
  c.to_sql records.select('id', 'glob').arel, records.bind_values
53
55
  else
54
- c.to_sql records.select('id', 'house_number_and_street', 'house_number', 'unit_number', 'city', 'state', "left(regexp_replace(postcode, '.0$', ''), 5) AS postcode").arel, records.bind_values
56
+ c.to_sql records.select('id', 'house_number_and_street', 'house_number', 'unit_number', 'city', 'state', "regexp_replace(postcode, '.0$', '') AS postcode").arel, records.bind_values
55
57
  end
56
58
  end
57
59
  end
data/package.json CHANGED
@@ -2,6 +2,6 @@
2
2
  "name": "rolodeck",
3
3
  "private": true,
4
4
  "dependencies": {
5
- "smartystreets": "^1.6.2"
5
+ "smartystreets": "^1.7.2"
6
6
  }
7
7
  }
@@ -21,8 +21,8 @@ describe GeocodeRecords::SmartyStreets do
21
21
  it { is_expected.to be false }
22
22
  end
23
23
 
24
- context 'v1.6.2' do
25
- let(:version) { '1.6.2' }
24
+ context 'v1.7.2' do
25
+ let(:version) { '1.7.2' }
26
26
 
27
27
  it { is_expected.to be true }
28
28
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  dbname = 'geocode_records_test'
4
- ENV['DATABASE_URL'] ||= "postgresql://127.0.0.1/#{dbname}"
4
+ ENV['DATABASE_URL'] = "postgresql://127.0.0.1/#{dbname}"
5
5
 
6
6
  unless ENV['FAST'] == 'true'
7
7
  psql = Pasqual.for ENV['DATABASE_URL']
@@ -43,11 +43,6 @@ end
43
43
 
44
44
  require 'active_record'
45
45
  ActiveRecord::Base.establish_connection
46
- # http://gray.fm/2013/09/17/unknown-oid-with-rails-and-postgresql/
47
- require 'active_record/connection_adapters/postgresql/oid'
48
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.tap do |klass|
49
- klass::OID.register_type('geometry', klass::OID::Identity.new)
50
- end
51
46
 
52
47
  class Home < ActiveRecord::Base
53
48
  end
@@ -95,6 +90,27 @@ describe GeocodeRecords do
95
90
  expect(home.house_number_and_street).to eq('36 Main St')
96
91
  end
97
92
 
93
+ it "doesn't break on zip-4" do
94
+ home = Home.create! house_number_and_street: '1038 e dayton st', postcode: '53703-2428'
95
+ GeocodeRecords.new(Home.all).perform
96
+ home.reload
97
+ expect(home.house_number_and_street).to eq('1038 E Dayton St')
98
+ end
99
+
100
+ it "accepts city and state only" do
101
+ home = Home.create! house_number_and_street: '1038 e dayton st', city: 'madison', state: 'wisconsin'
102
+ GeocodeRecords.new(Home.all).perform
103
+ home.reload
104
+ expect(home.house_number_and_street).to eq('1038 E Dayton St')
105
+ end
106
+
107
+ it "allows invalid" do
108
+ home = Home.create! house_number_and_street: '1039 e dayton st', city: 'madison', state: 'wisconsin'
109
+ GeocodeRecords.new(Home.all, include_invalid: true).perform
110
+ home.reload
111
+ expect(home.house_number_and_street).to eq('1039 E Dayton St')
112
+ end
113
+
98
114
  describe 'known issues' do
99
115
  it "doesn't fix float-format postcode on records that it can't geocode" do
100
116
  home = Home.create! house_number_and_street: 'gibberish', postcode: '53703.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geocode_records
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2016-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.1.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: pg
29
43
  requirement: !ruby/object:Gem::Requirement