open-meteo 0.3.0 → 0.3.1
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 +4 -4
- data/lib/open_meteo/client/config.rb +3 -2
- data/lib/open_meteo/client.rb +7 -8
- data/lib/open_meteo/configuration.rb +1 -0
- data/lib/open_meteo/faraday_connection.rb +26 -0
- data/lib/open_meteo/version.rb +1 -1
- 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: f89e15f29bfd187c332d5543477221061804b3a03e7a9773adebc62639284ab3
|
4
|
+
data.tar.gz: e2fd0e2e6c3b78a5448101ad8982da048e3532e4cb6089cfdc5b614d350184b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9e564dff02d8e28c5a3c45ef418b901da1dc5dc565231dd9608e8d0c02b8d1b340341d89ce2af7dcf7bec7f631cf38e4460a472d33cdcbec90cc5628767ef1d
|
7
|
+
data.tar.gz: f32d7c9de50a39a420aa64e8a7962f3c2fdf27f1bb04e5e86a0e2170077803ca9d31a14904fb0c839c3ef0f511e41d25667f90473501c2746f6beab717f980db
|
@@ -3,12 +3,13 @@ module OpenMeteo
|
|
3
3
|
##
|
4
4
|
# The configuration for the OpenMeteo::Client.
|
5
5
|
class Config
|
6
|
-
attr_reader :api_key, :host, :logger
|
6
|
+
attr_reader :api_key, :host, :logger, :timeouts
|
7
7
|
|
8
|
-
def initialize(api_key: nil, host: nil, logger: nil)
|
8
|
+
def initialize(api_key: nil, host: nil, logger: nil, timeouts: nil)
|
9
9
|
@api_key = api_key || OpenMeteo.configuration.api_key
|
10
10
|
@host = host || OpenMeteo.configuration.host
|
11
11
|
@logger = logger || OpenMeteo.configuration.logger
|
12
|
+
@timeouts = timeouts || OpenMeteo.configuration.timeouts
|
12
13
|
end
|
13
14
|
|
14
15
|
def url
|
data/lib/open_meteo/client.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require "faraday/retry"
|
3
|
-
|
1
|
+
require_relative "faraday_connection"
|
4
2
|
require_relative "client/config"
|
5
3
|
require_relative "client/url_builder"
|
6
4
|
|
@@ -13,15 +11,16 @@ module OpenMeteo
|
|
13
11
|
class Timeout < StandardError
|
14
12
|
end
|
15
13
|
|
16
|
-
# See https://github.com/lostisland/faraday-retry/tree/main#usage
|
17
|
-
RETRY_OPTIONS = { max: 3, interval: 0.05, interval_randomness: 0.5, backoff_factor: 3 }.freeze
|
18
|
-
|
19
14
|
attr_reader :api_config, :agent
|
20
15
|
|
21
|
-
def initialize(
|
16
|
+
def initialize(
|
17
|
+
api_config: OpenMeteo::Client::Config.new,
|
18
|
+
url_builder: nil,
|
19
|
+
agent: FaradayConnection.new.connect
|
20
|
+
)
|
22
21
|
@api_config = api_config
|
23
22
|
@url_builder = url_builder || UrlBuilder.new(api_config:)
|
24
|
-
@agent = agent
|
23
|
+
@agent = agent
|
25
24
|
end
|
26
25
|
|
27
26
|
def get(endpoint_name, *endpoint_args, **get_params)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday/retry"
|
3
|
+
|
4
|
+
module OpenMeteo
|
5
|
+
##
|
6
|
+
# The Faraday connection
|
7
|
+
class FaradayConnection
|
8
|
+
# See https://github.com/lostisland/faraday-retry/tree/main#usage
|
9
|
+
RETRY_OPTIONS = { max: 3, interval: 0.05, interval_randomness: 0.5, backoff_factor: 3 }.freeze
|
10
|
+
|
11
|
+
attr_reader :config
|
12
|
+
|
13
|
+
def initialize(config: OpenMeteo::Client::Config.new)
|
14
|
+
@config = config
|
15
|
+
end
|
16
|
+
|
17
|
+
def connect
|
18
|
+
Faraday.new do |conn|
|
19
|
+
conn.options[:timeout] = config.timeouts[:timeout]
|
20
|
+
conn.options[:open_timeout] = config.timeouts[:open_timeout]
|
21
|
+
|
22
|
+
conn.request :retry, RETRY_OPTIONS
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/open_meteo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open-meteo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Morgenstern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/open_meteo/entities/forecast/units.rb
|
114
114
|
- lib/open_meteo/entities/location.rb
|
115
115
|
- lib/open_meteo/errors.rb
|
116
|
+
- lib/open_meteo/faraday_connection.rb
|
116
117
|
- lib/open_meteo/forecast.rb
|
117
118
|
- lib/open_meteo/forecast/variables.rb
|
118
119
|
- lib/open_meteo/response_wrapper.rb
|