Skip to content

Commit

Permalink
fix: Update CloudEvents dependency (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuma authored Jun 28, 2021
1 parent 4239f18 commit 95703e7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Create a `Gemfile` listing the Functions Framework as a dependency:
```ruby
# Gemfile
source "https://rubygems.org"
gem "functions_framework", "~> 0.10"
gem "functions_framework", "~> 0.11"
```

Create a file called `app.rb` and include the following code. This defines a
Expand Down
2 changes: 1 addition & 1 deletion docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Create a `Gemfile` listing the Functions Framework as a dependency:
```ruby
# Gemfile
source "https://rubygems.org"
gem "functions_framework", "~> 0.10"
gem "functions_framework", "~> 0.11"
```

Create a file called `app.rb` and include the following code. This defines a
Expand Down
4 changes: 2 additions & 2 deletions docs/writing-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ dependency on Sinatra in your `Gemfile`:

```ruby
source "https://rubygems.org"
gem "functions_framework", "~> 0.10"
gem "functions_framework", "~> 0.11"
gem "sinatra", "~> 2.0"
```

Expand Down Expand Up @@ -470,7 +470,7 @@ Following is a typical layout for a Functions Framework based project.
```ruby
# Gemfile
source "https://rubygems.org"
gem "functions_framework", "~> 0.10"
gem "functions_framework", "~> 0.11"
```

```ruby
Expand Down
2 changes: 1 addition & 1 deletion functions_framework.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ version = ::FunctionsFramework::VERSION
spec.executables = ["functions-framework", "functions-framework-ruby"]

spec.required_ruby_version = ">= 2.5.0"
spec.add_dependency "cloud_events", ">= 0.4", "< 2.a"
spec.add_dependency "cloud_events", ">= 0.5.1", "< 2.a"
spec.add_dependency "puma", ">= 4.3.0", "< 6.a"
spec.add_dependency "rack", "~> 2.1"

Expand Down
10 changes: 7 additions & 3 deletions lib/functions_framework/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def call env
when ::CloudEvents::Event
handle_cloud_event event, logger
when ::Array
::CloudEvents::HttpContentError.new "Batched CloudEvents are not supported"
::CloudEvents::CloudEventsError.new "Batched CloudEvents are not supported"
when ::CloudEvents::CloudEventsError
event
else
Expand All @@ -443,9 +443,13 @@ def call env
private

def decode_event env
@cloud_events.decode_rack_env(env) ||
begin
@cloud_events.decode_event env
rescue ::CloudEvents::NotCloudEventError
env["rack.input"].rewind rescue nil
@legacy_events.decode_rack_env(env) ||
raise(::CloudEvents::HttpContentError, "Unrecognized event format")
raise(::CloudEvents::CloudEventsError, "Unrecognized event format")
end
rescue ::CloudEvents::CloudEventsError => e
e
end
Expand Down
3 changes: 2 additions & 1 deletion test/conformance/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
end

json_format = CloudEvents::JsonFormat.new
File.write OUTPUT_FILE, json_format.encode(event)
result = json_format.encode_event event: event
File.write OUTPUT_FILE, result[:content]
end
2 changes: 1 addition & 1 deletion test/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
let(:port) { 8077 }
let(:server_url) { "http://127.0.0.1:#{port}" }
let(:quiet_logger) {
logger = ::Logger.new $stdout
logger = ::Logger.new $stderr
logger.level = ::Logger::FATAL
logger
}
Expand Down

0 comments on commit 95703e7

Please sign in to comment.