cel 0.6.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bf9b40df18d849d9a964e668c0f1aee0d82f02ccd2de536dcfa73c8d714c718
4
- data.tar.gz: 0f348c6b1a4a09362d76db927aec94099fc2ac2b355ddcef963b72fa90549e07
3
+ metadata.gz: d6d9641e7b6b5cd40bda6d81519f89e9b5bd8e7d8d595306291e6d470ed3aa3c
4
+ data.tar.gz: 55490419080cc9eba65d907a99001deb7b3fbed08f1fc815e3dba293969162b8
5
5
  SHA512:
6
- metadata.gz: 936e0ea05567de1932de8a887dee32f3682cbdccc574999772283a98acef7ce47d4ad51446eb35a8bcb5195100dc0a3197ec7fb4a82f8ddc239aab47ba0f40c1
7
- data.tar.gz: d346ef64b5f777b1e368f234a43ad69cb2759313134558ef9760e68933e61a2e1f0644b01ad46b85702017955777ceebe31bce28c410ddbbbca49639eeeb1120
6
+ metadata.gz: 222160a59e461b0b0b6166fc839edb760b8b696a935c0471cae0f3437d1049215777a613cf9840e4fbd2c85c91fc80798e142de963ad0523eff9e586c9a53bd2
7
+ data.tar.gz: 6abacc2f4aa0be7f74af0f44fec56bbfb57ccb770f60bb0072aa5334ed9381c7bb75447f948cf85278b40f42714f44139e9a3b6cfc6634e116ba6e821ea54961
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.1] - 2026-07-27
4
+
5
+ * parser: enabled support for declaring CEL messages inside a CEL list.
6
+ * protobuf: don't convert primitive types onto protobuf values if the result is from an unexpected type.
7
+ * protobuf: workaround internal conversions of `Google::Protobuf::Map` into a hash, due to its incompatible block-less implementation of `#to_h`.
8
+ * protobuf: fix initialization of a proto fied with repeated values.
9
+
3
10
  ## [0.6.0] - 2026-02-28
4
11
 
5
12
  ### Features
@@ -16,7 +16,7 @@ module Cel
16
16
  end
17
17
 
18
18
  case val
19
- when Literal, Identifier, Invoke, Operation, Condition, Group, # already cel
19
+ when Literal, Message, Identifier, Invoke, Operation, Condition, Group, # already cel
20
20
  Protobuf.enum_class # already a usable class a la protobuf
21
21
  val
22
22
  when Protobuf.map_class
@@ -282,13 +282,39 @@ module Cel
282
282
 
283
283
  next([key, value]) unless field_subtype
284
284
 
285
- [
286
- key,
287
- # discard protobuf enums as well
288
- value.is_a?(field_subtype.msgclass) ?
289
- value :
290
- convert_to_proto(field_subtype.msgclass, value, convert_value_to_proto: true),
291
- ]
285
+ if field_descriptor.label == :repeated
286
+ value = case value
287
+ when Hash
288
+ key_type, value_type = field_subtype.msgclass.descriptor.map(&:subtype)
289
+ value.filter_map do |k, v|
290
+ kconv = key_type && !k.is_a?(key_type.msgclass) ?
291
+ convert_to_proto(key_type.msgclass, k, convert_value_to_proto: true) :
292
+ k
293
+ vconv = value_type && !v.is_a?(value_type.msgclass) ?
294
+ convert_to_proto(value_type.msgclass, v, convert_value_to_proto: true) :
295
+ v
296
+
297
+ next unless vconv
298
+
299
+ [kconv, vconv]
300
+ end.to_h
301
+ else
302
+ # Array
303
+ value.filter_map do |v|
304
+ if v.is_a?(field_subtype.msgclass)
305
+ v
306
+ else
307
+ convert_to_proto(field_subtype.msgclass, v, convert_value_to_proto: true)
308
+ end
309
+ end
310
+ end
311
+ else
312
+ unless value.is_a?(field_subtype.msgclass)
313
+ value = convert_to_proto(field_subtype.msgclass, value, convert_value_to_proto: true)
314
+ end
315
+ end
316
+
317
+ [key, value]
292
318
  end
293
319
 
294
320
  # protobuf sets maps as abstract classes, and there's apparently no way to identify them
@@ -298,7 +324,11 @@ module Cel
298
324
 
299
325
  proto_type.new(values)
300
326
  elsif values.nil?
301
- Google::Protobuf::Value.from_ruby(values)
327
+ v = Google::Protobuf::Value.from_ruby(values)
328
+
329
+ return if proto_type && !v.is_a?(proto_type)
330
+
331
+ v
302
332
  else
303
333
  proto_type.new(value: values)
304
334
  end
@@ -340,7 +370,7 @@ module Cel
340
370
  when :repeated
341
371
  case value
342
372
  when Google::Protobuf::Map
343
- value.to_h { |k, v| [k, convert_from_proto_field_type(field, v)] }
373
+ value.map { |k, v| [k, convert_from_proto_field_type(field, v)] }.to_h
344
374
  else
345
375
  value.map { |v| convert_from_proto_field_type(field, v) }
346
376
  end
data/lib/cel/program.rb CHANGED
@@ -76,6 +76,8 @@ module Cel
76
76
  case val
77
77
  when List
78
78
  List.new(val.value.map(&method(:call)))
79
+ when Map
80
+ Map.new(val.value.map { |k, v| [k, call(v)] }, depth: val.depth)
79
81
  else
80
82
  val
81
83
  end
data/lib/cel/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cel
4
4
  module Ruby
5
- VERSION = "0.6.0"
5
+ VERSION = "0.6.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso