avro_turf 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67ff8ee9b578227cd54a33d76a95fed8bd2c9a396aa360ad9df9f52d01e5c25a
4
- data.tar.gz: 8bca24236ce42f19f6db457ad13d76d33e89b18703dc0eb74a8adca53b2c7b6e
3
+ metadata.gz: 3cb36f9b1395a1a6210d1178ca0823636f30ad194caf57663e8fb5cc13273d68
4
+ data.tar.gz: 2fb489fe330b39b88ed585d6b622936e573b525c1f4c5c4fe50704b16b11fd39
5
5
  SHA512:
6
- metadata.gz: 859e8fa6938679007704d35b1b4a54616da7637c83f41c58cbd10828216e0af198846e755334f465613ceb9086ec0c63a823dc2cbf3ddbdc191a97423d2e3147
7
- data.tar.gz: 7900a85abaf9dd55ac3b89bba2d04935ddbafc850a92fb1941ff8984df864cfaa4bb5527ca4d48a74ef3715915d598044b7c486363909f2705ece83b0ffca50f
6
+ metadata.gz: be796c4b42daf30a79dd699d23842e61c61e8f8c70b1645f269ec25e4a4f4fb1e87148b0ffd69a68b24382e9abc01048cb3ba082bd3a3dd2162be714ecdcd57b
7
+ data.tar.gz: 332486d45cd611da3906247f4fb55386c7e1617043070dd44fff06b05c50c44237af6dad62f1fd087ca9c67580aadd53fc342f76509b69b67375532b60637bf9
@@ -7,17 +7,17 @@ jobs:
7
7
 
8
8
  runs-on: ubuntu-latest
9
9
  strategy:
10
+ fail-fast: false
10
11
  matrix:
11
- ruby: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0]
12
+ ruby: [2.6, 2.7, "3.0", 3.1, 3.2]
12
13
 
13
14
  steps:
14
- - uses: actions/checkout@v2
15
+ - uses: actions/checkout@v3
15
16
  - name: Set up Ruby ${{ matrix.ruby }}
16
17
  uses: ruby/setup-ruby@v1
17
18
  with:
18
19
  ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true
19
21
  - name: Build and test with RSpec
20
22
  run: |
21
- gem install bundler
22
- bundle install --jobs 4 --retry 3
23
23
  bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v1.9.0
