Skip to content

Commit

Permalink
feat(language-v1): Drop support for Ruby 2.4 and add support for Ruby…
Browse files Browse the repository at this point in the history
… 3.0
  • Loading branch information
yoshi-automation authored Mar 1, 2021
1 parent c1b2946 commit 98c8375
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 51 deletions.
14 changes: 2 additions & 12 deletions google-cloud-language-v1/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ AllCops:
- "acceptance/**/*"
- "Rakefile"

Layout/LineLength:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/LineLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Expand All @@ -27,13 +27,3 @@ Metrics/PerceivedComplexity:
Naming/FileName:
Exclude:
- "lib/google-cloud-language-v1.rb"
Naming/PredicateName:
Enabled: false
Style/AsciiComments:
Enabled: false
Style/CaseEquality:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
Style/ModuleFunction:
Enabled: false
12 changes: 12 additions & 0 deletions google-cloud-language-v1/.yardopts-cloudrad
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--no-private
--title=Natural Language V1 API
--exclude _pb\.rb$
--format yaml
--template-path ../template

./lib/**/*.rb
./proto_docs/**/*.rb
-
README.md
LICENSE.md
AUTHENTICATION.md
4 changes: 2 additions & 2 deletions google-cloud-language-v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ end

## Supported Ruby Versions

This library is supported on Ruby 2.4+.
This library is supported on Ruby 2.5+.

Google provides official support for Ruby versions that are actively supported
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
in security maintenance, and not end of life. Currently, this means Ruby 2.4
in security maintenance, and not end of life. Currently, this means Ruby 2.5
and later. Older versions of Ruby _may_ still work, but are unsupported and not
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
about the Ruby support schedule.
Expand Down
4 changes: 2 additions & 2 deletions google-cloud-language-v1/google-cloud-language-v1.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Gem::Specification.new do |gem|
["README.md", "LICENSE.md", "AUTHENTICATION.md", ".yardopts"]
gem.require_paths = ["lib"]

gem.required_ruby_version = ">= 2.4"
gem.required_ruby_version = ">= 2.5"

gem.add_dependency "gapic-common", "~> 0.3"
gem.add_dependency "google-cloud-errors", "~> 1.0"

gem.add_development_dependency "google-style", "~> 1.24.0"
gem.add_development_dependency "google-style", "~> 1.25.1"
gem.add_development_dependency "minitest", "~> 5.14"
gem.add_development_dependency "minitest-focus", "~> 1.1"
gem.add_development_dependency "minitest-rg", "~> 5.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,57 +59,57 @@ def self.configure
parent_config = while namespace.any?
parent_name = namespace.join "::"
parent_const = const_get parent_name
break parent_const.configure if parent_const&.respond_to? :configure
break parent_const.configure if parent_const.respond_to? :configure
namespace.pop
end
default_config = Client::Configuration.new parent_config

default_config.rpcs.analyze_sentiment.timeout = 600.0
default_config.rpcs.analyze_sentiment.retry_policy = {
initial_delay: 0.1,
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
}

default_config.rpcs.analyze_entities.timeout = 600.0
default_config.rpcs.analyze_entities.retry_policy = {
initial_delay: 0.1,
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
}

default_config.rpcs.analyze_entity_sentiment.timeout = 600.0
default_config.rpcs.analyze_entity_sentiment.retry_policy = {
initial_delay: 0.1,
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
}

default_config.rpcs.analyze_syntax.timeout = 600.0
default_config.rpcs.analyze_syntax.retry_policy = {
initial_delay: 0.1,
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
}

default_config.rpcs.classify_text.timeout = 600.0
default_config.rpcs.classify_text.retry_policy = {
initial_delay: 0.1,
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
}

default_config.rpcs.annotate_text.timeout = 600.0
default_config.rpcs.annotate_text.retry_policy = {
initial_delay: 0.1,
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
max_delay: 60.0,
multiplier: 1.3,
retry_codes: [4, 14]
}

default_config
Expand Down Expand Up @@ -178,7 +178,7 @@ def initialize
enable_self_signed_jwt = @config.scope == Client.configure.scope &&
@config.endpoint == Client.configure.endpoint &&
!@config.endpoint.split(".").first.include?("-")
credentials ||= Credentials.default scope: @config.scope,
credentials ||= Credentials.default scope: @config.scope,
enable_self_signed_jwt: enable_self_signed_jwt
if credentials.is_a?(String) || credentials.is_a?(Hash)
credentials = Credentials.new credentials, scope: @config.scope
Expand Down Expand Up @@ -667,7 +667,7 @@ class Configuration
config_attr :scope, nil, ::String, ::Array, nil
config_attr :lib_name, nil, ::String, nil
config_attr :lib_version, nil, ::String, nil
config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
config_attr :interceptors, nil, ::Array, nil
config_attr :timeout, nil, ::Numeric, nil
config_attr :metadata, nil, ::Hash, nil
Expand All @@ -688,7 +688,7 @@ def initialize parent_config = nil
def rpcs
@rpcs ||= begin
parent_rpcs = nil
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
Rpcs.new parent_rpcs
end
end
Expand Down Expand Up @@ -744,17 +744,17 @@ class Rpcs

