remora 0.0.1

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: 48c785686f8563c72d5111876b148884307951ee
4
+ data.tar.gz: ba09c9430cd89b174381addc84779665a220c51e
5
+ SHA512:
6
+ metadata.gz: 0cf5e6168ab064999a62c7a90f065d88de3e793a0377d2901e99316ef83e10906ef4785ba8c262572a98e6c9266d139590ff333031fb79952ca78f891f200de6
7
+ data.tar.gz: 0917d2df75b6e8708846841c054841f9f9a80e1bacb72288b252a4da49d02b1186a1857ea224bd43864fcc57931f397251539387fb935956621580b2a745fc0a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in remora.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'rspec' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Evan R
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Remora
2
+
3
+ Lightweight gem to discover information about San Francisco real estate. Can be adapted for anywhere in California.
4
+
5
+
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'remora'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install remora
20
+
21
+ ## Usage
22
+
23
+ shark = Remora::Remora.new(email, password)
24
+ report = shark.search_in_sf("155 14 St")
25
+ report[:neighborhood]
26
+ => "Inner Mission (09C)"
27
+ report[:building][:year_built]
28
+ => "1975"
29
+
30
+ For a full list of what's in a report, check `spec/remora_spec.rb`
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color', '--format', 'nested']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,3 @@
1
+ module Remora
2
+ VERSION = "0.0.1"
3
+ end
data/lib/remora.rb ADDED
@@ -0,0 +1,128 @@
1
+ require "remora/version"
2
+ require 'mechanize'
3
+ require 'nokogiri'
4
+
5
+ module Remora
6
+ class Remora
7
+ attr_accessor :cookies
8
+ def initialize(u,p)
9
+ @agent = Mechanize.new
10
+ @agent.user_agent_alias = 'Mac Safari'
11
+ @username = u
12
+ @password = p
13
+ response = ""
14
+ @agent.get("https://secure.propertyshark.com/mason/Accounts/logon.html")
15
+ r1 = @agent.post(
16
+ "https://secure.propertyshark.com/mason/Accounts/logon.html",
17
+ {
18
+ email:u,
19
+ password:p,
20
+ submit:"Sign in",
21
+ tracking_rfs_anon_users:""
22
+ })
23
+ response = @agent.get("http://www.propertyshark.com/mason/",headers: {'Cookie' => @cookies})
24
+ end
25
+ def my_name_is
26
+ resp = @agent.get("http://www.propertyshark.com/mason/")
27
+ sel = (".account button")
28
+ doc = Nokogiri::parse(resp.body)
29
+ doc.css(sel).text()
30
+ end
31
+ def reports_left
32
+ resp = @agent.get("http://www.propertyshark.com/mason/Accounts/My/")
33
+ doc = Nokogiri::parse(resp.body)
34
+ doc
35
+ .css(".my-subscriptions")[0]
36
+ .css(".details span")[-3]
37
+ .text().strip
38
+ end
39
+ def search_in_sf(address)
40
+ response = @agent.get("http://www.propertyshark.com/mason/ca/San-Francisco-County/Property-Search")
41
+ search_form = {
42
+ search_type:"address",
43
+ search_types_selector:"address",
44
+ search_token: address,
45
+ location:"San Francisco County, CA"
46
+ }
47
+ resp = @agent.post("http://www.propertyshark.com/mason/UI/homepage_search.html",search_form)
48
+
49
+ doc = Nokogiri::parse(resp.body)
50
+ address = doc.css(".header-address h2").text().strip()[/^.+\n/].strip
51
+
52
+ report_sections = resp.search("script")
53
+ .select{ |t| t.text[/psrk.ajaxLoader/] }
54
+ .map{ |t| t.text[/mason[^"]+/] }
55
+ .inject({}) do |memo, obj|
56
+ name = obj[/name[^&]+/][/[\w_]+$/];
57
+ memo[name.to_sym] = obj;
58
+ memo
59
+ end
60
+
61
+ overview_response = @agent.get("http://www.propertyshark.com/"+report_sections[:overview])
62
+
63
+ table1 = overview_response.search("table")[1]
64
+ neighborhood = table1.css(".r_align").text()
65
+
66
+ table2 = overview_response.search("table")[2]
67
+ last_sale = {
68
+ date: table2.css(".r_align")[0].text(),
69
+ price: table2.css(".r_align")[1].text()
70
+ }
71
+
72
+ table3 = overview_response.search("table")[3]
73
+ owner = {
74
+ name: table3.css(".r_align")[0].text(),
75
+ address:table3.css(".r_align")[1].text(),
76
+ line2: table3.css(".r_align")[2].text()
77
+ }
78
+
79
+ table5 = overview_response.search("table")[5]
80
+ land = {
81
+ lot_sq_ft: table5.css(".r_align")[0].text(),
82
+ prop_class: table5.css(".r_align")[1].text(),
83
+ depth: table5.css(".r_align")[2].text(),
84
+ zoning: table5.css(".r_align")[3].text(),
85
+ }
86
+
87
+ table6 = overview_response.search("table")[6]
88
+ building = {
89
+ sq_ft: table6.css(".r_align")[0].text(),
90
+ year_built: table6.css(".r_align")[1].text(),
91
+ }
92
+
93
+ overview = {
94
+ address: address,
95
+ neighborhood: neighborhood,
96
+ last_sale: last_sale,
97
+ owner: owner,
98
+ land: land,
99
+ building: building
100
+ }
101
+ end
102
+ def search_by_name_in_sf(name)
103
+ response = @agent.get("http://www.propertyshark.com/mason/ca/San-Francisco-County/Property-Search")
104
+
105
+ search_form = {
106
+ search_type:"owner",
107
+ search_types_selector:"owner",
108
+ search_token: name,
109
+ location:"San Francisco County, CA"
110
+ }
111
+
112
+ resp = @agent.post("http://www.propertyshark.com/mason/UI/homepage_search.html",search_form)
113
+
114
+ doc = Nokogiri::parse(resp.body)
115
+
116
+ results = doc.search(".owner_table tr.odd, .owner_table tr.even").reject{ |r| r[:style]=~/display:none/ }
117
+
118
+
119
+
120
+ results.map do |result|
121
+ {
122
+ address: result.css("td.first span.big_font").text().strip(),
123
+ owner: result.css(".single_line:first-child").text().strip()
124
+ }
125
+ end
126
+ end
127
+ end
128
+ end
data/remora.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'remora/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "remora"
8
+ spec.version = Remora::VERSION
9
+ spec.authors = ["Evan R"]
10
+ spec.email = ["eunoia.github+remora@gmail.com"]
11
+ spec.description = %q{ Get stats on San Franscisco real estate }
12
+ spec.summary = %q{ Lightweight gem to discover information about San Francisco real estate via Property Shark. Can be adapted for anywhere in California. }
13
+ spec.homepage = "http://github.com/eunoia/remora"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake", "~> 10.3"
23
+ spec.add_development_dependency "rspec", "~> 2.14"
24
+ spec.add_development_dependency "rspec-nc", "~> 0.0", ">= 0.0.6"
25
+ spec.add_development_dependency "guard", "~> 2.6"
26
+ spec.add_development_dependency "guard-rspec", "~> 4.2"
27
+ spec.add_development_dependency "pry", "~> 0.9", ">= 0.9.12.6"
28
+ spec.add_development_dependency "pry-remote", "~> 0.1", ">= 0.1.8"
29
+ spec.add_development_dependency "pry-nav", "~> 0.2", ">= 0.2.3"
30
+
31
+ spec.add_runtime_dependency "mechanize", "~>2.7"
32
+ spec.add_runtime_dependency "nokogiri", "~>1.6"
33
+
34
+ spec.requirements << "an account at propertyshark"
35
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe Remora do
4
+ before do
5
+ email = ENV['email']||"YOUREMAILHERE"
6
+ password = ENV['password']||"YOURPASSWORDHERE"
7
+ @shark = Remora::Remora.new(email, password)
8
+ end
9
+ describe '.my_name_is' do
10
+ it 'shows my name' do
11
+ expect(@shark.my_name_is).to eq("Hi E R")
12
+ end
13
+ end
14
+ describe ".reports_left" do
15
+ it 'checks how many reports left' do
16
+ rl = @shark.reports_left
17
+ expect(rl.split("/")[-1]).to eq("200")
18
+ end
19
+ end
20
+ describe ".search_in_sf" do
21
+ it 'loads reports for an SF property' do
22
+ report = @shark.search_in_sf("155 14 St")
23
+ expect(report).to eq({
24
+ :address => "155 14 St, San Francisco, CA 94103",
25
+ :neighborhood => "Inner Mission (09C)",
26
+ :building => {
27
+ :sq_ft => "4,900",
28
+ :year_built => "1975"
29
+ },
30
+ :land => {
31
+ :depth => "7,300",
32
+ :lot_sq_ft => "3,650",
33
+ :prop_class => "Flat & Store (F2)",
34
+ :zoning => "Light Industrial (M1)"
35
+ },
36
+ :last_sale => {
37
+ :date => "8/16/2002",
38
+ :price => "$368,000"
39
+ },
40
+ :owner => {
41
+ :address => "251 King Dr",
42
+ :line2 => "Walnut Creek, CA 94595",
43
+ :name => "Flores Family Revoc Lvg Tr"
44
+ }
45
+ })
46
+ end
47
+ end
48
+ describe '.search_by_name_in_sf' do
49
+ context 'a person has one property' do
50
+ it 'the Flores Family Lvg Tr' do
51
+ properties = @shark.search_by_name_in_sf("Flores Family Revoc Lvg Tr")
52
+ expect(properties.length).to eq(1)
53
+ expect(properties[0][:address]).to eq("155 14 St")
54
+ expect(properties[0][:owner]).to eq("Flores Family Revoc Lvg Tr")
55
+ end
56
+ end
57
+ context 'just a last name' do
58
+ it 'the Steins' do
59
+ properties = @shark.search_by_name_in_sf("Stein")
60
+ expect(properties.length).to eq(128)
61
+
62
+ expect(properties[0][:address]).to eq("954 De Haro St")
63
+ expect(properties[0][:owner]).to eq("Stein Quinton F Herz")
64
+
65
+ expect(properties[1][:address]).to eq("925-927 Dolores St")
66
+ expect(properties[1][:owner]).to eq("Katherine Stein Trust")
67
+
68
+ randys_property = properties.find{ |p| p[:owner]=="Stein Randy" }
69
+ expect(randys_property[:address]).to eq("3550 Market St #102")
70
+ end
71
+ end
72
+ end
73
+ end
74
+
@@ -0,0 +1,7 @@
1
+ require 'remora'
2
+ require 'pry'
3
+
4
+ RSpec.configure do |config|
5
+ # Use color in STDOUT
6
+ # config.color_enabled = true
7
+ end
metadata ADDED
@@ -0,0 +1,237 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remora
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Evan R
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-nc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.0'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 0.0.6
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '0.0'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.0.6
75
+ - !ruby/object:Gem::Dependency
76
+ name: guard
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.6'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.6'
89
+ - !ruby/object:Gem::Dependency
90
+ name: guard-rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '4.2'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '4.2'
103
+ - !ruby/object:Gem::Dependency
104
+ name: pry
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.9'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 0.9.12.6
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '0.9'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 0.9.12.6
123
+ - !ruby/object:Gem::Dependency
124
+ name: pry-remote
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '0.1'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 0.1.8
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0.1'
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 0.1.8
143
+ - !ruby/object:Gem::Dependency
144
+ name: pry-nav
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '0.2'
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 0.2.3
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.2'
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: 0.2.3
163
+ - !ruby/object:Gem::Dependency
164
+ name: mechanize
165
+ requirement: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '2.7'
170
+ type: :runtime
171
+ prerelease: false
172
+ version_requirements: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - "~>"
175
+ - !ruby/object:Gem::Version
176
+ version: '2.7'
177
+ - !ruby/object:Gem::Dependency
178
+ name: nokogiri
179
+ requirement: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: '1.6'
184
+ type: :runtime
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: '1.6'
191
+ description: " Get stats on San Franscisco real estate "
192
+ email:
193
+ - eunoia.github+remora@gmail.com
194
+ executables: []
195
+ extensions: []
196
+ extra_rdoc_files: []
197
+ files:
198
+ - ".gitignore"
199
+ - Gemfile
200
+ - Guardfile
201
+ - LICENSE.txt
202
+ - README.md
203
+ - Rakefile
204
+ - lib/remora.rb
205
+ - lib/remora/version.rb
206
+ - remora.gemspec
207
+ - spec/remora_spec.rb
208
+ - spec/spec_helper.rb
209
+ homepage: http://github.com/eunoia/remora
210
+ licenses:
211
+ - MIT
212
+ metadata: {}
213
+ post_install_message:
214
+ rdoc_options: []
215
+ require_paths:
216
+ - lib
217
+ required_ruby_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ required_rubygems_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ version: '0'
227
+ requirements:
228
+ - an account at propertyshark
229
+ rubyforge_project:
230
+ rubygems_version: 2.3.0
231
+ signing_key:
232
+ specification_version: 4
233
+ summary: Lightweight gem to discover information about San Francisco real estate via
234
+ Property Shark. Can be adapted for anywhere in California.
235
+ test_files:
236
+ - spec/remora_spec.rb
237
+ - spec/spec_helper.rb