| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A Ruby language implementation of the CloudEvents specification.
Features:
Install the cloud_events gem or add it to your bundle.
gem install cloud_eventsA simple Sinatra app that receives CloudEvents:
# examples/server/Gemfile
source "https://rubygems.org"
gem "cloud_events", "~> 0.8"
gem "sinatra", "~> 4.0"
gem "rackup"
gem "puma"# examples/server/app.rb
require "sinatra"
require "cloud_events"
cloud_events_http = CloudEvents::HttpBinding.default
post("/") do
event = cloud_events_http.decode_event(request.env)
logger.info("Received CloudEvent: #{event.to_h}")
endA simple Ruby script that sends a CloudEvent:
# examples/client/Gemfile
source "https://rubygems.org"
gem "cloud_events", "~> 0.8"# examples/client/send.rb
require "cloud_events"
require "net/http"
require "uri"
data = { message: "Hello, CloudEvents!" }
event = CloudEvents::Event.create(
spec_version: "1.0",
id: "1234-1234-1234",
source: "/mycontext",
type: "com.example.someevent",
data_content_type: "application/json",
data: data
)
cloud_events_http = CloudEvents::HttpBinding.default
headers, body = cloud_events_http.encode_event(event)
Net::HTTP.post(URI("http://localhost:4567"), body, headers)Start the server on localhost:
cd server
bundle install
bundle exec ruby app.rbThis will run the server in the foreground and start logging to the console.
In a separate terminal shell, send it an event from the client:
cd client
bundle install
bundle exec ruby send.rbThe event should be logged in the server logs.
Hit CTRL+C to stop the server.
Bug reports and pull requests are welcome on GitHub at https://github.com/cloudevents/sdk-ruby.
After cloning the repo locally, install the bundle, and install the toys gem if you do not already have it.
bundle install
gem install toysA variety of Toys scripts are provided for running tests and builds. For example:
# Run the unit tests
toys test
# Run CI locally, including unit tests, doc tests, and rubocop
toys ci
# Build and install the gem locally
toys install
# Clean temporary and build files
toys clean
# List all available scripts
toys
# Show online help for the "test" script
toys test --helpRuby code style is enforced by Rubocop rules. We've left the configuration largely on the Rubocop defaults, with a few exceptions, notably:
You can run rubocop directly using the rubocop binary:
bundle exec rubocopor via Toys:
toys rubocopThat said, we are not style sticklers, and if a break is necessary for code readability or practicality, Rubocop rules can be selectively disabled.
We welcome contributions from the community! Please take some time to become acquainted with the process before submitting a pull request. There are just a few things to keep in mind.
Weekly meetings: There are bi-weekly calls immediately following the Serverless/CloudEvents call at 9am PT (US Pacific). Which means they will typically start at 10am PT, but if the other call ends early then the SDK call will start early as well. See the CloudEvents meeting minutes to determine which week will have the call.
Slack: The #cloudeventssdk channel under CNCF's Slack workspace.
For additional information, contact Daniel Azuma (@dazuma on Slack).
Each SDK may have its own unique processes, tooling and guidelines, common governance related material can be found in the CloudEvents community directory. In particular, in there you will find information concerning how SDK projects are managed, guidelines for how PR reviews and approval, and our Code of Conduct information.
If there is a security concern with one of the CloudEvents specifications, or with one of the project's SDKs, please send an email to cncf-cloudevents-security@lists.cncf.io.
| Back | FazBrowse Home | New Git URL |