gapic-generator 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/gapic/formatting_utils.rb +6 -6
  4. data/lib/gapic/generator/version.rb +1 -1
  5. data/lib/gapic/helpers/filepath_helper.rb +1 -0
  6. data/lib/gapic/helpers/namespace_helper.rb +8 -1
  7. data/lib/gapic/presenters/field_presenter.rb +9 -9
  8. data/lib/gapic/presenters/file_presenter.rb +1 -1
  9. data/lib/gapic/presenters/method_presenter.rb +14 -14
  10. data/lib/gapic/presenters/service_presenter.rb +2 -2
  11. data/templates/default/layouts/_ruby.erb +5 -4
  12. data/templates/default/proto_docs/_message.erb +2 -2
  13. data/templates/default/service/client/_client.erb +3 -3
  14. data/templates/default/service/client/_config.erb +26 -26
  15. data/templates/default/service/client/_credentials.erb +1 -1
  16. data/templates/default/service/client/_operations.erb +1 -1
  17. data/templates/default/service/client/method/def/_options_defaults.erb +2 -2
  18. data/templates/default/service/client/method/def/_request_normal.erb +2 -2
  19. data/templates/default/service/client/method/def/_request_streaming.erb +3 -3
  20. data/templates/default/service/client/method/def/_response_normal.erb +1 -1
  21. data/templates/default/service/client/method/def/_response_paged.erb +2 -2
  22. data/templates/default/service/client/method/docs/_error.erb +1 -1
  23. data/templates/default/service/client/method/docs/_request_normal.erb +2 -2
  24. data/templates/default/service/client/method/docs/_request_streaming.erb +2 -2
  25. data/templates/default/service/client/method/docs/_response.erb +1 -1
  26. data/templates/default/service/client/resource/_def.erb +1 -1
  27. data/templates/default/service/client/resource/_multi.erb +2 -2
  28. data/templates/default/service/client/resource/_single.erb +1 -1
  29. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eb09d3958e2bf3212a940df300ab29228dabdb7dabc31b1d9755eddee129c5b
4
- data.tar.gz: e9431a7bc6f8680553e0bd682d68cdf6ec5fc61a6c564fec5c074f4884d362c9
3
+ metadata.gz: bd638c7b5855aa89dfd03c87f3f5d8d936d78005b51dd04a409ac7552e3eea05
4
+ data.tar.gz: 6372183134b8556a0a5ac7a4a6bf1250820c5b167b576454fae5f0228194078c
5
5
  SHA512:
6
- metadata.gz: 554bdbb8d1b6ca6dbfb646656cb91dc5f1080d60e8e7103771ca8e3352f09e33a0b9ef3edd86547c173cfc98e18d45da1be8b9648aef40525b1bfb13c5579d62
7
- data.tar.gz: c998693373a980357d17d540fdbaa891959666bfb2b2dd12b2843eb9b8df0bca1808259305c25614a3951f695b004fa28b862888e1e9e4fa706ce6cfcd2b4f5f
6
+ metadata.gz: 67b82518fe047ac185a3b596af6b3da223c774c96dbc6cb01761998920ca164e546bd72fc2222c6a945636c49e39a5b80ded892b821d493d79f40133fa973fa3
7
+ data.tar.gz: c316dd8c291a1204e73f18d7df06800734bf7e3690db5d5967e586cbaf0c215b02496a090a44eb5baee9b501fd418717312b8bb33d096fda5f5c6ef84e11d1fa
@@ -1,5 +1,10 @@
1
1
  # Release History for gapic-generator
2
2
 
3
+ ### 0.4.2 / 2020-04-28
4
+
5
+ * Prepend double-colon to absolute/global namespaces to prevent conflicts.
6
+ * Fix documentation/examples of timeouts to clarify they are in seconds.
7
+
3
8
  ### 0.4.0 / 2020-04-20
4
9
 
5
10
  * Support generating clients of "common" interfaces by delegating to another service config.
@@ -137,15 +137,15 @@ module Gapic
137
137
 
138
138
  case entity
139
139
  when Gapic::Schema::Service
140
- "{#{convert_address_to_ruby entity}::Client #{text}}"
140
+ "{::#{convert_address_to_ruby entity}::Client #{text}}"
141
141
  when Gapic::Schema::Method
142
- "{#{convert_address_to_ruby entity.parent}::Client##{entity.name.underscore} #{text}}"
142
+ "{::#{convert_address_to_ruby entity.parent}::Client##{entity.name.underscore} #{text}}"
143
143
  when Gapic::Schema::Message, Gapic::Schema::Enum
144
- "{#{convert_address_to_ruby entity} #{text}}"
144
+ "{::#{convert_address_to_ruby entity} #{text}}"
145
145
  when Gapic::Schema::EnumValue
146
- "{#{convert_address_to_ruby entity.parent}::#{entity.name} #{text}}"
146
+ "{::#{convert_address_to_ruby entity.parent}::#{entity.name} #{text}}"
147
147
  when Gapic::Schema::Field
148
- "{#{convert_address_to_ruby entity.parent}##{entity.name} #{text}}"
148
+ "{::#{convert_address_to_ruby entity.parent}##{entity.name} #{text}}"
149
149
  end
150
150
  end
151
151
 
@@ -155,7 +155,7 @@ module Gapic
155
155
  address = entity.address
156
156
  address = address.join "." if address.is_a? Array
157
157
  address = address.sub file.package, file.ruby_package if file.ruby_package&.present?
158
- address.split(".").reject(&:empty?).map(&:camelize).map { |node| api.fix_namespace node }.join("::")
158
+ address.split(/\.|::/).reject(&:empty?).map(&:camelize).map { |node| api.fix_namespace node }.join("::")
159
159
  end
160
160
  end
161
161
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Gapic
18
18
  module Generator
19
- VERSION = "0.4.0"
19
+ VERSION = "0.4.2"
20
20
  end
21
21
  end
@@ -25,6 +25,7 @@ module Gapic
25
25
  ##
26
26
  # Converts a ruby namespace string to a file path string.
27
27
  def ruby_file_path api, namespace
28
+ namespace = namespace.sub(/^::/, "")
28
29
  file_path = ruby_file_path_for_namespace namespace
29
30
  fix_file_path api, file_path
30
31
  end
@@ -38,7 +38,14 @@ module Gapic
38
38
  # Ruby double-semicolon separators.
39
39
  def ruby_namespace_for_address address
40
40
  address = address.split "." if address.is_a? String
41
- address.reject(&:empty?).map(&:camelize).join "::"
41
+ ensure_absolute_namespace address.reject(&:empty?).map(&:camelize).join("::")
42
+ end
43
+
44
+ ##
45
+ # Returns the given namespace, ensuring double colons are prepended
46
+ #
47
+ def ensure_absolute_namespace namespace
48
+ namespace.start_with?("::") ? namespace : "::#{namespace}"
42
49
  end
43
50
 
44
51
  ##
@@ -95,21 +95,21 @@ module Gapic
95
95
  base_type =
96
96
  if field.message?
97
97
  type = message_ruby_type field.message
98
- output ? type : "#{type}, Hash"
98
+ output ? type : "#{type}, ::Hash"
99
99
  elsif field.enum?
100
100
  # TODO: handle when arg message is nil and enum is the type
101
101
  message_ruby_type field.enum
102
102
  else
103
103
  case field.type
104
- when 1, 2 then "Float"
105
- when 3, 4, 5, 6, 7, 13, 15, 16, 17, 18 then "Integer"
106
- when 9, 12 then "String"
107
- when 8 then "Boolean"
104
+ when 1, 2 then "::Float"
105
+ when 3, 4, 5, 6, 7, 13, 15, 16, 17, 18 then "::Integer"
106
+ when 9, 12 then "::String"
107
+ when 8 then "::Boolean"
108
108
  else
109
- "Object"
109
+ "::Object"
110
110
  end
111
111
  end
112
- field.repeated? ? "Array<#{base_type}>" : base_type
112
+ field.repeated? ? "::Array<#{base_type}>" : base_type
113
113
  end
114
114
 
115
115
  def field_map_type entry_message, output
@@ -118,7 +118,7 @@ module Gapic
118
118
  key_field = field if field.name == "key"
119
119
  value_field = field if field.name == "value"
120
120
  end
121
- class_name = output ? "Google::Protobuf::Map" : "Hash"
121
+ class_name = output ? "::Google::Protobuf::Map" : "::Hash"
122
122
  if key_field && value_field
123
123
  key_type = field_doc_types key_field, output
