zilla 0.1.3 → 0.1.5

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: 67835482c78ededdf96d80a81e748354240776a1b8d696e3f8ea61a2e9a07a00
4
- data.tar.gz: 1bac88fb8c3db62b72163318331f770e7145b4b55b7792420bf89cf2132f2452
3
+ metadata.gz: 2e32481b500c093caa4f3e1b78ce31d6aeade29a25e3d15fdd265c49507d21c1
4
+ data.tar.gz: 41911744a98dda32a5ed0ba2d4e7ef9fe78b81e41e0110cd7b4dad90922dba76
5
5
  SHA512:
6
- metadata.gz: 646c19b46599f6cfb5791493a5a410e7702a1a706ffa1a0b7e919c56a6b2fb88b07b5f2e2111700bc344533e6810a96023dd627dcb4f1cad27306b5071954592
7
- data.tar.gz: 71e3293b3e08583dd862faaf95550fbb9c701c7ddfde921ad1bca13e573127191d7dcd55e0db558c4a5632798fd2152d9222aeec8f04cdf85bf88cafe024d57c
6
+ metadata.gz: 217131fe7d9574045f798f81e6ed581f7089e29bba55219f59080f4d86f9e53c85c23f38af7859ab00dc5d7d8c2eccc6355eb55019fb207fa7f9ecf5372a3fcc
7
+ data.tar.gz: 4cd0ae99796911f20056142521927c8c4a6e0f0566c0b6ff10bd120951a64f2e7cceb84f5fa8d6f2c3d995f8ca407997ca79c18a97de0ef7642f472f307443b8
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.2.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zilla (0.1.3)
4
+ zilla (0.1.5)
5
5
  faraday (~> 2.7.0)
6
6
  json_schemer (~> 0.2.0)
7
7
  memery (~> 1.4.0)
@@ -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
@@ -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
@@ -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
- @faraday_config_block.call(f, :loader)
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
@@ -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
@@ -4,5 +4,5 @@ module Zilla
4
4
  module Version
5
5
  end
6
6
 
7
- VERSION = "0.1.3"
7
+ VERSION = "0.1.5"
8
8
  end
@@ -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
 
@@ -23,7 +24,7 @@ class Zilla::Versions::V20::Executor
23
24
  private
24
25
 
25
26
  memoize def connection
26
- Faraday.new("#{scheme}://#{host}") do |f|
27
+ Faraday.new("#{scheme}://#{host}", @faraday_config) do |f|
27
28
  @faraday_config_block.call(f, :client)
28
29
  f.response :raise_error
29
30
  end
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.3
4
+ version: 0.1.5
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-30 00:00:00.000000000 Z
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