proto_turf 0.0.4 → 0.0.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: d406d02e3db35efe7976a07238831d78ffeefc9692b6082c240aaf61983ec8be
4
- data.tar.gz: 6ed547fb924c5d14526e22523417397b0b8b64682d4a79ca5aa78284ae940703
3
+ metadata.gz: 8239512fca1dd5698211d880f8af935172d618df491a556593328dc3fcf6962b
4
+ data.tar.gz: 76922a13957798957fbffb8bcfad086a850d4a0f4d76d019401bca2fcf073c0f
5
5
  SHA512:
6
- metadata.gz: 8bd87219da56f1a9c555265dde48c7b11e86986b3e14ce4f849747054e7e5dc1c51ac64b43b584894f2215320580a72a9a159f0e94c56b868d99fc4c6ed0cc05
7
- data.tar.gz: 43d9f128249dfc33e6f8db72a44541cc69a665e168075de1af6f40564e24c0bbdcc12587f1bdb4744ffe2606c3ff66cdc495ca08f06a6a7223c6882626d0b9be
6
+ metadata.gz: 62e0dc2021649ed6404dfa4aff7b55008922dcad1bd405bab49e8c8bd6e813f6a4633b75f1822a359c799d97c50bfc8454bcd0be6159a2b1805dab1b5c505c2e
7
+ data.tar.gz: e78d7140868439556d6be3a3e39844e27c3b408e7eccbc92fde258bd3b411b0264f91017b02894bbb8144295bc278844028101a0cce15dc452e6ecc64956870c
data/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ # 0.0.5 - 2025-08-20
11
+
12
+ * Minor fixes.
13
+
10
14
  # 0.0.4 - 2025-08-19
11
15
 
12
16
  * Changed emitting of protobuf schemas from file-based to generated from descriptors.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- proto_turf (0.0.4)
4
+ proto_turf (0.0.5)
5
5
  excon
6
6
  google-protobuf
7
7
 
data/README.md CHANGED
@@ -36,10 +36,6 @@ encoded = proto_turf.encode(message, subject: 'my-subject')
36
36
  decoded_proto_message = proto_turf.decode(encoded_string)
37
37
  ```
38
38
 
39
- If you're using [buf](https://buf.build/) to manage your Protobuf definitions, you should run `buf export` before using `proto_turf` to ensure that all the dependencies are available as `.proto` files in your project. The actual proto text is needed when registering the schema with the Schema Registry.
40
-
41
- Because `buf export` overwrites/deletes existing files, you should run it into a different directory and provide both as `schema_paths` to the `ProtoTurf` constructor.
42
-
43
39
  ## Notes about usage
44
40
 
45
41
  * When decoding, this library does *not* attempt to fully parse the Proto definition stored on the schema registry and generate dynamic classes. Instead, it simply parses out the package and message and assumes that the reader has the message available in the descriptor pool. Any compatibility issues should be detected through normal means, i.e. just by instantiating the message and seeing if any errors are raised.
@@ -49,4 +45,4 @@ Run the following to regenerate:
49
45
 
50
46
  ```sh
51
47
  protoc -I spec/schemas --ruby_out=spec/gen --ruby_opt=paths=source_relative spec/schemas/**/*.proto
52
- ```
48
+ ```
data/Rakefile CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
3
+ require "bundler/gem_tasks"
@@ -141,6 +141,8 @@ class ProtoTurf
141
141
  end
142
142
  write_oneofs(info, message_type)
143
143
  message_type.nested_type.each do |subtype|
144
+ next if subtype.options&.map_entry
145
+
144
146
  info.writenl
145
147
  write_message(info, subtype)
146
148
  end
@@ -189,8 +191,8 @@ class ProtoTurf
189
191
  end
190
192
 
191
193
  def write_field(info, field, oneof: false)
192
- info.write_indent("")
193
194
  return if !oneof && field.has_oneof_index?
195
+ info.write_indent("")
194
196
 
195
197
  klass = nil
196
198
  if field.type_name && field.type_name != ""
@@ -226,8 +228,10 @@ class ProtoTurf
226
228
 
227
229
  def write_oneofs(info, message)
228
230
  message.oneof_decl.each_with_index do |oneof, i|
231
+ # synthetic oneof for proto3 optional fields
229
232
  next if oneof.name.start_with?("_") &&
230
233
  message.field.any? { |f| f.proto3_optional && f.name == oneof.name[1..] }
234
+
231
235
  info.write_line("oneof #{oneof.name} {")
232
236
  info.indent
233
237
  message.field.select { |f| f.has_oneof_index? && f.oneof_index == i }.each do |field|
@@ -1,3 +1,3 @@
1
1
  class ProtoTurf
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/proto_turf.rb CHANGED
@@ -8,6 +8,8 @@ require "proto_turf/cached_confluent_schema_registry"
8
8
  require "proto_turf/proto_text"
9
9
 
10
10
  class ProtoTurf
11
+ class SchemaNotFoundError < StandardError; end
12
+
11
13
  # Provides a way to encode and decode messages without having to embed schemas
12
14
  # in the encoded data. Confluent's Schema Registry[1] is used to register
13
15
  # a schema when encoding a message -- the registry will issue a schema id that
@@ -115,12 +117,6 @@ class ProtoTurf
115
117
  stream.write(message.to_proto)
116
118
 
117
119
  stream.string
118
- rescue Excon::Error::NotFound
119
- if schema_id
120
- raise SchemaNotFoundError.new("Schema with id: #{schema_id} is not found on registry")
121
- else
122
- raise SchemaNotFoundError.new("Schema with subject: `#{subject}` version: `#{version}` is not found on registry")
123
- end
124
120
  end
125
121
 
126
122
  # Decodes data into the original message.
@@ -76,7 +76,7 @@ enum NestedEnum {
76
76
  repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
77
77
  repeated string repeated_cord = 55 [ctype = CORD];
78
78
  repeated NestedMessage repeated_lazy_message = 57 [lazy = true];
79
- oneof oneof_field {
79
+ oneof oneof_field {
80
80
  uint32 oneof_uint32 = 111;
81
81
  NestedMessage oneof_nested_message = 112;
82
82
  string oneof_string = 113;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proto_turf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner