cloud_events 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/cloud_events/content_type.rb +25 -10
- data/lib/cloud_events/event/opaque.rb +1 -1
- data/lib/cloud_events/format.rb +1 -1
- data/lib/cloud_events/text_format.rb +1 -1
- data/lib/cloud_events/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a711fe27eaab25a87e694f6436b2c34506b3a776457a77583c3f0f4bb0744ed
|
|
4
|
+
data.tar.gz: 01e81b176023ca2369999d2257c3157d4cef267ff0951e09a2df09f2848af0f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 96e2b1892b58bd5944d506ffff3e30a899fcb1bc03c31018637788cc8772def582e258b31f35786ebad8d054f22bfcbf2fdbe98e573ff098c2f89e2d8da4e1a0
|
|
7
|
+
data.tar.gz: e058c5c54f57224d02d42c9f52d7a320ef319b72573aa0d162f2362e06a0294bdd1f81f7705d55f47b40d8eadf418de85efb09c68c797978fcf0e5b49c91c1f4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### v0.8.3 / 2026-01-15
|
|
4
|
+
|
|
5
|
+
* FIXED: Fixed default charset behavior for various non-text/plain content types
|
|
6
|
+
|
|
7
|
+
### v0.8.2 / 2025-11-30
|
|
8
|
+
|
|
9
|
+
* DOCS: Fixed a few typos in documentation and error messages
|
|
10
|
+
|
|
3
11
|
### v0.8.1 / 2025-11-10
|
|
4
12
|
|
|
5
13
|
* DOCS: Some minor updates and corrections to the README and examples
|
|
@@ -22,17 +22,15 @@ module CloudEvents
|
|
|
22
22
|
#
|
|
23
23
|
# @param string [String] Content-Type header value in RFC 2045 format
|
|
24
24
|
# @param default_charset [String] Optional. The charset to use if none is
|
|
25
|
-
# specified. Defaults to `
|
|
25
|
+
# specified. Defaults to `utf-8` for all types other than `text/plain`
|
|
26
|
+
# for which it defaults to `us-ascii`.
|
|
26
27
|
#
|
|
27
28
|
def initialize(string, default_charset: nil)
|
|
28
29
|
@string = string.to_s
|
|
29
|
-
@media_type =
|
|
30
|
-
@subtype_base = @subtype = "plain"
|
|
31
|
-
@subtype_format = nil
|
|
30
|
+
@media_type = @subtype = @subtype_base = @subtype_format = @charset = nil
|
|
32
31
|
@params = []
|
|
33
|
-
@charset = default_charset || "us-ascii"
|
|
34
32
|
@error_message = nil
|
|
35
|
-
parse(consume_comments(@string.strip))
|
|
33
|
+
parse(consume_comments(@string.strip), default_charset)
|
|
36
34
|
@canonical_string = "#{@media_type}/#{@subtype}" +
|
|
37
35
|
@params.map { |k, v| "; #{k}=#{maybe_quote(v)}" }.join
|
|
38
36
|
full_freeze
|
|
@@ -86,8 +84,10 @@ module CloudEvents
|
|
|
86
84
|
attr_reader :params
|
|
87
85
|
|
|
88
86
|
##
|
|
89
|
-
#
|
|
90
|
-
#
|
|
87
|
+
# Returns the charset, which may be an appropriate default (e.g. `us-ascii`
|
|
88
|
+
# for `text/plain`, or `utf-8` for `application/json`), or may be nil for
|
|
89
|
+
# non-text cases.
|
|
90
|
+
# @return [String,nil]
|
|
91
91
|
#
|
|
92
92
|
attr_reader :charset
|
|
93
93
|
|
|
@@ -124,14 +124,14 @@ module CloudEvents
|
|
|
124
124
|
|
|
125
125
|
private
|
|
126
126
|
|
|
127
|
-
def parse(str)
|
|
127
|
+
def parse(str, default_charset)
|
|
128
128
|
@media_type, str = consume_token(str, downcase: true, error_message: "Failed to parse media type")
|
|
129
129
|
str = consume_special(str, "/")
|
|
130
130
|
@subtype, str = consume_token(str, downcase: true, error_message: "Failed to parse subtype")
|
|
131
131
|
@subtype_base, @subtype_format = @subtype.split("+", 2)
|
|
132
132
|
until str.empty?
|
|
133
133
|
str = consume_special(str, ";")
|
|
134
|
-
name, str = consume_token(str, downcase: true, error_message: "
|
|
134
|
+
name, str = consume_token(str, downcase: true, error_message: "Failed to parse attribute name")
|
|
135
135
|
str = consume_special(str, "=", error_message: "Failed to find value for attribute #{name}")
|
|
136
136
|
val, str = consume_token_or_quoted(str, error_message: "Failed to parse value for attribute #{name}")
|
|
137
137
|
@params << [name, val]
|
|
@@ -139,6 +139,13 @@ module CloudEvents
|
|
|
139
139
|
end
|
|
140
140
|
rescue ParseError => e
|
|
141
141
|
@error_message = e.message
|
|
142
|
+
ensure
|
|
143
|
+
unless @subtype
|
|
144
|
+
@media_type = "text"
|
|
145
|
+
@subtype_base = @subtype = "plain"
|
|
146
|
+
@subtype_format = nil
|
|
147
|
+
end
|
|
148
|
+
@charset ||= default_charset || choose_default_charset
|
|
142
149
|
end
|
|
143
150
|
|
|
144
151
|
def consume_token(str, downcase: false, error_message: nil)
|
|
@@ -210,6 +217,14 @@ module CloudEvents
|
|
|
210
217
|
"\"#{str}\""
|
|
211
218
|
end
|
|
212
219
|
|
|
220
|
+
def choose_default_charset
|
|
221
|
+
if @media_type == "text" && @subtype == "plain"
|
|
222
|
+
"us-ascii"
|
|
223
|
+
elsif @media_type == "text" || @subtype_base == "json" || @subtype_format == "json"
|
|
224
|
+
"utf-8"
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
213
228
|
def full_freeze
|
|
214
229
|
instance_variables.each do |iv|
|
|
215
230
|
instance_variable_get(iv).freeze
|
|
@@ -8,7 +8,7 @@ module CloudEvents
|
|
|
8
8
|
# single event or a batch of events.
|
|
9
9
|
#
|
|
10
10
|
# The event data is retained in a form that can be reserialized (in a
|
|
11
|
-
# structured
|
|
11
|
+
# structured content mode in the same format) but cannot otherwise be
|
|
12
12
|
# inspected.
|
|
13
13
|
#
|
|
14
14
|
# This object is immutable, and Ractor-shareable on Ruby 3.
|
data/lib/cloud_events/format.rb
CHANGED
|
@@ -30,7 +30,7 @@ module CloudEvents
|
|
|
30
30
|
#
|
|
31
31
|
# Both the keyword arguments recognized and the returned hash members may
|
|
32
32
|
# vary from formatter to formatter; similarly, the keyword arguments provided
|
|
33
|
-
# and the
|
|
33
|
+
# and the returned hash members recognized may also vary for different
|
|
34
34
|
# callers. This interface will define a set of common argument and result key
|
|
35
35
|
# names, but both callers and formatters must gracefully handle the case of
|
|
36
36
|
# missing or extra information. For example, if a formatter expects a certain
|
|
@@ -37,7 +37,7 @@ module CloudEvents
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
##
|
|
40
|
-
# Trivially an event data object using text format.
|
|
40
|
+
# Trivially encode an event data object using text format.
|
|
41
41
|
# See {CloudEvents::Format#encode_data} for a general description.
|
|
42
42
|
#
|
|
43
43
|
# Expects `:data` and `:content_type` arguments, and will decline the
|
data/lib/cloud_events/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloud_events
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Azuma
|
|
@@ -42,10 +42,10 @@ homepage: https://github.com/cloudevents/sdk-ruby
|
|
|
42
42
|
licenses:
|
|
43
43
|
- Apache-2.0
|
|
44
44
|
metadata:
|
|
45
|
-
changelog_uri: https://cloudevents.github.io/sdk-ruby/v0.8.
|
|
45
|
+
changelog_uri: https://cloudevents.github.io/sdk-ruby/v0.8.3/file.CHANGELOG.html
|
|
46
46
|
source_code_uri: https://github.com/cloudevents/sdk-ruby
|
|
47
47
|
bug_tracker_uri: https://github.com/cloudevents/sdk-ruby/issues
|
|
48
|
-
documentation_uri: https://cloudevents.github.io/sdk-ruby/v0.8.
|
|
48
|
+
documentation_uri: https://cloudevents.github.io/sdk-ruby/v0.8.3
|
|
49
49
|
rdoc_options: []
|
|
50
50
|
require_paths:
|
|
51
51
|
- lib
|
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0'
|
|
62
62
|
requirements: []
|
|
63
|
-
rubygems_version:
|
|
63
|
+
rubygems_version: 4.0.3
|
|
64
64
|
specification_version: 4
|
|
65
65
|
summary: Ruby SDK for CloudEvents
|
|
66
66
|
test_files: []
|