# @private
def initialize parent_rpcs = nil
analyze_sentiment_config = parent_rpcs&.analyze_sentiment if parent_rpcs&.respond_to? :analyze_sentiment
analyze_sentiment_config = parent_rpcs.analyze_sentiment if parent_rpcs.respond_to? :analyze_sentiment
@analyze_sentiment = ::Gapic::Config::Method.new analyze_sentiment_config
analyze_entities_config = parent_rpcs&.analyze_entities if parent_rpcs&.respond_to? :analyze_entities
analyze_entities_config = parent_rpcs.analyze_entities if parent_rpcs.respond_to? :analyze_entities
@analyze_entities = ::Gapic::Config::Method.new analyze_entities_config
analyze_entity_sentiment_config = parent_rpcs&.analyze_entity_sentiment if parent_rpcs&.respond_to? :analyze_entity_sentiment
analyze_entity_sentiment_config = parent_rpcs.analyze_entity_sentiment if parent_rpcs.respond_to? :analyze_entity_sentiment
@analyze_entity_sentiment = ::Gapic::Config::Method.new analyze_entity_sentiment_config
analyze_syntax_config = parent_rpcs&.analyze_syntax if parent_rpcs&.respond_to? :analyze_syntax
analyze_syntax_config = parent_rpcs.analyze_syntax if parent_rpcs.respond_to? :analyze_syntax
@analyze_syntax = ::Gapic::Config::Method.new analyze_syntax_config
classify_text_config = parent_rpcs&.classify_text if parent_rpcs&.respond_to? :classify_text
classify_text_config = parent_rpcs.classify_text if parent_rpcs.respond_to? :classify_text
@classify_text = ::Gapic::Config::Method.new classify_text_config
annotate_text_config = parent_rpcs&.annotate_text if parent_rpcs&.respond_to? :annotate_text
annotate_text_config = parent_rpcs.annotate_text if parent_rpcs.respond_to? :annotate_text
@annotate_text = ::Gapic::Config::Method.new annotate_text_config

yield self if block_given?
Expand Down
3 changes: 2 additions & 1 deletion google-cloud-language-v1/synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/google-cloud-ruby.git",
"sha": "c830c7d6f7b45ddb90cafc77707b1ecf323e600b"
"sha": "940404e086b1ea483ee79fd879d67c1c368790df"
}
},
{
Expand Down Expand Up @@ -32,6 +32,7 @@
".repo-metadata.json",
".rubocop.yml",
".yardopts",
".yardopts-cloudrad",
"AUTHENTICATION.md",
"CHANGELOG.md",
"Gemfile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_analyze_sentiment
end

# Use protobuf object with options
client.analyze_sentiment ::Google::Cloud::Language::V1::AnalyzeSentimentRequest.new(document: document, encoding_type: encoding_type), grpc_options do |response, operation|
client.analyze_sentiment(::Google::Cloud::Language::V1::AnalyzeSentimentRequest.new(document: document, encoding_type: encoding_type), grpc_options) do |response, operation|
assert_equal grpc_response, response
assert_equal grpc_operation, operation
end
Expand Down Expand Up @@ -157,7 +157,7 @@ def test_analyze_entities
end

# Use protobuf object with options
client.analyze_entities ::Google::Cloud::Language::V1::AnalyzeEntitiesRequest.new(document: document, encoding_type: encoding_type), grpc_options do |response, operation|
client.analyze_entities(::Google::Cloud::Language::V1::AnalyzeEntitiesRequest.new(document: document, encoding_type: encoding_type), grpc_options) do |response, operation|
assert_equal grpc_response, response
assert_equal grpc_operation, operation
end
Expand Down Expand Up @@ -217,7 +217,7 @@ def test_analyze_entity_sentiment
end

# Use protobuf object with options
client.analyze_entity_sentiment ::Google::Cloud::Language::V1::AnalyzeEntitySentimentRequest.new(document: document, encoding_type: encoding_type), grpc_options do |response, operation|
client.analyze_entity_sentiment(::Google::Cloud::Language::V1::AnalyzeEntitySentimentRequest.new(document: document, encoding_type: encoding_type), grpc_options) do |response, operation|
assert_equal grpc_response, response
assert_equal grpc_operation, operation
end
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_analyze_syntax
end

# Use protobuf object with options
client.analyze_syntax ::Google::Cloud::Language::V1::AnalyzeSyntaxRequest.new(document: document, encoding_type: encoding_type), grpc_options do |response, operation|
client.analyze_syntax(::Google::Cloud::Language::V1::AnalyzeSyntaxRequest.new(document: document, encoding_type: encoding_type), grpc_options) do |response, operation|
assert_equal grpc_response, response
assert_equal grpc_operation, operation
end
Expand Down Expand Up @@ -335,7 +335,7 @@ def test_classify_text
end

# Use protobuf object with options
client.classify_text ::Google::Cloud::Language::V1::ClassifyTextRequest.new(document: document), grpc_options do |response, operation|
client.classify_text(::Google::Cloud::Language::V1::ClassifyTextRequest.new(document: document), grpc_options) do |response, operation|
assert_equal grpc_response, response
assert_equal grpc_operation, operation
end
Expand Down Expand Up @@ -397,7 +397,7 @@ def test_annotate_text
end

# Use protobuf object with options
client.annotate_text ::Google::Cloud::Language::V1::AnnotateTextRequest.new(document: document, features: features, encoding_type: encoding_type), grpc_options do |response, operation|
client.annotate_text(::Google::Cloud::Language::V1::AnnotateTextRequest.new(document: document, features: features, encoding_type: encoding_type), grpc_options) do |response, operation|
assert_equal grpc_response, response
assert_equal grpc_operation, operation
end
Expand Down

0 comments on commit 98c8375

Please sign in to comment.