zilla 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/Gemfile.lock +1 -1
- data/lib/zilla/client_factory.rb +3 -3
- data/lib/zilla/loader_factory.rb +2 -2
- data/lib/zilla/loaders/http.rb +2 -2
- data/lib/zilla/loaders/loader.rb +3 -2
- data/lib/zilla/version.rb +1 -1
- data/lib/zilla/versions/v20/client.rb +4 -3
- data/lib/zilla/versions/v20/executor.rb +2 -1
- data/lib/zilla.rb +2 -2
- 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: 9feb47c8b31a9f05fd2b5e5b1c917ee8b560d7c3aa4a82c175f82f213fd268b2
|
4
|
+
data.tar.gz: 17e7dc8d8ca2452dabf295beef5eaf1e74cc062c23e3865602e5ab27405029a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dea759c5a3bfa6944ce907d8487b9049a10192573a8ef8c6cb72340a3f86f861f754c5eebaa92ff836ab07e57f0d9f10743d774265dbd5f1caaf48bf07f06eb
|
7
|
+
data.tar.gz: 44adaf118c2dbd1306216651274339639da34336aa3ec28c73723424a6451a27c97361e08d03f59a83a355cb6a53c7929e7716759c20ea3af56608f79b2f3af2
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.2.0
|
data/Gemfile.lock
CHANGED
data/lib/zilla/client_factory.rb
CHANGED
@@ -8,15 +8,15 @@ module Zilla::ClientFactory
|
|
8
8
|
}.freeze
|
9
9
|
|
10
10
|
class << self
|
11
|
-
def build(input, host: nil, scheme: nil, &block)
|
12
|
-
definition = Zilla::LoaderFactory.build(input, &block).load
|
11
|
+
def build(input, host: nil, scheme: nil, faraday_config: {}, &block)
|
12
|
+
definition = Zilla::LoaderFactory.build(input, faraday_config:, &block).load
|
13
13
|
|
14
14
|
version = definition["swagger"]
|
15
15
|
|
16
16
|
raise ArgumentError, "#{input.inspect} is not an OpenAPI definition" if version.nil?
|
17
17
|
raise UnsupportedVersion, "usupported version #{version.inspect}" if version && CLIENTS[version].nil?
|
18
18
|
|
19
|
-
CLIENTS[version].new(definition, host:, scheme:, faraday_config_block: block)
|
19
|
+
CLIENTS[version].new(definition, host:, scheme:, faraday_config:, faraday_config_block: block)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/zilla/loader_factory.rb
CHANGED
@@ -4,13 +4,13 @@ module Zilla::LoaderFactory
|
|
4
4
|
class UnknownLoader < Zilla::Error; end
|
5
5
|
|
6
6
|
class << self
|
7
|
-
def build(input, &block)
|
7
|
+
def build(input, faraday_config: {}, &block)
|
8
8
|
case input
|
9
9
|
when Hash
|
10
10
|
Zilla::Loaders::Hash
|
11
11
|
when String
|
12
12
|
for_string(input)
|
13
|
-
end.new(input, faraday_config_block: block)
|
13
|
+
end.new(input, faraday_config:, faraday_config_block: block)
|
14
14
|
rescue NoMethodError
|
15
15
|
raise UnknownLoader, "cannot find loader for #{input.inspect}"
|
16
16
|
end
|
data/lib/zilla/loaders/http.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
class Zilla::Loaders::HTTP < Zilla::Loaders::Loader
|
4
4
|
def load_string
|
5
|
-
Faraday.new(input) do |f|
|
6
|
-
|
5
|
+
Faraday.new(input, **faraday_config) do |f|
|
6
|
+
faraday_config_block.call(f, :loader)
|
7
7
|
f.response :raise_error
|
8
8
|
end.get.body
|
9
9
|
end
|
data/lib/zilla/loaders/loader.rb
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
class Zilla::Loaders::Loader
|
4
4
|
class LoaderError < Zilla::Error; end
|
5
5
|
|
6
|
-
attr_reader :input
|
6
|
+
attr_reader :input, :faraday_config, :faraday_config_block
|
7
7
|
|
8
|
-
def initialize(input, faraday_config_block: nil)
|
8
|
+
def initialize(input, faraday_config: {}, faraday_config_block: nil)
|
9
9
|
@input = input
|
10
|
+
@faraday_config = faraday_config
|
10
11
|
@faraday_config_block = faraday_config_block || ->(_f, _target) {}
|
11
12
|
end
|
12
13
|
|
data/lib/zilla/version.rb
CHANGED
@@ -5,12 +5,13 @@ class Zilla::Versions::V20::Client
|
|
5
5
|
|
6
6
|
include Memery
|
7
7
|
|
8
|
-
attr_reader :json, :host, :scheme, :faraday_config_block
|
8
|
+
attr_reader :json, :host, :scheme, :faraday_config_block, :faraday_config
|
9
9
|
|
10
|
-
def initialize(json, host: nil, scheme: nil, faraday_config_block: nil) # rubocop:disable Metrics/AbcSize
|
10
|
+
def initialize(json, host: nil, scheme: nil, faraday_config: {}, faraday_config_block: nil) # rubocop:disable Metrics/AbcSize
|
11
11
|
@json = json
|
12
12
|
@host = host || api.host || raise(ArgumentError, ":host must be specified")
|
13
13
|
@scheme = (scheme || :https).to_s
|
14
|
+
@faraday_config = faraday_config
|
14
15
|
@faraday_config_block = faraday_config_block || ->(_f, _target) {}
|
15
16
|
|
16
17
|
if api.schemes && !api.schemes.include?(@scheme)
|
@@ -22,7 +23,7 @@ class Zilla::Versions::V20::Client
|
|
22
23
|
|
23
24
|
memoize def api = API.new(json)
|
24
25
|
|
25
|
-
memoize def executor = Executor.new(scheme, host, faraday_config_block:)
|
26
|
+
memoize def executor = Executor.new(scheme, host, faraday_config:, faraday_config_block:)
|
26
27
|
|
27
28
|
private
|
28
29
|
|
@@ -5,9 +5,10 @@ class Zilla::Versions::V20::Executor
|
|
5
5
|
|
6
6
|
attr_reader :scheme, :host
|
7
7
|
|
8
|
-
def initialize(scheme, host, faraday_config_block:)
|
8
|
+
def initialize(scheme, host, faraday_config:, faraday_config_block:)
|
9
9
|
@scheme = scheme
|
10
10
|
@host = host
|
11
|
+
@faraday_config = faraday_config
|
11
12
|
@faraday_config_block = faraday_config_block || ->(_, _target) {}
|
12
13
|
end
|
13
14
|
|
data/lib/zilla.rb
CHANGED
@@ -16,8 +16,8 @@ loader.inflector.inflect(
|
|
16
16
|
module Zilla
|
17
17
|
class Error < StandardError; end
|
18
18
|
|
19
|
-
def self.for(input, host: nil, scheme: nil, &)
|
20
|
-
Zilla::ClientFactory.build(input, host:, scheme:, &)
|
19
|
+
def self.for(input, host: nil, scheme: nil, faraday_config: {}, &)
|
20
|
+
Zilla::ClientFactory.build(input, host:, scheme:, faraday_config:, &)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Sinyavskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- ".overcommit.yml"
|
92
92
|
- ".rspec"
|
93
93
|
- ".rubocop.yml"
|
94
|
+
- ".tool-versions"
|
94
95
|
- CODE_OF_CONDUCT.md
|
95
96
|
- Gemfile
|
96
97
|
- Gemfile.lock
|