gapic-generator-cloud 0.5.0
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 +7 -0
 - data/CHANGELOG.md +117 -0
 - data/CONTRIBUTING.md +28 -0
 - data/LICENSE +202 -0
 - data/README.md +84 -0
 - data/bin/protoc-gen-ruby_cloud +33 -0
 - data/bin/ruby-cloud-docker-entrypoint +130 -0
 - data/cloud-rubocop.yml +14 -0
 - data/lib/gapic/generator/cloud/version.rb +24 -0
 - data/lib/gapic/generators/cloud_generator.rb +119 -0
 - data/lib/gapic/presenters/wrapper_gem_presenter.rb +137 -0
 - data/lib/gapic/presenters/wrapper_service_presenter.rb +53 -0
 - data/templates/cloud/gem/authentication.erb +172 -0
 - data/templates/cloud/gem/gemspec.erb +40 -0
 - data/templates/cloud/gem/gitignore.erb +23 -0
 - data/templates/cloud/gem/license.erb +204 -0
 - data/templates/cloud/gem/rakefile.erb +157 -0
 - data/templates/cloud/gem/readme.erb +93 -0
 - data/templates/cloud/gem/repo-metadata.erb +6 -0
 - data/templates/cloud/gem/rubocop.erb +36 -0
 - data/templates/cloud/gem/yardopts.erb +13 -0
 - data/templates/cloud/service/client/_credentials.erb +30 -0
 - data/templates/cloud/service/client/_requires.erb +2 -0
 - data/templates/cloud/service/client/_self_configure.erb +15 -0
 - data/templates/cloud/service/client/method/def/_rescue.erb +3 -0
 - data/templates/cloud/service/client/method/docs/_error.erb +2 -0
 - data/templates/cloud/shared/_license.erb +13 -0
 - data/templates/cloud/wrapper_gem/_main.erb +102 -0
 - data/templates/cloud/wrapper_gem/client_test.erb +22 -0
 - data/templates/cloud/wrapper_gem/entrypoint.erb +4 -0
 - data/templates/cloud/wrapper_gem/gemfile.erb +14 -0
 - data/templates/cloud/wrapper_gem/gemspec.erb +39 -0
 - data/templates/cloud/wrapper_gem/main.erb +5 -0
 - data/templates/cloud/wrapper_gem/rakefile.erb +190 -0
 - data/templates/cloud/wrapper_gem/readme.erb +95 -0
 - data/templates/cloud/wrapper_gem/rubocop.erb +23 -0
 - data/templates/cloud/wrapper_gem/version_test.erb +11 -0
 - data/templates/cloud/wrapper_gem/yardopts.erb +15 -0
 - metadata +226 -0
 
| 
         @@ -0,0 +1,93 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Ruby Client for the <%= gem.title %> API
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            <%= gem.summary %>
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            <%= gem.description %>
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            <%= gem.homepage %>
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ```
         
     | 
| 
      
 12 
     | 
    
         
            +
            $ gem install <%= gem.name %>
         
     | 
| 
      
 13 
     | 
    
         
            +
            ```
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            ## Before You Begin
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            In order to use this library, you first need to go through the following steps:
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
         
     | 
| 
      
 20 
     | 
    
         
            +
            <%- if gem.free_tier? -%>
         
     | 
| 
      
 21 
     | 
    
         
            +
            1. This API has a free tier. You may not need to
         
     | 
