weather-api 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -6
- data/README.md +4 -0
- data/lib/weather-api.rb +29 -0
- data/lib/weather-api/version.rb +1 -1
- data/weather-api.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88fb29cf1629af396a668e14d90373d37b8bfa11
|
4
|
+
data.tar.gz: 21619f62ef93a74ea0ba71fbcb12dfd26fe801e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9601de81e651209eb74cdf95a12a3d8ebe05cea3655ebe742d9ba03fe8ec1a3354b6fb13c5968c98aaa33e9788602445daf8c2f77c605e863c613aa424df4123
|
7
|
+
data.tar.gz: dd28867996944b444a465d26e2a3208cac953717a62581897e934846e8b784159e8e3e54cada70768d3491dc66918b7b861ee67b27cb5c057f9505014231a1ac
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,10 @@ This produces:
|
|
36
36
|
13 degrees
|
37
37
|
Cloudy
|
38
38
|
|
39
|
+
Lookup via location name
|
40
|
+
|
41
|
+
response = Weather.lookup_by_location('San Francisco, CA', Weather::Units::FAHRENHEIT)
|
42
|
+
|
39
43
|
## Copyright
|
40
44
|
|
41
45
|
Copyright (c) 2012 Andrew Stewart. See `LICENSE` file for more details.
|
data/lib/weather-api.rb
CHANGED
@@ -45,6 +45,35 @@ module Weather
|
|
45
45
|
Response.new woeid, url, doc
|
46
46
|
end
|
47
47
|
|
48
|
+
# Public: Looks up current weather information using a location string
|
49
|
+
#
|
50
|
+
# location - String - A location name. 'City, state, country'
|
51
|
+
# Examples: Nome, AK
|
52
|
+
# San Francisco, CA, USA
|
53
|
+
# Berlin, Germany
|
54
|
+
# toronto, ca
|
55
|
+
#
|
56
|
+
# unit - system of measurement to use. Two acceptable inputs:
|
57
|
+
# 'c' - Celsius/Metric measurements
|
58
|
+
# 'f' - Fahrenheit/Imperial measurements.
|
59
|
+
#
|
60
|
+
# To make this easier, you can use the Weather::Units::FAHRENHEIT and
|
61
|
+
# Weather::Units::CELSIUS constants. Defaults to Celsius
|
62
|
+
#
|
63
|
+
# Returns a Weather::Response object containing forecast
|
64
|
+
def lookup_by_location(location, unit = Units::CELSIUS)
|
65
|
+
acceptable_units = [Units::CELSIUS, Units::FAHRENHEIT]
|
66
|
+
unit = Units::CELSIUS unless acceptable_units.include?(unit)
|
67
|
+
|
68
|
+
# per the documentation here: https://developer.yahoo.com/weather/
|
69
|
+
# can look up the woeid via geo places api from location
|
70
|
+
url = ROOT + "?q=select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='#{location}') and u='#{unit}'&format=json"
|
71
|
+
url = URI.escape(url)
|
72
|
+
|
73
|
+
doc = get_response url
|
74
|
+
Response.new location, url, doc
|
75
|
+
end
|
76
|
+
|
48
77
|
private
|
49
78
|
def get_response url
|
50
79
|
begin
|
data/lib/weather-api/version.rb
CHANGED
data/weather-api.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "map", "~> 6.6.0"
|
22
22
|
spec.add_dependency "json"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.5.0"
|
24
|
-
spec.add_development_dependency "webmock", "~> 2.
|
24
|
+
spec.add_development_dependency "webmock", "~> 2.3.2"
|
25
25
|
spec.add_development_dependency "rake", "~> 11.2.2"
|
26
26
|
spec.add_development_dependency "vcr", "~> 3.0.3"
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weather-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: 2.3.2
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
82
|
+
version: 2.3.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '0'
|
198
198
|
requirements: []
|
199
199
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.
|
200
|
+
rubygems_version: 2.6.8
|
201
201
|
signing_key:
|
202
202
|
specification_version: 4
|
203
203
|
summary: Weather-API provides an object-oriented interface to the Yahoo! Weather XML
|