umbrella_cli_app 0.1.0 → 0.2.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 +4 -4
- data/README.md +5 -3
- data/bin/{umbrella → umbrella_cli} +0 -0
- data/lib/Umbrella/CLI.rb +18 -4
- data/lib/Umbrella/scraper.rb +18 -0
- data/lib/Umbrella/version.rb +1 -1
- data/lib/Umbrella/weather.rb +15 -16
- data/lib/Umbrella.rb +2 -1
- data/umbrella_cli_app.gemspec +2 -2
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c7954b0ceb6cda4a0dba00882bb74ed98847ad768c117a2928f05074dc9583
|
4
|
+
data.tar.gz: 6e7477e9b91a57c374a00f0b4fc8b0c45f21bb1489d29e9011d4dc35cf2131e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae8c80283a3f093f88628e062ef344645cfdcd14809cd2570387eb87b6b487f2c9492bd8a786ef93763e5fc9823bb388474e53b1707374980c68c309ade0bace
|
7
|
+
data.tar.gz: a9cc683ec134ed36b26fa02a88089da1f39008417930b958fb1c670a1b2ccbce09e61e2d47c451c3abbae090cc0c7df5914ec698fd547c12ea4293780a0aa764
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Have you ever ran out the door wondering if you need an umbrella? This CLI Data
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem '
|
10
|
+
gem 'umbrella_cli_app'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -16,11 +16,13 @@ And then execute:
|
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
$ gem install
|
19
|
+
$ gem install umbrella_cli_app
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
Run executable file.
|
24
|
+
|
25
|
+
Follow on screen prompts to choose location and access further weather features.
|
24
26
|
|
25
27
|
## Development
|
26
28
|
|
File without changes
|
data/lib/Umbrella/CLI.rb
CHANGED
@@ -11,16 +11,30 @@ class Umbrella::CLI
|
|
11
11
|
def choose_location
|
12
12
|
puts "Do you need an Umbrella today in:(pick a number)"
|
13
13
|
|
14
|
-
["Chicago", "New York", "Los Angeles"].each.with_index(1){|a, i| puts "#{i}. #{a}"}
|
14
|
+
["Chicago, IL", "New York, NY", "Los Angeles, CA"].each.with_index(1){|a, i| puts "#{i}. #{a}"}
|
15
15
|
|
16
16
|
input = gets.chomp.downcase
|
17
17
|
case input
|
18
18
|
when "1"
|
19
|
-
|
19
|
+
if Umbrella::Weather.find_by_city("Chicago, IL") == nil
|
20
|
+
@rain = Umbrella::Scraper.weather_setter("Chicago+IL+USIL0225:1:US")
|
21
|
+
else
|
22
|
+
@rain = Umbrella::Weather.find_by_city("Chicago, IL")
|
23
|
+
end
|
24
|
+
|
20
25
|
when "2"
|
21
|
-
|
26
|
+
if Umbrella::Weather.find_by_city("New York, NY") == nil
|
27
|
+
@rain = Umbrella::Scraper.weather_setter("USNY0996:1:US")
|
28
|
+
else
|
29
|
+
@rain = Umbrella::Weather.find_by_city("New York, NY")
|
30
|
+
end
|
31
|
+
|
22
32
|
when "3"
|
23
|
-
|
33
|
+
if Umbrella::Weather.find_by_city("Los Angeles, CA") == nil
|
34
|
+
@rain = Umbrella::Scraper.weather_setter("USCA0638:1:US")
|
35
|
+
else
|
36
|
+
@rain = Umbrella::Weather.find_by_city("Los Angeles, CA")
|
37
|
+
end
|
24
38
|
when "exit"
|
25
39
|
puts "Stay dry!"
|
26
40
|
exit
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Umbrella::Scraper
|
2
|
+
|
3
|
+
def self.weather_setter(location_url)
|
4
|
+
doc = Nokogiri::HTML(open("https://weather.com/weather/today/l/#{location_url}"))
|
5
|
+
|
6
|
+
rain = Umbrella::Weather.new
|
7
|
+
|
8
|
+
rain.city = doc.search("h1.today_nowcard-location").text
|
9
|
+
rain.temperature = doc.search("div.today_nowcard-temp").text
|
10
|
+
rain.weather_condition = doc.search("div.today_nowcard-phrase").text
|
11
|
+
rain.wind = doc.search("div.today_nowcard-sidecar").search("td")[0].text
|
12
|
+
rain.sunrise = doc.search("span.wx-dsxdate")[0].text
|
13
|
+
rain.sunset = doc.search("span.wx-dsxdate")[1].text
|
14
|
+
rain.rain_perc = doc.search("span.precip-val").first.text
|
15
|
+
rain.save
|
16
|
+
rain
|
17
|
+
end
|
18
|
+
end
|
data/lib/Umbrella/version.rb
CHANGED
data/lib/Umbrella/weather.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
class Umbrella::Weather
|
2
|
-
|
2
|
+
attr_accessor :temperature, :wind, :sunrise, :sunset, :weather_condition, :rain_perc, :city
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rain
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def save
|
7
|
+
@@all << self
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.all
|
11
|
+
@@all
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find_by_city(city)
|
15
|
+
self.all.find{|a| a.city == city}
|
18
16
|
end
|
19
17
|
|
20
|
-
|
18
|
+
end
|
19
|
+
|
data/lib/Umbrella.rb
CHANGED
data/umbrella_cli_app.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
22
|
end
|
23
|
-
spec.bindir = "
|
24
|
-
spec.executables =
|
23
|
+
spec.bindir = "bin"
|
24
|
+
spec.executables = ["umbrella_cli"]
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.16"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umbrella_cli_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conor Hamilton
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,7 +69,8 @@ dependencies:
|
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- conhamil19@gmail.com
|
72
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- umbrella_cli
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files: []
|
75
76
|
files:
|
@@ -83,9 +84,10 @@ files:
|
|
83
84
|
- Rakefile
|
84
85
|
- bin/console
|
85
86
|
- bin/setup
|
86
|
-
- bin/
|
87
|
+
- bin/umbrella_cli
|
87
88
|
- lib/Umbrella.rb
|
88
89
|
- lib/Umbrella/CLI.rb
|
90
|
+
- lib/Umbrella/scraper.rb
|
89
91
|
- lib/Umbrella/version.rb
|
90
92
|
- lib/Umbrella/weather.rb
|
91
93
|
- spec.md
|