Class: Gapic::Presenters::WrapperGemPresenter
Overview
A presenter for wrapper gems.
Instance Method Summary
collapse
#cloud_env_prefix, #description, #generator_args_for_metadata, #has_wrapper?, #library_documentation_url, #license_name, #readme_description, #wrapper_name
Instance Method Details
#default_version ⇒ Object
100
101
102
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 100
def default_version
version_dependencies.first&.first
end
|
#default_versioned_gem ⇒ Object
104
105
106
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 104
def default_versioned_gem
versioned_gems.first
end
|
#dependencies ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 108
def dependencies
@dependencies ||= begin
deps = { "google-cloud-core" => "~> 1.6" }
version_dependencies.each do |version, requirement|
deps["#{name}-#{version}"] =
if requirement.start_with? "0."
[">= #{requirement}", "< 2.a"]
else
"~> #{requirement}"
end
end
= gem_config_dependencies
deps.merge! if
deps
end
end
|
#docs_link(version: nil, class_name: nil, text: nil) ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 135
def docs_link version: nil, class_name: nil, text: nil
gem_name = version ? "#{name}-#{version}" : name
base_url = "https://googleapis.dev/ruby/#{gem_name}/latest"
if class_name
path = namespace.gsub "::", "/"
path = "#{path}/#{version.capitalize}" if version
class_path = class_name.gsub "::", "/"
text ||= namespaced_class class_name, version: version
return "[#{text}](#{base_url}/#{path}/#{class_path}.html)"
end
"[#{text || name}](#{base_url})"
end
|
#entrypoint_require ⇒ Object
26
27
28
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 26
def entrypoint_require
namespace_require
end
|
81
82
83
84
85
86
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 81
def
files = ["README.md", "LICENSE.md", ".yardopts"]
files.insert 1, "AUTHENTICATION.md" unless generic_endpoint?
files.append "MIGRATING.md" if migration?
files
end
|
#factory_method_suffix ⇒ Object
88
89
90
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 88
def factory_method_suffix
gem_config(:factory_method_suffix).to_s
end
|
#google_cloud_short_name ⇒ Object
129
130
131
132
133
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 129
def google_cloud_short_name
m = /^google-cloud-(.*)$/.match name
return nil unless m
m[1].tr "-", "_"
end
|
#helpers_require ⇒ Object
45
46
47
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 45
def helpers_require
"#{namespace_require}/helpers"
end
|
#main_directory_name ⇒ Object
41
42
43
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 41
def main_directory_name
namespace_require.split("/").last
end
|
#migration? ⇒ Boolean
77
78
79
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 77
def migration?
migration_version ? true : false
end
|
#migration_version ⇒ Object
61
62
63
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 61
def migration_version
gem_config :migration_version
end
|
#namespace_file_path ⇒ Object
49
50
51
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 49
def namespace_file_path
"#{namespace_require}.rb"
end
|
#namespace_require ⇒ Object
37
38
39
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 37
def namespace_require
ruby_file_path @api, namespace
end
|
#namespaced_class(name, version: nil) ⇒ Object
148
149
150
151
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 148
def namespaced_class name, version: nil
base = version ? "#{namespace}::#{version.capitalize}" : namespace
"#{base}::#{name}"
end
|
#needs_default_config_block? ⇒ Boolean
57
58
59
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 57
def needs_default_config_block?
needs_entrypoint? && !google_cloud_short_name.nil?
end
|
#needs_entrypoint? ⇒ Boolean
53
54
55
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 53
def needs_entrypoint?
name != namespace_require
end
|
#pre_migration_version ⇒ Object
A description of the versions prior to the migration version. Could be “a.x” if the migration version is 1.0 or later, otherwise falls back to “pre-a.b”.
68
69
70
71
72
73
74
75
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 68
def pre_migration_version
match = /^(\d)+\.0/.match migration_version.to_s
if match
major = match[1].to_i
return "#{major - 1}.x" if major.positive?
end
"pre-#{migration_version}"
end
|
#services ⇒ Object
30
31
32
33
34
35
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 30
def services
@services ||= begin
files = @api.generate_files
files.map(&:services).flatten.map { |s| WrapperServicePresenter.new self, @api, s }
end
end
|
#version_dependencies ⇒ Object
92
93
94
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 92
def version_dependencies
gem_config(:version_dependencies).to_s.split(";").map { |str| str.split ":" }
end
|
#versioned_gems ⇒ Object
96
97
98
|
# File 'lib/gapic/presenters/wrapper_gem_presenter.rb', line 96
def versioned_gems
version_dependencies.map { |version, _requirement| "#{name}-#{version}" }.sort
end
|