forecast_api 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/bin/weather +6 -0
- data/forecast_api.gemspec +24 -0
- data/lib/forecast_api.rb +5 -0
- data/lib/forecast_api/version.rb +3 -0
- data/lib/forecast_api/weather.rb +31 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e259878b80cba42e9c5ab09f5e00fec772d3f1b6
|
4
|
+
data.tar.gz: 08c868a77638110ec880d8a773badeb52737f57f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aee6310878c90974a10bbc3d524232b7e85011e33b50bf3a647b66510102cc9884fea6b11c5120b0567ae7a26103dc0545db1605ca9fdd0766a7433ef5240061
|
7
|
+
data.tar.gz: e037377660e1abb063acbe760db6c93ab515121b5d0a978e17cc157bf4b19ac365ed42902f91a1c9fba3cfd804dacddd6e2ce677e23573191aff3f12989714f4
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Trevor Jones
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Forecast_Api
|
2
|
+
|
3
|
+
A faboulous weather gem for your convenience. Instead of going through the hassle of opening an app, you
|
4
|
+
can use your terminal and type in commands!
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
This is meant to be an executive gem!
|
9
|
+
|
10
|
+
Install it yourself as:
|
11
|
+
|
12
|
+
$ gem install forecast_api
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
To get the current weather in your location, type in
|
17
|
+
|
18
|
+
weather 'zip code'
|
19
|
+
|
20
|
+
If I lived in Chicago, I would type
|
21
|
+
|
22
|
+
weather 60610
|
23
|
+
|
24
|
+
You'll get a list of the current, next day, 3 day and 7 day weather forecasts.
|
25
|
+
|
26
|
+
This was just for practice so don't take it too seriously.
|
27
|
+
|
28
|
+
## Contributing (if you're bored)
|
29
|
+
|
30
|
+
1. Fork it ( https://github.com/[my-github-username]/forecast_api/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/weather
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'forecast_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "forecast_api"
|
8
|
+
spec.version = ForecastApi::VERSION
|
9
|
+
spec.authors = ["Trevor Jones"]
|
10
|
+
spec.email = ["trevordavidjones@gmail.com"]
|
11
|
+
spec.summary = %q{A simple way to get the weather based on zip code. You can choose current, tomorrow, 3 day or 10 day forecast.}
|
12
|
+
spec.description = %q{All you need to know is the zip code you want the weather for. You can then bring up current, next day, 3 day or 7 day forecasts.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "unirest"
|
24
|
+
end
|
data/lib/forecast_api.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'unirest'
|
2
|
+
|
3
|
+
module Forecast
|
4
|
+
|
5
|
+
class Weather
|
6
|
+
def initialize(zip_code)
|
7
|
+
|
8
|
+
lat_lon = Unirest.get("http://maps.googleapis.com/maps/api/geocode/json?address=#{zip_code}",
|
9
|
+
headers: { "Accept" => "application/json" }).body
|
10
|
+
|
11
|
+
lat = lat_lon["results"][0]["geometry"]["location"]["lat"]
|
12
|
+
long = lat_lon["results"][0]["geometry"]["location"]["lng"]
|
13
|
+
city = lat_lon["results"][0]["address_components"][1]["long_name"]
|
14
|
+
state = lat_lon["results"][0]["address_components"][2]["short_name"]
|
15
|
+
|
16
|
+
weather = Unirest.get("https://api.forecast.io/forecast/f48f53dad752fdd952eac2d70d9fad13/#{lat},#{long}",
|
17
|
+
headers: { "Accept" => "application/json" }).body
|
18
|
+
|
19
|
+
puts "Weather for #{city}, #{state}"
|
20
|
+
puts weather["daily"]["summary"]
|
21
|
+
puts "Today's weather is " + weather["daily"]["data"][0]["summary"] + " The high is " + weather["daily"]["data"][0]["temperatureMax"].to_s + "°F with a low of " + weather["daily"]["data"][0]["temperatureMin"].to_s + "°F."
|
22
|
+
puts "Tomorrow is " + weather["daily"]["data"][1]["summary"] + " The high is " + weather["daily"]["data"][1]["temperatureMax"].to_s + "°F with a low of " + weather["daily"]["data"][1]["temperatureMin"].to_s + "°F."
|
23
|
+
puts "3 day forecast is " + weather["daily"]["data"][3]["summary"] + " The high is " + weather["daily"]["data"][3]["temperatureMax"].to_s + "°F with a low of " + weather["daily"]["data"][3]["temperatureMin"].to_s + "°F."
|
24
|
+
puts "7 day forecast is " + weather["daily"]["data"][7]["summary"] + " The high is " + weather["daily"]["data"][7]["temperatureMax"].to_s + "°F with a low of " + weather["daily"]["data"][7]["temperatureMin"].to_s + "°F."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: forecast_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Trevor Jones
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-01 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: unirest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: All you need to know is the zip code you want the weather for. You can
|
56
|
+
then bring up current, next day, 3 day or 7 day forecasts.
|
57
|
+
email:
|
58
|
+
- trevordavidjones@gmail.com
|
59
|
+
executables:
|
60
|
+
- weather
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/weather
|
70
|
+
- forecast_api.gemspec
|
71
|
+
- lib/forecast_api.rb
|
72
|
+
- lib/forecast_api/version.rb
|
73
|
+
- lib/forecast_api/weather.rb
|
74
|
+
homepage: ''
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.2.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: A simple way to get the weather based on zip code. You can choose current,
|
98
|
+
tomorrow, 3 day or 10 day forecast.
|
99
|
+
test_files: []
|