124
124
  value_type = field_doc_types value_field, output
@@ -141,7 +141,7 @@ module Gapic
141
141
  when 9, 12 then "\"hello world\""
142
142
  when 8 then "true"
143
143
  else
144
- "Object"
144
+ "::Object"
145
145
  end
146
146
  end
147
147
  end
@@ -39,7 +39,7 @@ module Gapic
39
39
  end
40
40
 
41
41
  def namespace
42
- return @file.ruby_package if @file.ruby_package.present?
42
+ return ensure_absolute_namespace @file.ruby_package if @file.ruby_package.present?
43
43
  ruby_namespace_for_address address
44
44
  end
45
45
 
@@ -64,13 +64,13 @@ module Gapic
64
64
 
65
65
  def doc_response_type
66
66
  ret = return_type
67
- ret = "Gapic::Operation" if lro?
67
+ ret = "::Gapic::Operation" if lro?
68
68
  if server_streaming?
69
- ret = "Enumerable<#{ret}>"
69
+ ret = "::Enumerable<#{ret}>"
70
70
  elsif paged?
71
71
  paged_type = paged_response_type
72
- paged_type = "Gapic::Operation" if paged_type == "Google::Longrunning::Operation"
73
- ret = "Gapic::PagedEnumerable<#{paged_type}>"
72
+ paged_type = "::Gapic::Operation" if paged_type == "::Google::Longrunning::Operation"
73
+ ret = "::Gapic::PagedEnumerable<#{paged_type}>"
74
74
  end
75
75
  ret
76
76
  end
@@ -123,7 +123,7 @@ module Gapic
123
123
  return [
124
124
  OpenStruct.new(
125
125
  name: "operation",
126
- doc_types: "Gapic::Operation"
126
+ doc_types: "::Gapic::Operation"
127
127
  )
128
128
  ]
129
129
  end
@@ -134,7 +134,7 @@ module Gapic
134
134
  ),
135
135
  OpenStruct.new(
136
136
  name: "operation",
137
- doc_types: "GRPC::ActiveCall::Operation"
137
+ doc_types: "::GRPC::ActiveCall::Operation"
138
138
  )
139
139
  ]
140
140
  end
@@ -150,9 +150,9 @@ module Gapic
150
150
  end
151
151
 
152
152
  def lro?
153
- return paged_response_type == "Google::Longrunning::Operation" if paged?
153
+ return paged_response_type == "::Google::Longrunning::Operation" if paged?
154
154
 
155
- message_ruby_type(@method.output) == "Google::Longrunning::Operation"
155
+ message_ruby_type(@method.output) == "::Google::Longrunning::Operation"
156
156
  end
157
157
 
158
158
  def client_streaming?
@@ -226,12 +226,12 @@ module Gapic
226
226
  message_ruby_type arg.enum
227
227
  else
228
228
  case arg.type
229
- when 1, 2 then "Float"
230
- when 3, 4, 5, 6, 7, 13, 15, 16, 17, 18 then "Integer"
231
- when 9, 12 then "String"
232
- when 8 then "Boolean"
229
+ when 1, 2 then "::Float"
230
+ when 3, 4, 5, 6, 7, 13, 15, 16, 17, 18 then "::Integer"
231
+ when 9, 12 then "::String"
232
+ when 8 then "::Boolean"
233
233
  else
234
- "Object"
234
+ "::Object"
235
235
  end
236
236
  end
237
237
  end
@@ -256,7 +256,7 @@ module Gapic
256
256
  when 9, 12 then "\"hello world\""
257
257
  when 8 then "true"
258
258
  else
259
- "Object"
259
+ "::Object"
260
260
  end
261
261
  end
262
262
  end
@@ -74,7 +74,7 @@ module Gapic
74
74
  # into the KMS namespace.
75
75
  return common_service_delegate.namespace if common_service_delegate
76
76
 
77
- return @service.ruby_package if @service.ruby_package.present?
77
+ return ensure_absolute_namespace @service.ruby_package if @service.ruby_package.present?
78
78
 
79
79
  namespace = ruby_namespace_for_address @service.address[0...-1]
80
80
  fix_namespace @api, namespace
@@ -95,7 +95,7 @@ module Gapic
95
95
  # The namespace of the protos. This may be different from the client
96
96
  # namespace for a common service.
