darksky_weather-api 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8bd21657beb125dc98f3c51b3977657043ec25c2751808719da0d79d9a60c77
4
- data.tar.gz: ca55d7395122e2f7fd7d5577bb71bb75cc5f0c3929e00e05a89a4604a7e8821b
3
+ metadata.gz: 4eba09792870cf4182256c99e2e1234bcf39f903efd575fc4ce685207e46c6da
4
+ data.tar.gz: e5f84fef340ef2d477c69616351a0bde93e57e79960f550495fb26bf90d977a5
5
5
  SHA512:
6
- metadata.gz: 9774400e23f8776038041b587438d94c6f1290848daa32334bccfe5deb932f4593aa2fb4df749a6cd0f407558fb4a4f1b77ff41bbcb9449f63320d6be212a28e
7
- data.tar.gz: 977ec6e9f44bf6cb797ef0267ef5b237bb81c35a6a8db281407fe00baea03fa9d92f0d06f2c0c75fdd4f2bf8c3ddd56d62266d2bdf525af7446a79193a2db684
6
+ metadata.gz: 97b948b1eac878fd2eb465992e21935390cd1ce494f500cd44ce5f36b4d6cd2ca3a7ed6b09456e3e35baf4e74c9110655667117e343539234051fb41db245cbf
7
+ data.tar.gz: 79c326c4241a7fbdfc352ab1e6ce2786cdb13d2fa778051d626638dd8fc3c6cd5d3594b38fc87feeeceb1c378e9718e38969834f1a61cbde1f8f79b63b1b6343
@@ -1,3 +1,7 @@
1
+ ### 0.2.2 (2019-12-02)
2
+
3
+ * Support optional request args.
4
+
1
5
  ### 0.1.2 (2019-09-20)
2
6
 
3
7
  * Changed module names and paths to make auto-inclusion work properly
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- darksky_weather-api (0.2.1)
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.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.1, >= 2.1.8)
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.12.2)
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.10)
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
- For more information about all of the data that comes back from the request, [see the documentation](https://darksky.net/dev/docs).
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
 
@@ -1,5 +1,5 @@
1
1
  module DarkskyWeather
2
2
  module Api
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
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.1
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-10-22 00:00:00.000000000 Z
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty