GitHub - duglin/sdk-ruby: Ruby SDK for CloudEvents | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

duglin/sdk-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: https://github.com/cloudevents/spec. This gem currently supports reading version 0.1 cloudevents in binary and json format.

Usage

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)
  logger.info("Received cloudevent: #{event.inspect}")
end

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!' \
       'http://localhost:4567'

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!">

Installation

Add this line to your application's Gemfile:

gem 'cloudevents'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cloudevents

Development

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 rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cloudevents/ruby-sdk.

About

Ruby SDK for CloudEvents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 98.8%
  • Shell 1.2%

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.