97
97
  def proto_namespace
98
- return @service.ruby_package if @service.ruby_package.present?
98
+ return ensure_absolute_namespace @service.ruby_package if @service.ruby_package.present?
99
99
 
100
100
  namespace = ruby_namespace_for_address @service.address[0...-1]
101
101
  @api.override_proto_namespaces? ? fix_namespace(@api, namespace) : namespace
@@ -5,12 +5,13 @@
5
5
  <%= @requires -%>
6
6
  <%- end -%>
7
7
 
8
- <%- namespace.split("::").each_with_index do |ns, i| -%>
8
+ <%- namespace_components = namespace.split("::").reject(&:empty?) -%>
9
+ <%- namespace_components.each_with_index do |ns, i| -%>
9
10
  <%= indent "module #{ns}", i*2 %>
10
11
  <%- end -%>
11
- <%= indent yield, namespace.split("::").count*2 %>
12
- <%- namespace.split("::").count.times do |i| -%>
13
- <%= indent "end", (namespace.split("::").count-1-i)*2 %>
12
+ <%= indent yield, namespace_components.count*2 %>
13
+ <%- namespace_components.count.times do |i| -%>
14
+ <%= indent "end", (namespace_components.count-1-i)*2 %>
14
15
  <%- end -%>
15
16
  <%- if instance_variable_defined? :@footer -%>
16
17
 
@@ -10,8 +10,8 @@
10
10
  <%- end -%>
11
11
  <%- end -%>
12
12
  class <%= message.name %>
13
- include Google::Protobuf::MessageExts
14
- extend Google::Protobuf::MessageExts::ClassMethods
13
+ include ::Google::Protobuf::MessageExts
14
+ extend ::Google::Protobuf::MessageExts::ClassMethods
15
15
  <%- message.nested_messages.each do |submsg| -%>
16
16
 
17
17
  <%= indent_tail render(partial: "proto_docs/message", locals: { message: submsg }), 2 %>
@@ -29,7 +29,7 @@ class <%= service.client_name %>
29
29
  # To modify the configuration for all <%= service.name %> clients:
30
30
  #
31
31
  # <%= service.client_name_full %>.configure do |config|
32
- # config.timeout = 10_000
32
+ # config.timeout = 10.0
33
33
  # end
34
34
  #
35
35
  # @yield [config] Configure the <%= service.client_name %> client.
@@ -75,7 +75,7 @@ class <%= service.client_name %>
75
75
  # configuration:
76
76
  #
77
77
  # client = <%= service.client_name_full %>.new do |config|
78
- # config.timeout = 10_000
78
+ # config.timeout = 10.0
79
79
  # end
80
80
  #
81
81
  # @yield [config] Configure the <%= service.name %> client.
@@ -109,7 +109,7 @@ class <%= service.client_name %>
109
109
  end
110
110
 
111
111
  <%- end -%>
