masonellwood_cli_app_two 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 813b613929c40888c03a0c9fe1be79c9368216b5
4
+ data.tar.gz: 1a457ebc400f0c1bd3bae26915c535ff486702a8
5
+ SHA512:
6
+ metadata.gz: 886715a213b520698740b1861a8a9bca7a31d5e4e278671e5afb3526a4e47e136ddb234b46bed34103598ed551a2f5a8e0584fc4ed23eebd9aa955b42f400de4
7
+ data.tar.gz: 36c34b27c8473b4ce1a919a5ce027353076571c2190b70148180d4bd1dc72af375e42a5ee73db0bd8c449732e22915ee0a91c89232c9a00e718021a1703716fb
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.3.1
5
+ before_install: gem install bundler -v 1.15.1
@@ -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 masonellwood@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
+ # Specify your gem's dependencies in masonellwood_cli_app_two.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Mason Ellwood
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/NOTES.mb ADDED
@@ -0,0 +1,11 @@
1
+ 1 Asks user for state that they want to get the weather from.
2
+
3
+ 2 Asks user which city they would like to know the weather.
4
+
5
+ 3 Display the current weather of that city.
6
+
7
+ 4 Asks user if they would like to get the weather of a new city within that state, or would they like to move back to get a new state.
8
+
9
+ Utilities:
10
+ This is the url to scrape from.
11
+ <!-- https://www.wunderground.com/cgi-bin/findweather/getForecast?query=85742 -->
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # MasonellwoodCliAppTwo
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/masonellwood_cli_app_two`. 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 'masonellwood_cli_app_two'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install masonellwood_cli_app_two
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/MasonEllwood/masonellwood_cli_app_two. 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
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the MasonellwoodCliAppTwo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/MasonEllwood/masonellwood_cli_app_two/blob/master/CODE_OF_CONDUCT.md).
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 "masonellwood_cli_app_two"
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__)
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,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "masonellwood_cli_app_two"
5
+
6
+ MasonellwoodCliAppTwo::CLI.new.call
@@ -0,0 +1,96 @@
1
+ class MasonellwoodCliAppTwo::CLI
2
+
3
+ attr_accessor :state_info
4
+
5
+ def call
6
+ greet_with_prompt
7
+ set_up_instance_variable
8
+ goodbye
9
+ end
10
+
11
+ def greet_with_prompt
12
+ puts "Welcome to your local Weather Channel!"
13
+ end
14
+
15
+ def set_up_instance_variable
16
+ every_state = ["alabama", "alaska", "arizona", "arkansas", "california", "colorado", "connecticut", "delaware", "florida", "georgia", "hawaii", "idaho", "illinois", "indiana", "iowa", "kansas", "kentucky", "louisiana", "maine", "maryland", "massachusetts", "michigan", "minnesota", "mississippi", "missouri", "montana", "nebraska", "nevada", "new hampshire", "new jersey", "new mexico", "new york", "north carolina", "north dakota", "ohio", "oklahoma", "oregon", "pennsylvania", "rhode island",
17
+ "south carolina", "south dakota", "tennessee", "texas", "utah", "vermont", "virginia", "washington", "west virginia", "wisconsin", "wyoming" ]
18
+ puts "Please type your State of interest."
19
+ puts "If you forgot how to spell some of the state names, just type states."
20
+ puts "If you don't care about the weather today, just type exit."
21
+ state = nil
22
+ while state != "exit"
23
+ state = gets.strip.downcase
24
+ if every_state.include?(state)
25
+ @state_info = MasonellwoodCliAppTwo::StateScraper.new(state)
26
+ @state_info.scrape_cities
27
+ display_citie_option
28
+ puts "Are you sure you don't want to check the weather of a different state?"
29
+ puts "Like before: type States, the State name, or simply type exit."
30
+ elsif state == "states"
31
+ every_state.each_with_index do |the_state, index|
32
+ index += 1
33
+ puts "#{index}. #{the_state.capitalize}"
34
+ end
35
+ puts "Here are all the valid States, which one would you like to know the weather?"
36
+ elsif every_state.include?(state) == false && state != "states" && state != "exit"
37
+ puts "Not sure what you want bud. Please type exit to quit. Or see the valid states by typing states."
38
+ end
39
+ end
40
+ end
41
+
42
+ def display_citie_option
43
+ puts "Awesome! It looks like you are interested in #{@state_info.state.capitalize}!"
44
+ puts "Here are all of the cities in #{@state_info.state.capitalize}!"
45
+ @state_info.cities.each_with_index.each do |city, index|
46
+ index += 1
47
+ citys = city.split(/ : /)
48
+ puts "#{index}: #{citys[0]}"
49
+ end
50
+ display_city_weather
51
+ end
52
+
53
+ def display_city_weather
54
+ puts "Now type the name of the city you want to know the weather of."
55
+ input = nil
56
+ array = []
57
+ @state_info.cities.each_with_index.each do |city, index|
58
+ index += 1
59
+ city = city.split(/ : /)
60
+ array << city[0].downcase
61
+ end
62
+ while input != "exit"
63
+ input = gets.strip.downcase
64
+ if input == "cities"
65
+ @state_info.cities.each_with_index.each do |city, index|
66
+ index += 1
67
+ city = city.split(/ : /)
68
+ puts "#{index}: #{city[0]}"
69
+ end
70
+ puts "Now type the name of the city you want to know the weather of."
71
+ elsif array.include?(input)
72
+ @state_info.city_weather(input)
73
+ elsif input != "exit"
74
+ puts "Please type a valid city, or type exit."
75
+ end
76
+ end
77
+ end
78
+
79
+ def another_state
80
+ puts "would you like to check a different state? Type yes or no."
81
+ input = nil
82
+ input = gets.strip.downcase
83
+ case input
84
+ when "yes"
85
+ set_up_instance_variable
86
+ when "no"
87
+ goodbye
88
+ else
89
+ puts "Please type yes or no"
90
+ end
91
+ end
92
+
93
+ def goodbye
94
+ puts "See you tomorrow for more weather reports!"
95
+ end
96
+ end
@@ -0,0 +1,39 @@
1
+ class MasonellwoodCliAppTwo::StateScraper
2
+ attr_accessor :name, :cities, :state, :url
3
+
4
+ def initialize(state)
5
+ @state = state
6
+ end
7
+
8
+ def scrape_cities
9
+ html = open("https://www.wunderground.com/cgi-bin/findweather/getForecast?query=#{@state}") #pulls html
10
+ student_file = Nokogiri::HTML(html)
11
+ cities_array = []
12
+ student_file.css("tbody tr").each do |x|
13
+ city = x.css("a").text
14
+ url = x.search("a").attr("href").value
15
+ cities_array << "#{city} : #{url}"
16
+ end
17
+ @cities = cities_array
18
+ end
19
+
20
+ def city_weather(input)
21
+ input_city = input
22
+ self.cities.each do |x|
23
+ citys = x.split(/ : /)
24
+ downcase_city = citys[0].downcase
25
+ if downcase_city == input_city
26
+ html = open("https://www.wunderground.com/#{citys[1]}") #pulls html
27
+ student_file = Nokogiri::HTML(html)
28
+ weather_conditions = student_file.css("#curCond .wx-value").text
29
+ temperature = student_file.css("#curTemp .wx-value").text
30
+ puts "It looks like you are interested in beautiful #{input_city.capitalize}!"
31
+ puts "Weather Conditions for Today: #{weather_conditions}"
32
+ puts "Current Temperature: #{temperature} Degrees Fahrenheit"
33
+ puts "Check more or the Cities in your area by typing the City name."
34
+ puts "If you want to see all the Cities again, type Cities."
35
+ puts "Or type exit."
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module MasonellwoodCliAppTwo
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "nokogiri"
2
+ require 'open-uri'
3
+
4
+ require "masonellwood_cli_app_two/version"
5
+ require_relative './masonellwood_cli_app_two/cli'
6
+ require_relative './masonellwood_cli_app_two/state-scraper'
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "masonellwood_cli_app_two/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "masonellwood_cli_app_two"
8
+ spec.version = MasonellwoodCliAppTwo::VERSION
9
+ spec.authors = ["Mason Ellwood"]
10
+ spec.email = ["masonellwood@gmail.com"]
11
+
12
+ spec.summary = %q{Checks current weather in your area.}
13
+ spec.description = %q{This gem with asks user input for there state name, then will prompt the use to type there city they would like to check the daily weather of."}
14
+ spec.homepage = "https://github.com/MasonEllwood/masonellwood_cli_app_two"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.executables = ["weather-channel"]
21
+ spec.require_paths = ["lib", "lib/masonellwood_cli_app_two"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.15"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "pry"
27
+
28
+ spec.add_dependency "nokogiri"
29
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: masonellwood_cli_app_two
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mason Ellwood
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-13 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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: This gem with asks user input for there state name, then will prompt
84
+ the use to type there city they would like to check the daily weather of."
85
+ email:
86
+ - masonellwood@gmail.com
87
+ executables:
88
+ - weather-channel
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".travis.yml"
95
+ - CODE_OF_CONDUCT.md
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - NOTES.mb
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - bin/weather-channel
104
+ - lib/masonellwood_cli_app_two.rb
105
+ - lib/masonellwood_cli_app_two/cli.rb
106
+ - lib/masonellwood_cli_app_two/state-scraper.rb
107
+ - lib/masonellwood_cli_app_two/version.rb
108
+ - masonellwood_cli_app_two.gemspec
109
+ homepage: https://github.com/MasonEllwood/masonellwood_cli_app_two
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ - lib/masonellwood_cli_app_two
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.6.12
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Checks current weather in your area.
134
+ test_files: []