local_real_estate 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e1da2e4db5010d9028cedfff2ee7c584385fb4ba4b5e389c3a3d4691632557d5
4
+ data.tar.gz: c46ae16452bf39e0e90de2d090aea1b81261aa472c25e5ee55900c4df98456b5
5
+ SHA512:
6
+ metadata.gz: 688077939c8b68954f004b66936bf87ca8a55f1580c39244ceffbe92bb28be7ee7e2d60b46381f3f45b6b9b95ef10654c7ebfe3241aa02c294abd06ce6615b79
7
+ data.tar.gz: aa93871f472b16e81551dc4e2a623ee17228efe086464eacca6859ab00c588fb0c1972b56f9cc95b2beb209f0ead05d9bf1ebcb3a66136301107f51d9a785e1d
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ local_real_estate (0.1.0)
5
+ nokogiri
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.2)
11
+ diff-lcs (1.3)
12
+ method_source (0.9.0)
13
+ mini_portile2 (2.3.0)
14
+ nokogiri (1.8.2)
15
+ mini_portile2 (~> 2.3.0)
16
+ pry (0.11.3)
17
+ coderay (~> 1.1.0)
18
+ method_source (~> 0.9.0)
19
+ rake (10.4.2)
20
+ rspec (3.7.0)
21
+ rspec-core (~> 3.7.0)
22
+ rspec-expectations (~> 3.7.0)
23
+ rspec-mocks (~> 3.7.0)
24
+ rspec-core (3.7.1)
25
+ rspec-support (~> 3.7.0)
26
+ rspec-expectations (3.7.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-mocks (3.7.0)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-support (3.7.0)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler (~> 1.16)
39
+ local_real_estate!
40
+ pry
41
+ rake (~> 10.0)
42
+ rspec (~> 3.0)
43
+
44
+ BUNDLED WITH
45
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Connor Gallopo
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.
@@ -0,0 +1,42 @@
1
+ # LocalRealEstate
2
+
3
+ This Ruby Gem will allow you to search for real estate for sale by zip code and learn about each listing.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'local_real_estate'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install local_real_estate
20
+
21
+ ## Usage
22
+
23
+ Type the following and follow the on screen prompts.
24
+
25
+ NOTE: local_real_estate only accepts US 5-digit zip codes.
26
+
27
+ $ local_real_estate
28
+
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ 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).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<connorgallopo>/local_real_estate.
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "local_real_estate"
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
+
15
+
16
+ LocalRealEstate::CLI.new.call
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "local_real_estate"
5
+
6
+
7
+ LocalRealEstate::CLI.new.call
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ require 'nokogiri'
2
+
3
+ require 'local_real_estate/version'
4
+ require 'local_real_estate/cli'
5
+ require 'local_real_estate/scraper'
6
+ require 'local_real_estate/listing'
7
+
8
+ # this is working as my enviornment file
@@ -0,0 +1,82 @@
1
+ class LocalRealEstate::CLI
2
+ def call
3
+ greeting
4
+ menu
5
+ end
6
+
7
+ def greeting
8
+ system 'clear'
9
+ puts '-------------------------------------------'
10
+ puts '-------------------------------------------'
11
+ puts 'Welcome to the Local Real Estate Listing app'
12
+ puts 'This will display local real estate listings by'
13
+ puts 'zip code and allow you to see expanded details on each listing'
14
+ puts ''
15
+ end
16
+
17
+ def menu
18
+ new_search
19
+ detail_menu
20
+ end
21
+
22
+ def detail_menu
23
+ print_listings
24
+ puts 'To see more info on a listing, please select a number from the list above:'
25
+ detailed_view(gets.strip)
26
+ puts 'To go back to the previous list type "back". Or "new" to start a new search by zip. To quit, type "exit"'
27
+ input = gets.strip.downcase
28
+ case input
29
+ when 'back'
30
+ detail_menu
31
+ when 'new'
32
+ menu
33
+ when 'exit'
34
+ goodbye
35
+ else
36
+ invalid_input
37
+ end
38
+ end
39
+
40
+ def new_search
41
+ LocalRealEstate::Listing.all.clear
42
+ puts 'Please type in the Zip code in which you would like to search'
43
+ zip_method
44
+ end
45
+
46
+ def detailed_view(selection)
47
+ home = LocalRealEstate::Listing.all[selection.to_i - 1]
48
+ puts '-------------------------------------------'
49
+ puts "Address: #{home.address}. #{home.city},#{home.state}."
50
+ puts "Price: #{home.price}"
51
+ puts "Bedrooms:#{home.bedrooms}"
52
+ puts "Bathrooms: #{home.bathrooms}"
53
+ unless home.sqft == '' then puts "Square Feet: #{home.sqft}" end
54
+ unless home.lot_size == '' then puts "Lot Size #{home.lot_size}" end
55
+ unless home.cars == '' then puts "Garage: #{home.cars}" end
56
+ puts '-------------------------------------------'
57
+ end
58
+
59
+ def zip_method
60
+ LocalRealEstate::Scraper.new(gets.strip).create_listings
61
+ end
62
+
63
+ def print_listings
64
+ puts "--------Listings in #{LocalRealEstate::Listing.current_city}--------"
65
+ LocalRealEstate::Listing.all.each_with_index do |listing, i|
66
+ puts "#{i + 1}. #{listing.address} - #{listing.bedrooms} #{listing.price}"
67
+ end
68
+ puts '-------------------------------------------'
69
+ end
70
+
71
+ def invalid_input
72
+ puts ' - - - - - - - - - - - - - '
73
+ puts 'Input not recognized, please try again:'
74
+ puts ' - - - - - - - - - - - - - '
75
+ sleep 2
76
+ detail_menu
77
+ end
78
+
79
+ def goodbye
80
+ puts 'See you next time!'
81
+ end
82
+ end
@@ -0,0 +1,27 @@
1
+ class LocalRealEstate::Listing
2
+
3
+ attr_accessor :address, :city, :state, :url, :price, :bedrooms, :bathrooms, :sqft, :cars, :lot_size
4
+ @@all = []
5
+
6
+ def initialize(address: nil, city: nil, state: nil, url: nil, price: nil, bedrooms: nil, bathrooms: nil, sqft: nil, cars: "none", lot_size: nil)
7
+ @address = address
8
+ @city = city
9
+ @state = state
10
+ @url = url
11
+ @price = price
12
+ @bedrooms = bedrooms
13
+ @bathrooms = bathrooms
14
+ @sqft = sqft
15
+ @cars = cars
16
+ @lot_size = lot_size
17
+ @@all << self
18
+ end
19
+
20
+ def self.all
21
+ @@all
22
+ end
23
+
24
+ def self.current_city
25
+ @@all[0].city
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ require 'open-uri'
2
+ require 'pry'
3
+ require 'nokogiri'
4
+
5
+ #Each Indoc.css('.srp-item-body')
6
+
7
+ class LocalRealEstate::Scraper
8
+ attr_accessor :zip
9
+
10
+ def initialize(zip)
11
+ @zip = zip
12
+ end
13
+
14
+ def get_page #this needs to be fixed. If zip starts with zero its lost with .to_i
15
+ Nokogiri::HTML(open("https://www.realtor.com/realestateandhomes-search/#{@zip}"))
16
+ end
17
+
18
+ def scrape_listings
19
+ self.get_page.css('.srp-item-body')
20
+ end
21
+
22
+ def create_listings
23
+ scrape_listings.each_with_index do |object, index|
24
+ LocalRealEstate::Listing.new(
25
+ address: object.css('.listing-street-address').text.strip,
26
+ city: object.css('.listing-city').text,
27
+ state: object.css('.listing-region').text,
28
+ price: object.css('.srp-item-price').text.strip,
29
+ bedrooms: object.css("ul li[data-label='property-meta-beds']").text,
30
+ bathrooms: object.css("ul li[data-label='property-meta-baths']").text,
31
+ sqft: object.css("ul li[data-label='property-meta-sqft']").text,
32
+ cars: object.css("ul li[data-label='property-meta-garage']").text,
33
+ lot_size: object.css("ul li[data-label='property-meta-lotsize']").text
34
+ )
35
+ end
36
+ end
37
+
38
+ def expand_listing(index)
39
+ LocalRealEstate::Listing
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module LocalRealEstate
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "local_real_estate/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "local_real_estate"
8
+ spec.version = LocalRealEstate::VERSION
9
+ spec.authors = ["Connor Gallopo"]
10
+ spec.email = ["connor.gallopo@me.com"]
11
+
12
+ spec.summary = "Local Real Estate Listings"
13
+ spec.description = "Local Real Estate Listings"
14
+ spec.homepage = "https://github.com/connorgallopo/local-real-estate-cli"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "pry"
31
+
32
+ spec.add_dependency 'nokogiri'
33
+ end
data/spec.md ADDED
@@ -0,0 +1,10 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ CLI has been implimented to greet the user, ask for input and will scrape based on that input. It also will allow you to go back and start over.
6
+ - [X] Pull data from an external source
7
+ Data is pulled from realtor.com. Users input is also used in the url to make each use potentially different.
8
+ - [X] Implement both list and detail views
9
+ After first setting your default zip code within the Gem it will return a list view of properties. From there you have the ability to select one and view additional information about that property.
10
+
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: local_real_estate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Connor Gallopo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-31 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Local Real Estate Listings
84
+ email:
85
+ - connor.gallopo@me.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/local_real_estate
100
+ - bin/setup
101
+ - lib/local_real_estate.rb
102
+ - lib/local_real_estate/cli.rb
103
+ - lib/local_real_estate/listing.rb
104
+ - lib/local_real_estate/scraper.rb
105
+ - lib/local_real_estate/version.rb
106
+ - local_real_estate.gemspec
107
+ - spec.md
108
+ homepage: https://github.com/connorgallopo/local-real-estate-cli
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.7.2
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Local Real Estate Listings
132
+ test_files: []