daily_properties 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 79508d1eeffdbd502b88fdc271ef9cbeca8666b3
4
+ data.tar.gz: 2c03abac6d896c3b552e6c12dbac56c772b4053b
5
+ SHA512:
6
+ metadata.gz: 67253c6b591a798b54298e627b93b2cfe36e634536ccbda58dd4c7dc938271a9fb4b42a89c6da35a3a1d6daa384e8d39c1074bd458a4e48697f16c4a121c7a35
7
+ data.tar.gz: 4edd381c52017fe946fe180e440313b8f6148b2c36cf1a9c7f1ed6513dc3b3b45a626a3ccca61a9f63c4d03258f68e2afc48eb8ae560b93be40f122d83b05c69
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at zhang.jingru.93@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Specify your gem's dependencies in daily_properties.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 JingruZhang
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/NOTE.md ADDED
@@ -0,0 +1,33 @@
1
+ Imagine the interface
2
+ Start with project structure
3
+ Start with the entry point
4
+ Discover objects
5
+ Program
6
+
7
+ bundle gem daily_properties
8
+
9
+ command line interface for new properties sold in the neighborhood (& later maybe new houses listed in the neighborhood, too) zillow
10
+
11
+ with users typing in zip code, it shows a list of properties recently sold within the zipcode (a list of 20)
12
+
13
+ (Build from where the user is going to interact with the program!)
14
+ CLI interface:
15
+ User type in: daily_properties
16
+ 60618
17
+ A list of 26 properties
18
+ 3904 N Seeley Ave, Chicago, IL, $1.93M, sold 04/05/2017, 6 bds, 6 ba
19
+ 2631 W Belmont Ave UNIT 4, Chicago, IL, $312,000, sold 04/04/2017, 2bds, 2ba
20
+
21
+ Which one would you like to learn more about? (1-26)
22
+ Goodbye!
23
+
24
+ Step zero: basic interface and fake data(completed)
25
+ Step one: scrape zillow with a static zipcode--60618(completed)
26
+ Step two: scrape zillow with a zipcode given by user
27
+
28
+ What is a property?
29
+ A property has an address
30
+ A property has a price
31
+ A property has a sold date
32
+ A property has a URL
33
+
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # DailyProperties
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/daily_properties`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'daily_properties'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install daily_properties
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/daily_properties. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "daily_properties"
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(__FILE__)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "daily_properties"
5
+
6
+ DailyProperties::CLI.new.call #a useful pattern
data/bin/setup ADDED
@@ -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,12 @@
1
+ require "nokogiri"
2
+ require 'open-uri'
3
+ require 'pry'
4
+ require 'bundler'
5
+ Bundler.require
6
+
7
+ require_relative "../lib/daily_properties/version"
8
+ require_relative '../lib/daily_properties/cli'
9
+ require_relative '../lib/daily_properties/scraper'
10
+ require_relative '../lib/daily_properties/property'
11
+
12
+ # serves as a config/environment file that requires the rest of the files and is required by the main console file
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'daily_properties/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "daily_properties"
8
+ spec.version = DailyProperties::VERSION
9
+ spec.authors = ["Jingru Zhang"]
10
+ spec.email = ["zhang.jingru.93@gmail.com"]
11
+
12
+ spec.summary = %q{It displays a list of 26 properties recently sold within a zipcode area, scrapped from zillow.com}
13
+ spec.description = <<-EOF
14
+ This CLI gem helps home buyers and sellers to view the most recently sold properties within a given zipcode. Use 'daily_properties' command to run.
15
+ It asks users for a zipcode input, and gives users a list of 26 most recently sold properties. Users can type respective property number to get the url to view more details of the property.
16
+ EOF
17
+
18
+ spec.homepage = "https://github.com/jingruzhang/cli_daily_properties"
19
+ spec.license = "MIT"
20
+
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{^(test|spec|features)/})
24
+ end
25
+ spec.bindir = "bin"
26
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.14"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "pry"
33
+ spec.add_dependency "nokogiri"
34
+ end
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,50 @@
1
+ # CLI Controller
2
+
3
+ class DailyProperties::CLI
4
+ def call
5
+ puts "Welcome! Please enter the zipcode, and I will list the 26 most recently sold properties in that area:"
6
+ zipcode = gets.strip.to_i
7
+ list_properties(zipcode)
8
+ menu
9
+ end
10
+
11
+ def list_properties(zipcode)
12
+ DailyProperties::Scraper.make_properties(zipcode)
13
+ @properties = DailyProperties::Property.property
14
+ @properties.each.with_index(1) do |property, i|
15
+ puts "#{i}. #{property.address}, #{property.sold_date} at #{property.price}"
16
+ end
17
+ puts "--------------------------------------------------"
18
+ end
19
+
20
+ def menu
21
+ input = nil
22
+ while input != "exit"
23
+ puts "Enter the number of the property that you'd like to know more about, or enter another to look up another zipcode, or enter list to see the list, or enter exit: "
24
+ input = gets.strip.downcase
25
+ if input.to_i > 0 && input.to_i < 27
26
+ the_property = @properties[input.to_i - 1]
27
+ puts "#{the_property.address}, #{the_property.sold_date} at #{the_property.price}"
28
+ puts "See more at #{the_property.url}"
29
+ elsif input == "another"
30
+ DailyProperties::Property.clear_all
31
+ puts "--------------------------------------------------"
32
+ call
33
+ elsif input == "list"
34
+ list_properties
35
+ elsif input == "exit"
36
+ goodbye
37
+ exit
38
+ else
39
+ puts "Not sure what you just enter. Type list or exit. "
40
+ puts "--------------------------------------------------"
41
+ end
42
+ end
43
+ end
44
+
45
+ def goodbye
46
+ puts "Thanks for trying me out. See you soon!"
47
+ puts "--------------------------------------------------"
48
+ end
49
+
50
+ end
@@ -0,0 +1,31 @@
1
+ class DailyProperties::Property
2
+ attr_accessor :address, :price, :sold_date, :url
3
+ @@all = []
4
+
5
+ def initialize(address = nil, price = nil, sold_date = nil, url = nil)
6
+ @address = address
7
+ @price = price
8
+ @sold_date = sold_date
9
+ @url = url
10
+ @@all << self unless @@all.detect{|p| p.address == address}
11
+ end
12
+
13
+ def self.new_from_page(property)
14
+ self.new(
15
+ property.css(".zsg-photo-card-address").text,
16
+ property.css("span.zsg-photo-card-status").text,
17
+ property.css(".zsg-photo-card-notification").text,
18
+ 'http://www.zillow.com' + property.css("a").attr("href")
19
+ )
20
+ end
21
+
22
+ def self.property
23
+ @@all
24
+ end
25
+
26
+ def self.clear_all
27
+ @@all.clear
28
+ end
29
+
30
+ end
31
+
@@ -0,0 +1,16 @@
1
+ class DailyProperties::Scraper
2
+
3
+ def self.get_page(zipcode)
4
+ index_url = "https://www.zillow.com/homes/recently_sold/#{zipcode}/"
5
+ doc = Nokogiri::HTML(open(index_url))
6
+ doc.css(".zsg-photo-card-content")
7
+ end
8
+
9
+ def self.make_properties(zipcode)
10
+ self.get_page(zipcode).each do |property|
11
+ DailyProperties::Property.new_from_page(property)
12
+ end
13
+ end
14
+
15
+
16
+ end
@@ -0,0 +1,3 @@
1
+ module DailyProperties
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ #serves as a module file
2
+
3
+ module DailyProperties
4
+ end
5
+
6
+ require_relative '../config/environment'
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: daily_properties
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jingru Zhang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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: |2
84
+ This CLI gem helps home buyers and sellers to view the most recently sold properties within a given zipcode. Use 'daily_properties' command to run.
85
+ It asks users for a zipcode input, and gives users a list of 26 most recently sold properties. Users can type respective property number to get the url to view more details of the property.
86
+ email:
87
+ - zhang.jingru.93@gmail.com
88
+ executables:
89
+ - console
90
+ - daily-properties
91
+ - setup
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".DS_Store"
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".travis.yml"
99
+ - CODE_OF_CONDUCT.md
100
+ - Gemfile
101
+ - LICENSE.txt
102
+ - NOTE.md
103
+ - README.md
104
+ - Rakefile
105
+ - bin/console
106
+ - bin/daily-properties
107
+ - bin/setup
108
+ - config/environment.rb
109
+ - daily_properties.gemspec
110
+ - lib/.DS_Store
111
+ - lib/daily_properties.rb
112
+ - lib/daily_properties/cli.rb
113
+ - lib/daily_properties/property.rb
114
+ - lib/daily_properties/scraper.rb
115
+ - lib/daily_properties/version.rb
116
+ homepage: https://github.com/jingruzhang/cli_daily_properties
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.6.11
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: It displays a list of 26 properties recently sold within a zipcode area,
140
+ scrapped from zillow.com
141
+ test_files: []