Module: Gapic::Helpers::NamespaceHelper

Overview

Helpers related to generating ruby namespaces

Instance Method Summary collapse

Instance Method Details

#fix_namespace(api, namespace) ⇒ Object

Corrects a namespace by replacing known bad values with good values.



46
47
48
# File 'lib/gapic/helpers/namespace_helper.rb', line 46

def fix_namespace api, namespace
  namespace.split("::").map { |node| api.fix_namespace node }.join("::")
end

#ruby_namespace(api, address) ⇒ Object

Looks up the ruby_package for a dot-separated address string to a new string and creates the corrected Ruby namespace



28
29
30
31
32
33
34
# File 'lib/gapic/helpers/namespace_helper.rb', line 28

def ruby_namespace api, address
  file = api.file_for address
  address = address.dup
  address[file.package] = file.ruby_package if file.ruby_package.present?
  namespace = ruby_namespace_for_address address
  fix_namespace api, namespace
end

#ruby_namespace_for_address(address) ⇒ Object

Converts an array or dot-separated address string to a new string with Ruby double-semicolon separators.



39
40
41
42
# File 'lib/gapic/helpers/namespace_helper.rb', line 39

def ruby_namespace_for_address address
  address = address.split "." if address.is_a? String
  address.reject(&:empty?).map(&:camelize).join "::"
end