feedx 0.7.0 → 0.7.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: b306ae446c9cae375b6ad538cc41d88a621bbb5cb59d9adf5aa114326567b2ca
4
- data.tar.gz: 218b0aabdf6d1dda76e520b226f7d211a27ba14421db4ed8e34a9f59451e1e20
3
+ metadata.gz: 2769dc5b097e9d5c17d467070cd3fa638ab7573f7e3cd310843c5c023a84aa5c
4
+ data.tar.gz: 6edf76ff62393e0ea29aa7a3b8c74fb66d2a0328ddcf4a256f6fda297806f6f3
5
5
  SHA512:
6
- metadata.gz: 246d39971aa5d6fe96267b95fba832f90d24ae8c8a16c4ea949fb3bca3f8777fd036e311f8d5f97b7cfed301b3782c2035e4e4ba1b62b7373e1f1e7d090ab00d
7
- data.tar.gz: a151e2c9cde8820505912ceca55afa58f3a44cb25581eda9b66f830e057fe1254093c93ad5be77848fa8e3b0033d14885cb4a412bb4308bf0109b2bb57a47771
6
+ metadata.gz: 27c60344dfd2fab31e8c38f0a2368440e43ed5ab698b3df16dfb7820625f6d6646bdfc81211ce3c9c15ec9ffd44a12cea8b33fbaa357bc5cc664d1bf7d0599ad
7
+ data.tar.gz: db9073b92564898bb535e725f09c32e76c07f32a050da2ad7bf7d513c4fdf8e6402c8733dc1de53238e528bc2986c18e2635ae0e16e006052b6827de350fcd13
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feedx (0.7.0)
4
+ feedx (0.7.1)
5
5
  bfs (>= 0.3.4)
6
6
 
7
7
  GEM
@@ -10,7 +10,7 @@ GEM
10
10
  ast (2.4.0)
11
11
  bfs (0.3.7)
12
12
  diff-lcs (1.3)
13
- google-protobuf (3.8.0.rc.1)
13
+ google-protobuf (3.8.0)
14
14
  jaro_winkler (1.5.2)
15
15
  parallel (1.17.0)
16
16
  parser (2.6.3.0)
@@ -25,14 +25,14 @@ GEM
25
25
  rspec-mocks (~> 3.8.0)
26
26
  rspec-core (3.8.0)
27
27
  rspec-support (~> 3.8.0)
28
- rspec-expectations (3.8.3)
28
+ rspec-expectations (3.8.4)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
30
  rspec-support (~> 3.8.0)
31
31
  rspec-mocks (3.8.0)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.8.0)
34
- rspec-support (3.8.0)
35
- rubocop (0.70.0)
34
+ rspec-support (3.8.2)
35
+ rubocop (0.71.0)
36
36
  jaro_winkler (~> 1.5.1)
37
37
  parallel (~> 1.10)
38
38
  parser (>= 2.6)
@@ -41,7 +41,7 @@ GEM
41
41
  unicode-display_width (>= 1.4.0, < 1.7)
42
42
  rubocop-performance (1.3.0)
43
43
  rubocop (>= 0.68.0)
44
- ruby-progressbar (1.10.0)
44
+ ruby-progressbar (1.10.1)
45
45
  unicode-display_width (1.6.0)
46
46
 
47
47
  PLATFORMS
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'feedx'
3
- s.version = '0.7.0'
3
+ s.version = '0.7.1'
4
4
  s.authors = ['Black Square Media Ltd']
5
5
  s.email = ['info@blacksquaremedia.com']
6
6
  s.summary = %(Exchange data between components via feeds)
@@ -7,11 +7,19 @@ class Feedx::Format::Abstract
7
7
  @io.eof?
8
8
  end
9
9
 
10
- def decode(_klass)
10
+ def decode_each(klass, **opts)
11
+ if block_given?
12
+ yield decode(klass, opts) until eof?
13
+ else
14
+ Enumerator.new {|y| y << decode(klass, opts) until eof? }
15
+ end
16
+ end
17
+
18
+ def decode(_klass, **)
11
19
  raise 'Not implemented'
12
20
  end
13
21
 
14
- def encode(_msg)
22
+ def encode(_msg, **)
15
23
  raise 'Not implemented'
16
24
  end
17
25
  end
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
3
  class Feedx::Format::JSON < Feedx::Format::Abstract
4
- def decode(obj)
4
+ def decode(obj, **)
5
5
  line = @io.gets
6
6
  return unless line
7
7
 
@@ -10,7 +10,7 @@ class Feedx::Format::JSON < Feedx::Format::Abstract
10
10
  obj
11
11
  end
12
12
 
13
- def encode(msg)
13
+ def encode(msg, **)
14
14
  @io.write msg.to_json << "\n"
15
15
  end
16
16
  end
@@ -5,12 +5,12 @@ class Feedx::Format::Protobuf < Feedx::Format::Abstract
5
5
  super PBIO::Delimited.new(io)
6
6
  end
7
7
 
8
- def decode(klass)
8
+ def decode(klass, **)
9
9
  @io.read(klass)
10
10
  end
11
11
 
12
- def encode(msg)
13
- msg = msg.to_pb if msg.respond_to?(:to_pb)
12
+ def encode(msg, **opts)
13
+ msg = msg.to_pb(**opts) if msg.respond_to?(:to_pb)
14
14
  @io.write msg
15
15
  end
16
16
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Feedx::Format::Abstract do
4
+ subject { Feedx::Format::JSON.new(wio) }
5
+ let(:wio) { StringIO.new }
6
+
7
+ it 'should decode each' do
8
+ subject.encode(Feedx::TestCase::Model.new('X'))
9
+ subject.encode(Feedx::TestCase::Model.new('Y'))
10
+ subject.encode(Feedx::TestCase::Message.new(title: 'Z'))
11
+ StringIO.open(wio.string) do |rio|
12
+ fmt = subject.class.new(rio)
13
+ dec = fmt.decode_each(Feedx::TestCase::Model).to_a
14
+ expect(dec.map(&:title)).to eq(%w[X Y Z])
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-23 00:00:00.000000000 Z
11
+ date: 2019-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bfs
@@ -155,6 +155,7 @@ files:
155
155
  - spec/feedx/compression/gzip_spec.rb
156
156
  - spec/feedx/compression/none_spec.rb
157
157
  - spec/feedx/compression_spec.rb
158
+ - spec/feedx/format/abstract_spec.rb
158
159
  - spec/feedx/format/json_spec.rb
159
160
  - spec/feedx/format/protobuf_spec.rb
160
161
  - spec/feedx/format_spec.rb
@@ -190,6 +191,7 @@ test_files:
190
191
  - spec/feedx/compression/gzip_spec.rb
191
192
  - spec/feedx/compression/none_spec.rb
192
193
  - spec/feedx/compression_spec.rb
194
+ - spec/feedx/format/abstract_spec.rb
193
195
  - spec/feedx/format/json_spec.rb
194
196
  - spec/feedx/format/protobuf_spec.rb
195
197
  - spec/feedx/format_spec.rb