cheapest_gas_CLI 0.0.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
+ SHA256:
3
+ metadata.gz: 711050f306fc40b905c01d00745823f32422605385cb9369c54a5c75dbb833b1
4
+ data.tar.gz: 441125ac0954aa7c5859d02c1e87f41da47b947953bf2e2d81ec9e83ef4bc899
5
+ SHA512:
6
+ metadata.gz: b1331983f6020fb28ec18e561635b15ca495bca990e251140eb02c702a308717bf27b8045b9339e5002fc34f428e854750dcaa4f8a5b8a9b95bc08c181b59974
7
+ data.tar.gz: 104db77cd61ac3c897a73801b2fe680097667e4b17ef037648b3518ead596f09a6091ebd1b1e45626ad9fdc0ef25536844a07d129a62e50aa3f6b7e92e642570
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
@@ -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 armelfli50@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,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'nokogiri', '1.6'
4
+ gem 'rake'
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ mini_portile (0.5.3)
5
+ nokogiri (1.6.0)
6
+ mini_portile (~> 0.5.0)
7
+ rake (12.3.3)
8
+
9
+ PLATFORMS
10
+ ruby
11
+
12
+ DEPENDENCIES
13
+ nokogiri (= 1.6)
14
+ rake
15
+
16
+ BUNDLED WITH
17
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 TODO: Write your name
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/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # CheapestGasCLI
2
+
3
+ Welcome to your fully operational gem. It was in a world where people, strive to spend less in order to accomplish great things that, this gem saw the light. The `CheapestGasCLI` will provide its users with all the cheapest gas stations near them.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'cheapest_gas_CLI'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install cheapest_gas_CLI
20
+
21
+ ## Usage
22
+
23
+ The gem was design to provide information such as the name of the gas station, its price, and its address.To experiment with that code, run `bin/console` for an interactive prompt.
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bundle install` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec cheapest_gas_CLI 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/armel50/cheapest_gas.CLI. 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.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the CheapestGasCLI project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/armel50/cheapest_gas.CLI/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # require_relative '../config/environment'
3
+ # require "bundler/setup"
4
+ require '/Users/home/Desktop/learn.co/cheapest_gas_CLI/lib/command_line_interface.rb'
5
+
6
+
7
+ CommandLineInterface.new
8
+
9
+
@@ -0,0 +1,32 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "cheapest_gas_CLI/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "cheapest_gas_CLI"
7
+ spec.version = "0.0.0"
8
+ spec.authors = ["Cloe Kouadjo"]
9
+ spec.email = ["armelfli50@gmail.com"]
10
+
11
+ spec.summary = %q{A gem to generate the location of the cheapest gas station near the user.}
12
+ spec.homepage = "https://github.com/armel50/cheapest_gas.CLI"
13
+ spec.license = "MIT"
14
+
15
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
+
17
+ # spec.metadata["homepage_uri"] = spec.homepage
18
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
19
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 2.0"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ end
@@ -0,0 +1,2 @@
1
+ require 'bundler/setup'
2
+ Bundler.require(:default, :development)
@@ -0,0 +1,4 @@
1
+ module CheapestGasCLI
2
+ VERSION = "0.1.0"
3
+ end
4
+
@@ -0,0 +1,122 @@
1
+ require "/Users/home/Desktop/learn.co/cheapest_gas_CLI/lib/gas_station.rb"
2
+ require "/Users/home/Desktop/learn.co/cheapest_gas_CLI/lib/scraper.rb"
3
+ require 'nokogiri'
4
+ require 'colorize'
5
+ require 'pry'
6
+
7
+
8
+ class CommandLineInterface
9
+ attr_accessor :url
10
+
11
+ def initialize
12
+ welcome
13
+ proccess
14
+ end
15
+
16
+
17
+ def welcome
18
+ puts "--------------------------------------------------".colorize(:light_blue)
19
+ puts "| |".colorize(:light_blue)
20
+ puts "| Welcome To Our Wonderful CLI |".colorize(:light_blue)
21
+ puts "| |".colorize(:light_blue)
22
+ puts "--------------------------------------------------".colorize(:light_blue)
23
+ puts ""
24
+ puts ""
25
+ end
26
+
27
+
28
+ def proccess
29
+ puts "Would like to see the cheapest gas stations near you? (yes/no)"
30
+ answer_to_zip_code = gets.strip
31
+
32
+ if ["YES","Y"].include?(answer_to_zip_code.upcase)
33
+ basic_info
34
+ puts "Would you like more information? (yes/no)"
35
+ more_info_answer = gets.strip
36
+ ["YES","Y"].include?(more_info_answer.upcase) ? more_info : goodbye
37
+ else
38
+ goodbye
39
+ end
40
+
41
+
42
+ end
43
+
44
+
45
+ def valid?(zip_code)
46
+ true if zip_code.to_i != 0 && zip_code.length == 5
47
+ end
48
+
49
+
50
+ def goodbye
51
+ puts "--------------------------------------------------".colorize(:light_blue)
52
+ puts "| |".colorize(:light_blue)
53
+ puts "| Goodbye!!!!! |".colorize(:light_blue)
54
+ puts "| |".colorize(:light_blue)
55
+ puts "--------------------------------------------------".colorize(:light_blue)
56
+ puts ""
57
+ puts ""
58
+ end
59
+
60
+
61
+ def display
62
+ Gas_station.all.each do |gas_station|
63
+ puts "=====================================================================================".colorize(:blue)
64
+ puts "Gas Station: ".colorize(:green) + "#{gas_station.name}".colorize(:yellow)
65
+ puts "price: ".colorize(:green) + "#{gas_station.price}".colorize(:yellow)
66
+ puts "Gas Address: ".colorize(:green) + "#{gas_station.address}".colorize(:yellow)
67
+ puts "=====================================================================================".colorize(:blue)
68
+ puts ""
69
+ puts ""
70
+ puts ""
71
+ end
72
+ end
73
+
74
+
75
+ def basic_info
76
+ puts "You can now enter your zip code."
77
+ the_user_zip_code = gets.strip
78
+ while !valid?(the_user_zip_code) do
79
+ puts "Please enter a valid zip code"
80
+ the_user_zip_code = gets.strip
81
+ end
82
+ url ="https://www.gasbuddy.com/home?search=#{the_user_zip_code}&fuel=1"
83
+ gas_stations = Scraper.scraper_the_cheapest_nearby(url)
84
+ Gas_station.create_gas_station_from_data(gas_stations)
85
+
86
+ display
87
+ end
88
+
89
+
90
+ def more_info
91
+ Gas_station.all.each do |gas_station|
92
+ new_info = Scraper.scraper_detailled_info("https://www.gasbuddy.com#{gas_station.detail_url}")
93
+ gas_station.add_more_info(new_info)
94
+ end
95
+ display_more_info
96
+ end
97
+
98
+
99
+ def display_more_info
100
+ Gas_station.all.each do |gas_station|
101
+ puts "=====================================================================================".colorize(:blue)
102
+ puts "Gas Station: ".colorize(:green) + "#{gas_station.name}".colorize(:yellow)
103
+ puts "Price: ".colorize(:green) + "#{gas_station.price}".colorize(:yellow)
104
+
105
+ gas_station.new_array.each do |el|
106
+ puts "--------------------------------------------------------------------------------------"
107
+ puts " Type of Gas: ".colorize(:green) + "#{el[:type_of_gas]}".colorize(:yellow)
108
+ puts " Price of Gas: ".colorize(:green) + "#{el[:price_of_gas]}".colorize(:yellow)
109
+ puts " Last Reported: ".colorize(:green) + "#{el[:last_report]}".colorize(:yellow)
110
+ puts "--------------------------------------------------------------------------------------"
111
+ end
112
+
113
+ puts "Overall Rating: ".colorize(:green) + "#{gas_station.rating}".colorize(:yellow)
114
+ puts "Gas Address: ".colorize(:green) + "#{gas_station.address}".colorize(:yellow)
115
+ puts "=====================================================================================".colorize(:blue)
116
+ puts ""
117
+ puts ""
118
+ puts ""
119
+ end
120
+ end
121
+
122
+ end
@@ -0,0 +1,31 @@
1
+ class Gas_station
2
+ @@all = []
3
+ attr_accessor :name, :address, :price , :rating , :detail_url , :new_array
4
+
5
+ def initialize(name:,address:,price:, detail_url:)
6
+ @name = name
7
+ @address = address
8
+ @price = price
9
+ @detail_url = detail_url
10
+ end
11
+
12
+
13
+ def self.create_gas_station_from_data(array_of_gas_station)
14
+ array_of_gas_station.each do |gas_station|
15
+ gas_object =self.new(gas_station)
16
+ @@all << gas_object if gas_object.price
17
+ end
18
+ end
19
+
20
+
21
+ def add_more_info(data)
22
+ the_gas_station = self
23
+ data.each {|key,val| the_gas_station.send("#{key}=",val) }
24
+ end
25
+
26
+
27
+ def self.all
28
+ @@all.sort_by{|gas_station| gas_station.price }
29
+ end
30
+
31
+ end
data/lib/scraper.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'pry'
4
+
5
+ class Scraper
6
+
7
+ def self.scraper_the_cheapest_nearby(url)
8
+ title = Nokogiri::HTML(open(url)).css("h2.SearchResultsPage__resultsHeader___3FgQj").text
9
+ gas_stations = Nokogiri::HTML(open(url)).css("div.GenericStationListItem__stationListItem___3Jmn4")
10
+
11
+ gas_stations.collect do |station|
12
+ {name: station.css("h3 a").text, price: station.css("div.GenericStationListItem__priceContainer___YbVoO").css("span.text__left___1iOw3").text,address: station.css("div.GenericStationListItem__address___1VFQ3").text, detail_url: station.css("h3 a").attribute("href").value } if station.css("h3 a").attribute("href").value
13
+ end
14
+ end
15
+
16
+
17
+ def self.scraper_detailled_info(url)
18
+ details = Nokogiri::HTML(open(url))
19
+ prices = details.css("div.carousel__scrollContainer___hDjMb")
20
+ array_of_prices_info = details.css("div.carousel__scrollContainer___hDjMb").css("div.GasPriceCollection__fuelTypePriceSection___3iGR-")
21
+
22
+ new_array = array_of_prices_info.collect do |price|
23
+ type_of_gas = price.css("span").first.text
24
+ price_of_gas = price.css("span")[price.css("span").index(price.css("span").first) + 1 ].text
25
+ last_report = price.css("p").text
26
+ {:type_of_gas => type_of_gas, :price_of_gas => price_of_gas, :last_report => last_report}
27
+ end
28
+
29
+ rating = details.css("div.Reviews__reviewComponentContainer___3Njgz").css("div.panel__panel___3Q2zW.panel__white___19KTz.colors__bgWhite___1stjL.panel__bordered___1Xe-S.panel__rounded___2etNE").css("span").first.text
30
+ {new_array:new_array,rating:rating}
31
+
32
+ end
33
+
34
+ end
35
+
36
+
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cheapest_gas_CLI
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Cloe Kouadjo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-04 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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
+ description:
42
+ email:
43
+ - armelfli50@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".DS_Store"
49
+ - ".gitignore"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - cheapest_gas_CLI.gemspec
58
+ - config/environment
59
+ - lib/cheapest_gas_CLI/version.rb
60
+ - lib/command_line_interface.rb
61
+ - lib/gas_station.rb
62
+ - lib/scraper.rb
63
+ homepage: https://github.com/armel50/cheapest_gas.CLI
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.0.4
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: A gem to generate the location of the cheapest gas station near the user.
86
+ test_files: []