hanami-events-cloud_pubsub 2.2.1 → 2.3.0

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: 8628eee6e27df70fa6ffb5161faed7c6002d4a67551606e166cf7998742f27e9
4
- data.tar.gz: 448ae6c3b88c65e34841a083e717be14d7530c774a7ae8849ebaa585a217207e
3
+ metadata.gz: 6a149ec7d07642ff795eb1102b595bc2332368f4baf41b438a8b2a3cba181e11
4
+ data.tar.gz: c053e05e3cb6523acc2e6b0e4c63579081f09e76ef20285ad7ea4e72ca59b90b
5
5
  SHA512:
6
- metadata.gz: c39c96539290ab6a7b6d7e52725a41286e660ea544fa58e87b127981ce3ff62490554207f597998ef94ffe1c94f7d63902342fa9216fbc89e3b7927466c8af6b
7
- data.tar.gz: 13a1fe610f431e52d8784e4466ac593ff790c96bdc8b129a50645639623bd37cded0766396f6f2d3fb74cd2064f5c77d625d6ea4ff459a4fb193682336586ba7
6
+ metadata.gz: cc39732f19e786147e7023389e71b30e1f0e61170df1edbd6e8e03ea9eb37fa5be5f300f18cf368bacc765e12f6b53de16df27b17a41f1a0849b137fc632443d
7
+ data.tar.gz: aa90fc9e19feacb57f9928c05bfc4f8fec02a4ea28e76e16739e6447165b1271edd6de8b972e4e645e12268af072c0ceab253dbd2e42d45086aebd9d5f62b33d
data/.rubocop_todo.yml CHANGED
@@ -1,29 +1,25 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-06-13 22:39:48 -0400 using RuboCop version 0.54.0.
3
+ # on 2019-10-30 15:26:46 -0400 using RuboCop version 0.72.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
- # Configuration parameters: CountComments.
10
+ # Configuration parameters: CountComments, ExcludedMethods.
11
11
  Metrics/MethodLength:
12
12
  Max: 14
13
13
 
14
- # Offense count: 1
15
- # Configuration parameters: CountKeywordArgs.
16
- Metrics/ParameterLists:
17
- Max: 6
18
-
19
14
  # Offense count: 1
20
15
  # Configuration parameters: AllowedVariables.
21
16
  Style/GlobalVars:
22
17
  Exclude:
23
18
  - 'examples/server.rb'
24
19
 
25
- # Offense count: 23
26
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
20
+ # Offense count: 35
21
+ # Cop supports --auto-correct.
22
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
27
23
  # URISchemes: http, https
28
24
  Metrics/LineLength:
29
- Max: 93
25
+ Max: 96
data/Gemfile.lock CHANGED
@@ -8,17 +8,17 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- hanami-events-cloud_pubsub (2.2.1)
11
+ hanami-events-cloud_pubsub (2.3.0)
12
12
  dry-configurable (~> 0.8.0)
13
- google-cloud-pubsub (>= 0.38.1, < 0.39)
13
+ google-cloud-pubsub (>= 0.38.1, < 1.2)
14
14
  hanami-cli (~> 0.2)
15
15
  hanami-events (~> 0.2.0)
16
16
 
17
17
  GEM
18
18
  remote: https://rubygems.org/
19
19
  specs:
20
- addressable (2.6.0)
21
- public_suffix (>= 2.0.2, < 4.0)
20
+ addressable (2.7.0)
21
+ public_suffix (>= 2.0.2, < 5.0)
22
22
  ast (2.4.0)
23
23
  coderay (1.1.2)
24
24
  concurrent-ruby (1.1.5)
@@ -32,39 +32,39 @@ GEM
32
32
  dry-configurable (~> 0.1, >= 0.1.3)
33
33
  dry-core (0.4.8)
34
34
  concurrent-ruby (~> 1.0)
35
- faraday (0.15.4)
35
+ faraday (0.17.0)
36
36
  multipart-post (>= 1.2, < 3)
37
- google-cloud-core (1.3.0)
37
+ google-cloud-core (1.4.1)
38
38
  google-cloud-env (~> 1.0)
39
- google-cloud-env (1.2.0)
39
+ google-cloud-env (1.3.0)
40
40
  faraday (~> 0.11)
41
- google-cloud-pubsub (0.38.1)
41
+ google-cloud-pubsub (1.1.0)
42
42
  concurrent-ruby (~> 1.1)
43
43
  google-cloud-core (~> 1.2)
