wfrmls 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+ require 'autotest'
2
+
3
+
4
+ Autotest.add_hook :initialize do |at|
5
+ # at.add_exception %r%^\./(?:db|doc|log|public|script|tmp|vendor)%
6
+
7
+ at.clear_mappings
8
+
9
+ # Map filename w/o slash to test name.
10
+ at.add_mapping %r%^lib/.*?([^/]+)\.rb$% do |_, m|
11
+ ["test/#{m[1]}_test.rb"]
12
+ end
13
+
14
+ # Map test to themselves
15
+ at.add_mapping %r%^test/.*_test.rb% do |filename, _|
16
+ filename
17
+ end
18
+
19
+ end
20
+
21
+
22
+ # vim:filetype=ruby
23
+
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2010-01-22
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,11 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/wfrmls
7
+ lib/wfrmls.rb
8
+ lib/wfrmls/cli/options.rb
9
+ lib/wfrmls/ie.rb
10
+ test/wfrmls_test.rb
11
+
@@ -0,0 +1,61 @@
1
+ = wfrmls
2
+
3
+ * http://github.com/zhon
4
+
5
+ == DESCRIPTION:
6
+
7
+ Help searching the WFRMLS
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Occasionally you will end up on the wrong page, PLEASE VERIFY ALL DATA!
12
+ * Will only run on windows using Internet Explorer
13
+
14
+ == SYNOPSIS:
15
+
16
+ wfrmls <address>
17
+
18
+ wfrmls --help
19
+
20
+ == REQUIREMENTS:
21
+
22
+ * watir
23
+ * StreetAddress
24
+
25
+ == INSTALL:
26
+
27
+ * gem install wfrmls
28
+
29
+ == DEVELOPERS:
30
+
31
+ After checking out the source, run:
32
+
33
+ $ rake newb
34
+
35
+ This task will install any missing dependencies, run the tests/specs,
36
+ and generate the RDoc.
37
+
38
+ == LICENSE:
39
+
40
+ (The MIT License)
41
+
42
+ Copyright (c) 2010
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ 'Software'), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.spec 'wfrmls' do
7
+ developer('zhon', 'zhon@xputah.com')
8
+
9
+ # self.rubyforge_name = 'wfrmlsx' # if different than 'wfrmls'
10
+ end
11
+
12
+ # vim: syntax=ruby
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ CONFIG_FILE_NAME = File.expand_path('~/wfrmls_config.yml')
4
+
5
+ require 'wfrmls/ie'
6
+ require 'wfrmls/cli/options'
7
+
8
+ options = Wfrmls::CLI::Options.parse! ARGV
9
+
10
+ config = nil
11
+ begin
12
+ config = YAML::load_file(CONFIG_FILE_NAME)
13
+ rescue => e
14
+ # TODO initialize password
15
+ #File.open(CONFIG_FILE_NAME, 'w') do |item|
16
+ #end
17
+ end
18
+
19
+ username = config['username']
20
+ password = config['password']
21
+
22
+ ie = Watir::Browser.new
23
+ mls = Wfrmls::IE.new(ie, username, password)
24
+
25
+
26
+ addr = StreetAddress::US.parse(options.address)
27
+ if addr.nil?
28
+ addr = StreetAddress::US.parse(options.address+', UT')
29
+ end
30
+
31
+ puts addr
32
+
33
+ mls.lookup_address(addr)
34
+
35
+
@@ -0,0 +1,7 @@
1
+ require 'wfrmls/ie'
2
+
3
+ module Wfrmls
4
+ VERSION = '0.3.0'
5
+
6
+ end
7
+
@@ -0,0 +1,52 @@
1
+ require 'optparse'
2
+ require 'wfrmls'
3
+
4
+ module Wfrmls #:nodoc:
5
+ module CLI #:nodoc:
6
+ class Options #:nodoc:
7
+ class << self
8
+ alias_method :parse!, :new
9
+ end
10
+
11
+ attr_reader :address
12
+
13
+ def initialize(*args)
14
+ address = ''
15
+
16
+ argv = args.flatten
17
+
18
+ opt = OptionParser.new do |opt|
19
+ opt.banner = "Usage: #{script_name} [options] <address>"
20
+ opt.version = version
21
+
22
+ #opt.on("-r [PATH]", "Require [PATH] before executing") do |path|
23
+ # @paths_to_require << path
24
+ #end
25
+
26
+ opt.on("-h", "-?", "--help", "Show this message") do
27
+ puts opt
28
+ exit
29
+ end
30
+
31
+ opt.on("-v", "--version", "Show #{script_name}'s version (#{version})") do
32
+ puts version
33
+ exit
34
+ end
35
+ end
36
+
37
+ opt.parse!(argv)
38
+ @address = argv.dup.join(' ')
39
+ end
40
+
41
+ def version
42
+ Wfrmls::VERSION
43
+ end
44
+
45
+ def script_name
46
+ @script_name ||= File.basename($0)
47
+ @script_name
48
+ end
49
+ end
50
+ end
51
+ end
52
+
@@ -0,0 +1,112 @@
1
+ require 'watir'
2
+ require 'street_address'
3
+
4
+
5
+ module Wfrmls
6
+ class IE
7
+
8
+ def initialize(ie, username, password)
9
+ @username = username
10
+ @password = password
11
+ @ie = ie
12
+ end
13
+
14
+ def login
15
+ @ie.goto 'http://www.utahrealestate.com/auth/login/login_redirect//force_redirect/1'
16
+ begin
17
+ @ie.text_field(:id, 'login').set @username
18
+ @ie.text_field(:id, 'pass').set @password
19
+ @ie.button(:id, 'submit_button').click
20
+
21
+ sleep_until { @ie.url == 'http://www.utahrealestate.com/' }
22
+ rescue
23
+ # we are already logged in
24
+ end
25
+ end
26
+
27
+ def residential_full_search
28
+ @ie.radio(:id, 'historical_data_yes').set
29
+ end
30
+
31
+ def lookup_address(addr)
32
+ goto 'http://www.utahrealestate.com/search/form/type/1/name/full?advanced_search=1'
33
+ residential_full_search
34
+
35
+ status
36
+
37
+ @ie.text_field(:id, 'street').set addr.street
38
+ @ie.text_field(:id, 'housenum').set addr.number
39
+
40
+ city(addr.city)
41
+
42
+ result_count = @ie.span(:id, 'action_search_count').text.to_i
43
+
44
+ if result_count > 0
45
+
46
+ @ie.button(:id, 'SEARCH_button').click
47
+ begin
48
+ sleep 1
49
+ @ie.checkbox(:id, 'ListingController').click
50
+ rescue
51
+ retry
52
+ end
53
+
54
+ @ie.select_list(:id, 'report-selector').set('Full Report')
55
+ else
56
+ show_tax_data(addr)
57
+ end
58
+ end
59
+
60
+ def status
61
+ settings = ['Active', 'Sold', 'Under Contract', 'Expired']
62
+ @ie.div(:id, 'status1Container_clear_button').click
63
+ tf = @ie.text_field(:id, 'status1Container_input')
64
+ settings.each do |item|
65
+ tf.set(item)
66
+ end
67
+ end
68
+
69
+ def city(name)
70
+ # clear the city field
71
+ if not @ie.hidden(:id, 'city').value.empty?
72
+ @ie.div(:id, 'city1Container_clear_button').click
73
+ sleep_until { @ie.hidden(:id, 'city').value.empty? }
74
+ @ie.focus
75
+ end
76
+
77
+ @ie.text_field(:id, 'city1Container_input').set( name + ',' )
78
+ @ie.focus
79
+
80
+ sleep_until { @ie.dd(:id, 'left_search_criteria').text.include? 'City is' }
81
+ end
82
+
83
+ def sleep_until &block
84
+ count = 0
85
+ until yield block
86
+ sleep 1
87
+ count += 1
88
+ exit if count > 10
89
+ end
90
+ end
91
+
92
+ def show_tax_data(addr)
93
+ goto "http://www.utahrealestate.com/taxdata/index?county%5B%5D=2&county%5B%5D=8&searchtype=house&searchbox=#{addr.number}"
94
+
95
+ street_regx = Regexp.new(addr.street, Regexp::IGNORECASE)
96
+ @ie.table(:class, 'tax-data').rows.each do |row|
97
+ if street_regx =~ row.text
98
+ row.cells[2].links[1].click
99
+ break
100
+ end
101
+ end
102
+ end
103
+
104
+ def goto(url)
105
+ @ie.goto url
106
+ if @ie.link(:id, 'login_anchor').exists?
107
+ login
108
+ @ie.goto url
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,8 @@
1
+ require "wfrmls"
2
+
3
+ require "test/unit"
4
+
5
+ class TestWfrmls < Test::Unit::TestCase
6
+ def test_sanity
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wfrmls
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - zhon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-23 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubyforge
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: gemcutter
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.0
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.5.0
44
+ version:
45
+ description: Help searching the WFRMLS
46
+ email:
47
+ - zhon@xputah.com
48
+ executables:
49
+ - wfrmls
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - History.txt
54
+ - Manifest.txt
55
+ - README.txt
56
+ files:
57
+ - .autotest
58
+ - History.txt
59
+ - Manifest.txt
60
+ - README.txt
61
+ - Rakefile
62
+ - bin/wfrmls
63
+ - lib/wfrmls.rb
64
+ - lib/wfrmls/cli/options.rb
65
+ - lib/wfrmls/ie.rb
66
+ - test/wfrmls_test.rb
67
+ has_rdoc: true
68
+ homepage: http://github.com/zhon
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --main
74
+ - README.txt
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ requirements: []
90
+
91
+ rubyforge_project: wfrmls
92
+ rubygems_version: 1.3.5
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Help searching the WFRMLS
96
+ test_files: []
97
+