feedx 0.9.0 → 0.9.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bc9eeecc2bf0ab3dbe9f3ff113908dea8a8dd666ac5dd07d16a71f0558af1ea
4
- data.tar.gz: f9c939c92f7582f7e5b812112f51ccf6f3d153755121d45b381e9374df209d31
3
+ metadata.gz: c6a031f3dd500b1d022708f6997ce6b99fc1ca764c58d0d1a2d5c49430797975
4
+ data.tar.gz: 3cb5fa9951cd4918bb9191c8c644cb422b9c9d9a00944b5f68afc247b80a5935
5
5
  SHA512:
6
- metadata.gz: 7011a7c08a47c6a747b3faee003625bfa998bb634f60dfa05f530deabbcba334c269f47b22d95d284335ce1fa63cb96ac2c134f7faf690483962ffd0214922c7
7
- data.tar.gz: 5c42b111a8d440ec945939c923dc8fcfbc011964787154b240ae73309e7f0c6fe784f249ecba7b6001740f201460adf660ad72528e817d2546f457481e99fae4
6
+ metadata.gz: b2e0b49aafcc5b0f8ddad15b7738f815d097057ed205709a19ce8f734f1aaa50aaf10add1d580412c4fb673decb706c6a73094f8fb6d624e5de15a95c21c74a0
7
+ data.tar.gz: 96130e3b806c74c719fe6d31cbb4c3dcaa1dcbbdbb80e7a417df9d54a478b1eec166f6b4abeb4f665bf4c37c1f26a6640baaef3a9d3fb4c11afe233c6538a3a3
@@ -15,8 +15,3 @@ matrix:
15
15
  - 1.13.x
16
16
  env:
17
17
  - GO111MODULE=on
18
- - language: go
19
- go:
20
- - 1.12.x
21
- env:
22
- - GO111MODULE=on
@@ -1,45 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feedx (0.9.0)
4
+ feedx (0.9.2)
5
5
  bfs (>= 0.5.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.0)
11
- bfs (0.5.1)
11
+ bfs (0.6.0)
12
12
  diff-lcs (1.3)
13
- google-protobuf (3.10.0.rc.1)
14
- jaro_winkler (1.5.3)
15
- parallel (1.18.0)
16
- parser (2.6.5.0)
13
+ google-protobuf (3.11.2)
14
+ jaro_winkler (1.5.4)
15
+ parallel (1.19.1)
16
+ parser (2.7.0.2)
17
17
  ast (~> 2.4.0)
18
18
  pbio (0.2.0)
19
19
  google-protobuf
20
20
  rainbow (3.0.0)
21
- rake (13.0.0)
21
+ rake (13.0.1)
22
22
  rspec (3.9.0)
23
23
  rspec-core (~> 3.9.0)
24
24
  rspec-expectations (~> 3.9.0)
25
25
  rspec-mocks (~> 3.9.0)
26
- rspec-core (3.9.0)
27
- rspec-support (~> 3.9.0)
26
+ rspec-core (3.9.1)
27
+ rspec-support (~> 3.9.1)
28
28
  rspec-expectations (3.9.0)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
30
  rspec-support (~> 3.9.0)
31
- rspec-mocks (3.9.0)
31
+ rspec-mocks (3.9.1)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.9.0)
34
- rspec-support (3.9.0)
35
- rubocop (0.75.0)
34
+ rspec-support (3.9.2)
35
+ rubocop (0.79.0)
36
36
  jaro_winkler (~> 1.5.1)
37
37
  parallel (~> 1.10)
38
- parser (>= 2.6)
38
+ parser (>= 2.7.0.1)
39
39
  rainbow (>= 2.2.2, < 4.0)
40
40
  ruby-progressbar (~> 1.7)
41
41
  unicode-display_width (>= 1.4.0, < 1.7)
42
- rubocop-performance (1.5.0)
42
+ rubocop-performance (1.5.2)
43
43
  rubocop (>= 0.71.0)
