google-cloud-translate 1.3.1 → 1.4.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 +4 -4
 - data/CHANGELOG.md +6 -0
 - data/lib/google-cloud-translate.rb +1 -0
 - data/lib/google/cloud/translate.rb +24 -7
 - data/lib/google/cloud/translate/service.rb +4 -2
 - data/lib/google/cloud/translate/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 446be46e3daa8f7a75ccacfe05f26725697c67fe4f84607f4926df2fe4f9e909
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a29473454843607b347d16cbffe1c9a27e152e2589e9a1294fa4f0c89b959fd9
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 076d7957b5fd21f68e4e7b7dafbdf1bf0e08b4da8c5ee876f008eec7c728f587bb63a26a58e6bbc6cffdf9df7369a48a87d0f01a00bed3b5b84bc807828392fc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 7ef9781612d55d99564dc1691b0c689ea0d242d30804b54c48f37b1a08f44e7b33560b1ac856f42483f00e57cb6062e8f3cb7c8fcf3ea60c9c9f07b107494393
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
| 
         @@ -168,4 +168,5 @@ Google::Cloud.configure.add_config! :translate do |config| 
     | 
|
| 
       168 
168 
     | 
    
         
             
              config.add_field! :scope, nil, match: [String, Array]
         
     | 
| 
       169 
169 
     | 
    
         
             
              config.add_field! :retries, nil, match: Integer
         
     | 
| 
       170 
170 
     | 
    
         
             
              config.add_field! :timeout, nil, match: Integer
         
     | 
| 
      
 171 
     | 
    
         
            +
              config.add_field! :endpoint, nil, match: String
         
     | 
| 
       171 
172 
     | 
    
         
             
            end
         
     | 
| 
         @@ -68,6 +68,8 @@ module Google 
     | 
|
| 
       68 
68 
     | 
    
         
             
                  # @param [Integer] retries Number of times to retry requests on server
         
     | 
| 
       69 
69 
     | 
    
         
             
                  #   error. The default value is `3`. Optional.
         
     | 
| 
       70 
70 
     | 
    
         
             
                  # @param [Integer] timeout Default timeout to use in requests. Optional.
         
     | 
| 
      
 71 
     | 
    
         
            +
                  # @param [String] endpoint Override of the endpoint host name. Optional.
         
     | 
| 
      
 72 
     | 
    
         
            +
                  #   If the param is nil, uses the default endpoint.
         
     | 
| 
       71 
73 
     | 
    
         
             
                  # @param [String] project Alias for the `project_id` argument. Deprecated.
         
     | 
| 
       72 
74 
     | 
    
         
             
                  # @param [String] keyfile Alias for the `credentials` argument.
         
     | 
| 
       73 
75 
     | 
    
         
             
                  #   Deprecated.
         
     | 
| 
         @@ -106,34 +108,37 @@ module Google 
     | 
|
| 
       106 
108 
     | 
    
         
             
                  #   translation.text #=> "Salve mundi!"
         
     | 
| 
       107 
109 
     | 
    
         
             
                  #
         
     | 
| 
       108 
110 
     | 
    
         
             
                  def self.new project_id: nil, credentials: nil, key: nil, scope: nil,
         
     | 
| 
       109 
     | 
    
         
            -
                               retries: nil, timeout: nil,  
     | 
| 
      
 111 
     | 
    
         
            +
                               retries: nil, timeout: nil, endpoint: nil, project: nil,
         
     | 
| 
      
 112 
     | 
    
         
            +
                               keyfile: nil
         
     | 
| 
       110 
113 
     | 
    
         
             
                    project_id ||= (project || default_project_id)
         
     | 
| 
       111 
114 
     | 
    
         
             
                    key        ||= configure.key
         
     | 
| 
      
 115 
     | 
    
         
            +
                    retries    ||= configure.retries
         
     | 
| 
      
 116 
     | 
    
         
            +
                    timeout    ||= configure.timeout
         
     | 
| 
      
 117 
     | 
    
         
            +
                    endpoint   ||= configure.endpoint
         
     | 
