tomorrowio_rb 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/configuration.rb +27 -0
- data/lib/tomorrowio_rb.rb +8 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 755bdab30c734df598fc0b9de45f63fbc0dfbc6730dcbd560fa39c3cdfedd566
|
4
|
+
data.tar.gz: 04622c8355659e9ff0df021f5167c9a024325c5adf881856e2f746101edf566f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e9f005bb58ccb7ee7f5d913d0f218b10305a347e32b6aca9403a4b8b531f246b751cf850c099b6237d6e3c308ecb9c28f0955a859d2e1987fd3bc610037fc38
|
7
|
+
data.tar.gz: 801927921423c19038d5c2d72451f71ce262ebb78cb5242d44d158b56061d05c4e0bfc54e9b5a2a8faad5e2165376d0e69ba24ef76c2081a03d753da517bcc83
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Tomorrowiorb
|
2
|
+
module Configuration
|
3
|
+
DEFAULT_API_ENDPOINT = 'https://api.tomorrow.io/v4'
|
4
|
+
|
5
|
+
attr_writer :api_endpoint
|
6
|
+
attr_writer :api_key
|
7
|
+
|
8
|
+
# Yield self to be able to configure Tomorrowiorb with block-style configuration.
|
9
|
+
#
|
10
|
+
# Example:
|
11
|
+
#
|
12
|
+
# Tomorrowiorb.configure do |configuration|
|
13
|
+
# configuration.api_key = 'this-is-your-api-key'
|
14
|
+
# end
|
15
|
+
def configure
|
16
|
+
yield self
|
17
|
+
end
|
18
|
+
|
19
|
+
def api_endpoint
|
20
|
+
@api_endpoint ||= DEFAULT_API_ENDPOINT
|
21
|
+
end
|
22
|
+
|
23
|
+
def api_key
|
24
|
+
@api_key
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/tomorrowio_rb.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'configuration.rb'
|
2
2
|
require 'faraday'
|
3
3
|
require 'json'
|
4
4
|
|
@@ -6,7 +6,7 @@ module Tomorrowiorb
|
|
6
6
|
extend Configuration
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def forecast(location, timesteps=
|
9
|
+
def forecast(location, timesteps=["1d"], units="metric")
|
10
10
|
connection = Faraday.new(
|
11
11
|
url: "#{Tomorrowiorb.api_endpoint}/weather/forecast",
|
12
12
|
params: {
|
@@ -15,9 +15,11 @@ module Tomorrowiorb
|
|
15
15
|
},
|
16
16
|
headers: {'Content-Type' => 'application/json'}
|
17
17
|
)
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
response = connection.get('') do |req|
|
19
|
+
req.options.params_encoder = Faraday::FlatParamsEncoder
|
20
|
+
req.params['timesteps'] = timesteps
|
21
|
+
req.params['units'] = units
|
22
|
+
end
|
21
23
|
|
22
24
|
return TomorrowioResponse.new(response.status,response.headers, response.body)
|
23
25
|
end
|
@@ -42,4 +44,4 @@ module Tomorrowiorb
|
|
42
44
|
@body
|
43
45
|
end
|
44
46
|
end
|
45
|
-
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomorrowio_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cedric Wille
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby wrapper for the Tomorrow.io weather API, currently only the forecast
|
14
14
|
endpoint.
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- lib/configuration.rb
|
20
21
|
- lib/tomorrowio_rb.rb
|
21
22
|
homepage: https://github.com/cwille97/tomorrowio_rb
|
22
23
|
licenses:
|