interop 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: 3354d110f9c8fd23ec9681841e3403ec92b57d1d8247b2b856795f52344cc387
4
- data.tar.gz: a9ecc3aaa1428509a120c7cfba1582ff28a237abbe86898ab0a31b034e8dfd76
3
+ metadata.gz: d87e7c23c67f9e2d514ff393cee8789856588ff4b399e51305008608d9e9d316
4
+ data.tar.gz: bbb0a45add6f441698a5f4d07016d9613b36f3273f51c891894742090fce6769
5
5
  SHA512:
6
- metadata.gz: 238204d49f14974ee72c8ece083866204a187788e55f3f3ad9047bf697f085480561d6f632cd183914c923605ca190cbdd6ac31b51d5cc0e9179bec149c556a3
7
- data.tar.gz: 1aa9d43425c0f37a5671947a88448289c9d9bf3775a261e7d8fbf0bca99e34909c0364bb1148fcbf47b3d6643abe75dc7558bde358be6f4906973f0b4a579cff
6
+ metadata.gz: 0fce7c36089b584c1b2496705ff4dec7e1902db1e965327fc50fded4c26483a6fc4733021287d7c262754cae2abf4da663a464a579b848242d883c023a957a3f
7
+ data.tar.gz: fc4a78d74b5af7eb5aad0ac5aaa1a8972a720a535ab233587e26c0f5f0a9e689fcb7a85450f9a6436e216c52aaaee88ddb2eac2f797328a632f28da28567e742
@@ -53,7 +53,7 @@ module Hx
53
53
  end
54
54
 
55
55
  # @param [ContentType, ContentTypes] decoder
56
- def decode(decoder)
56
+ def decode(decoder = ContentType::STANDARD)
57
57
  decoder.decode self
58
58
  end
59
59
 
@@ -0,0 +1,17 @@
1
+ module Hx
2
+ module Interop
3
+ # Base class for StreamReader and StreamWriter
4
+ class StreamAdapter
5
+ # @param [IO, StringIO] stream
6
+ def initialize(stream)
7
+ if stream.is_a? IO
8
+ stream.sync = true
9
+ stream.binmode
10
+ end
11
+
12
+ @stream = stream
13
+ @mutex = Mutex.new
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,22 +2,17 @@ require 'set'
2
2
 
3
3
  require 'interop/message'
4
4
  require 'interop/reader'
5
+ require 'interop/stream_adapter'
5
6
 
6
7
  module Hx
7
8
  module Interop
8
9
  # Reads messages from a stream (e.g. STDIN)
9
- class StreamReader
10
+ class StreamReader < StreamAdapter
10
11
  include Reader
11
12
 
12
13
  # Acceptable line terminators
13
14
  NEWLINES = Set.new(%W[\n \r\n]).freeze
14
15
 
15
- # @param [IO, StringIO] stream
16
- def initialize(stream)
17
- @stream = stream
18
- @mutex = Mutex.new
19
- end
20
-
21
16
  protected
22
17
 
23
18
  def _read
@@ -1,18 +1,13 @@
1
1
  require 'interop/message'
2
2
  require 'interop/writer'
3
+ require 'interop/stream_adapter'
3
4
 
4
5
  module Hx
5
6
  module Interop
6
7
  # Writes messages to a stream (e.g. STDOUT)
7
- class StreamWriter
8
+ class StreamWriter < StreamAdapter
8
9
  include Writer
9
10
 
10
- # @param [IO, StringIO] stream
11
- def initialize(stream)
12
- @stream = stream
13
- @mutex = Mutex.new
14
- end
15
-
16
11
  protected
17
12
 
18
13
  # @param [Message] message
@@ -1,5 +1,5 @@
1
1
  module Hx
2
2
  module Interop
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.3.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interop
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
  - Neil E. Pearson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-19 00:00:00.000000000 Z
11
+ date: 2021-10-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby implementation of hx/interop cross-language interop abstraction
14
14
  email:
@@ -40,6 +40,7 @@ files:
40
40
  - lib/interop/rpc/dispatcher.rb
41
41
  - lib/interop/rpc/magic.rb
42
42
  - lib/interop/rpc/server.rb
43
+ - lib/interop/stream_adapter.rb
43
44
  - lib/interop/stream_reader.rb
44
45
  - lib/interop/stream_writer.rb
45
46
  - lib/interop/version.rb