Class: Gapic::Presenters::CloudGemPresenter

Inherits:
GemPresenter
  • Object
show all
Defined in:
lib/gapic/presenters/cloud_gem_presenter.rb

Overview

A presenter subclass for cloud gems.

Direct Known Subclasses

WrapperGemPresenter

Instance Method Summary collapse

Instance Method Details

#cloud_env_prefixObject



80
81
82
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 80

def cloud_env_prefix
  env_prefix || "GOOGLE_CLOUD"
end

#dependenciesObject



35
36
37
38
39
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 35

def dependencies
  deps = super
  deps["google-cloud-errors"] = "~> 1.0"
  deps
end

#descriptionString

Overrides the gemspec description including a note that users should consider installing the wrapper instead of this versioned gem.

Note: The method `readme_description` was aliased to the superclass method because the description without this note is used in the readme.

Returns:

  • (String)


70
71
72
73
74
75
76
77
78
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 70

def description
  desc = readme_description
  if has_wrapper?
    desc += " Note that #{name} is a version-specific client library." \
      " For most uses, we recommend installing the main client library" \
      " #{wrapper_name} instead. See the readme for more details."
  end
  desc
end

#extra_filesObject



30
31
32
33
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 30

def extra_files
  return ["README.md", "LICENSE.md", ".yardopts"] if generic_endpoint?
  ["README.md", "LICENSE.md", "AUTHENTICATION.md", ".yardopts"]
end

#generator_args_for_metadataObject

Returns a hash of extra generator arguments to be rendered into the repo-metadata.json file.



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 88

def 
  result = {}
  result["ruby-cloud-description"] = description
  result["ruby-cloud-env-prefix"] = env_prefix if env_prefix
  result["ruby-cloud-product-url"] = product_documentation_url if product_documentation_url
  path_overrides = @api.overrides_of(:file_path).map { |k, v| "#{k}=#{v}" }.join ";"
  result["ruby-cloud-path-override"] = path_overrides unless path_overrides.empty?
  namespace_overrides = @api.overrides_of(:namespace).map { |k, v| "#{k}=#{v}" }.join ";"
  result["ruby-cloud-namespace-override"] = namespace_overrides unless namespace_overrides.empty?
  service_overrides = @api.overrides_of(:service).map { |k, v| "#{k}=#{v}" }.join ";"
  result["ruby-cloud-service-override"] = service_overrides unless service_overrides.empty?
  result
end

#has_wrapper?Boolean

Whether this gem has a wrapper

Returns:

  • (Boolean)


44
45
46
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 44

def has_wrapper?
  !wrapper_name.nil?
end

#library_documentation_urlObject

Overrides the reference doc URL to point to the cloud-rad page



104
105
106
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 104

def library_documentation_url
  gem_config(:library_documentation_url) || "https://cloud.google.com/ruby/docs/reference/#{name}/latest"
end

#license_nameObject



26
27
28
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 26

def license_name
  "Apache-2.0"
end

#readme_descriptionObject

rubocop:disable Style/Alias



59
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 59

alias_method :readme_description, :description

#wrapper_nameString?

The name of the wrapper gem corresponding to this versioned gem

Returns:

  • (String, nil)


52
53
54
55
56
57
# File 'lib/gapic/presenters/cloud_gem_presenter.rb', line 52

def wrapper_name
  return @api.wrapper_gem_name_override if @api.wrapper_gem_name_override?

  minfo = /^(.+)-v\d\w*$/.match name
  minfo ? minfo[1] : nil
end