| 
      
 22 
     | 
    
         
            +
               [enable billing](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
         
     | 
| 
      
 23 
     | 
    
         
            +
               to get started.
         
     | 
| 
      
 24 
     | 
    
         
            +
            <%- else -%>
         
     | 
| 
      
 25 
     | 
    
         
            +
            1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
         
     | 
| 
      
 26 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 27 
     | 
    
         
            +
            <%- if gem.api_id -%>
         
     | 
| 
      
 28 
     | 
    
         
            +
            1. [Enable the API.](https://console.cloud.google.com/apis/library/<%= gem.api_id %>.googleapis.com)
         
     | 
| 
      
 29 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 30 
     | 
    
         
            +
            1. {file:AUTHENTICATION.md Set up authentication.}
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            ## Quick Start
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            <%- if gem.packages? -%>
         
     | 
| 
      
 35 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 36 
     | 
    
         
            +
            require "<%= gem.entrypoint_require %>"
         
     | 
| 
      
 37 
     | 
    
         
            +
            <%- service = gem.packages.first.services.first -%>
         
     | 
| 
      
 38 
     | 
    
         
            +
            <%- method = service&.methods.first -%>
         
     | 
| 
      
 39 
     | 
    
         
            +
            <%- if service && method -%>
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            client = <%= service.create_client_call %>
         
     | 
| 
      
 42 
     | 
    
         
            +
            request = my_create_request
         
     | 
| 
      
 43 
     | 
    
         
            +
            response = client.<%= method.name %> request
         
     | 
| 
      
 44 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 45 
     | 
    
         
            +
            ```
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 48 
     | 
    
         
            +
            <%- unless gem.library_documentation_url.to_s.empty? -%>
         
     | 
| 
      
 49 
     | 
    
         
            +
            View the [Client Library Documentation](<%= gem.library_documentation_url %>)
         
     | 
| 
      
 50 
     | 
    
         
            +
            for class and method documentation.
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 53 
     | 
    
         
            +
            <%- if gem.product_documentation_url -%>
         
     | 
| 
      
 54 
     | 
    
         
            +
            See also the [Product Documentation](<%= gem.product_documentation_url %>)
         
     | 
| 
      
 55 
     | 
    
         
            +
            for general usage information.
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 58 
     | 
    
         
            +
            ## Enabling Logging
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
         
     | 
| 
      
 61 
     | 
    
         
            +
            The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
         
     | 
| 
      
 62 
     | 
    
         
            +
            or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
         
     | 
| 
      
 63 
     | 
    
         
            +
            that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
         
     | 
| 
      
 64 
     | 
    
         
            +
            and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            Configuring a Ruby stdlib logger:
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 69 
     | 
    
         
            +
            require "logger"
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            module MyLogger
         
     | 
| 
      
 72 
     | 
    
         
            +
              LOGGER = Logger.new $stderr, level: Logger::WARN
         
     | 
| 
      
 73 
     | 
    
         
            +
              def logger
         
     | 
| 
      
 74 
     | 
    
         
            +
                LOGGER
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
         
     | 
| 
      
 79 
     | 
    
         
            +
            module GRPC
         
     | 
| 
      
 80 
     | 
    
         
            +
              extend MyLogger
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
| 
      
 82 
     | 
    
         
            +
            ```
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            ## Supported Ruby Versions
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            This library is supported on Ruby 2.4+.
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            Google provides official support for Ruby versions that are actively supported
         
     | 
| 
      
 89 
     | 
    
         
            +
            by Ruby Core—that is, Ruby versions that are either in normal maintenance or
         
     | 
| 
      
 90 
     | 
    
         
            +
            in security maintenance, and not end of life. Currently, this means Ruby 2.4
         
     | 
| 
      
 91 
     | 
    
         
            +
            and later. Older versions of Ruby _may_ still work, but are unsupported and not
         
     | 
| 
      
 92 
     | 
    
         
            +
            recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
         
     | 
| 
      
 93 
     | 
    
         
            +
            about the Ruby support schedule.
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%- assert_locals gem -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            inherit_gem:
         
     | 
| 
      
 3 
     | 
    
         
            +
              google-style: google-style.yml
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            AllCops:
         
     | 
| 
      
 6 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 7 
     | 
    
         
            +
                - "<%= gem.name %>.gemspec"
         
     | 
| 
      
 8 
     | 
    
         
            +
                - "lib/**/*_pb.rb"
         
     | 
| 
      
 9 
     | 
    
         
            +
                - "proto_docs/**/*"
         
     | 
| 
      
 10 
     | 
    
         
            +
                - "test/**/*"
         
     | 
| 
      
 11 
     | 
    
         
            +
                - "acceptance/**/*"
         
     | 
| 
      
 12 
     | 
    
         
            +
                - "Rakefile"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Metrics/AbcSize:
         
     | 
| 
      
 15 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 16 
     | 
    
         
            +
            Metrics/ClassLength:
         
     | 
| 
      
 17 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 18 
     | 
    
         
            +
            Metrics/CyclomaticComplexity:
         
     | 
| 
      
 19 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 20 
     | 
    
         
            +
            Metrics/LineLength:
         
     | 
| 
      
 21 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 22 
     | 
    
         
            +
            Metrics/MethodLength:
         
     | 
| 
      
 23 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 24 
     | 
    
         
            +
            Metrics/ModuleLength:
         
     | 
| 
      
 25 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 26 
     | 
    
         
            +
            Metrics/PerceivedComplexity:
         
     | 
| 
      
 27 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 28 
     | 
    
         
            +
            Naming/FileName:
         
     | 
| 
      
 29 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 30 
     | 
    
         
            +
                - "lib/<%= gem.name %>.rb"
         
     | 
| 
      
 31 
     | 
    
         
            +
            Style/CaseEquality:
         
     | 
| 
      
 32 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 33 
     | 
    
         
            +
            Style/IfUnlessModifier:
         
     | 
| 
      
 34 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 35 
     | 
    
         
            +
            Style/ModuleFunction:
         
     | 
| 
      
 36 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%- assert_locals service -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <% @requires = capture do %>
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "googleauth"
         
     | 
| 
      
 4 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Credentials for the <%= service.name %> API.
         
     | 
| 
      
 6 
     | 
    
         
            +
            class <%= service.credentials_name %> < ::Google::Auth::Credentials
         
     | 
| 
      
 7 
     | 
    
         
            +
              <%- if service.client_scopes.any? -%>
         
     | 
| 
      
 8 
     | 
    
         
            +
              self.scope = [
         
     | 
| 
      
 9 
     | 
    
         
            +
              <%- service.client_scopes.each_with_index do |client_scope, index| -%>
         
     | 
| 
      
 10 
     | 
    
         
            +
                <%- comma = index == service.client_scopes.count - 1 ? "" : "," -%>
         
     | 
| 
      
 11 
     | 
    
         
            +
                <%= client_scope.inspect %><%= comma %>
         
     | 
| 
      
 12 
     | 
    
         
            +
              <%- end -%>
         
     | 
| 
      
 13 
     | 
    
         
            +
              ]
         
     | 
| 
      
 14 
     | 
    
         
            +
              <%- end -%>
         
     | 
| 
      
 15 
     | 
    
         
            +
              self.env_vars = [
         
     | 
| 
      
 16 
     | 
    
         
            +
                "<%= service.gem.env_prefix %>_CREDENTIALS",
         
     | 
| 
      
 17 
     | 
    
         
            +
                "<%= service.gem.env_prefix %>_KEYFILE",
         
     | 
| 
      
 18 
     | 
    
         
            +
                "GOOGLE_CLOUD_CREDENTIALS",
         
     | 
| 
      
 19 
     | 
    
         
            +
                "GOOGLE_CLOUD_KEYFILE",
         
     | 
| 
      
 20 
     | 
    
         
            +
                "GCLOUD_KEYFILE",
         
     | 
| 
      
 21 
     | 
    
         
            +
                "<%= service.gem.env_prefix %>_CREDENTIALS_JSON",
         
     | 
| 
      
 22 
     | 
    
         
            +
                "<%= service.gem.env_prefix %>_KEYFILE_JSON",
         
     | 
| 
      
 23 
     | 
    
         
            +
                "GOOGLE_CLOUD_CREDENTIALS_JSON",
         
     | 
| 
      
 24 
     | 
    
         
            +
                "GOOGLE_CLOUD_KEYFILE_JSON",
         
     | 
| 
      
 25 
     | 
    
         
            +
                "GCLOUD_KEYFILE_JSON"
         
     | 
| 
      
 26 
     | 
    
         
            +
              ]
         
     | 
| 
      
 27 
     | 
    
         
            +
              self.paths = [
         
     | 
| 
      
 28 
     | 
    
         
            +
                "~/.config/google_cloud/application_default_credentials.json"
         
     | 
| 
      
 29 
     | 
    
         
            +
              ]
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%- assert_locals service -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            @configure ||= begin
         
     | 
| 
      
 3 
     | 
    
         
            +
              namespace = <%= service.namespace.split("::").reject(&:empty?).inspect %>
         
     | 
| 
      
 4 
     | 
    
         
            +
              parent_config = while namespace.any?
         
     | 
| 
      
 5 
     | 
    
         
            +
                                parent_name = namespace.join "::"
         
     | 
| 
      
 6 
     | 
    
         
            +
                                parent_const = const_get parent_name
         
     | 
| 
      
 7 
     | 
    
         
            +
                                break parent_const.configure if parent_const&.respond_to? :configure
         
     | 
| 
      
 8 
     | 
    
         
            +
                                namespace.pop
         
     | 
| 
      
 9 
     | 
    
         
            +
                              end
         
     | 
| 
      
 10 
     | 
    
         
            +
              default_config = <%= service.client_name %>::Configuration.new parent_config
         
     | 
| 
      
 11 
     | 
    
         
            +
              <%= render partial: "service/client/self_configure_defaults", locals: {service: service} %>
         
     | 
| 
      
 12 
     | 
    
         
            +
              default_config
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
      
 14 
     | 
    
         
            +
            yield @configure if block_given?
         
     | 
| 
      
 15 
     | 
    
         
            +
            @configure
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Copyright <%= Time.now.year %> Google LLC
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
      
 4 
     | 
    
         
            +
            # you may not use this file except in compliance with the License.
         
     | 
| 
      
 5 
     | 
    
         
            +
            # You may obtain a copy of the License at
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            #     https://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
      
 10 
     | 
    
         
            +
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
      
 11 
     | 
    
         
            +
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
      
 12 
     | 
    
         
            +
            # See the License for the specific language governing permissions and
         
     | 
| 
      
 13 
     | 
    
         
            +
            # limitations under the License.
         
     | 
| 
         @@ -0,0 +1,102 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%- assert_locals gem -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <% @requires = capture do %>
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Require this file early so that the version constant gets defined before
         
     | 
| 
      
 4 
     | 
    
         
            +
            # requiring "google/cloud". This is because google-cloud-core will load the
         
     | 
| 
      
 5 
     | 
    
         
            +
            # entrypoint (gem name) file, which in turn re-requires this file (hence
         
     | 
| 
      
 6 
     | 
    
         
            +
            # causing a require cycle) unless the version constant is already defined.
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "<%= gem.version_require %>"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            require "googleauth"
         
     | 
| 
      
 10 
     | 
    
         
            +
            <%- if gem.needs_default_config_block? -%>
         
     | 
| 
      
 11 
     | 
    
         
            +
            gem "google-cloud-core"
         
     | 
| 
      
 12 
     | 
    
         
            +
            require "google/cloud" unless defined? ::Google::Cloud.new
         
     | 
| 
      
 13 
     | 
    
         
            +
            require "google/cloud/config"
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            # Set the default configuration
         
     | 
| 
      
 16 
     | 
    
         
            +
            ::Google::Cloud.configure.add_config! :<%= gem.google_cloud_short_name %> do |config|
         
     | 
| 
      
 17 
     | 
    
         
            +
              config.add_field! :endpoint,      <%= gem.services.first&.client_endpoint.inspect %>, match: ::String
         
     | 
| 
      
 18 
     | 
    
         
            +
              config.add_field! :credentials,   nil, match: [::String, ::Hash, ::Google::Auth::Credentials]
         
     | 
| 
      
 19 
     | 
    
         
            +
              config.add_field! :scope,         nil, match: [::Array, ::String]
         
     | 
| 
      
 20 
     | 
    
         
            +
              config.add_field! :lib_name,      nil, match: ::String
         
     | 
| 
      
 21 
     | 
    
         
            +
              config.add_field! :lib_version,   nil, match: ::String
         
     | 
| 
      
 22 
     | 
    
         
            +
              config.add_field! :interceptors,  nil, match: ::Array
         
     | 
| 
      
 23 
     | 
    
         
            +
              config.add_field! :timeout,       nil, match: ::Numeric
         
     | 
| 
      
 24 
     | 
    
         
            +
              config.add_field! :metadata,      nil, match: ::Hash
         
     | 
| 
      
 25 
     | 
    
         
            +
              config.add_field! :retry_policy,  nil, match: [::Hash, ::Proc]
         
     | 
| 
      
 26 
     | 
    
         
            +
              config.add_field! :quota_project, nil, match: ::String
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 29 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 30 
     | 
    
         
            +
            <%- gem.services.each do |service| -%>
         
     | 
| 
      
 31 
     | 
    
         
            +
            ##
         
     | 
| 
      
 32 
     | 
    
         
            +
            # Create a new client object for <%= service.module_name %>.
         
     | 
| 
      
 33 
     | 
    
         
            +
            #
         
     | 
| 
      
 34 
     | 
    
         
            +
            # By default, this returns an instance of
         
     | 
| 
      
 35 
     | 
    
         
            +
            # <%= gem.docs_link version: gem.default_version, class_name: "#{service.module_name}::Client" %>
         
     | 
| 
      
 36 
     | 
    
         
            +
            # for version <%= gem.default_version.capitalize %> of the API.
         
     | 
| 
      
 37 
     | 
    
         
            +
            # However, you can specify specify a different API version by passing it in the
         
     | 
| 
      
 38 
     | 
    
         
            +
            # `version` parameter. If the <%= service.module_name %> service is
         
     | 
| 
      
 39 
     | 
    
         
            +
            # supported by that API version, and the corresponding gem is available, the
         
     | 
| 
      
 40 
     | 
    
         
            +
            # appropriate versioned client will be returned.
         
     | 
| 
      
 41 
     | 
    
         
            +
            #
         
     | 
| 
      
 42 
     | 
    
         
            +
            <%- if service.doc_description -%>
         
     | 
| 
      
 43 
     | 
    
         
            +
            # ## About <%= service.module_name %>
         
     | 
| 
      
 44 
     | 
    
         
            +
            #
         
     | 
| 
      
 45 
     | 
    
         
            +
            <%= indent service.doc_description(disable_xrefs: true), "# " %>
         
     | 
| 
      
 46 
     | 
    
         
            +
            #
         
     | 
| 
      
 47 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 48 
     | 
    
         
            +
            # @param version [::String, ::Symbol] The API version to connect to. Optional.
         
     | 
| 
      
 49 
     | 
    
         
            +
            #   Defaults to `:<%= gem.default_version %>`.
         
     | 
| 
      
 50 
     | 
    
         
            +
            # @return [<%= service.module_name %>::Client] A client object for the specified version.
         
     | 
| 
      
 51 
     | 
    
         
            +
            #
         
     | 
| 
      
 52 
     | 
    
         
            +
            def self.<%= service.factory_method_name %> version: :<%= gem.default_version %>, &block
         
     | 
| 
      
 53 
     | 
    
         
            +
              require "<%= gem.namespace_require %>/#{version.to_s.downcase}"
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              package_name = <%= gem.namespace %>
         
     | 
| 
      
 56 
     | 
    
         
            +
                              .constants
         
     | 
| 
      
 57 
     | 
    
         
            +
                              .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
         
     | 
| 
      
 58 
     | 
    
         
            +
                              .first
         
     | 
| 
      
 59 
     | 
    
         
            +
              package_module = <%= gem.namespace %>.const_get package_name
         
     | 
| 
      
 60 
     | 
    
         
            +
              package_module.const_get(:<%= service.module_name %>).const_get(:Client).new(&block)
         
     | 
| 
      
 61 
     | 
    
         
            +
            end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 64 
     | 
    
         
            +
            <%- if gem.google_cloud_short_name -%>
         
     | 
| 
      
 65 
     | 
    
         
            +
            ##
         
     | 
| 
      
 66 
     | 
    
         
            +
            # Configure the <%= gem.name %> library.
         
     | 
| 
      
 67 
     | 
    
         
            +
            #
         
     | 
| 
      
 68 
     | 
    
         
            +
            # The following configuration parameters are supported:
         
     | 
| 
      
 69 
     | 
    
         
            +
            #
         
     | 
| 
      
 70 
     | 
    
         
            +
            # * `credentials` (*type:* `String, Hash, Google::Auth::Credentials`) -
         
     | 
| 
      
 71 
     | 
    
         
            +
            #   The path to the keyfile as a String, the contents of the keyfile as a
         
     | 
| 
      
 72 
     | 
    
         
            +
            #   Hash, or a Google::Auth::Credentials object.
         
     | 
| 
      
 73 
     | 
    
         
            +
            # * `lib_name` (*type:* `String`) -
         
     | 
| 
      
 74 
     | 
    
         
            +
            #   The library name as recorded in instrumentation and logging.
         
     | 
| 
      
 75 
     | 
    
         
            +
            # * `lib_version` (*type:* `String`) -
         
     | 
| 
      
 76 
     | 
    
         
            +
            #   The library version as recorded in instrumentation and logging.
         
     | 
| 
      
 77 
     | 
    
         
            +
            # * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) -
         
     | 
| 
      
 78 
     | 
    
         
            +
            #   An array of interceptors that are run before calls are executed.
         
     | 
| 
      
 79 
     | 
    
         
            +
            # * `timeout` (*type:* `Integer`) -
         
     | 
| 
      
 80 
     | 
    
         
            +
            #   Default timeout in milliseconds.
         
     | 
| 
      
 81 
     | 
    
         
            +
            # * `metadata` (*type:* `Hash{Symbol=>String}`) -
         
     | 
| 
      
 82 
     | 
    
         
            +
            #   Additional gRPC headers to be sent with the call.
         
     | 
| 
      
 83 
     | 
    
         
            +
            # * `retry_policy` (*type:* `Hash`) -
         
     | 
| 
      
 84 
     | 
    
         
            +
            #   The retry policy. The value is a hash with the following keys:
         
     | 
| 
      
 85 
     | 
    
         
            +
            #     * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
         
     | 
| 
      
 86 
     | 
    
         
            +
            #     * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
         
     | 
| 
      
 87 
     | 
    
         
            +
            #     * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
         
     | 
| 
      
 88 
     | 
    
         
            +
            #     * `:retry_codes` (*type:* `Array<String>`) -
         
     | 
| 
      
 89 
     | 
    
         
            +
            #       The error codes that should trigger a retry.
         
     | 
| 
      
 90 
     | 
    
         
            +
            #
         
     | 
| 
      
 91 
     | 
    
         
            +
            # @return [::Google::Cloud::Config] The default configuration used by this library
         
     | 
| 
      
 92 
     | 
    
         
            +
            #
         
     | 
| 
      
 93 
     | 
    
         
            +
            def self.configure
         
     | 
| 
      
 94 
     | 
    
         
            +
              yield ::Google::Cloud.configure.<%= gem.google_cloud_short_name %> if block_given?
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              ::Google::Cloud.configure.<%= gem.google_cloud_short_name %>
         
     | 
| 
      
 97 
     | 
    
         
            +
            end
         
     | 
| 
      
 98 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 99 
     | 
    
         
            +
            <% @footer = capture do %>
         
     | 
| 
      
 100 
     | 
    
         
            +
            helper_path = ::File.join __dir__, "<%= gem.main_directory_name %>", "helpers.rb"
         
     | 
| 
      
 101 
     | 
    
         
            +
            require "<%= gem.helpers_require %>" if ::File.file? helper_path
         
     | 
| 
      
 102 
     | 
    
         
            +
            <% end %>
         
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%- assert_locals gem -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <%= render partial: "shared/header" -%>
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            require "helper"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "<%= gem.namespace_require %>"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "gapic/common"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "gapic/grpc"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            class <%= gem.namespace %>::ClientConstructionMinitest < Minitest::Test
         
     | 
| 
      
 10 
     | 
    
         
            +
            <%- gem.services.each do |service| -%>
         
     | 
| 
      
 11 
     | 
    
         
            +
              def test_<%= service.factory_method_name %>
         
     | 
| 
      
 12 
     | 
    
         
            +
                Gapic::ServiceStub.stub :new, :stub do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
         
     | 
| 
      
 14 
     | 
    
         
            +
                  client = <%= gem.namespace %>.<%= service.factory_method_name %> do |config|
         
     | 
| 
      
 15 
     | 
    
         
            +
                    config.credentials = grpc_channel
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                  assert_kind_of <%= gem.namespaced_class "#{service.module_name}::Client", version: gem.default_version %>, client
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%- assert_locals gem -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            source "https://rubygems.org"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            gemspec
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            gem "google-cloud-core", path: "../google-cloud-core"
         
     | 
| 
      
 7 
     | 
    
         
            +
            gem "google-cloud-env", path: "../google-cloud-env"
         
     | 
| 
      
 8 
     | 
    
         
            +
            gem "google-cloud-errors", path: "../google-cloud-errors"
         
     | 
| 
      
 9 
     | 
    
         
            +
            <%- gem.gem_version_dependencies.each do |name, _requirement| -%>
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem "<%= name %>", path: "../<%= name %>"
         
     | 
| 
      
 11 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            # google-protobuf 3.12.0 requires Ruby 2.5 or later, so pin to 3.11 on older Rubies
         
     | 
| 
      
 14 
     | 
    
         
            +
            gem "google-protobuf", (RUBY_VERSION < "2.5" ? "~> 3.11.4" : "~> 3.12")
         
     | 
| 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%- assert_locals gem -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            # -*- ruby -*-
         
     | 
| 
      
 3 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require File.expand_path("lib/<%= gem.version_require %>", __dir__)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Gem::Specification.new do |gem|
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem.name          = "<%= gem.name %>"
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem.version       = <%= gem.version_name_full %>
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              gem.authors       = <%= gem.authors.inspect %>
         
     | 
| 
      
 12 
     | 
    
         
            +
              gem.email         = <%= gem.email.inspect %>
         
     | 
| 
      
 13 
     | 
    
         
            +
              gem.description   = <%= gem.description.inspect %>
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem.summary       = <%= gem.summary.inspect %>
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem.homepage      = <%= gem.homepage.inspect %>
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem.license       = "Apache-2.0"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              gem.platform      = Gem::Platform::RUBY
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              gem.files         = `git ls-files -- lib/*`.split("\n") +
         
     | 
| 
      
 21 
     | 
    
         
            +
                                  <%= gem.extra_files.inspect %>
         
     | 
| 
      
 22 
     | 
    
         
            +
              gem.require_paths = ["lib"]
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              gem.required_ruby_version = ">= 2.4"
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              gem.add_dependency "google-cloud-core", "~> 1.5"
         
     | 
| 
      
 27 
     | 
    
         
            +
              <%- gem.gem_version_dependencies.each do |name, requirement| -%>
         
     | 
| 
      
 28 
     | 
    
         
            +
              gem.add_dependency "<%= name %>", "~> <%= requirement %>"
         
     | 
| 
      
 29 
     | 
    
         
            +
              <%- end -%>
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              gem.add_development_dependency "google-style", "~> 1.24.0"
         
     | 
| 
      
 32 
     | 
    
         
            +
              gem.add_development_dependency "minitest", "~> 5.14"
         
     | 
| 
      
 33 
     | 
    
         
            +
              gem.add_development_dependency "minitest-focus", "~> 1.1"
         
     | 
| 
      
 34 
     | 
    
         
            +
              gem.add_development_dependency "minitest-rg", "~> 5.2"
         
     | 
| 
      
 35 
     | 
    
         
            +
              gem.add_development_dependency "rake", ">= 12.0"
         
     | 
| 
      
 36 
     | 
    
         
            +
              gem.add_development_dependency "redcarpet", "~> 3.0"
         
     | 
| 
      
 37 
     | 
    
         
            +
              gem.add_development_dependency "simplecov", "~> 0.9"
         
     | 
| 
      
 38 
     | 
    
         
            +
              gem.add_development_dependency "yard", "~> 0.9"
         
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,190 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%- assert_locals gem -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <%- service = gem.services.first -%>
         
     | 
| 
      
 3 
     | 
    
         
            +
            <%- assert_locals service -%>
         
     | 
| 
      
 4 
     | 
    
         
            +
            <%= render partial: "shared/header" -%>
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "bundler/gem_tasks"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            require "rubocop/rake_task"
         
     | 
| 
      
 10 
     | 
    
         
            +
            RuboCop::RakeTask.new
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            require "rake/testtask"
         
     | 
| 
      
 13 
     | 
    
         
            +
            desc "Run tests."
         
     | 
| 
      
 14 
     | 
    
         
            +
            Rake::TestTask.new do |t|
         
     | 
| 
      
 15 
     | 
    
         
            +
              t.libs << "test"
         
     | 
| 
      
 16 
     | 
    
         
            +
              t.test_files = FileList["test/**/*_test.rb"]
         
     | 
| 
      
 17 
     | 
    
         
            +
              t.warning = true
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            namespace :test do
         
     | 
| 
      
 21 
     | 
    
         
            +
              desc "Runs tests with coverage."
         
     | 
| 
      
 22 
     | 
    
         
            +
              task :coverage do
         
     | 
| 
      
 23 
     | 
    
         
            +
                require "simplecov"
         
     | 
| 
      
 24 
     | 
    
         
            +
                SimpleCov.start do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  command_name "<%= gem.name %>"
         
     | 
| 
      
 26 
     | 
    
         
            +
                  track_files "lib/**/*.rb"
         
     | 
| 
      
 27 
     | 
    
         
            +
                  add_filter "test/"
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                Rake::Task[:test].invoke
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            desc "Runs the smoke tests."
         
     | 
| 
      
 35 
     | 
    
         
            +
            Rake::TestTask.new :smoke_test do |t|
         
     | 
| 
      
 36 
     | 
    
         
            +
              t.test_files = FileList["acceptance/**/*smoke_test.rb"]
         
     | 
| 
      
 37 
     | 
    
         
            +
              t.warning = false
         
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            namespace :smoke_test do
         
     | 
| 
      
 41 
     | 
    
         
            +
              desc "Runs smoke tests with coverage."
         
     | 
| 
      
 42 
     | 
    
         
            +
              task :coverage do
         
     | 
| 
      
 43 
     | 
    
         
            +
                require "simplecov"
         
     | 
| 
      
 44 
     | 
    
         
            +
                SimpleCov.start do
         
     | 
| 
      
 45 
     | 
    
         
            +
                  command_name "<%= gem.name %>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  track_files "lib/**/*.rb"
         
     | 
| 
      
 47 
     | 
    
         
            +
                  add_filter "test/"
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                Rake::Task[:smoke_test].invoke
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            # Acceptance tests
         
     | 
| 
      
 55 
     | 
    
         
            +
            desc "Run the <%= gem.name %> acceptance tests."
         
     | 
| 
      
 56 
     | 
    
         
            +
            task :acceptance, :project, :keyfile do |t, args|
         
     | 
| 
      
 57 
     | 
    
         
            +
              project = args[:project]
         
     | 
| 
      
 58 
     | 
    
         
            +
              project ||=
         
     | 
| 
      
 59 
     | 
    
         
            +
                ENV["<%= gem.env_prefix %>_TEST_PROJECT"] ||
         
     | 
| 
      
 60 
     | 
    
         
            +
                ENV["GCLOUD_TEST_PROJECT"]
         
     | 
| 
      
 61 
     | 
    
         
            +
              keyfile = args[:keyfile]
         
     | 
| 
      
 62 
     | 
    
         
            +
              keyfile ||=
         
     | 
| 
      
 63 
     | 
    
         
            +
                ENV["<%= gem.env_prefix %>_TEST_KEYFILE"] ||
         
     | 
| 
      
 64 
     | 
    
         
            +
                ENV["GCLOUD_TEST_KEYFILE"]
         
     | 
| 
      
 65 
     | 
    
         
            +
              if keyfile
         
     | 
| 
      
 66 
     | 
    
         
            +
                keyfile = File.read keyfile
         
     | 
| 
      
 67 
     | 
    
         
            +
              else
         
     | 
| 
      
 68 
     | 
    
         
            +
                keyfile ||=
         
     | 
| 
      
 69 
     | 
    
         
            +
                  ENV["<%= gem.env_prefix %>_TEST_KEYFILE_JSON"] ||
         
     | 
| 
      
 70 
     | 
    
         
            +
                  ENV["GCLOUD_TEST_KEYFILE_JSON"]
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
              if project.nil? || keyfile.nil?
         
     | 
| 
      
 73 
     | 
    
         
            +
                fail "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or <%= gem.env_prefix %>_TEST_PROJECT=test123 <%= gem.env_prefix %>_TEST_KEYFILE=/path/to/keyfile.json rake acceptance"
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
              require "<%= service.credentials_require %>"
         
     | 
| 
      
 76 
     | 
    
         
            +
              <%= service.credentials_name_full %>.env_vars.each do |path|
         
     | 
| 
      
 77 
     | 
    
         
            +
                ENV[path] = nil
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
              ENV["<%= gem.env_prefix %>_PROJECT"] = project
         
     | 
| 
      
 80 
     | 
    
         
            +
              ENV["<%= gem.env_prefix %>_TEST_PROJECT"] = project
         
     | 
| 
      
 81 
     | 
    
         
            +
              ENV["<%= gem.env_prefix %>_KEYFILE_JSON"] = keyfile
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              Rake::Task["acceptance:run"].invoke
         
     | 
| 
      
 84 
     | 
    
         
            +
            end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            namespace :acceptance do
         
     | 
| 
      
 87 
     | 
    
         
            +
              task :run do
         
     | 
| 
      
 88 
     | 
    
         
            +
                if File.directory? "acceptance"
         
     | 
| 
      
 89 
     | 
    
         
            +
                  Rake::Task[:smoke_test].invoke
         
     | 
| 
      
 90 
     | 
    
         
            +
                else
         
     | 
| 
      
 91 
     | 
    
         
            +
                  puts "The <%= gem.name %> gem has no acceptance tests."
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              desc "Run acceptance tests with coverage."
         
     | 
| 
      
 96 
     | 
    
         
            +
              task :coverage do
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              desc "Run acceptance cleanup."
         
     | 
| 
      
 100 
     | 
    
         
            +
              task :cleanup do
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
            end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
            task :samples do
         
     | 
| 
      
 105 
     | 
    
         
            +
              Rake::Task["samples:latest"].invoke
         
     | 
| 
      
 106 
     | 
    
         
            +
            end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            namespace :samples do
         
     | 
| 
      
 109 
     | 
    
         
            +
              task :latest do
         
     | 
| 
      
 110 
     | 
    
         
            +
                if File.directory? "samples"
         
     | 
| 
      
 111 
     | 
    
         
            +
                  Dir.chdir "samples" do
         
     | 
| 
      
 112 
     | 
    
         
            +
                    Bundler.with_clean_env do
         
     | 
| 
      
 113 
     | 
    
         
            +
                      ENV["GOOGLE_CLOUD_SAMPLES_TEST"] = "not_master"
         
     | 
| 
      
 114 
     | 
    
         
            +
                      sh "bundle update"
         
     | 
| 
      
 115 
     | 
    
         
            +
                      sh "bundle exec rake test"
         
     | 
| 
      
 116 
     | 
    
         
            +
                    end
         
     | 
| 
      
 117 
     | 
    
         
            +
                  end
         
     | 
| 
      
 118 
     | 
    
         
            +
                else
         
     | 
| 
      
 119 
     | 
    
         
            +
                  puts "The <%= gem.name %> gem has no samples to test."
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
              task :master do
         
     | 
| 
      
 124 
     | 
    
         
            +
                if File.directory? "samples"
         
     | 
| 
      
 125 
     | 
    
         
            +
                  Dir.chdir "samples" do
         
     | 
| 
      
 126 
     | 
    
         
            +
                    Bundler.with_clean_env do
         
     | 
| 
      
 127 
     | 
    
         
            +
                      ENV["GOOGLE_CLOUD_SAMPLES_TEST"] = "master"
         
     | 
| 
      
 128 
     | 
    
         
            +
                      sh "bundle update"
         
     | 
| 
      
 129 
     | 
    
         
            +
                      sh "bundle exec rake test"
         
     | 
| 
      
 130 
     | 
    
         
            +
                    end
         
     | 
| 
      
 131 
     | 
    
         
            +
                  end
         
     | 
| 
      
 132 
     | 
    
         
            +
                else
         
     | 
| 
      
 133 
     | 
    
         
            +
                  puts "The <%= gem.name %> gem has no samples to test."
         
     | 
| 
      
 134 
     | 
    
         
            +
                end
         
     | 
| 
      
 135 
     | 
    
         
            +
              end
         
     | 
| 
      
 136 
     | 
    
         
            +
            end
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
            require "yard"
         
     | 
| 
      
 139 
     | 
    
         
            +
            require "yard/rake/yardoc_task"
         
     | 
| 
      
 140 
     | 
    
         
            +
            YARD::Rake::YardocTask.new do |y|
         
     | 
| 
      
 141 
     | 
    
         
            +
            <%- if gem.yard_strict? -%>
         
     | 
| 
      
 142 
     | 
    
         
            +
              y.options << "--fail-on-warning"
         
     | 
| 
      
 143 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 144 
     | 
    
         
            +
            end
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
            desc "Run yard-doctest example tests."
         
     | 
| 
      
 147 
     | 
    
         
            +
            task :doctest do
         
     | 
| 
      
 148 
     | 
    
         
            +
              puts "The <%= gem.name %> gem does not have doctest tests."
         
     | 
| 
      
 149 
     | 
    
         
            +
            end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
            desc "Run the CI build"
         
     | 
| 
      
 152 
     | 
    
         
            +
            task :ci do
         
     | 
| 
      
 153 
     | 
    
         
            +
              header "BUILDING <%= gem.name %>"
         
     | 
| 
      
 154 
     | 
    
         
            +
              header "<%= gem.name %> rubocop", "*"
         
     | 
| 
      
 155 
     | 
    
         
            +
              Rake::Task[:rubocop].invoke
         
     | 
| 
      
 156 
     | 
    
         
            +
              header "<%= gem.name %> yard", "*"
         
     | 
| 
      
 157 
     | 
    
         
            +
              Rake::Task[:yard].invoke
         
     | 
| 
      
 158 
     | 
    
         
            +
              header "<%= gem.name %> test", "*"
         
     | 
| 
      
 159 
     | 
    
         
            +
              Rake::Task[:test].invoke
         
     | 
| 
      
 160 
     | 
    
         
            +
            end
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
            namespace :ci do
         
     | 
| 
      
 163 
     | 
    
         
            +
              desc "Run the CI build, with smoke tests."
         
     | 
| 
      
 164 
     | 
    
         
            +
              task :smoke_test do
         
     | 
| 
      
 165 
     | 
    
         
            +
                Rake::Task[:ci].invoke
         
     | 
| 
      
 166 
     | 
    
         
            +
                header "<%= gem.name %> smoke_test", "*"
         
     | 
| 
      
 167 
     | 
    
         
            +
                Rake::Task[:smoke_test].invoke
         
     | 
| 
      
 168 
     | 
    
         
            +
              end
         
     | 
| 
      
 169 
     | 
    
         
            +
              desc "Run the CI build, with acceptance tests."
         
     | 
| 
      
 170 
     | 
    
         
            +
              task :acceptance do
         
     | 
| 
      
 171 
     | 
    
         
            +
                Rake::Task[:ci].invoke
         
     | 
| 
      
 172 
     | 
    
         
            +
                header "<%= gem.name %> acceptance", "*"
         
     | 
| 
      
 173 
     | 
    
         
            +
                Rake::Task[:acceptance].invoke
         
     | 
| 
      
 174 
     | 
    
         
            +
              end
         
     | 
| 
      
 175 
     | 
    
         
            +
              task :a do
         
     | 
| 
      
 176 
     | 
    
         
            +
                # This is a handy shortcut to save typing
         
     | 
| 
      
 177 
     | 
    
         
            +
                Rake::Task["ci:acceptance"].invoke
         
     | 
| 
      
 178 
     | 
    
         
            +
              end
         
     | 
| 
      
 179 
     | 
    
         
            +
            end
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
            task default: :test
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
            def header str, token = "#"
         
     | 
| 
      
 184 
     | 
    
         
            +
              line_length = str.length + 8
         
     | 
| 
      
 185 
     | 
    
         
            +
              puts ""
         
     | 
| 
      
 186 
     | 
    
         
            +
              puts token * line_length
         
     | 
| 
      
 187 
     | 
    
         
            +
              puts "#{token * 3} #{str} #{token * 3}"
         
     | 
| 
      
 188 
     | 
    
         
            +
              puts token * line_length
         
     | 
| 
      
 189 
     | 
    
         
            +
              puts ""
         
     | 
| 
      
 190 
     | 
    
         
            +
            end
         
     |