Skip to content

Commit 592eac0

Browse files
authored
docs: A number of documentation fixes (#61)
Signed-off-by: Daniel Azuma <[email protected]>
1 parent 1528945 commit 592eac0

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Features:
1313
JSON Batch Format.
1414
* Support for sending and receiving CloudEvents via HTTP Bindings.
1515
* Supports the [CloudEvent 0.3](https://github.com/cloudevents/spec/tree/v0.3)
16-
and [CloudEvents 1.0](https://github.com/cloudevents/spec/tree/v1.0)
16+
and [CloudEvents 1.0](https://github.com/cloudevents/spec/tree/v1.0.1)
1717
specifications.
1818
* Extensible to additional formats and protocol bindings, and future
1919
specification versions.
@@ -35,7 +35,7 @@ A simple [Sinatra](https://sinatrarb.com) app that receives CloudEvents:
3535
```ruby
3636
# examples/server/Gemfile
3737
source "https://rubygems.org"
38-
gem "cloud_events", "~> 0.2"
38+
gem "cloud_events", "~> 0.5"
3939
gem "sinatra", "~> 2.0"
4040
```
4141

@@ -59,7 +59,7 @@ A simple Ruby script that sends a CloudEvent:
5959
```ruby
6060
# examples/client/Gemfile
6161
source "https://rubygems.org"
62-
gem "cloud_events", "~> 0.2"
62+
gem "cloud_events", "~> 0.5"
6363
```
6464

6565
```ruby
@@ -69,14 +69,16 @@ require "net/http"
6969
require "uri"
7070

7171
data = { message: "Hello, CloudEvents!" }
72-
event = CloudEvents::Event.create spec_version: "1.0",
73-
id: "1234-1234-1234",
74-
source: "/mycontext",
75-
type: "com.example.someevent",
76-
data: data
72+
event = CloudEvents::Event.create \
73+
spec_version: "1.0",
74+
id: "1234-1234-1234",
75+
source: "/mycontext",
76+
type: "com.example.someevent",
77+
data_content_type: "application/json",
78+
data: data
7779

7880
cloud_events_http = CloudEvents::HttpBinding.default
79-
headers, body = cloud_events_http.encode_binary_content event
81+
headers, body = cloud_events_http.encode_event event
8082
Net::HTTP.post URI("http://localhost:4567"), body, headers
8183
```
8284

examples/client/send.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
require "uri"
44

55
data = { message: "Hello, CloudEvents!" }
6-
event = CloudEvents::Event.create spec_version: "1.0",
7-
id: "1234-1234-1234",
8-
source: "/mycontext",
9-
type: "com.example.someevent",
10-
data: data
6+
event = CloudEvents::Event.create \
7+
spec_version: "1.0",
8+
id: "1234-1234-1234",
9+
source: "/mycontext",
10+
type: "com.example.someevent",
11+
data_content_type: "application/json",
12+
data: data
1113

1214
cloud_events_http = CloudEvents::HttpBinding.default
13-
headers, body = cloud_events_http.encode_binary_content event
15+
headers, body = cloud_events_http.encode_event event
1416
Net::HTTP.post URI("http://localhost:4567"), body, headers

lib/cloud_events/http_binding.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class HttpBinding
2323
##
2424
# Returns a default HTTP binding, including support for JSON format.
2525
#
26+
# @return [HttpBinding]
27+
#
2628
def self.default
2729
@default ||= begin
2830
http_binding = new
@@ -53,6 +55,7 @@ def initialize
5355
# @param name [String] The encoder name under which this formatter will
5456
# register its encode operations. Optional. If not specified, any event
5557
# encoder will _not_ be registered.
58+
# @return [self]
5659
#
5760
def register_formatter formatter, name = nil
5861
name = name.to_s.strip.downcase if name
@@ -82,6 +85,7 @@ def register_formatter formatter, name = nil
8285
# {CloudEvents::Format#decode_data} method.
8386
# @param encode_data [boolean] If true, register the formatter's
8487
# {CloudEvents::Format#encode_data} method.
88+
# @return [self]
8589
#
8690
def register_formatter_methods formatter,
8791
decode_event: false,

0 commit comments

Comments
 (0)