cheapest_gas_CLI 0.0.1 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9245d56366275dee7a85f8ce7e723eb81f1a65c60c19a020b8b728231a4a8b0a
4
- data.tar.gz: a5d884fb04d4220be632a7a11d0678028933adbfd5788223aad6ed3bc336b157
3
+ metadata.gz: aea74e3fdb591d17ab91c15b36fe114901ae66e0c7ec9c372393b0bea4d46229
4
+ data.tar.gz: 90e53f8802fad56c14e106ed38118bcad4476c498aa5397db96dbd6faa20c734
5
5
  SHA512:
6
- metadata.gz: b9ea81fc8c2f6b205e3813caff3d2a4614ab2fa96d3ce0df155f334bfaab895b82312a38dc1b4c564eb2134ba0e8c63c243bb3407ec07c38171ca12e68c933eb
7
- data.tar.gz: 9ebbd27bc773ccb95b44894afc1c2ad20cbe0fb26656a2d43817de281ca0f7f012e725922c2537c33ca3b7194c64fe8300112247113062086e100c6f4e5c5c72
6
+ metadata.gz: 263a1b6feee426aa51d31d96385c1a36cd17fbce5cb6490d17fe4effcf5145311f3447d1cfd0afe3fff640cce88c7220a44718d022b722560b227765f7bc8fef
7
+ data.tar.gz: b7b47a7751d9f0b9b7eff26295b10d3f1cf67c621f58b3a3e623b5b9d49a11de521a0a5a15f7edeec2e0c0e4402580848c594e4d87d3d047f613b5c048526ee4
@@ -1,8 +1,8 @@
1
- !/usr/bin/env ruby
2
- require_relative '../config/environment'
3
- require "bundler/setup"
4
- require_relative '../lib/cheapest_gas_CLI.rb'
1
+ #!/usr/bin/env ruby
2
+ # require_relative '../config/environment'
3
+ # require "bundler/setup"
4
+ require_relative '../lib/cheapest_gas_CLI.rb'
5
5
 
6
- CommandLineInterface.new
6
+ Cheapest_gas_CLI.new
7
7
 
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheapest_gas_CLI
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloe Kouadjo
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
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'
41
69
  description:
42
70
  email:
43
71
  - armelfli50@gmail.com
@@ -46,21 +74,7 @@ executables:
46
74
  extensions: []
47
75
  extra_rdoc_files: []
48
76
  files:
49
- - ".DS_Store"
50
- - ".gitignore"
51
- - CODE_OF_CONDUCT.md
52
- - Gemfile
53
- - Gemfile.lock
54
- - LICENSE.txt
55
- - README.md
56
- - Rakefile
57
77
  - bin/find-gas
58
- - cheapest_gas_CLI.gemspec
59
- - config/environment
60
- - lib/cheapest_gas_CLI.rb
61
- - lib/cheapest_gas_CLI/version.rb
62
- - lib/gas_station.rb
63
- - lib/scraper.rb
64
78
  homepage: https://github.com/armel50/cheapest_gas.CLI
65
79
  licenses:
66
80
  - MIT
