weatherpotato 1.0.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 +7 -0
- data/bin/weatherpotato +9 -0
- data/lib/weatherpotato.rb +42 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d529c5eccc8bc63e59c39dc493012cf1fa3d4f1
|
4
|
+
data.tar.gz: fea5d2256a3416ef324419e3ecf91d2f5434a2af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79c22a683b0649914e89c5e76e260d85bc1a50538c1d61bf3529b6cc1d431821149fc1d8fa03fc9a389bce45090793fb7e25a93cadf6926a5e055b6501f4a853
|
7
|
+
data.tar.gz: 2dd605e7ec07645e2f4a8acea10b859c5cc5c7db8b0b0041d9a960a9aa0375d9e152666fa58c42abfd908cc80ffb564df120e3d95b77a04fc5a690b557e2eb56
|
data/bin/weatherpotato
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'uri'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
class Weatherpotato
|
6
|
+
API_URL = 'http://api.openweathermap.org/data/2.5/weather'
|
7
|
+
|
8
|
+
def fetch location
|
9
|
+
response = HTTParty.get "#{API_URL}?q=#{URI.escape(location)}"
|
10
|
+
JSON.parse response.body
|
11
|
+
end
|
12
|
+
|
13
|
+
def format obj
|
14
|
+
output = "#{obj['name']}"
|
15
|
+
|
16
|
+
country = obj['sys']['country']
|
17
|
+
|
18
|
+
if !country.nil?
|
19
|
+
output += " (#{country})"
|
20
|
+
end
|
21
|
+
|
22
|
+
output += "\n #{obj['weather'].first['main']}"
|
23
|
+
|
24
|
+
description = obj['weather'].first['description']
|
25
|
+
if !description.nil?
|
26
|
+
output += " - #{description}"
|
27
|
+
end
|
28
|
+
|
29
|
+
temp = obj['main']['temp']
|
30
|
+
celsius = temp.to_f - 273.15
|
31
|
+
farenheit = celsius * 1.8 + 32
|
32
|
+
output += "\n #{celsius.to_i} C / #{farenheit.to_i} F"
|
33
|
+
|
34
|
+
output
|
35
|
+
end
|
36
|
+
|
37
|
+
def run location
|
38
|
+
puts format(fetch(location))
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: weatherpotato
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Albert Pachino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables:
|
16
|
+
- weatherpotato
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/weatherpotato
|
21
|
+
- lib/weatherpotato.rb
|
22
|
+
homepage:
|
23
|
+
licenses: []
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.4.6
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Pulls weather forecast.
|
45
|
+
test_files: []
|