cloud_events 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 561f1577a53c99db91573da43e0caa899add4388169a8c4784910dbfb3ae94d7
4
- data.tar.gz: eb936cd23fbbd2b2658ec8a5c52ad5857c50b8f81019e15f341bdeb89346d037
3
+ metadata.gz: 7449de71a0d20b1c7fa726bbb850080c977299ebb92c3c52ecc04c3acaa65a0c
4
+ data.tar.gz: 60c0bfa47f39b3c4a10d12122c57d2ee2b26e75f4a82bc0622033275a5866946
5
5
  SHA512:
6
- metadata.gz: 0c702c7b33d247b38c9ef8c46dc0d0ef3253d5ffe5d6e8ba7ba6043a0d0f597b748c40514bbe94f0836c150d5f7336e67005f550bbabe6ecfefd73b6f9925ff0
7
- data.tar.gz: f765051aec3c216b36eafdd082f771701d8647d7c4cead2489a61370fb598390fb5d7f43b138a7ab0af91a039d4a88e36c9f4897e91d37650220b474260c9d3d
6
+ metadata.gz: ba15c5d5fd8fd432b39a861297c57f04c659f0329783ad8a02f30c60f839836438df4371937d4d063f14bef326e45741140690be854dc2f8865c3defbb948074
7
+ data.tar.gz: 05cca16a9b8436a8cf7e7a23189d6873fbc322dbd177cd5d71886081a2a116d75ccb2215bc8c112a013976d769691ab0be96ab41b2d16e4acb57948c9aa7b8fc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ### v0.3.1 / 2021-04-25
4
+
5
+ * FIXED: Fixed exception when decoding from a rack source that uses InputWrapper
6
+ * FIXED: Fixed equality checking for V0 events
7
+
3
8
  ### v0.3.0 / 2021-03-02
4
9
 
5
10
  * ADDED: Require Ruby 2.5 or later
@@ -221,7 +221,7 @@ module CloudEvents
221
221
 
222
222
  ## @private
223
223
  def == other
224
- other.is_a?(V1) && @attributes == other.instance_variable_get(:@attributes)
224
+ other.is_a?(V0) && @attributes == other.instance_variable_get(:@attributes)
225
225
  end
226
226
  alias eql? ==
227
227
 
@@ -89,11 +89,11 @@ module CloudEvents
89
89
  if input && content_type&.media_type == "application"
90
90
  case content_type.subtype_base
91
91
  when "cloudevents"
92
- input.set_encoding content_type.charset if content_type.charset
93
- return decode_structured_content input.read, content_type.subtype_format, **format_args
92
+ content = read_with_charset input, content_type.charset
93
+ return decode_structured_content content, content_type.subtype_format, **format_args
94
94
  when "cloudevents-batch"
95
- input.set_encoding content_type.charset if content_type.charset
96
- return decode_batched_content input.read, content_type.subtype_format, **format_args
95
+ content = read_with_charset input, content_type.charset
96
+ return decode_batched_content content, content_type.subtype_format, **format_args
97
97
  end
98
98
  end
99
99
  decode_binary_content env, content_type
@@ -152,10 +152,7 @@ module CloudEvents
152
152
  return nil if spec_version.nil?
153
153
  raise SpecVersionError, "Unrecognized specversion: #{spec_version}" unless spec_version == "1.0"
154
154
  input = env["rack.input"]
155
- data = if input
156
- input.set_encoding content_type.charset if content_type&.charset
157
- input.read
158
- end
155
+ data = read_with_charset input, content_type&.charset if input
159
156
  attributes = { "spec_version" => spec_version, "data" => data }
160
157
  attributes["data_content_type"] = content_type if content_type
161
158
  omit_names = ["specversion", "spec_version", "data", "datacontenttype", "data_content_type"]
@@ -289,6 +286,18 @@ module CloudEvents
289
286
 
290
287
  private
291
288
 
289
+ def read_with_charset io, charset
290
+ str = io.read
291
+ if charset
292
+ begin
293
+ str.force_encoding charset
294
+ rescue ::ArgumentError
295
+ # Do nothing for now if the charset is unrecognized
296
+ end
297
+ end
298
+ str
299
+ end
300
+
292
301
  def string_content_type str
293
302
  if str.encoding == ::Encoding.ASCII_8BIT
294
303
  "application/octet-stream"
@@ -5,5 +5,5 @@ module CloudEvents
5
5
  # Version of the Ruby CloudEvents SDK
6
6
  # @return [String]
7
7
  #
8
- VERSION = "0.3.0"
8
+ VERSION = "0.3.1"
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2021-04-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The official Ruby implementation of the CloudEvents Specification. Provides
14
14
  data types for events, and HTTP/JSON bindings for marshalling and unmarshalling
@@ -38,10 +38,10 @@ homepage: https://github.com/cloudevents/sdk-ruby
38
38
  licenses:
39
39
  - Apache-2.0
40
40
  metadata:
41
- changelog_uri: https://cloudevents.github.io/sdk-ruby/v0.3.0/file.CHANGELOG.html
41
+ changelog_uri: https://cloudevents.github.io/sdk-ruby/v0.3.1/file.CHANGELOG.html
42
42
  source_code_uri: https://github.com/cloudevents/sdk-ruby
43
43
  bug_tracker_uri: https://github.com/cloudevents/sdk-ruby/issues
44
- documentation_uri: https://cloudevents.github.io/sdk-ruby/v0.3.0
44
+ documentation_uri: https://cloudevents.github.io/sdk-ruby/v0.3.1
45
45
  post_install_message:
46
46
  rdoc_options: []
47
47
  require_paths:
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.1.4
60
+ rubygems_version: 3.1.6
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: Ruby SDK for CloudEvents