Class: Gapic::Presenters::GemPresenter

Inherits:
Object
  • Object
show all
Includes:
Helpers::FilepathHelper, Helpers::NamespaceHelper
Defined in:
lib/gapic/presenters/gem_presenter.rb

Overview

A presenter for gems.

Instance Method Summary collapse

Methods included from Helpers::NamespaceHelper

#fix_namespace, #ruby_namespace, #ruby_namespace_for_address

Methods included from Helpers::FilepathHelper

#fix_file_path, #ruby_file_path, #ruby_file_path_for_namespace

Constructor Details

#initialize(api) ⇒ GemPresenter

Returns a new instance of GemPresenter.



29
30
31
# File 'lib/gapic/presenters/gem_presenter.rb', line 29

def initialize api
  @api = api
end

Instance Method Details

#address ⇒ Object



56
57
58
# File 'lib/gapic/presenters/gem_presenter.rb', line 56

def address
  name.split("-").map(&:camelize)
end

#api_id ⇒ Object



132
133
134
# File 'lib/gapic/presenters/gem_presenter.rb', line 132

def api_id
  gem_config :api_id
end

#authors ⇒ Object



91
92
93
94
# File 'lib/gapic/presenters/gem_presenter.rb', line 91

def authors
  gem_config(:authors) ||
    ["Google LLC"]
end

#description ⇒ Object



101
102
103
104
# File 'lib/gapic/presenters/gem_presenter.rb', line 101

def description
  gem_config(:description) ||
    "#{name} is the official client library for the #{title} API."
end

#email ⇒ Object



96
97
98
99
# File 'lib/gapic/presenters/gem_presenter.rb', line 96

def email
  gem_config(:email) ||
    "[email protected]"
end

#entrypoint_require ⇒ Object



146
147
148
# File 'lib/gapic/presenters/gem_presenter.rb', line 146

def entrypoint_require
  packages.first.package_require
end

#env_prefix ⇒ Object



116
117
118
# File 'lib/gapic/presenters/gem_presenter.rb', line 116

def env_prefix
  (gem_config(:env_prefix) || name.split("-").last).upcase
end

#free_tier? ⇒ Boolean

Returns:

  • (Boolean)


136
137
138
139
# File 'lib/gapic/presenters/gem_presenter.rb', line 136

def free_tier?
  # Default to false unless the config is explicitly set to "true"
  gem_config(:free_tier) == "true"
end

#homepage ⇒ Object



111
112
113
114
# File 'lib/gapic/presenters/gem_presenter.rb', line 111

def homepage
  gem_config(:homepage) ||
    "https://github.com/googleapis/googleapis"
end

#iam_dependency? ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/gapic/presenters/gem_presenter.rb', line 120

def iam_dependency?
  @api.files.map(&:name).any? { |f| f.start_with? "google/iam/v1/" }
end

#library_documentation_url ⇒ Object



124
125
126
# File 'lib/gapic/presenters/gem_presenter.rb', line 124

def library_documentation_url
  gem_config(:library_documentation_url) || "https://googleapis.dev/ruby/#{name}/latest"
end

#name ⇒ Object



60
61
62
# File 'lib/gapic/presenters/gem_presenter.rb', line 60

def name
  gem_config :name
end

#namespace ⇒ Object



64
65
66
67
# File 'lib/gapic/presenters/gem_presenter.rb', line 64

def namespace
  gem_config(:namespace) ||
    fix_namespace(@api, name.split("-").map(&:camelize).join("::"))
end

#packages ⇒ Object



33
34
35
36
37
38
# File 'lib/gapic/presenters/gem_presenter.rb', line 33

def packages
  @packages ||= begin
    packages = @api.generate_files.map(&:package).uniq.sort
    packages.map { |p| PackagePresenter.new @api, p }.delete_if(&:empty?)
  end
end

#product_documentation_url ⇒ Object



128
129
130
# File 'lib/gapic/presenters/gem_presenter.rb', line 128

def product_documentation_url
  gem_config :product_documentation_url
end

#proto_files ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/gapic/presenters/gem_presenter.rb', line 47

def proto_files
  @proto_files ||= begin
    files = @api.files
    files = files.reject { |f| blacklist_protos.include? f.name }
    files = files.reject { |f| f.messages.empty? && f.enums.empty? }
    files.map { |f| FilePresenter.new @api, f }
  end
end

#services ⇒ Object



40
41
42
43
44
45
# File 'lib/gapic/presenters/gem_presenter.rb', line 40

def services
  @services ||= begin
    files = @api.generate_files
    files.map(&:services).flatten.map { |s| ServicePresenter.new @api, s }
  end
end

#summary ⇒ Object



106
107
108
109
# File 'lib/gapic/presenters/gem_presenter.rb', line 106

def summary
  gem_config(:summary) ||
    "API Client library for the #{title} API"
end

#title ⇒ Object



69
70
71
72
# File 'lib/gapic/presenters/gem_presenter.rb', line 69

def title
  gem_config(:title) ||
    namespace.split("::").join(" ")
end

#version ⇒ Object



74
75
76
77
# File 'lib/gapic/presenters/gem_presenter.rb', line 74

def version
  gem_config(:version) ||
    "0.0.1"
end

#version_file_path ⇒ Object



83
84
85
# File 'lib/gapic/presenters/gem_presenter.rb', line 83

def version_file_path
  "#{version_require}.rb"
end

#version_name_full ⇒ Object



87
88
89
# File 'lib/gapic/presenters/gem_presenter.rb', line 87

def version_name_full
  "#{namespace}::VERSION"
end

#version_require ⇒ Object



79
80
81
# File 'lib/gapic/presenters/gem_presenter.rb', line 79

def version_require
  ruby_file_path @api, version_name_full
end

#yard_strict? ⇒ Boolean

Returns:

  • (Boolean)


141
142
143
144
# File 'lib/gapic/presenters/gem_presenter.rb', line 141

def yard_strict?
  # Default to true unless the config is explicitly set to "false"
  gem_config(:yard_strict) != "false"
end