melissa_data 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8040dba4069d61c3b05133f053973d0a23b794a9
4
+ data.tar.gz: 2acf1ec4b535a7fd34c79c0682c3e97017e894f8
5
+ SHA512:
6
+ metadata.gz: 66df5eb47e0c23353abb4b6480fab7011da4b389e43af0f274ebc348b3169349efd9e482256d1894387b783447a00bbf13dec472469f7a28936192fc18271b22
7
+ data.tar.gz: 8cb3a6a4b1ce6e9002ed3cab0c02d9709b5ccbaf5f2efc1ebc9c1a8a35b5dc2c0666d49fd06ddf16d363fde88c72a75f59b7916955e07f4283a5816fa6d1c95b
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in melissa_data.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Robert Grayson
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,244 @@
1
+ # Melissa Data
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'melissa_data'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install melissa_data
18
+
19
+ ## Usage
20
+
21
+ ### Smart Web APIs
22
+
23
+ #### Property
24
+ There is a client included for the property API on Melissa. This requires very little.
25
+ You will need two environment variables: `MELISSA_DATA_WEB_SMART_ID`, and `MELISSA_DATA_PROPERTY_API_URL`
26
+ Once you have these, you may use the following client. To instantiate a client:
27
+
28
+ ```ruby
29
+ irb> client = MelissaData::WebSmart::Client.new
30
+ irb> client.property(some_fips_code, some_apn)
31
+ # => property data
32
+ ```
33
+
34
+ Data comes in the following form:
35
+
36
+ ```json
37
+ {
38
+ "record_id": null,
39
+ "result": {
40
+ "code": "YS01,YS03,YC01,GS05",
41
+ "description": "FIPS/APN Match Found. Basic information returned."
42
+ },
43
+ "parcel": {
44
+ "fips_code": "12071",
45
+ "fips_sub_code": null,
46
+ "unformatted_apn": null,
47
+ "apn_sequence_no": null,
48
+ "formatted_apn": "24-43-24-03-00022.0040",
49
+ "original_apn": null,
50
+ "census_tract": null,
51
+ "zoning": null,
52
+ "range": null,
53
+ "township": null,
54
+ "section": null,
55
+ "quarter_section": null,
56
+ "homestead_exempt": null,
57
+ "absentee_owner_code": null,
58
+ "land_use_code": null,
59
+ "county_land_use1": null,
60
+ "county_land_use2": null,
61
+ "property_indicator_code": null,
62
+ "municipality_name": null,
63
+ "view_code": null,
64
+ "location_influence_code": null,
65
+ "number_of_buildings": null
66
+ },
67
+ "property_address": {
68
+ "address": "8351 Bartholomew Dr",
69
+ "city": "North Fort Myers",
70
+ "state": "FL",
71
+ "zip": "33917-1758",
72
+ "address_key": "33917175851",
73
+ "latitude": "26.72156",
74
+ "longitude": "-81.85911"
75
+ },
76
+ "parsed_property_address": {
77
+ "range": "8351",
78
+ "pre_directional": null,
79
+ "street_name": "Bartholomew",
80
+ "suffix": "Dr",
81
+ "post_directional": null,
82
+ "suite_name": null,
83
+ "suite_range": null
84
+ },
85
+ "owner": {
86
+ "corporate_owner": null,
87
+ "name": "EDWARDS JOHN V",
88
+ "name2": null,
89
+ "unparsed_name1": null,
90
+ "unparsed_name2": null,
91
+ "phone": null,
92
+ "phone_opt_out": null
93
+ },
94
+ "owner_address": {
95
+ "address": null,
96
+ "suite": null,
97
+ "city": null,
98
+ "state": null,
99
+ "zip": null,
100
+ "carrier_route": null,
101
+ "matchcode": null,
102
+ "mail_opt_out": null
103
+ },
104
+ "values": {
105
+ "calculated_total_value": "17300",
106
+ "calculated_land_value": null,
107
+ "calculated_improvement_value": null,
108
+ "calculated_total_value_code": null,
109
+ "calculated_land_value_code": null,
110
+ "calculated_improvement_value_code": null,
111
+ "assessed_total_value": "17300",
112
+ "assessed_land_value": null,
113
+ "assessed_improvement_value": null,
114
+ "market_total_value": null,
115
+ "market_land_value": null,
116
+ "market_improvement_value": null,
117
+ "appraised_total_value": null,
118
+ "appraised_land_value": null,
119
+ "appraised_improvement_value": null,
120
+ "tax_amount": "235.82",
121
+ "tax_year": null
122
+ },
123
+ "current_sale": {
124
+ "transaction_id": null,
125
+ "document_year": null,
126
+ "deed_category_code": null,
127
+ "recording_date": null,
128
+ "sale_date": "19920109",
129
+ "sale_price": "69000",
130
+ "sale_code": null,
131
+ "seller_name": null,
132
+ "multi_apn_code": null,
133
+ "multi_apn_count": null,
134
+ "residental_model": null
135
+ },
136
+ "current_deed": {
137
+ "mortgage_amount": "68900",
138
+ "mortgage_date": null,
139
+ "mortgage_loan_type_code": null,
140
+ "mortgage_deed_type_code": null,
141
+ "mortgage_term_code": null,
142
+ "mortgage_term": null,
143
+ "mortgage_due_date": null,
144
+ "mortgage_assumption_amount": null,
145
+ "lender_code": null,
146
+ "lender_name": null,
147
+ "second_mortgage_amount": null,
148
+ "second_mortgage_loan_type_code": null,
149
+ "second_mortgage_deed_type_code": null
150
+ },
151
+ "prior_sale": {
152
+ "transaction_id": null,
153
+ "document_year": null,
154
+ "deed_category_code": null,
155
+ "recording_date": null,
156
+ "sale_date": null,
157
+ "sale_price": null,
158
+ "sale_code": null,
159
+ "transaction_code": null,
160
+ "multi_apn_code": null,
161
+ "multi_apn_count": null,
162
+ "mortgage_amount": null,
163
+ "deed_type_code": null
164
+ },
165
+ "lot": {
166
+ "front_footage": null,
167
+ "depth_footage": null,
168
+ "acreage": "2.1491",
169
+ "square_footage": "93615"
170
+ },
171
+ "square_footage": {
172
+ "universal_building": null,
173
+ "building_area_code": null,
174
+ "building_area": null,
175
+ "living_space": null,
176
+ "ground_floor": null,
177
+ "gross": null,
178
+ "adjusted_gross": null,
179
+ "basement": null,
180
+ "garage_or_parking": null
181
+ },
182
+ "building": {
183
+ "year_built": null,
184
+ "effective_year_built": null,
185
+ "bed_rooms": "0",
186
+ "total_rooms": "0",
187
+ "total_baths_calculated": null,
188
+ "total_baths": "0.00",
189
+ "full_baths": null,
190
+ "half_baths": null,
191
+ "one_quarter_baths": null,
192
+ "three_quarter_baths": null,
193
+ "bath_fixtures": null,
194
+ "air_conditioning_code": null,
195
+ "basement_code": null,
196
+ "building_code": null,
197
+ "improvement_code": null,
198
+ "condition_code": null,
199
+ "construction_code": null,
200
+ "exterior_wall_code": null,
201
+ "fireplace": null,
202
+ "fireplaces": null,
203
+ "fireplace_code": null,
204
+ "foundation_code": null,
205
+ "flooring_code": null,
206
+ "roof_framing_code": null,
207
+ "garage_code": null,
208
+ "heating_code": null,
209
+ "mobile_home": null,
210
+ "parking_spaces": null,
211
+ "parking_code": null,
212
+ "pool": null,
213
+ "pool_code": null,
214
+ "quality_code": null,
215
+ "roof_cover_code": null,
216
+ "roof_type_code": null,
217
+ "stories_code": null,
218
+ "stories": null,
219
+ "building_style_code": null,
220
+ "units": null,
221
+ "electricity_code": null,
222
+ "fuel_code": null,
223
+ "sewer_code": null,
224
+ "water_code": null
225
+ }
226
+ }
227
+ ```
228
+
229
+
230
+ ## Development
231
+
232
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
233
+
234
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
235
+
236
+ ## Contributing
237
+
238
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/melissa_data. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
239
+
240
+
241
+ ## License
242
+
243
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
244
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "melissa_data"
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,96 @@
1
+ require "melissa_data/version"
2
+ #require "mellissa_data/web_smart/xml"
3
+ #require "mellissa_data/web_smart/property_api"
4
+ #require "mellissa_data/web_smart/client"
5
+ require 'rest-client'
6
+ require 'nokogiri'
7
+
8
+ module MelissaData
9
+ module WebSmart
10
+ class PropertyAPI
11
+ def property(fips, apn)
12
+ url = 'https://property.melissadata.net/v3/REST/Service.svc/doLookup'
13
+ resp = RestClient.get(url,
14
+ { params: { id: ENV['MELISSA_DATA_WEB_SMART_ID'],
15
+ fips: fips,
16
+ apn: apn } })
17
+ PropertyXMLParser.new(Nokogiri::XML(resp)).parse
18
+ end
19
+ end
20
+
21
+ class XMLParser
22
+ attr_accessor :xml_document
23
+
24
+ def initialize(xml)
25
+ @xml_document = xml
26
+ end
27
+
28
+ def children?(xml_node)
29
+ xml_node.children.empty?
30
+ end
31
+
32
+ def viperize_hash hash
33
+ hash.map { |key, value| { viperize(key.to_s) => value } }.reduce(:merge)
34
+ end
35
+
36
+ def viperize(string)
37
+ word = string.to_s.dup
38
+ word.gsub!(/::/, '/')
39
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
40
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
41
+ word.tr!("-", "_")
42
+ word.downcase!
43
+ word.to_sym
44
+ end
45
+ end
46
+
47
+ class PropertyXMLParser < XMLParser
48
+ def parse
49
+ parsed_hash = {}
50
+ if expected_retrieved?
51
+ retrieved_fields.each_with_index { |f, i| parsed_hash[f] = { data: field_details[i] } }
52
+ parsed_hash.keys.each { |k| parsed_hash[k] = build_subdictionary(parsed_hash[k][:data]) }
53
+ viperize_hash(parsed_hash)
54
+ end
55
+ end
56
+
57
+ def field_details
58
+ record_node.children.map { |n| n.children }
59
+ end
60
+
61
+ def build_subdictionary(xml_vals)
62
+ keys = xml_vals.map(&:name)
63
+ vals = xml_vals.map { |v| v.children.first.text unless children? v }
64
+ viperize_hash(keys.zip(vals).to_h)
65
+ end
66
+
67
+ def expected_fields
68
+ [ "RecordID", "Result", "Parcel", "PropertyAddress", "ParsedPropertyAddress",
69
+ "Owner", "OwnerAddress", "Values", "CurrentSale", "CurrentDeed", "PriorSale",
70
+ "Lot", "SquareFootage", "Building" ].sort
71
+ end
72
+
73
+ def expected_fields?(fields)
74
+ expected_fields == fields.sort
75
+ end
76
+
77
+ def record_node
78
+ xml_document.children.first.children.last # its just how they structure it..
79
+ end
80
+
81
+ def retrieved_fields
82
+ record_node.children.map { |n| n.name }
83
+ end
84
+
85
+ def expected_retrieved?
86
+ expected_fields?(retrieved_fields)
87
+ end
88
+ end
89
+
90
+ class Client
91
+ def property(fips, apn)
92
+ MelissaData::WebSmart::PropertyAPI.new.property(fips, apn)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,3 @@
1
+ module MelissaData
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'melissa_data/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "melissa_data"
8
+ spec.version = MelissaData::VERSION
9
+ spec.authors = ["Robert Grayson"]
10
+ spec.email = ["bobbygrayson@gmail.com"]
11
+
12
+ spec.summary = %q{A simple interface to Melissa Data's Web Smart Property API}
13
+ spec.description = %q{A simple interface to Melissa Data's Web Smart Property API}
14
+ spec.homepage = "http://github.com/cometaworks/melissa_data"
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 "nokogiri"
23
+ spec.add_runtime_dependency "rest-client"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.3"
28
+ spec.add_development_dependency "pry"
29
+ spec.add_development_dependency "webmock"
30
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: melissa_data
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Robert Grayson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
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: webmock
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
+ description: A simple interface to Melissa Data's Web Smart Property API
112
+ email:
113
+ - bobbygrayson@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - CODE_OF_CONDUCT.md
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/melissa_data.rb
129
+ - lib/melissa_data/version.rb
130
+ - melissa_data.gemspec
131
+ homepage: http://github.com/cometaworks/melissa_data
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.4.6
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: A simple interface to Melissa Data's Web Smart Property API
155
+ test_files: []