darksky_weather-api 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +5 -5
- data/README.md +5 -2
- data/lib/darksky_weather/api/client.rb +8 -1
- data/lib/darksky_weather/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eba09792870cf4182256c99e2e1234bcf39f903efd575fc4ce685207e46c6da
|
4
|
+
data.tar.gz: e5f84fef340ef2d477c69616351a0bde93e57e79960f550495fb26bf90d977a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97b948b1eac878fd2eb465992e21935390cd1ce494f500cd44ce5f36b4d6cd2ca3a7ed6b09456e3e35baf4e74c9110655667117e343539234051fb41db245cbf
|
7
|
+
data.tar.gz: 79c326c4241a7fbdfc352ab1e6ce2786cdb13d2fa778051d626638dd8fc3c6cd5d3594b38fc87feeeceb1c378e9718e38969834f1a61cbde1f8f79b63b1b6343
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
darksky_weather-api (0.2.
|
4
|
+
darksky_weather-api (0.2.2)
|
5
5
|
activesupport
|
6
6
|
httparty
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.0.
|
11
|
+
activesupport (6.0.1)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 0.7, < 2)
|
14
14
|
minitest (~> 5.1)
|
15
15
|
tzinfo (~> 1.1)
|
16
|
-
zeitwerk (~> 2.
|
16
|
+
zeitwerk (~> 2.2)
|
17
17
|
concurrent-ruby (1.1.5)
|
18
18
|
diff-lcs (1.3)
|
19
19
|
httparty (0.17.1)
|
@@ -24,7 +24,7 @@ GEM
|
|
24
24
|
mime-types (3.3)
|
25
25
|
mime-types-data (~> 3.2015)
|
26
26
|
mime-types-data (3.2019.0904)
|
27
|
-
minitest (5.
|
27
|
+
minitest (5.13.0)
|
28
28
|
multi_xml (0.6.0)
|
29
29
|
rake (10.5.0)
|
30
30
|
rspec (3.8.0)
|
@@ -43,7 +43,7 @@ GEM
|
|
43
43
|
thread_safe (0.3.6)
|
44
44
|
tzinfo (1.2.5)
|
45
45
|
thread_safe (~> 0.1)
|
46
|
-
zeitwerk (2.1
|
46
|
+
zeitwerk (2.2.1)
|
47
47
|
|
48
48
|
PLATFORMS
|
49
49
|
ruby
|
data/README.md
CHANGED
@@ -49,13 +49,16 @@ To fetch the current weather for a given location, you'll need to know the latit
|
|
49
49
|
|
50
50
|
```ruby
|
51
51
|
client = DarkskyWeather::Api::Client.new
|
52
|
+
opts = {units: 'auto'}
|
52
53
|
lat, lng = [37.8267, -122.4233]
|
53
|
-
weather_data = client.get_weather(lat: lat, lng: lng)
|
54
|
+
weather_data = client.get_weather(lat: lat, lng: lng, opts: opts)
|
54
55
|
```
|
55
56
|
|
56
57
|
Note the use of kwargs in the method call. Calling the `get_weather` method will return a `WeatherData` object that defines a number of useful methods/attributes. The attributes all correspond to the snake-cased version of the JSON key present in the API response. For instance, `weather_data.currently.apparent_temperature` corresponds with the JSON at `raw_response['currently']['apparentTemperature']`.
|
57
58
|
|
58
|
-
|
59
|
+
The `opts` hash will be converted into a query string and may contain key/value pairs for the four optional query parameters supported by the Darksky Api: `extend`, `units`, `exclude`, and `lang`.
|
60
|
+
|
61
|
+
For more information about the optional parameters and all of the data that comes back from the request, [see the documentation](https://darksky.net/dev/docs).
|
59
62
|
|
60
63
|
In addition, you can retrieve the URL for your particular API request by calling `source_url` on the `WeatherData` instance.
|
61
64
|
|
@@ -6,12 +6,19 @@ module DarkskyWeather
|
|
6
6
|
include HTTParty
|
7
7
|
base_uri "https://api.darksky.net/forecast/"
|
8
8
|
|
9
|
-
def get_weather(lat:, lng:, timestamp: nil)
|
9
|
+
def get_weather(lat:, lng:, timestamp: nil, opts: {})
|
10
10
|
key = DarkskyWeather::Api.configuration.api_key
|
11
11
|
|
12
12
|
request_path = "/#{key}/#{lat},#{lng}"
|
13
13
|
request_path << ",#{timestamp}" if timestamp
|
14
14
|
|
15
|
+
allowed_opts = %w(extend exclude lang units)
|
16
|
+
opts.each_with_index do |o, idx|
|
17
|
+
next unless allowed_opts.include?(o.first.to_s)
|
18
|
+
sep_sym = idx == 0 ? '?' : '&'
|
19
|
+
request_path << "#{sep_sym}#{o.first}=#{o.last}"
|
20
|
+
end
|
21
|
+
|
15
22
|
raw_result = self.class.get(request_path)
|
16
23
|
request_uri = raw_result.request.uri.to_s
|
17
24
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darksky_weather-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lojistic Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|