masonellwood_cli_app_two 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/weather-channel +1 -1
- data/lib/masonellwood_cli_app_two/city.rb +7 -0
- data/lib/masonellwood_cli_app_two/cli.rb +12 -34
- data/lib/masonellwood_cli_app_two/state-scraper.rb +7 -14
- data/lib/masonellwood_cli_app_two/version.rb +1 -1
- data/lib/masonellwood_cli_app_two.rb +2 -0
- data/masonellwood_cli_app_two-0.1.0.gem +0 -0
- data/masonellwood_cli_app_two-0.1.1.gem +0 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ad776e66245d9f40cf8f7cb7f2077d05d540ac0
|
4
|
+
data.tar.gz: 9bf0c9aacd0dedeffd74b17a1e31e26c29fe4c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa12bc769421fc0a5026f7cc583c7085788cef33f79ff2a6c22593e3e517aa0146462e8d136a81e213dbf3cfa4be6c0c31db3126e2fc0b15217feb8f99e0b554
|
7
|
+
data.tar.gz: 908040f4443678f44f3f377ec4dfd9bb1c1127001714d0bb300301a7bf474b153adfc808d3890973c705626e9802ea6008579dfd3893cdae0e1e35a83e6bc0a7
|
data/bin/weather-channel
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
class MasonellwoodCliAppTwo::CLI
|
2
2
|
|
3
3
|
attr_accessor :state_info
|
4
|
-
|
4
|
+
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",
|
5
|
+
"south carolina", "south dakota", "tennessee", "texas", "utah", "vermont", "virginia", "washington", "west virginia", "wisconsin", "wyoming" ]
|
5
6
|
def call
|
6
7
|
greet_with_prompt
|
7
8
|
set_up_instance_variable
|
@@ -13,15 +14,13 @@ class MasonellwoodCliAppTwo::CLI
|
|
13
14
|
end
|
14
15
|
|
15
16
|
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
17
|
puts "Please type your State of interest."
|
19
18
|
puts "If you forgot how to spell some of the state names, just type states."
|
20
19
|
puts "If you don't care about the weather today, just type exit."
|
21
20
|
state = nil
|
22
21
|
while state != "exit"
|
23
22
|
state = gets.strip.downcase
|
24
|
-
if
|
23
|
+
if EVERY_STATE.include?(state)
|
25
24
|
@state_info = MasonellwoodCliAppTwo::StateScraper.new(state)
|
26
25
|
@state_info.scrape_cities
|
27
26
|
display_citie_option
|
@@ -33,7 +32,7 @@ class MasonellwoodCliAppTwo::CLI
|
|
33
32
|
puts "#{index}. #{the_state.capitalize}"
|
34
33
|
end
|
35
34
|
puts "Here are all the valid States, which one would you like to know the weather?"
|
36
|
-
elsif
|
35
|
+
elsif state != "exit"
|
37
36
|
puts "Not sure what you want bud. Please type exit to quit. Or see the valid states by typing states."
|
38
37
|
end
|
39
38
|
end
|
@@ -44,52 +43,31 @@ class MasonellwoodCliAppTwo::CLI
|
|
44
43
|
puts "Here are all of the cities in #{@state_info.state.capitalize}!"
|
45
44
|
@state_info.cities.each_with_index.each do |city, index|
|
46
45
|
index += 1
|
47
|
-
|
48
|
-
puts "#{index}: #{citys[0]}"
|
46
|
+
puts "#{index}: #{city.name}"
|
49
47
|
end
|
50
48
|
display_city_weather
|
51
49
|
end
|
52
50
|
|
53
51
|
def display_city_weather
|
54
|
-
puts "
|
52
|
+
puts "Enter the number of the city you want to view"
|
55
53
|
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
54
|
while input != "exit"
|
63
55
|
input = gets.strip.downcase
|
64
56
|
if input == "cities"
|
65
57
|
@state_info.cities.each_with_index.each do |city, index|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
58
|
+
index += 1
|
59
|
+
puts "#{index}: #{city.name}"
|
60
|
+
end
|
70
61
|
puts "Now type the name of the city you want to know the weather of."
|
71
|
-
elsif
|
72
|
-
@state_info.
|
62
|
+
elsif input.to_i.between?(1, @state_info.cities.size)
|
63
|
+
city = @state_info.cities[input.to_i - 1]
|
64
|
+
@state_info.city_weather(city)
|
73
65
|
elsif input != "exit"
|
74
66
|
puts "Please type a valid city, or type exit."
|
75
67
|
end
|
76
68
|
end
|
77
69
|
end
|
78
70
|
|
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
71
|
def goodbye
|
94
72
|
puts "See you tomorrow for more weather reports!"
|
95
73
|
end
|
@@ -3,37 +3,30 @@ class MasonellwoodCliAppTwo::StateScraper
|
|
3
3
|
|
4
4
|
def initialize(state)
|
5
5
|
@state = state
|
6
|
+
@cities = []
|
6
7
|
end
|
7
8
|
|
8
9
|
def scrape_cities
|
9
10
|
html = open("https://www.wunderground.com/cgi-bin/findweather/getForecast?query=#{@state}") #pulls html
|
10
11
|
student_file = Nokogiri::HTML(html)
|
11
|
-
cities_array = []
|
12
12
|
student_file.css("tbody tr").each do |x|
|
13
13
|
city = x.css("a").text
|
14
14
|
url = x.search("a").attr("href").value
|
15
|
-
|
15
|
+
new_city = MasonellwoodCliAppTwo::City.new(city, url)
|
16
|
+
@cities << new_city
|
16
17
|
end
|
17
|
-
@cities = cities_array
|
18
18
|
end
|
19
19
|
|
20
|
-
def city_weather(
|
21
|
-
|
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
|
20
|
+
def city_weather(city)
|
21
|
+
html = open("https://www.wunderground.com/#{city.url}") #pulls html
|
27
22
|
student_file = Nokogiri::HTML(html)
|
28
23
|
weather_conditions = student_file.css("#curCond .wx-value").text
|
29
24
|
temperature = student_file.css("#curTemp .wx-value").text
|
30
|
-
puts "It looks like you are interested in beautiful #{
|
25
|
+
puts "It looks like you are interested in beautiful #{city.name}!"
|
31
26
|
puts "Weather Conditions for Today: #{weather_conditions}"
|
32
27
|
puts "Current Temperature: #{temperature} Degrees Fahrenheit"
|
33
|
-
puts "Check more or the Cities in your area by typing the
|
28
|
+
puts "Check more or the Cities in your area by typing the Number Name."
|
34
29
|
puts "If you want to see all the Cities again, type Cities."
|
35
30
|
puts "Or type exit."
|
36
|
-
end
|
37
|
-
end
|
38
31
|
end
|
39
32
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "nokogiri"
|
2
2
|
require 'open-uri'
|
3
|
+
require 'pry'
|
3
4
|
|
4
5
|
require "masonellwood_cli_app_two/version"
|
5
6
|
require_relative './masonellwood_cli_app_two/cli'
|
6
7
|
require_relative './masonellwood_cli_app_two/state-scraper'
|
8
|
+
require_relative './masonellwood_cli_app_two/city'
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: masonellwood_cli_app_two
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mason Ellwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,9 +102,12 @@ files:
|
|
102
102
|
- bin/setup
|
103
103
|
- bin/weather-channel
|
104
104
|
- lib/masonellwood_cli_app_two.rb
|
105
|
+
- lib/masonellwood_cli_app_two/city.rb
|
105
106
|
- lib/masonellwood_cli_app_two/cli.rb
|
106
107
|
- lib/masonellwood_cli_app_two/state-scraper.rb
|
107
108
|
- lib/masonellwood_cli_app_two/version.rb
|
109
|
+
- masonellwood_cli_app_two-0.1.0.gem
|
110
|
+
- masonellwood_cli_app_two-0.1.1.gem
|
108
111
|
- masonellwood_cli_app_two.gemspec
|
109
112
|
homepage: https://github.com/MasonEllwood/masonellwood_cli_app_two
|
110
113
|
licenses:
|