44
- google-gax (~> 1.7)
44
+ google-gax (~> 1.8)
45
45
  googleapis-common-protos (>= 1.3.9, < 2.0)
46
46
  grpc-google-iam-v1 (~> 0.6.9)
47
- google-gax (1.7.0)
48
- google-protobuf (~> 3.2)
49
- googleapis-common-protos (>= 1.3.5, < 2.0)
50
- googleauth (>= 0.6.2, < 0.10.0)
51
- grpc (>= 1.7.2, < 2.0)
47
+ google-gax (1.8.1)
48
+ google-protobuf (~> 3.9)
49
+ googleapis-common-protos (>= 1.3.9, < 2.0)
50
+ googleauth (~> 0.9)
51
+ grpc (~> 1.24)
52
52
  rly (~> 0.2.3)
53
- google-protobuf (3.9.1)
53
+ google-protobuf (3.10.1)
54
54
  googleapis-common-protos (1.3.9)
55
55
  google-protobuf (~> 3.0)
56
56
  googleapis-common-protos-types (~> 1.0)
57
57
  grpc (~> 1.0)
58
58
  googleapis-common-protos-types (1.0.4)
59
59
  google-protobuf (~> 3.0)
60
- googleauth (0.9.0)
60
+ googleauth (0.10.0)
61
61
  faraday (~> 0.12)
62
62
  jwt (>= 1.4, < 3.0)
63
63
  memoist (~> 0.16)
64
64
  multi_json (~> 1.11)
65
65
  os (>= 0.9, < 2.0)
66
- signet (~> 0.7)
67
- grpc (1.23.0)
66
+ signet (~> 0.12)
67
+ grpc (1.24.0)
68
68
  google-protobuf (~> 3.8)
69
69
  googleapis-common-protos-types (~> 1.0)
70
70
  grpc-google-iam-v1 (0.6.9)
@@ -73,7 +73,7 @@ GEM
73
73
  hanami-cli (0.3.1)
74
74
  concurrent-ruby (~> 1.0)
75
75
  hanami-utils (~> 1.3)
76
- hanami-utils (1.3.2)
76
+ hanami-utils (1.3.5)
77
77
  concurrent-ruby (~> 1.0)
78
78
  transproc (~> 1.0)
79
79
  jaro_winkler (1.5.3)
@@ -81,7 +81,7 @@ GEM
81
81
  jwt (2.2.1)
82
82
  memoist (0.16.0)
83
83
  method_source (0.9.2)
84
- multi_json (1.13.1)
84
+ multi_json (1.14.1)
85
85
  multipart-post (2.1.1)
86
86
  os (1.0.1)
87
87
  parallel (1.17.0)
@@ -90,24 +90,24 @@ GEM
90
90
  pry (0.12.2)
91
91
  coderay (~> 1.1.0)
92
92
  method_source (~> 0.9.0)
93
- public_suffix (3.1.1)
93
+ public_suffix (4.0.1)
94
94
  rainbow (3.0.0)
95
- rake (12.3.2)
95
+ rake (13.0.0)
96
96
  rly (0.2.3)
97
- rspec (3.8.0)
98
- rspec-core (~> 3.8.0)
99
- rspec-expectations (~> 3.8.0)
100
- rspec-mocks (~> 3.8.0)
101
- rspec-core (3.8.2)
102
- rspec-support (~> 3.8.0)
103
- rspec-expectations (3.8.4)
97
+ rspec (3.9.0)
98
+ rspec-core (~> 3.9.0)
99
+ rspec-expectations (~> 3.9.0)
100
+ rspec-mocks (~> 3.9.0)
101
+ rspec-core (3.9.0)
102
+ rspec-support (~> 3.9.0)
103
+ rspec-expectations (3.9.0)
104
104
  diff-lcs (>= 1.2.0, < 2.0)
105
- rspec-support (~> 3.8.0)
106
- rspec-mocks (3.8.1)
105
+ rspec-support (~> 3.9.0)
106
+ rspec-mocks (3.9.0)
107
107
  diff-lcs (>= 1.2.0, < 2.0)
108
- rspec-support (~> 3.8.0)
109
- rspec-support (3.8.2)
110
- rubocop (0.72.0)
108
+ rspec-support (~> 3.9.0)
109
+ rspec-support (3.9.0)
110
+ rubocop (0.74.0)
111
111
  jaro_winkler (~> 1.5.1)
112
112
  parallel (~> 1.10)
113
113
  parser (>= 2.6)
@@ -115,7 +115,7 @@ GEM
115
115
  ruby-progressbar (~> 1.7)