44
44
  ruby-progressbar (1.10.1)
45
45
  unicode-display_width (1.6.0)
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  rubocop-performance
59
59
 
60
60
  BUNDLED WITH
61
- 2.0.2
61
+ 2.1.2
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'feedx'
3
- s.version = '0.9.0'
3
+ s.version = '0.9.2'
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)
data/go.mod CHANGED
@@ -1,8 +1,9 @@
1
1
  module github.com/bsm/feedx
2
2
 
3
3
  require (
4
- github.com/bsm/bfs v0.8.0
5
- github.com/gogo/protobuf v1.3.0
4
+ github.com/bmatcuk/doublestar v1.2.2 // indirect
5
+ github.com/bsm/bfs v0.8.1
6
+ github.com/gogo/protobuf v1.3.1
6
7
  github.com/golang/protobuf v1.3.2
7
8
  github.com/onsi/ginkgo v1.10.2
8
9
  github.com/onsi/gomega v1.7.0
data/go.sum CHANGED
@@ -1,11 +1,13 @@
1
1
  github.com/bmatcuk/doublestar v1.1.5 h1:2bNwBOmhyFEFcoB3tGvTD5xanq+4kyOZlB8wFYbMjkk=
2
2
  github.com/bmatcuk/doublestar v1.1.5/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
3
- github.com/bsm/bfs v0.8.0 h1:/suMKytZ3WhVY62osdFm6VD+gJtxaohlUBuf76vGC78=
4
- github.com/bsm/bfs v0.8.0/go.mod h1:cVv0jyqUY/jbHoG/WYPuWvOaOhW/HZ4jl7/JMlypvAE=
3
+ github.com/bmatcuk/doublestar v1.2.2 h1:oC24CykoSAB8zd7XgruHo33E0cHJf/WhQA/7BeXj+x0=
4
+ github.com/bmatcuk/doublestar v1.2.2/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
5
+ github.com/bsm/bfs v0.8.1 h1:PS+kH6Pu8IsKUrxOp8E/B6/ASLvGEz2kIeX0GM4DdPc=
6
+ github.com/bsm/bfs v0.8.1/go.mod h1:cVv0jyqUY/jbHoG/WYPuWvOaOhW/HZ4jl7/JMlypvAE=
5
7
  github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
6
8
  github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
7
- github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE=
8
- github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
9
+ github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
10
+ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
9
11
  github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
10
12
  github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
11
13
  github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
@@ -8,7 +8,7 @@ module Feedx
8
8
  include Enumerable
9
9
 
10
10
  # See constructor.
11
- def self.each(url, klass, opts={}, &block)
11
+ def self.each(url, klass, opts = {}, &block)
12
12
  new(url, klass, opts).each(&block)
13
13
  end
14
14
 
@@ -19,7 +19,7 @@ module Feedx
19
19
  # @option opts [Hash] :format_options format decode options. Default: {}.
20
20
  # @option opts [Symbol,Class<Feedx::Compression::Abstract>] :compress enable compression. Default: from file extension.
21
21
  # @option opts [Feedx::Cache::Value] :cache cache value to store remote last modified time and consume conditionally.
22
- def initialize(url, klass, opts={})
22
+ def initialize(url, klass, opts = {})
23
23
  @klass = klass
24
24
  @stream = Feedx::Stream.new(url, opts)
25
25
  @fmt_opts = opts[:format_options] || {}
@@ -6,7 +6,7 @@ module Feedx
6
6
  # Produces a relation as an encoded feed to a remote location.
7
7
  class Producer
8
8
  # See constructor.
9
- def self.perform(url, opts={}, &block)
9
+ def self.perform(url, opts = {}, &block)
10
10
  new(url, opts, &block).perform
11
11
  end
12
12
 
@@ -19,7 +19,7 @@ module Feedx
19
19
  # @option opts [Time,Proc] :last_modified the last modified time, used to determine if a push is necessary.
20
20
  # @yield A block factory to generate the relation or enumerator.
21
21
  # @yieldreturn [Enumerable,ActiveRecord::Relation] the relation or enumerator to stream.
22
- def initialize(url, opts={}, &block)
22
+ def initialize(url, opts = {}, &block)
23
23
  @enum = opts[:enum] || block
24
24
  raise ArgumentError, "#{self.class.name}.new expects an :enum option or a block factory" unless @enum
25
25
 
@@ -37,7 +37,8 @@ module Feedx
37
37
  metadata = @stream.blob.info.metadata
38
38
  remote_rev = (metadata[META_LAST_MODIFIED] || metadata[META_LAST_MODIFIED_DC]).to_i
39
39
  return -1 unless local_rev > remote_rev
40
- rescue BFS::FileNotFound # rubocop:disable Lint/HandleExceptions
40
+ rescue BFS::FileNotFound
41
+ nil
41
42
  end if local_rev.positive?
42
43
 
43
44
  @stream.create metadata: { META_LAST_MODIFIED => local_rev.to_s } do |fmt|
@@ -10,7 +10,7 @@ module Feedx
10
10
  # @param [Hash] opts options
11
11
  # @option opts [Symbol,Class<Feedx::Format::Abstract>] :format custom formatter. Default: from file extension.
12
12
  # @option opts [Symbol,Class<Feedx::Compression::Abstract>] :compress enable compression. Default: from file extension.
13
- def initialize(url, opts={})
13
+ def initialize(url, opts = {})
14
14
  @blob = BFS::Blob.new(url)
15
15
  @format = detect_format(opts[:format])
16
16
  @compress = detect_compress(opts[:compress])
@@ -20,7 +20,7 @@ module Feedx
20
20
  # @param [Hash] opts BFS::Blob#open options
21
21
  # @yield A block over a formatted stream.
22
22
  # @yieldparam [Feedx::Format::Abstract] formatted input stream.
23
- def open(opts={})
23
+ def open(opts = {})
24
24
  @blob.open(opts) do |io|
25
25
  @compress.reader(io) do |cio|
26
26
  fmt = @format.new(cio)
@@ -33,7 +33,7 @@ module Feedx
33
33
  # @param [Hash] opts BFS::Blob#create options
34
34
  # @yield A block over a formatted stream.
35
35
  # @yieldparam [Feedx::Format::Abstract] formatted output stream.
36
- def create(opts={})
36
+ def create(opts = {})
37
37
  @blob.create(opts) do |io|
38
38
  @compress.writer(io) do |cio|
39
39
  fmt = @format.new(cio)
@@ -140,14 +140,10 @@ func (p *Producer) push() (*ProducerPush, error) {
140
140
  wopt.LastMod = modTime
141
141
  }
142
142
 
143
- // retrieve original last modified time
144
- lastMod, err := remoteLastModified(p.ctx, p.remote)
145
- if err != nil {
143
+ // retrieve original last modified time, skip if not modified
144
+ if rts, err := remoteLastModified(p.ctx, p.remote); err != nil {
146
145
  return nil, err
147
- }
148
-
149
- // skip push if not modified
150
- if lastMod.Time().Equal(wopt.LastMod) {
146
+ } else if rts == timestampFromTime(wopt.LastMod) {
151
147
  return &ProducerPush{Producer: p}, nil
152
148
  }
153
149
 
@@ -2,6 +2,7 @@ package feedx_test
2
2
 
3
3
  import (
4
4
  "context"
5
+ "sync/atomic"
5
6
  "time"
6
7
 
7
8
  "github.com/bsm/bfs"
@@ -13,11 +14,14 @@ import (
13
14
  var _ = Describe("Producer", func() {
14
15
  var subject *feedx.Producer
15
16
  var obj *bfs.Object
17
+ var numRuns uint32
16
18
  var ctx = context.Background()
17
19
 
18
20
  setup := func(o *feedx.ProducerOptions) {
19
21
  var err error
20
22
  subject, err = feedx.NewProducerForRemote(ctx, obj, o, func(w *feedx.Writer) error {
23
+ atomic.AddUint32(&numRuns, 1)
24
+
21
25
  for i := 0; i < 10; i++ {
22
26
  fix := fixture
23
27
  if err := w.Encode(&fix); err != nil {
@@ -30,6 +34,7 @@ var _ = Describe("Producer", func() {
30
34
  }
31
35
 
32
36
  BeforeEach(func() {
37
+ atomic.StoreUint32(&numRuns, 0)
33
38
  obj = bfs.NewInMemObject("path/to/file.jsonz")
34
39
  })
35
40
 
@@ -54,16 +59,22 @@ var _ = Describe("Producer", func() {
54
59
 
55
60
  It("should produce with custom last-mod check", func() {
56
61
  setup(&feedx.ProducerOptions{
57
- LastModCheck: func(_ context.Context) (time.Time, error) { return time.Unix(1515151515, 0), nil },
62
+ Interval: 50 * time.Millisecond,
63
+ LastModCheck: func(_ context.Context) (time.Time, error) { return time.Unix(1515151515, 987654321), nil },
58
64
  })
59
65
 
60
- Expect(subject.LastPush()).To(BeTemporally("~", time.Now(), time.Second))
61
- Expect(subject.LastModified()).To(Equal(time.Unix(1515151515, 0)))
66
+ firstPush := subject.LastPush()
67
+ Expect(firstPush).To(BeTemporally("~", time.Now(), time.Second))
68
+ Expect(subject.LastModified()).To(Equal(time.Unix(1515151515, 987000000)))
62
69
  Expect(subject.NumWritten()).To(Equal(10))
70
+ Expect(atomic.LoadUint32(&numRuns)).To(Equal(uint32(1)))
63
71
 
64
72
  info, err := obj.Head(ctx)
65
73
  Expect(err).NotTo(HaveOccurred())
66
74
  Expect(info.Size).To(BeNumerically("~", 75, 10))
67
- Expect(info.Metadata).To(HaveKeyWithValue("X-Feedx-Last-Modified", "1515151515000"))
75
+ Expect(info.Metadata).To(HaveKeyWithValue("X-Feedx-Last-Modified", "1515151515987"))
76
+
77
+ Eventually(func() bool { return subject.LastPush().After(firstPush) }).Should(BeTrue())
78
+ Expect(atomic.LoadUint32(&numRuns)).To(Equal(uint32(1)))
68
79
  })
69
80
  })
@@ -36,7 +36,7 @@ RSpec.describe Feedx::Consumer do
36
36
 
37
37
  private
38
38
 
39
- def mock_produce!(opts={})
39
+ def mock_produce!(opts = {})
40
40
  url = 'mock:///dir/file.json'
41
41
  opts[:enum] ||= %w[x y z].map {|t| Feedx::TestCase::Model.new(t) } * 100
42
42
  Feedx::Producer.perform url, opts
data/writer.go CHANGED
@@ -3,6 +3,7 @@ package feedx
3
3
  import (
4
4
  "bufio"
5
5
  "context"
6
+ "errors"
6
7
  "io"
7
8
  "time"
8
9
 
@@ -114,7 +115,10 @@ func (w *Writer) NumWritten() int {
114
115
  // Discard closes the writer and discards the contents.
115
116
  func (w *Writer) Discard() error {
116
117
  w.cancel()
117
- return w.Commit()
118
+ if err := w.Commit(); err != nil && !errors.Is(err, context.Canceled) {
119
+ return err
120
+ }
121
+ return nil
118
122
  }
119
123
 
120
124
  // Commit closes the writer and persists the contents.
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.9.0
4
+ version: 0.9.2
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-10-10 00:00:00.000000000 Z
11
+ date: 2020-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bfs
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
- rubygems_version: 3.0.3
194
+ rubygems_version: 3.0.6
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Exchange data between components via feeds