data/.DS_Store DELETED
Binary file
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- *.gem
@@ -1,74 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'nokogiri', '1.6'
4
- gem 'rake'
@@ -1,17 +0,0 @@
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
@@ -1,21 +0,0 @@
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 DELETED
@@ -1,41 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
@@ -1,32 +0,0 @@
1
- lib = File.expand_path("lib", __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- #require "cheapest_gas_CLI/command_line_interface"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "cheapest_gas_CLI"
7
- spec.version = "0.0.1"
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 = "bin"
27
- spec.executables = "find-gas"
28
- spec.require_paths = ["lib"]
29
-
30
- spec.add_development_dependency "bundler", "~> 2.0"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- end
@@ -1,2 +0,0 @@
1
- require 'bundler/setup'
2
- Bundler.require(:default, :development)
@@ -1,124 +0,0 @@
1
- require_relative "./gas_station.rb"
2
- require_relative "./scraper.rb"
3
- require 'nokogiri'
4
- require 'colorize'
5
- require 'pry'
6
-
7
-
8
- class CommandLineInterface
9
-
10
-
11
- attr_accessor :url, :the_user_zip_code
12
-
13
- def initialize(the_user_zip_code = nil)
14
- welcome
15
- proccess
16
- end
17
-
18
-
19
- def welcome
20
- puts "--------------------------------------------------".colorize(:light_blue)
21
- puts "| |".colorize(:light_blue)
22
- puts "| Welcome To Our Wonderful CLI |".colorize(:light_blue)
23
- puts "| |".colorize(:light_blue)
24
- puts "--------------------------------------------------".colorize(:light_blue)
25
- puts ""
26
- puts ""
27
- end
28
-
29
-
30
- def proccess
31
- puts "Would like to see the cheapest gas stations near you? (yes/no)"
32
- answer_to_zip_code = gets.strip
33
-
34
- if ["YES","Y"].include?(answer_to_zip_code.upcase)
35
- basic_info
36
- puts "Would you like more information? (yes/no)"
37
- more_info_answer = gets.strip
38
- ["YES","Y"].include?(more_info_answer.upcase) ? more_info : goodbye
39
- else
40
- goodbye
41
- end
42
-
43
-
44
- end
45
-
46
-
47
- def valid?(zip_code)
48
- true if zip_code.to_i != 0 && zip_code.length == 5
49
- end
50
-
51
-
52
- def goodbye
53
- puts "--------------------------------------------------".colorize(:light_blue)
54
- puts "| |".colorize(:light_blue)
55
- puts "| Goodbye!!!!! |".colorize(:light_blue)
56
- puts "| |".colorize(:light_blue)
57
- puts "--------------------------------------------------".colorize(:light_blue)
58
- puts ""
59
- puts ""
60
- end
61
-
62
-
63
- def display
64
- Gas_station.all.each do |gas_station|
65
- puts "=====================================================================================".colorize(:blue)
66
- puts "Gas Station: ".colorize(:green) + "#{gas_station.name}".colorize(:yellow)
67
- puts "price: ".colorize(:green) + "#{gas_station.price}".colorize(:yellow)
68
- puts "Gas Address: ".colorize(:green) + "#{gas_station.address}".colorize(:yellow)
69
- puts "=====================================================================================".colorize(:blue)
70
- puts ""
71
- puts ""
72
- puts ""
73
- end
74
- end
75
-
76
-
77
- def basic_info
78
- puts "You can now enter your zip code."
79
- the_user_zip_code = gets.strip
80
- while !valid?(the_user_zip_code) do
81
- puts "Please enter a valid zip code"
82
- @the_user_zip_code = gets.strip
83
- end
84
- url ="https://www.gasbuddy.com/home?search=#{the_user_zip_code}&fuel=1"
85
- gas_stations = Scraper.scraper_the_cheapest_nearby(url)
86
- Gas_station.create_gas_station_from_data(gas_stations)
87
-
88
- display
89
- end
90
-
91
-
92
- def more_info
93
- Gas_station.all.each do |gas_station|
94
- new_info = Scraper.scraper_detailled_info("https://www.gasbuddy.com#{gas_station.detail_url}")
95
- gas_station.add_more_info(new_info)
96
- end
97
- display_more_info
98
- end
99
-
100
-
101
- def display_more_info
102
- Gas_station.all.each do |gas_station|
103
- puts "=====================================================================================".colorize(:blue)
104
- puts "Gas Station: ".colorize(:green) + "#{gas_station.name}".colorize(:yellow)
105
- puts "Price: ".colorize(:green) + "#{gas_station.price}".colorize(:yellow)
106
-
107
- gas_station.new_array.each do |el|
108
- puts "--------------------------------------------------------------------------------------"
109
- puts " Type of Gas: ".colorize(:green) + "#{el[:type_of_gas]}".colorize(:yellow)
110
- puts " Price of Gas: ".colorize(:green) + "#{el[:price_of_gas]}".colorize(:yellow)
111
- puts " Last Reported: ".colorize(:green) + "#{el[:last_report]}".colorize(:yellow)
112
- puts "--------------------------------------------------------------------------------------"
113
- end
114
-
115
- puts "Overall Rating: ".colorize(:green) + "#{gas_station.rating}".colorize(:yellow)
116
- puts "Gas Address: ".colorize(:green) + "#{gas_station.address}".colorize(:yellow)
117
- puts "=====================================================================================".colorize(:blue)
118
- puts ""
119
- puts ""
120
- puts ""
121
- end
122
- end
123
-
124
- end
@@ -1,4 +0,0 @@
1
- module CheapestGasCLI
2
- VERSION = "0.1.0"
3
- end
4
-
@@ -1,31 +0,0 @@
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
@@ -1,36 +0,0 @@
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
-