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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb9754f3bb9ec137791204a3dce1c98ab24ae8447d9c4c743db65fa6b4466f41
4
- data.tar.gz: 4859a853e5e3c86f6c29bd5c025c740e5f63c2b6232bd62d46eae344dc3887eb
3
+ metadata.gz: 26c7954b0ceb6cda4a0dba00882bb74ed98847ad768c117a2928f05074dc9583
4
+ data.tar.gz: 6e7477e9b91a57c374a00f0b4fc8b0c45f21bb1489d29e9011d4dc35cf2131e4
5
5
  SHA512:
6
- metadata.gz: e026929fd77323f1ecb6d18ef85505a0f72d8798b56ddb4fa3196f933406f84bc39801019f4a45388e90ca6bd8cadc551c8ef2a6b526b171cac597e9bb419c05
7
- data.tar.gz: 658443fd3146d507049bc0355b92d21c66eab7d27ac82d6e86131fdf1dff5a39e7afa75f0bbe15b890523b9f07b5bf047877ade5ab9c268481d67f7e7b99efc2
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 'Umbrella'
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 Umbrella
19
+ $ gem install umbrella_cli_app
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
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
- @rain = Umbrella::Weather.weather_setter("Chicago+IL+USIL0225:1:US")
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
- @rain = Umbrella::Weather.weather_setter("USNY0996:1:US")
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
- @rain = Umbrella::Weather.weather_setter("USCA0638:1:US")
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
@@ -1,3 +1,3 @@
1
1
  module Umbrella
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,20 +1,19 @@
1
1
  class Umbrella::Weather
2
- attr_accessor :temperature, :wind, :sunrise, :sunset, :weather_condition, :rain_perc
2
+ attr_accessor :temperature, :wind, :sunrise, :sunset, :weather_condition, :rain_perc, :city
3
3
 
4
- def self.weather_setter(location_url)
5
-
6
- doc = Nokogiri::HTML(open("https://weather.com/weather/today/l/#{location_url}"))
7
-
8
- rain = self.new
9
-
10
- rain.temperature = doc.search("div.today_nowcard-temp").text
11
- rain.weather_condition = doc.search("div.today_nowcard-phrase").text
12
- rain.wind = doc.search("div.today_nowcard-sidecar").search("td")[0].text
13
- rain.sunrise = doc.search("span.wx-dsxdate")[0].text
14
- rain.sunset = doc.search("span.wx-dsxdate")[1].text
15
- rain.rain_perc = doc.search("span.precip-val").first.text
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
- end
18
+ end
19
+
data/lib/Umbrella.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'open-uri'
2
2
  require 'nokogiri'
3
+ require 'pry'
3
4
 
4
5
 
5
6
  require_relative "./Umbrella/version"
6
7
  require_relative "./Umbrella/CLI"
7
8
  require_relative "./Umbrella/weather"
8
-
9
+ require_relative "./Umbrella/scraper"
@@ -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 = "exe"
24
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conor Hamilton
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-13 00:00:00.000000000 Z
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/umbrella
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