Skip to content
Ruby SDK for CloudEvents
Ruby Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples initial implementation Dec 10, 2018
lib correcting headers Dec 10, 2018
spec correcting headers Dec 10, 2018
.envrc initial implementation Dec 10, 2018
.gitignore initial implementation Dec 10, 2018
Gemfile initial implementation Dec 10, 2018
LICENSE Initial commit Dec 7, 2018 correcting headers Dec 10, 2018
Rakefile initial implementation Dec 10, 2018
cloudevents.gemspec initial implementation Dec 10, 2018

Ruby SDK for CloudEvents

NOTE: This SDK is still considered work in progress, things might (and will) break with every update.

Package cloudevents provides primitives to work with CloudEvents specification: This gem currently supports reading version 0.1 cloudevents in binary and json format.


Parsing upstream Event from HTTP Request with the helps of gem 'sinatra':

Create a file named app.rb and add the following code.

require "sinatra"
require "cloudevents"

marshaller = Cloudevents::V01::HTTPMarshaller.default

post "/" do
  event = marshaller.from_request(request)"Received cloudevent: #{event.inspect}")

Start the web application server and send a cloudevent.

$ ruby app.rb
$ curl -H 'Content-Type: application/json' \
       -H 'CE-CloudEventsVersion: 1' \
       -H 'CE-EventType: com.example.someevent' \
       -H 'CE-Source: /mycontext' \
       -H 'CE-EventID: 1234-1234-1234' \
       -X POST \
       -d 'Hello CloudEvents!' \

The console should output your freshly send cloudevent.

INFO -- : Received cloudevent: #<Cloudevents::V01::Event:0x00007fbbd581f108 @cloud_events_version="1", @event_type="com.example.someevent", @event_type_version=nil, @source="/mycontext", @event_id="1234-1234-1234", @event_time=nil, @schema_url=nil, @content_type="application/json", @data="Hello CloudEvents!">


Add this line to your application's Gemfile:

gem 'cloudevents'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cloudevents


After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at

You can’t perform that action at this time.