6
+
7
+ - Send Accept and User-Agent headers on every request (#184)
8
+
5
9
  ## v1.8.0
6
10
 
7
- - add support for `Date` via appropriate logicalType defintion. This is a backwards incompatible change (#177)
11
+ - Add support for `Date` via appropriate logicalType defintion. This is a backwards incompatible change (#177)
8
12
  - Fixed schema file cache truncation on multiple running instances and parallel access to the cache files.
9
13
 
10
14
  ## v1.7.0
data/avro_turf.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "bundler", "~> 2.0"
26
26
  spec.add_development_dependency "rake", "~> 13.0"
27
27
  spec.add_development_dependency "rspec", "~> 3.2"
28
- spec.add_development_dependency "fakefs", "~> 0.20.0"
28
+ spec.add_development_dependency "fakefs", "< 3"
29
29
  spec.add_development_dependency "webmock"
30
30
  spec.add_development_dependency "sinatra"
31
31
  spec.add_development_dependency "json_spec"
@@ -19,9 +19,9 @@ class AvroTurf::ConfluentSchemaRegistry
19
19
  )
20
20
  @path_prefix = path_prefix
21
21
  @logger = logger
22
- headers = {
22
+ headers = Excon.defaults[:headers].merge(
23
23
  "Content-Type" => CONTENT_TYPE
24
- }
24
+ )
25
25
  headers[:proxy] = proxy unless proxy.nil?
26
26
  @connection = Excon.new(
27
27
  url,
@@ -17,12 +17,12 @@ class AvroTurf::InMemoryCache
17
17
  end
18
18
 
19
19
  def lookup_by_schema(subject, schema)
20
- key = [subject, schema.to_s]
20
+ key = [subject, schema]
21
21
  @ids_by_schema[key]
22
22
  end
23
23
 
24
24
  def store_by_schema(subject, schema, id)
25
- key = [subject, schema.to_s]
25
+ key = [subject, schema]
26
26
  @ids_by_schema[key] = id
27
27
  end
28
28
 
@@ -1,3 +1,3 @@
1
1
  class AvroTurf
2
- VERSION = "1.8.0"
2
+ VERSION = "1.9.0"
3
3
  end
data/lib/avro_turf.rb CHANGED
@@ -121,10 +121,9 @@ class AvroTurf
121
121
  # namespace - The namespace of the Avro schema (optional).
122
122
  #
123
123
  # Returns true if the data is valid, false otherwise.
124
- def valid?(data, schema_name: nil, namespace: @namespace)
124
+ def valid?(data, schema_name: nil, namespace: @namespace, validate_options: {})
125
125
  schema = schema_name && @schema_store.find(schema_name, namespace)
126
-
127
- Avro::Schema.validate(schema, data.as_avro)
126
+ Avro::Schema.validate(schema, data.as_avro, **validate_options)
128
127
  end
129
128
 
130
129
  # Loads all schema definition files in the `schemas_dir`.
@@ -360,11 +360,42 @@ describe AvroTurf do
360
360
  }
361
361
  AVSC
362
362
 
363
- datum = {
363
+ datum = {
364
364
  message: "hello",
365
365
  sent_date: Date.new(2022, 9, 11)
366
366
  }
367
367
  expect(avro.valid?(datum, schema_name: "postcard")).to eq true
368
368
  end
369
+
370
+ context "when message contains extra fields (typo in key)" do
371
+ let(:message) { { "fulll_name" => "John Doe" } }
372
+
373
+ before do
374
+ define_schema "message.avsc", <<-AVSC
375
+ {
376
+ "name": "message",
377
+ "type": "record",
378
+ "fields": [
379
+ { "name": "full_name", "type": "string" }
380
+ ]
381
+ }
382
+ AVSC
383
+ end
384
+
385
+ it "is valid" do
386
+ datum = { "full_name" => "John Doe", "extra" => "extra" }
387
+ expect(avro.valid?(datum, schema_name: "message")).to eq true
388
+ end
389
+
390
+ it "is invalid when passing fail_on_extra_fields" do
391
+ datum = { "full_name" => "John Doe", "extra" => "extra" }
392
+ validate_options = {
393
+ recursive: true,
394
+ encoded: false,
395
+ fail_on_extra_fields: true }
396
+ valid = avro.valid?(datum, schema_name: "message", validate_options: validate_options)
397
+ expect(valid).to eq false
398
+ end
399
+ end
369
400
  end
370
401
  end
@@ -13,9 +13,20 @@ shared_examples_for "a confluent schema registry client" do
13
13
  ]
14
14
  }.to_json
15
15
  end
16
+ let(:headers) do
17
+ {
18
+ 'Accept'=>'*/*',
19
+ 'Content-Type'=> AvroTurf::ConfluentSchemaRegistry::CONTENT_TYPE,
20
+ 'Host'=> "#{URI.parse(registry_url).host}:80",
21
+ 'User-Agent'=> "excon/#{Excon::VERSION}"
22
+ }
23
+ end
16
24
 
17
25
  before do
18
- stub_request(:any, /^#{registry_url}/).to_rack(FakeConfluentSchemaRegistryServer)
26
+ stub_request(:any, /^#{registry_url}/)
27
+ .with(headers: headers)
28
+ .to_rack(FakeConfluentSchemaRegistryServer)
29
+
19
30
  FakeConfluentSchemaRegistryServer.clear
20
31
  end
21
32
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avro_turf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-14 00:00:00.000000000 Z
11
+ date: 2023-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro
@@ -90,16 +90,16 @@ dependencies:
90
90
  name: fakefs
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - "<"
94
94
  - !ruby/object:Gem::Version
95
- version: 0.20.0
95
+ version: '3'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - "<"
101
101
  - !ruby/object:Gem::Version
102
- version: 0.20.0
102
+ version: '3'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: webmock
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +156,7 @@ dependencies:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
- description:
159
+ description:
160
160
  email:
161
161
  - dasch@zendesk.com
162
162
  executables: []
@@ -251,8 +251,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
251
  - !ruby/object:Gem::Version
252
252
  version: '0'
253
253
  requirements: []
254
- rubygems_version: 3.3.3
255
- signing_key:
254
+ rubygems_version: 3.0.3.1
255
+ signing_key:
256
256
  specification_version: 4
257
257
  summary: A library that makes it easier to use the Avro serialization format from
258
258
  Ruby