google-pubsub-enhancer 0.5.5 → 0.6.2

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
- SHA1:
3
- metadata.gz: a42402edc4e8d1145de6b1afcf02b7eee20b861d
4
- data.tar.gz: 42050fe16783ad5f6a41dbbffd5d53bbafd19732
2
+ SHA256:
3
+ metadata.gz: fc398084613f43dfcdd11e2ed39b9ef649b943e6b6bbeb936f0612d8982cc219
4
+ data.tar.gz: c00727a4953eb43f5dcd0a9f5194d31e00029939d12019aa9c2f1d4ff123cc4c
5
5
  SHA512:
6
- metadata.gz: 0b7812cbf3721a2ccd2db48b7985a9f4469a608ba078ce8e98a8e5bff1e55cc117a8671d0e83204bc396fa56f66a14637c66e97eb9e5299527ea837e84e44c3d
7
- data.tar.gz: 9cdecea24e52ffa9ad07da021011fbd1c5caa4281c260775a1dc6aed3dd95ffbac2ef74d8f8b9285929d0942f65b809873f20348187a0026a75d14358a3d9106
6
+ metadata.gz: 75e95daafa4e9a28b7607b318efce2b4baf72c16870e2e0726b2aff35b4d80978aeba32ce0d81b5ce6a25f22bc69a5b38d1d796b35e499d38a9204863cdd9757
7
+ data.tar.gz: 1fb3cb5da45d41c97fab78edc0cfdcdcc4d09013d574984bd8243c6526535272f1e6168895758abe4e3cc4ae1b3095a6ea124af1ff63823d020d3f90fadcc719
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  /tags
11
11
  /spike
12
12
  .ruby-version
13
+ .DS_Store
data/README.md CHANGED
@@ -53,10 +53,11 @@ require 'spec_helper'
53
53
 
54
54
  describe YourApplication do
55
55
 
56
+ #include the test framework for end to end testing
56
57
  include GooglePubsubEnhancer::Spec
57
58
 
58
- #the only user specific setting you need
59
- let(:messages) {[{foo:1}, {bar:2}]}
59
+ #set messages that come from a topic
60
+ let(:messages) {[JSON.dump({foo:1}), JSON.dump({bar:2})]}
60
61
 
61
62
  it "should do the magic you write into" do
62
63
 
@@ -64,7 +65,9 @@ describe YourApplication do
64
65
 
65
66
  # in this case the test middleware creates messages from pubsub objects
66
67
  use YourMiddleware, -> env do
67
- env[:messages_key] = env[:received_messages].map(&:data)
68
+ env[:messages_key] = env[:received_messages].map do |msg|
69
+ JSON.parse msg.data
70
+ end
68
71
  end
69
72
 
70
73
  use GooglePubsubEnhancer::Middleware::Publisher,
@@ -72,9 +75,9 @@ describe YourApplication do
72
75
  messages: :messages_key
73
76
  end
74
77
 
75
- # the only expectation you need (further more you can check the)
76
- expect(publisher).to receive(:publish).with({foo:1}).ordered
77
- expect(publisher).to receive(:publish).with({bar:2}).ordered
78
+ # the only expectation you need
79
+ expect_publish_called_with({"foo" => 1})
80
+ expect_publish_called_with({"bar" => 2})
78
81
 
79
82
  app.run 'subscription_short_name'
80
83
  end
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.13"
24
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "bundler", ">= 2.2.10"
24
+ spec.add_development_dependency "rake", ">= 12.3.3"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
26
 
27
27
  spec.add_dependency "middleware", "~>0"
@@ -14,7 +14,7 @@ class GooglePubsubEnhancer::Middleware::Publisher
14
14
  @logger.debug("#{env[@messages_key].length} messages published")
15
15
  @google_cloud_pubsub.publish(@full_topic_name) do |publisher|
16
16
  [*env[@messages_key]].each do |m|
17
- publisher.publish(m)
17
+ publisher.publish(m, {recordId: Digest::MD5.hexdigest(m)} )
18
18
  end
19
19
  end
20
20
  rescue => ex
@@ -5,7 +5,8 @@ module GooglePubsubEnhancer::Spec
5
5
  let(:pubsub) {double "pubsub"}
6
6
  let(:publisher) { double "publisher"}
7
7
  let(:subscription) { double 'subscription'}
8
- let(:google_messages) {messages.map { |m| Google::Cloud::Pubsub::Message.new(m.to_s)}}
8
+ let(:google_messages) {messages.map { |m| Google::Cloud::Pubsub::Message.new(m)}}
9
+
9
10
  before do
10
11
  ENV['PUBSUB_KEYFILE_JSON'] = JSON.dump(project_id: 'cica')
11
12
  allow(Google::Cloud::Pubsub).to receive(:new).and_return(pubsub)
@@ -14,6 +15,7 @@ module GooglePubsubEnhancer::Spec
14
15
  allow(subscription).to receive(:pull).and_return(google_messages, nil)
15
16
  allow(publisher).to receive(:publish)
16
17
  allow(subscription).to receive(:acknowledge)
18
+ allow(Digest::MD5).to receive(:hexdigest).and_return("a1s2d3f4g5")
17
19
  end
18
20
 
19
21
  after do
@@ -22,9 +24,18 @@ module GooglePubsubEnhancer::Spec
22
24
  end
23
25
  end
24
26
 
27
+ module PublisherTester
28
+ def expect_publish_called_with(msg)
29
+ expect(publisher).to receive(:publish).with(msg, {recordId: "a1s2d3f4g5"}).ordered
30
+ end
31
+ end
32
+
25
33
  def self.included(klass)
26
34
  klass.extend ClassMethods
27
35
  klass.__setup_pubsub!
36
+ RSpec.configuration.include(PublisherTester)
28
37
  end
29
38
 
39
+
40
+
30
41
  end
@@ -1,3 +1,3 @@
1
1
  class GooglePubsubEnhancer
2
- VERSION = "0.5.5"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,44 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-pubsub-enhancer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bejczib
8
8
  - karoly_bujtor
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-04-12 00:00:00.000000000 Z
12
+ date: 2021-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '1.13'
20
+ version: 2.2.10
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '1.13'
27
+ version: 2.2.10
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '10.0'
34
+ version: 12.3.3
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '10.0'
41
+ version: 12.3.3
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +81,7 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
- description:
84
+ description:
85
85
  email:
86
86
  - bejczi.balint@gmail.com
87
87
  - bujtor.karoly@gmail.com
@@ -112,7 +112,7 @@ homepage: http://github.com/bejczib/google-pubsub-enhancer
112
112
  licenses:
113
113
  - MIT
114
114
  metadata: {}
115
- post_install_message:
115
+ post_install_message:
116
116
  rdoc_options: []
117
117
  require_paths:
118
118
  - lib
@@ -127,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubyforge_project:
131
- rubygems_version: 2.5.1
132
- signing_key:
130
+ rubygems_version: 3.0.4
131
+ signing_key:
133
132
  specification_version: 4
134
133
  summary: Enhancement for a pipeline built with Google PubSub Services
135
134
  test_files: []