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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7520c59f2f6d5b9b9bfd80436644e904209f9af
4
- data.tar.gz: 211b83c303cb7df52778f942a580a59f4745efa4
3
+ metadata.gz: 88fb29cf1629af396a668e14d90373d37b8bfa11
4
+ data.tar.gz: 21619f62ef93a74ea0ba71fbcb12dfd26fe801e7
5
5
  SHA512:
6
- metadata.gz: 2e91559829b0a7714aa6677b01eb28ec8113bfd88b70dee3e0eb2fa6daf489e57d9e09d93c9382044693e59cc29547c9d2867a0dd5e8b557f5dbb94f7242e50f
7
- data.tar.gz: f52ee41fb7639eb447b06ec0d4de75a4c8683b21f74611d8a5f0a9f11a872e4a21b07cab8d872abe8ea581e064f0433154dc6502ea9bef0e6ade4a6f9b1c798b
6
+ metadata.gz: 9601de81e651209eb74cdf95a12a3d8ebe05cea3655ebe742d9ba03fe8ec1a3354b6fb13c5968c98aaa33e9788602445daf8c2f77c605e863c613aa424df4123
7
+ data.tar.gz: dd28867996944b444a465d26e2a3208cac953717a62581897e934846e8b784159e8e3e54cada70768d3491dc66918b7b861ee67b27cb5c057f9505014231a1ac
@@ -1,8 +1,5 @@
1
1
  sudo: false
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
6
- - 2.2.0
7
- - jruby-19mode
8
- - rbx-2
3
+ - 2.2.6
4
+ - 2.3.3
5
+ - 2.4.0
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.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Weather
2
- VERSION = "1.3.0" unless defined?(Weather::VERSION)
2
+ VERSION = "1.4.0" unless defined?(Weather::VERSION)
3
3
  end
@@ -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.1.0"
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.3.0
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: 2016-08-21 00:00:00.000000000 Z
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.1.0
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.1.0
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.4.5.1
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