| 
       112 
118 
     | 
    
         | 
| 
       113 
119 
     | 
    
         
             
                    if key
         
     | 
| 
       114 
120 
     | 
    
         
             
                      return Google::Cloud::Translate::Api.new(
         
     | 
| 
       115 
121 
     | 
    
         
             
                        Google::Cloud::Translate::Service.new(
         
     | 
| 
       116 
     | 
    
         
            -
                          project_id.to_s, nil, 
     | 
| 
      
 122 
     | 
    
         
            +
                          project_id.to_s, nil,
         
     | 
| 
      
 123 
     | 
    
         
            +
                          retries: retries, timeout: timeout, key: key, host: endpoint
         
     | 
| 
       117 
124 
     | 
    
         
             
                        )
         
     | 
| 
       118 
125 
     | 
    
         
             
                      )
         
     | 
| 
       119 
126 
     | 
    
         
             
                    end
         
     | 
| 
       120 
127 
     | 
    
         | 
| 
       121 
128 
     | 
    
         
             
                    scope       ||= configure.scope
         
     | 
| 
       122 
     | 
    
         
            -
                    retries     ||= configure.retries
         
     | 
| 
       123 
     | 
    
         
            -
                    timeout     ||= configure.timeout
         
     | 
| 
       124 
129 
     | 
    
         
             
                    credentials ||= keyfile || default_credentials(scope: scope)
         
     | 
| 
       125 
130 
     | 
    
         | 
| 
       126 
131 
     | 
    
         
             
                    unless credentials.is_a? Google::Auth::Credentials
         
     | 
| 
       127 
132 
     | 
    
         
             
                      credentials = Translate::Credentials.new credentials, scope: scope
         
     | 
| 
       128 
133 
     | 
    
         
             
                    end
         
     | 
| 
       129 
134 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
                    project_id  
     | 
| 
       131 
     | 
    
         
            -
                    project_id = project_id.to_s # Always cast to a string
         
     | 
| 
      
 135 
     | 
    
         
            +
                    project_id = resolve_project_id project_id, credentials
         
     | 
| 
       132 
136 
     | 
    
         
             
                    raise ArgumentError, "project_id is missing" if project_id.empty?
         
     | 
| 
       133 
137 
     | 
    
         | 
| 
       134 
138 
     | 
    
         
             
                    Translate::Api.new(
         
     | 
| 
       135 
139 
     | 
    
         
             
                      Translate::Service.new(
         
     | 
| 
       136 
     | 
    
         
            -
                        project_id, credentials, 
     | 
| 
      
 140 
     | 
    
         
            +
                        project_id, credentials,
         
     | 
| 
      
 141 
     | 
    
         
            +
                        retries: retries, timeout: timeout, host: endpoint
         
     | 
| 
       137 
142 
     | 
    
         
             
                      )
         
     | 
| 
       138 
143 
     | 
    
         
             
                    )
         
     | 
| 
       139 
144 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -154,6 +159,8 @@ module Google 
     | 
|
| 
       154 
159 
     | 
    
         
             
                  # * `retries` - (Integer) Number of times to retry requests on server
         
     | 
| 
       155 
160 
     | 
    
         
             
                  #   error.
         
     | 
| 
       156 
161 
     | 
    
         
             
                  # * `timeout` - (Integer) Default timeout to use in requests.
         
     | 
| 
      
 162 
     | 
    
         
            +
                  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
         
     | 
| 
      
 163 
     | 
    
         
            +
                  #   to use the default endpoint.
         
     | 
| 
       157 
164 
     | 
    
         
             
                  #
         
     | 
| 
       158 
165 
     | 
    
         
             
                  # @return [Google::Cloud::Config] The configuration object the
         
     | 
| 
       159 
166 
     | 
    
         
             
                  #   Google::Cloud::Translate library uses.
         
     | 
| 
         @@ -179,6 +186,16 @@ module Google 
     | 
|
| 
       179 
186 
     | 
    
         
             
                      Google::Cloud.configure.credentials ||
         
     | 
| 
       180 
187 
     | 
    
         
             
                      Translate::Credentials.default(scope: scope)
         
     | 
| 
       181 
188 
     | 
    
         
             
                  end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                  ##
         
     | 
| 
      
 191 
     | 
    
         
            +
                  # @private Resolve project.
         
     | 
| 
      
 192 
     | 
    
         
            +
                  def self.resolve_project_id project_id, credentials
         
     | 
| 
      
 193 
     | 
    
         
            +
                    # Always cast to a string
         
     | 
| 
      
 194 
     | 
    
         
            +
                    return project_id.to_s unless credentials.respond_to? :project_id
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
                    # Always cast to a string
         
     | 
| 
      
 197 
     | 
    
         
            +
                    project_id || credentials.project_id.to_s
         
     | 
| 
      
 198 
     | 
    
         
            +
                  end
         
     | 
| 
       182 
199 
     | 
    
         
             
                end
         
     | 
| 
       183 
200 
     | 
    
         
             
              end
         
     | 
| 
       184 
201 
     | 
    
         
             
            end
         
     | 
| 
         @@ -17,6 +17,7 @@ require "google/cloud/errors" 
     | 
|
| 
       17 
17 
     | 
    
         
             
            require "google/cloud/translate/credentials"
         
     | 
| 
       18 
18 
     | 
    
         
             
            require "google/cloud/translate/version"
         
     | 
| 
       19 
19 
     | 
    
         
             
            require "faraday"
         
     | 
| 
      
 20 
     | 
    
         
            +
            require "uri"
         
     | 
| 
       20 
21 
     | 
    
         | 
| 
       21 
22 
     | 
    
         
             
            module Google
         
     | 
| 
       22 
23 
     | 
    
         
             
              module Cloud
         
     | 
| 
         @@ -34,12 +35,13 @@ module Google 
     | 
|
| 
       34 
35 
     | 
    
         
             
                    ##
         
     | 
| 
       35 
36 
     | 
    
         
             
                    # Creates a new Service instance.
         
     | 
| 
       36 
37 
     | 
    
         
             
                    def initialize project, credentials, retries: nil, timeout: nil,
         
     | 
| 
       37 
     | 
    
         
            -
                                   key: nil
         
     | 
| 
      
 38 
     | 
    
         
            +
                                   key: nil, host: nil
         
     | 
| 
       38 
39 
     | 
    
         
             
                      @project = project
         
     | 
| 
       39 
40 
     | 
    
         
             
                      @credentials = credentials
         
     | 
| 
       40 
41 
     | 
    
         
             
                      @retries = retries
         
     | 
| 
       41 
42 
     | 
    
         
             
                      @timeout = timeout
         
     | 
| 
       42 
43 
     | 
    
         
             
                      @key = key
         
     | 
| 
      
 44 
     | 
    
         
            +
                      @host = host || API_URL
         
     | 
| 
       43 
45 
     | 
    
         
             
                    end
         
     | 
| 
       44 
46 
     | 
    
         | 
| 
       45 
47 
     | 
    
         
             
                    ##
         
     | 
| 
         @@ -101,7 +103,7 @@ module Google 
     | 
|
| 
       101 
103 
     | 
    
         
             
                    # The HTTP object that makes calls to API.
         
     | 
| 
       102 
104 
     | 
    
         
             
                    # This must be a Faraday object.
         
     | 
| 
       103 
105 
     | 
    
         
             
                    def http
         
     | 
| 
       104 
     | 
    
         
            -
                      @http ||= Faraday.new url:  
     | 
| 
      
 106 
     | 
    
         
            +
                      @http ||= Faraday.new url: @host, request: {
         
     | 
| 
       105 
107 
     | 
    
         
             
                        open_timeout: @timeout, timeout: @timeout
         
     | 
| 
       106 
108 
     | 
    
         
             
                      }.delete_if { |_k, v| v.nil? }
         
     | 
| 
       107 
109 
     | 
    
         
             
                    end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: google-cloud-translate
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Mike Moore
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2019- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2019-10-02 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: google-cloud-core
         
     |