cel 0.3.0 has been released.
cel is a pure Ruby implementation of Google Common Expression Language,
GitHub - google/cel-spec: Common Expression Language -- specification and binary representation.
The Common Expression Language (CEL) implements common semantics for
expression evaluation, enabling different applications to more easily
interoperate.
require "cel"
# set the environment
env = Cel::Environment.new(name: :string, group: :string)
# parse
ast = env.compile('name.startsWith("/groups/" + group)')
# check
prg = env.program(ast)
# evaluate
prg.evaluate(name: Cel::String.new("/groups/acme.co/documents/secret-stuff
"),
group: Cel::String.new("acme.co")) #=> true
# or do it all in one go
env.evaluate('name.startsWith("/groups/" + group)',
name: Cel::String.new("/groups/acme.co/documents/secret-stuff"),
group: Cel::String.new("acme.co")
)
Here are the updates since the last release:
# [0.3.0] - 2025-06-12
### Features
* Integration with `google-protobuf` (optional dependency) by evaluating
messages to protobuf stubs, and making them an integral part of the CEL
type set. Some examples:
* auto-conversion of protobuf wrapper types.
* enums support
### Improvements
* More correct parsing, checking and evaluation of CEL expressions, thanks
to the issues identified by conformance tests.
### Chore
* Incorporation of the oficial cel-spec conformance tests into the test
suite, to ensure feature correctness.
* `bigdecimal` added as explicit dependency.
## [0.2.3] - 2023-09-19
### Bugfixes
* `cel` is loadable without the need to install `google/protobuf` again.
+ expressions containing te operator `<=` were failing while parsing.
## [0.2.2] - 2023-08-17
* Reimplements `Cel::Literal#==` in a simpler way, to avoid several
comparison issues arising from the previous implementation.
* fix initialization of `Cel::Duration` and `Cel::Timestamp` from string
notation.
* fix protobuf-to-cel parsing of negative literals.
* more consistent usage of Cel types internally.
* fix condition clause evaluation.
## [0.2.1] - 2023-07-26
### Improvements
Collection type declarations are now better supported, i.e. declaring "an
array of strings" is now possible:
Cel::Types[:list, :string] # array of strings
Cel::Environment.new(
names: Cel::Types[:list, :string],
owned_by: Cel::Types[:map, :string] # hash map of string keys
)
### Bugfixes
Collections passed as variables of an expression are now correctly cast to
Cel types:
env.evaluate("a", { a: [1, 2, 3] }) #=> now returns a Cel::List
Conversely, custom functions now expose ruby types in the blocks, instead
of its Cel counterparts:
func = Cel::Function(:list, :list, return_type: :list) do |a, b|
# a is now a ruby array, b as well
a & b
# function returns a ruby array, will be converted to a Cel::List for use
in the expression
end