sjain-redfin_api 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +16 -0
- data/README.rdoc +38 -0
- data/Rakefile +15 -0
- data/VERSION.yml +4 -0
- data/lib/object.rb +10 -0
- data/lib/redfin_api/base.rb +80 -0
- data/lib/redfin_api.rb +10 -0
- data/redfin_api.gemspec +31 -0
- data/tasks/redfin.rake +15 -0
- data/test/data/gis_id_search.json +1 -0
- data/test/data/property_page.html +5090 -0
- data/test/data/query_location_listings.json +1 -0
- data/test/data/query_location_pastSalesBuildings.json +1 -0
- data/test/test_helper.rb +6 -0
- data/test/test_redfin_api.rb +11 -0
- data/test/test_redfin_base.rb +80 -0
- metadata +80 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*{"listings":[{"id":3467651,"point":{"long":-88.115638,"lat":42.021069},"market":"chicago","address":{"zip":"60193","state":"IL","streetName":"Arlington","number":"1420","undisclosed":false,"directionalPrefix":"","streetType":"Ln","unitValue":"A","city":"Schaumburg","directionalSuffix":""}}],"regions":[]}*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*{"pastSalesBuildings":[{"id":18016252,"point":{"long":-87.98056,"lat":41.777641},"market":"chicago","address":{"zip":"60559","unitType":"","state":"IL","streetName":"Carlisle","number":"225","directionalPrefix":"","streetType":"Ave","unitValue":"","city":"Westmont","directionalSuffix":""}}],"listings":[],"regions":[]}*/
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
|
+
|
|
3
|
+
class TestRedfinApiBase < Test::Unit::TestCase
|
|
4
|
+
context "with property page containing parcel-id-number" do
|
|
5
|
+
setup do
|
|
6
|
+
@url = "http://www.redfin.com/IL/Roselle/999-Main-St-60606/home/99999999"
|
|
7
|
+
RedfinApi::Base.stubs(:http_get).with(@url).returns(File.read(File.dirname(__FILE__) + "/data/property_page.html"))
|
|
8
|
+
end
|
|
9
|
+
should "extract PIN information" do
|
|
10
|
+
address = RedfinApi::Base.fetch_address(@url)
|
|
11
|
+
assert_equal("07343000300000", address[:pin])
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
should "fetch address from redfin url" do
|
|
15
|
+
url = "http://www.redfin.com/IL/Roselle/999-Main-St-60606/home/99999999"
|
|
16
|
+
RedfinApi::Base.stubs(:http_get).with(url).returns(File.read(File.dirname(__FILE__) + "/data/property_page.html"))
|
|
17
|
+
address = RedfinApi::Base.fetch_address(url)
|
|
18
|
+
assert_equal("640 WASHINGTON Ct", address[:address_line_1])
|
|
19
|
+
assert_equal("ROSELLE", address[:city])
|
|
20
|
+
assert_equal("IL", address[:state])
|
|
21
|
+
assert_equal("60172", address[:zip])
|
|
22
|
+
end
|
|
23
|
+
context "with query location returning pastSalesBuildings" do
|
|
24
|
+
setup do
|
|
25
|
+
@address = "123 Main ST City ST" # address that is not perfect (query should still find it)
|
|
26
|
+
query_location_url = "http://www.redfin.com/stingray/do/query-location?location=#{URI.encode(@address)}"
|
|
27
|
+
RedfinApi::Base.stubs(:http_get).with(query_location_url).returns(File.read(File.dirname(__FILE__) + "/data/query_location_pastSalesBuildings.json"))
|
|
28
|
+
end
|
|
29
|
+
should "return query location by address string" do
|
|
30
|
+
location = RedfinApi::Base.query_location(@address)
|
|
31
|
+
assert_equal("41.777641", location[:lat])
|
|
32
|
+
assert_equal("-87.98056", location[:lon])
|
|
33
|
+
assert_equal("225 Carlisle Ave", location[:address_line_1])
|
|
34
|
+
assert_equal("Westmont", location[:city])
|
|
35
|
+
assert_equal("IL", location[:state])
|
|
36
|
+
assert_equal("60559", location[:zip])
|
|
37
|
+
assert_equal("18016252", location[:property_id])
|
|
38
|
+
assert_equal("http://www.redfin.com/IL/Westmont/225-Carlisle-Ave-60559/home/18016252", location[:url])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
context "with query location returning listings" do
|
|
42
|
+
setup do
|
|
43
|
+
@address = "123 Main ST City ST" # address that is not perfect (query should still find it)
|
|
44
|
+
query_location_url = "http://www.redfin.com/stingray/do/query-location?location=#{URI.encode(@address)}"
|
|
45
|
+
RedfinApi::Base.stubs(:http_get).with(query_location_url).returns(File.read(File.dirname(__FILE__) + "/data/query_location_listings.json"))
|
|
46
|
+
listing_id = "3467651"
|
|
47
|
+
gis_url ="http://www.redfin.com/stingray/do/gis-id-search?listing_id=#{listing_id}"
|
|
48
|
+
RedfinApi::Base.stubs(:http_get).with(gis_url).returns(File.read(File.dirname(__FILE__) + "/data/gis_id_search.json"))
|
|
49
|
+
end
|
|
50
|
+
should "return query location by address string" do
|
|
51
|
+
address = "123 Main ST City ST" # address that is not perfect (query should still find it)
|
|
52
|
+
location = RedfinApi::Base.query_location(address)
|
|
53
|
+
assert_equal("42.021069", location[:lat])
|
|
54
|
+
assert_equal("-88.115638", location[:lon])
|
|
55
|
+
assert_equal("1420", location[:number])
|
|
56
|
+
assert_equal("Arlington", location[:street_name])
|
|
57
|
+
assert_equal("Ln", location[:street_type])
|
|
58
|
+
assert_equal("A", location[:unit])
|
|
59
|
+
assert_equal("1420 Arlington Ln", location[:address_line_1])
|
|
60
|
+
assert_equal("Schaumburg", location[:city])
|
|
61
|
+
assert_equal("IL", location[:state])
|
|
62
|
+
assert_equal("60193", location[:zip])
|
|
63
|
+
assert_equal("3467651", location[:listing_id])
|
|
64
|
+
# the 'id' returned with "listings" is not the correct redfin_id
|
|
65
|
+
assert_equal("21620838", location[:property_id])
|
|
66
|
+
assert_equal("http://www.redfin.com/IL/Schaumburg/1930-Keystone-Pl-60193/unit-A/home/21620838", location[:url])
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
context "with gis_id_search returning json" do
|
|
70
|
+
setup do
|
|
71
|
+
RedfinApi::Base.stubs(:http_get).returns(File.read(File.dirname(__FILE__) + "/data/gis_id_search.json"))
|
|
72
|
+
end
|
|
73
|
+
should "return query location by address string" do
|
|
74
|
+
listing_id = "12345"
|
|
75
|
+
resp = RedfinApi::Base.gis_id_search(listing_id)
|
|
76
|
+
assert_equal("21620838", resp[:property_id])
|
|
77
|
+
assert_equal("http://www.redfin.com/IL/Schaumburg/1930-Keystone-Pl-60193/unit-A/home/21620838", resp[:url])
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sjain-redfin_api
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sharad Jain
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-08-08 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: Redfin.com webservice interface
|
|
17
|
+
email: shaanjain@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- tasks/redfin.rake
|
|
24
|
+
- README.rdoc
|
|
25
|
+
- lib/redfin_api/base.rb
|
|
26
|
+
- lib/redfin_api.rb
|
|
27
|
+
- lib/object.rb
|
|
28
|
+
files:
|
|
29
|
+
- Rakefile
|
|
30
|
+
- tasks/redfin.rake
|
|
31
|
+
- redfin_api.gemspec
|
|
32
|
+
- README.rdoc
|
|
33
|
+
- Manifest
|
|
34
|
+
- lib/redfin_api/base.rb
|
|
35
|
+
- lib/redfin_api.rb
|
|
36
|
+
- lib/object.rb
|
|
37
|
+
- test/test_helper.rb
|
|
38
|
+
- test/data/property_page.html
|
|
39
|
+
- test/data/query_location_listings.json
|
|
40
|
+
- test/data/gis_id_search.json
|
|
41
|
+
- test/data/query_location_pastSalesBuildings.json
|
|
42
|
+
- test/test_redfin_api.rb
|
|
43
|
+
- test/test_redfin_base.rb
|
|
44
|
+
- VERSION.yml
|
|
45
|
+
has_rdoc: true
|
|
46
|
+
homepage: http://github.com/sjain/redfin_api
|
|
47
|
+
licenses:
|
|
48
|
+
post_install_message:
|
|
49
|
+
rdoc_options:
|
|
50
|
+
- --line-numbers
|
|
51
|
+
- --inline-source
|
|
52
|
+
- --title
|
|
53
|
+
- Redfin_api
|
|
54
|
+
- --main
|
|
55
|
+
- README.rdoc
|
|
56
|
+
require_paths:
|
|
57
|
+
- lib
|
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: "0"
|
|
63
|
+
version:
|
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: "1.2"
|
|
69
|
+
version:
|
|
70
|
+
requirements: []
|
|
71
|
+
|
|
72
|
+
rubyforge_project: redfin_api
|
|
73
|
+
rubygems_version: 1.3.5
|
|
74
|
+
signing_key:
|
|
75
|
+
specification_version: 2
|
|
76
|
+
summary: Redfin.com webservice interface
|
|
77
|
+
test_files:
|
|
78
|
+
- test/test_helper.rb
|
|
79
|
+
- test/test_redfin_api.rb
|
|
80
|
+
- test/test_redfin_base.rb
|