112
- @<%= service.stub_name %> = Gapic::ServiceStub.new(
112
+ @<%= service.stub_name %> = ::Gapic::ServiceStub.new(
113
113
  <%= service.proto_service_stub_name_full %>,
114
114
  credentials: credentials,
115
115
  endpoint: @config.endpoint,
@@ -20,22 +20,22 @@
20
20
  # to 20 seconds, and all remaining timeouts to 10 seconds:
21
21
  #
22
22
  # <%= service.client_name_full %>.configure do |config|
23
- # config.timeout = 10_000
24
- # config.rpcs.<%= method_service.methods.first.name %>.timeout = 20_000
23
+ # config.timeout = 10.0
24
+ # config.rpcs.<%= method_service.methods.first.name %>.timeout = 20.0
25
25
  # end
26
26
  #
27
27
  # To apply the above configuration only to a new client:
28
28
  #
29
29
  # client = <%= service.client_name_full %>.new do |config|
30
- # config.timeout = 10_000
31
- # config.rpcs.<%= method_service.methods.first.name %>.timeout = 20_000
30
+ # config.timeout = 10.0
31
+ # config.rpcs.<%= method_service.methods.first.name %>.timeout = 20.0
32
32
  # end
33
33
  #
34
34
  <%- end -%>
35
35
  # @!attribute [rw] endpoint
36
36
  # The hostname or hostname:port of the service endpoint.
37
37
  # Defaults to `<%= service.client_endpoint.inspect %>`.
38
- # @return [String]
38
+ # @return [::String]
39
39
  # @!attribute [rw] credentials
40
40
  # Credentials to send with calls. You may provide any of the following types:
41
41
  # * (`String`) The path to a service account key file in JSON format
@@ -47,29 +47,29 @@
47
47
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
48
48
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
49
49
  # * (`nil`) indicating no credentials
50
- # @return [Object]
50
+ # @return [::Object]
51
51
  # @!attribute [rw] scope
52
52
  # The OAuth scopes
53
- # @return [Array<String>]
53
+ # @return [::Array<::String>]
54
54
  # @!attribute [rw] lib_name
55
55
  # The library name as recorded in instrumentation and logging
56
- # @return [String]
56
+ # @return [::String]
57
57
  # @!attribute [rw] lib_version
58
58
  # The library version as recorded in instrumentation and logging
59
- # @return [String]
59
+ # @return [::String]
60
60
  # @!attribute [rw] channel_args
61
61
  # Extra parameters passed to the gRPC channel. Note: this is ignored if a
62
62
  # `GRPC::Core::Channel` object is provided as the credential.
63
- # @return [Hash]
63
+ # @return [::Hash]
64
64
  # @!attribute [rw] interceptors
65
65
  # An array of interceptors that are run before calls are executed.
66
- # @return [Array<GRPC::ClientInterceptor>]
66
+ # @return [::Array<::GRPC::ClientInterceptor>]
67
67
  # @!attribute [rw] timeout
68
- # The call timeout in milliseconds.
69
- # @return [Numeric]
68
+ # The call timeout in seconds.
69
+ # @return [::Numeric]
70
70
  # @!attribute [rw] metadata
71
71
  # Additional gRPC headers to be sent with the call.
72
- # @return [Hash{Symbol=>String}]
72
+ # @return [::Hash{::Symbol=>::String}]
73
73
  # @!attribute [rw] retry_policy
74
74
  # The retry policy. The value is a hash with the following keys:
75
75
  # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
@@ -77,10 +77,10 @@
77
77
  # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
78
78
  # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
79
79
  # trigger a retry.
80
- # @return [Hash]
80
+ # @return [::Hash]
81
81
  #
82
82
  class Configuration
83
- extend Gapic::Config
83
+ extend ::Gapic::Config
84
84
 
85
85
  config_attr :endpoint, <%= service.client_endpoint.inspect %>, String
86
86
  config_attr :credentials, nil do |value|
@@ -88,14 +88,14 @@ class Configuration
88
88
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
89
89
  allowed.any? { |klass| klass === value }
90
90
  end
91
- config_attr :scope, nil, String, Array, nil
92
- config_attr :lib_name, nil, String, nil
93
- config_attr :lib_version, nil, String, nil
94
- config_attr(:channel_args, <%= service.config_channel_args.inspect %>, Hash, nil)
95
- config_attr :interceptors, nil, Array, nil
96
- config_attr :timeout, nil, Numeric, nil
97
- config_attr :metadata, nil, Hash, nil
98
- config_attr :retry_policy, nil, Hash, Proc, nil
91
+ config_attr :scope, nil, ::String, ::Array, nil
92
+ config_attr :lib_name, nil, ::String, nil
93
+ config_attr :lib_version, nil, ::String, nil
94
+ config_attr(:channel_args, <%= service.config_channel_args.inspect %>, ::Hash, nil)
95
+ config_attr :interceptors, nil, ::Array, nil
96
+ config_attr :timeout, nil, ::Numeric, nil
97
+ config_attr :metadata, nil, ::Hash, nil
98
+ config_attr :retry_policy, nil, ::Hash, Proc, nil
99
99
 
100
100
  # @private
101
101
  def initialize parent_config = nil
@@ -137,7 +137,7 @@ class Configuration
137
137
  <%- method_service.methods.each do |method| -%>
138
138
  ##
139
139
  # RPC-specific configuration for `<%= method.name %>`
140
- # @return [Gapic::Config::Method]
140
+ # @return [::Gapic::Config::Method]
141
141
  #
142
142
  attr_reader :<%= method.name %>
143
143
  <%- end -%>
@@ -146,7 +146,7 @@ class Configuration
146
146
  def initialize parent_rpcs = nil
147
147
  <%- method_service.methods.each do |method| -%>
148
148
  <%= method.name %>_config = parent_rpcs&.<%= method.name %> if parent_rpcs&.respond_to? :<%= method.name %>
149
- @<%= method.name %> = Gapic::Config::Method.new <%= method.name %>_config
149
+ @<%= method.name %> = ::Gapic::Config::Method.new <%= method.name %>_config
150
150
  <%- end -%>
151
151
 
152
152
  yield self if block_given?
@@ -3,7 +3,7 @@
3
3
  require "googleauth"
4
4
  <% end %>
5
5
  # Credentials for the <%= service.name %> API.
6
- class <%= service.credentials_name %> < Google::Auth::Credentials
6
+ class <%= service.credentials_name %> < ::Google::Auth::Credentials
7
7
  <%- if service.client_scopes.any? -%>
8
8
  self.scope = [
9
9
  <%- service.client_scopes.each_with_index do |client_scope, index| -%>
@@ -65,7 +65,7 @@ class <%= service.operations_name %>
65
65
  credentials = Credentials.new credentials, scope: @config.scope
66
66
  end
67
67
 
68
- @<%= service.lro_service.stub_name %> = Gapic::ServiceStub.new(
68
+ @<%= service.lro_service.stub_name %> = ::Gapic::ServiceStub.new(
69
69
  <%= service.lro_service.proto_service_stub_name_full %>,
70
70
  credentials: credentials,
71
71
  endpoint: @config.endpoint,
@@ -1,12 +1,12 @@
1
1
  <%- assert_locals method -%>
2
2
  # Converts hash and nil to an options object
3
- options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
3
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
4
4
 
5
5
  # Customize the options with defaults
6
6
  metadata = @config.rpcs.<%= method.name %>.metadata.to_h
7
7
 
8
8
  # Set x-goog-api-client and x-goog-user-project headers
9
- metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
9
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
10
10
  lib_name: @config.lib_name, lib_version: @config.lib_version,
11
11
  gapic_version: ::<%= method.service.gem.version_name_full %>
12
12
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
@@ -1,4 +1,4 @@
1
1
  <%- assert_locals method -%>
2
- raise ArgumentError, "request must be provided" if request.nil?
2
+ raise ::ArgumentError, "request must be provided" if request.nil?
3
3
 
4
- request = Gapic::Protobuf.coerce request, to: <%= method.request_type %>
4
+ request = ::Gapic::Protobuf.coerce request, to: <%= method.request_type %>
@@ -1,9 +1,9 @@
1
1
  <%- assert_locals method -%>
2
- unless request.is_a? Enumerable
3
- raise ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
2
+ unless request.is_a? ::Enumerable
3
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
4
4
  request = request.to_enum
5
5
  end
6
6
 
7
7
  request = request.lazy.map do |req|
8
- Gapic::Protobuf.coerce req, to: <%= method.request_type %>
8
+ ::Gapic::Protobuf.coerce req, to: <%= method.request_type %>
9
9
  end
@@ -1,7 +1,7 @@
1
1
  <%- assert_locals method -%>
2
2
  @<%= method.service.stub_name %>.call_rpc :<%= method.name %>, request, options: options do |response, operation|
3
3
  <%- if method.lro? -%>
4
- response = Gapic::Operation.new response, <%= method.service.lro_client_ivar %>, options: options
4
+ response = ::Gapic::Operation.new response, <%= method.service.lro_client_ivar %>, options: options
5
5
  <%- end -%>
6
6
  yield response, operation if block_given?
7
7
  return response
@@ -1,9 +1,9 @@
1
1
  <%- assert_locals method -%>
2
2
  @<%= method.service.stub_name %>.call_rpc :<%= method.name %>, request, options: options do |response, operation|
3
3
  <%- if method.lro? -%>
4
- wrap_lro_operation = ->(op_response) { Gapic::Operation.new op_response, <%= method.service.lro_client_ivar %> }
4
+ wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, <%= method.service.lro_client_ivar %> }
5
5
  <%- end -%>
6
- response = Gapic::PagedEnumerable.new @<%= method.service.stub_name %>, :<%= method.name %>, request, response, operation, options<%- if method.lro? -%>, format_resource: wrap_lro_operation<%- end -%>
6
+ response = ::Gapic::PagedEnumerable.new @<%= method.service.stub_name %>, :<%= method.name %>, request, response, operation, options<%- if method.lro? -%>, format_resource: wrap_lro_operation<%- end -%>
7
7
  yield response, operation if block_given?
8
8
  return response
9
9
  end
@@ -1,2 +1,2 @@
1
1
  <%- assert_locals method -%>
2
- # @raise [GRPC::BadStatus] if the RPC is aborted.
2
+ # @raise [::GRPC::BadStatus] if the RPC is aborted.
@@ -3,10 +3,10 @@
3
3
  # Pass arguments to `<%= method.name %>` via a request object, either of type
4
4
  # {<%= method.request_type %>} or an equivalent Hash.
5
5
  #
6
- # @param request [<%= method.request_type %>, Hash]
6
+ # @param request [<%= method.request_type %>, ::Hash]
7
7
  # A request object representing the call parameters. Required. To specify no
8
8
  # parameters, or to keep all the default parameter values, pass an empty Hash.
9
- # @param options [Gapic::CallOptions, Hash]
9
+ # @param options [::Gapic::CallOptions, ::Hash]
10
10
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
11
11
  <%-if method.arguments.any?-%>
12
12
  #
@@ -1,5 +1,5 @@
1
1
  <%- assert_locals method -%>
2
- # @param request [Gapic::StreamInput, Enumerable<<%= method.request_type %>, Hash>]
2
+ # @param request [::Gapic::StreamInput, ::Enumerable<<%= method.request_type %>, ::Hash>]
3
3
  # An enumerable of {<%= method.request_type %>} instances.
4
- # @param options [Gapic::CallOptions, Hash]
4
+ # @param options [::Gapic::CallOptions, ::Hash]
5
5
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@@ -1,6 +1,6 @@
1
1
  <%- assert_locals method -%>
2
2
  # @yield [response, operation] Access the result along with the RPC operation
3
3
  # @yieldparam response [<%= method.doc_response_type %>]
4
- # @yieldparam operation [GRPC::ActiveCall::Operation]
4
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
5
5
  #
6
6
  # @return [<%= method.doc_response_type %>]
@@ -1,6 +1,6 @@
1
1
  <%- assert_locals pattern -%>
2
2
  <%- pattern.arguments[0...-1].each do |arg| -%>
3
- raise ArgumentError, "<%= arg %> cannot contain /" if <%= arg %>.to_s.include? "/"
3
+ raise ::ArgumentError, "<%= arg %> cannot contain /" if <%= arg %>.to_s.include? "/"
4
4
  <%- end -%>
5
5
 
6
6
  "<%= pattern.path_string %>"
@@ -8,7 +8,7 @@
8
8
  <%= indent render(partial: "service/client/resource/doc", locals: { pattern: pattern }), "# " %>
9
9
  #
10
10
  <%- end -%>
11
- # @return [String]
11
+ # @return [::String]
12
12
  def <%= resource.path_helper %> **args
13
13
  resources = {
14
14
  <%- last_pattern_index = resource.patterns.count - 1 -%>
@@ -23,6 +23,6 @@ def <%= resource.path_helper %> **args
23
23
  }
24
24
 
25
25
  resource = resources[args.keys.sort.join(":")]
26
- raise ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
26
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
27
27
  resource.call(**args)
28
28
  end
@@ -4,7 +4,7 @@
4
4
  #
5
5
  <%= indent render(partial: "service/client/resource/doc", locals: { pattern: resource.patterns.first }), "# " %>
6
6
  #
7
- # @return [String]
7
+ # @return [::String]
8
8
  <%- args = resource.patterns.first.arguments.map { |arg| "#{arg}:" }.join ", " -%>
9
9
  def <%= resource.path_helper %> <%= args %>
10
10
  <%= indent render(partial: "service/client/resource/def", locals: { pattern: resource.patterns.first }), 2 %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gapic-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernest Landrito
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-04-20 00:00:00.000000000 Z
13
+ date: 2020-04-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionpack
@@ -351,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
351
351
  - !ruby/object:Gem::Version
352
352
  version: '0'
353
353
  requirements: []
354
- rubygems_version: 3.1.2
354
+ rubygems_version: 3.0.3
355
355
  signing_key:
356
356
  specification_version: 4
357
357
  summary: An API Client Generator for Ruby in Ruby!