cucumber-messages 15.0.0 → 17.0.1
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/README.md +1 -1
- data/VERSION +1 -1
- data/lib/cucumber/messages.deserializers.rb +1180 -0
- data/lib/cucumber/messages.dtos.rb +1911 -0
- data/lib/cucumber/messages.rb +2 -9
- data/lib/cucumber/messages/message.rb +11 -0
- data/lib/cucumber/messages/message/deserialization.rb +39 -0
- data/lib/cucumber/messages/message/serialization.rb +73 -0
- data/lib/cucumber/messages/message/utils.rb +46 -0
- data/lib/cucumber/messages/ndjson_to_message_enumerator.rb +2 -2
- data/lib/cucumber/messages/time_conversion.rb +11 -8
- data/spec/cucumber/messages/acceptance_spec.rb +27 -0
- data/spec/cucumber/messages/message/deserialization_spec.rb +30 -0
- data/spec/cucumber/messages/message/dummy_messages.rb +38 -0
- data/spec/cucumber/messages/message/serialization_spec.rb +89 -0
- data/spec/cucumber/messages/message/utils_spec.rb +30 -0
- data/spec/cucumber/messages/ndjson_serialization_spec.rb +13 -72
- data/spec/cucumber/messages/time_conversion_spec.rb +8 -0
- metadata +24 -35
- data/lib/cucumber/messages.pb.rb +0 -525
- data/lib/cucumber/messages/binary_to_message_enumerator.rb +0 -15
- data/lib/cucumber/messages/protobuf_delimited.rb +0 -21
- data/lib/cucumber/messages/protobuf_ndjson.rb +0 -12
- data/lib/cucumber/messages/varint.rb +0 -37
- data/spec/cucumber/messages/protobuf_serialization_spec.rb +0 -29
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'cucumber/messages/varint'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Messages
|
5
|
-
class BinaryToMessageEnumerator < Enumerator
|
6
|
-
def initialize(io)
|
7
|
-
super() do |yielder|
|
8
|
-
while !io.eof?
|
9
|
-
yielder.yield(Cucumber::Messages::Envelope.parse_delimited_from(io))
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'cucumber/messages/varint'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Messages
|
5
|
-
module WriteDelimited
|
6
|
-
def write_delimited_to(io)
|
7
|
-
proto = self.class.encode(self)
|
8
|
-
Varint.encode_varint(io, proto.length)
|
9
|
-
io.write(proto)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module ParseDelimited
|
14
|
-
def parse_delimited_from(io)
|
15
|
-
len = Varint.decode_varint(io)
|
16
|
-
buf = io.read(len)
|
17
|
-
self.decode(buf)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Messages
|
3
|
-
# Varint (variable byte-length int) is an encoding format commonly used
|
4
|
-
# to encode the length of Protocol Buffer message frames.
|
5
|
-
module Varint
|
6
|
-
|
7
|
-
def self.decode_varint(io)
|
8
|
-
# https://github.com/ruby-protobuf/protobuf/blob/master/lib/protobuf/varint_pure.rb
|
9
|
-
value = index = 0
|
10
|
-
begin
|
11
|
-
byte = io.readbyte
|
12
|
-
value |= (byte & 0x7f) << (7 * index)
|
13
|
-
index += 1
|
14
|
-
end while (byte & 0x80).nonzero?
|
15
|
-
value
|
16
|
-
end
|
17
|
-
|
18
|
-
# https://www.rubydoc.info/gems/ruby-protocol-buffers/1.2.2/ProtocolBuffers%2FVarint.encode
|
19
|
-
def self.encode_varint(io, int_val)
|
20
|
-
if int_val < 0
|
21
|
-
# negative varints are always encoded with the full 10 bytes
|
22
|
-
int_val = int_val & 0xffffffff_ffffffff
|
23
|
-
end
|
24
|
-
loop do
|
25
|
-
byte = int_val & 0x7f
|
26
|
-
int_val >>= 7
|
27
|
-
if int_val == 0
|
28
|
-
io << byte.chr
|
29
|
-
break
|
30
|
-
else
|
31
|
-
io << (byte | 0x80).chr
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'cucumber/messages'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Messages
|
5
|
-
describe Messages do
|
6
|
-
|
7
|
-
it "can be serialised over a binary stream" do
|
8
|
-
outgoing_messages = [
|
9
|
-
Envelope.new(source: Source.new(data: 'Feature: Hello')),
|
10
|
-
Envelope.new(attachment: Attachment.new(body: "JALLA"))
|
11
|
-
]
|
12
|
-
|
13
|
-
io = StringIO.new
|
14
|
-
write_outgoing_messages(outgoing_messages, io)
|
15
|
-
|
16
|
-
io.rewind
|
17
|
-
incoming_messages = BinaryToMessageEnumerator.new(io)
|
18
|
-
|
19
|
-
expect(incoming_messages.to_a).to(eq(outgoing_messages))
|
20
|
-
end
|
21
|
-
|
22
|
-
def write_outgoing_messages(messages, out)
|
23
|
-
messages.each do |message|
|
24
|
-
message.write_delimited_to(out)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|