116
116
  unicode-display_width (>= 1.4.0, < 1.7)
117
117
  ruby-progressbar (1.10.1)
118
- signet (0.11.0)
118
+ signet (0.12.0)
119
119
  addressable (~> 2.3)
120
120
  faraday (~> 0.9)
121
121
  jwt (>= 1.5, < 3.0)
@@ -136,7 +136,7 @@ DEPENDENCIES
136
136
  hanami-events!
137
137
  hanami-events-cloud_pubsub!
138
138
  pry
139
- rake (~> 12.3)
139
+ rake (~> 13.0)
140
140
  rspec (~> 3.0)
141
141
  rubocop
142
142
  simplecov
@@ -23,11 +23,11 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ['lib']
24
24
 
25
25
  spec.add_dependency 'dry-configurable', '~> 0.8.0'
26
- spec.add_dependency 'google-cloud-pubsub', '>= 0.38.1', '< 0.39'
26
+ spec.add_dependency 'google-cloud-pubsub', '>= 0.38.1', '< 1.2'
27
27
  spec.add_dependency 'hanami-cli', '~> 0.2'
28
28
  spec.add_dependency 'hanami-events', '~> 0.2.0'
29
29
 
30
30
  spec.add_development_dependency 'bundler', '~> 1.16'
31
- spec.add_development_dependency 'rake', '~> 12.3'
31
+ spec.add_development_dependency 'rake', '~> 13.0'
32
32
  spec.add_development_dependency 'rspec', '~> 3.0'
33
33
  end
@@ -8,6 +8,8 @@ module Hanami
8
8
  class Error < StandardError; end
9
9
  class TopicNotFoundError < Error; end
10
10
  class SubscriptionNotFoundError < Error; end
11
+ class SubscriptionTopicNameMismatch < Error; end
12
+ class NoSubscriberError < Error; end
11
13
  end
12
14
  end
13
15
  end
@@ -7,8 +7,6 @@ module Hanami
7
7
  module CloudPubsub
8
8
  # @api private
9
9
  class Listener
10
- class NoSubscriberError < StandardError; end
11
-
12
10
  attr_reader :topic,
13
11
  :subscriber,
14
12
  :subscriber_id,
@@ -89,13 +87,20 @@ module Hanami
89
87
  end
90
88
 
91
89
  def subscription_for(name)
92
- topic.find_subscription(name) ||
93
- (CloudPubsub.auto_create_subscriptions && topic.create_subscription(name)) ||
94
- raise(Errors::SubscriptionNotFoundError, "no subscription named: #{name}")
90
+ found_subscription = topic.find_subscription(name)
91
+
92
+ if found_subscription
93
+ ensure_topic_names_match!(name, found_subscription)
94
+ found_subscription
95
+ elsif CloudPubsub.auto_create_subscriptions
96
+ topic.create_subscription(name)
97
+ else
98
+ raise Errors::SubscriptionNotFoundError, "no subscription named: #{name}"
99
+ end
95
100
  end
96
101
 
97
102
  def ensure_subscriber!
98
- raise NoSubscriberError, 'No subsriber has been registered' unless @subscriber
103
+ raise Errors::NoSubscriberError, 'No subsriber has been registered' unless @subscriber
99
104
  end
100
105
 
101
106
  def run_error_handlers(err, message)
@@ -103,6 +108,16 @@ module Hanami
103
108
  SafeErrorHandler.call(handler, err, message)
104
109
  end
105
110
  end
111
+
112
+ def ensure_topic_names_match!(sub_name, found_subscription)
113
+ parsed_name = found_subscription.topic.name.split('/').last
114
+
115
+ return true if parsed_name == @event_name
116
+
117
+ raise Errors::SubscriptionTopicNameMismatch,
118
+ "a subscription already exists for #{sub_name} " \
119
+ "but its name #{found_subscription.topic.name} does not match #{@event_name}"
120
+ end
106
121
  end
107
122
  end
108
123
  end
@@ -3,7 +3,7 @@
3
3
  module Hanami
4
4
  module Events
5
5
  module CloudPubsub
6
- VERSION = '2.2.1'
6
+ VERSION = '2.3.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-events-cloud_pubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-21 00:00:00.000000000 Z
11
+ date: 2019-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 0.38.1
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '0.39'
36
+ version: '1.2'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.38.1
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.39'
46
+ version: '1.2'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hanami-cli
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '12.3'
95
+ version: '13.0'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '12.3'
102
+ version: '13.0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rspec
105
105
  requirement: !ruby/object:Gem::Requirement