class ModuleSync::SourceCode

Provide methods to retrieve source code attributes

Attributes

given_name[R]
options[R]

Public Class Methods

new(given_name, options) click to toggle source
# File lib/modulesync/source_code.rb, line 11
def initialize(given_name, options)
  @options = Util.symbolize_keys(options || {})

  @given_name = given_name

  return unless given_name.include?('/')

  @repository_name = given_name.split('/').last
  @repository_namespace = given_name.split('/')[0...-1].join('/')
end

Public Instance Methods

path(*parts) click to toggle source
# File lib/modulesync/source_code.rb, line 46
def path(*parts)
  File.join(working_directory, *parts)
end
repository() click to toggle source
# File lib/modulesync/source_code.rb, line 22
def repository
  @repository ||= Repository.new directory: working_directory, remote: repository_remote
end
repository_name() click to toggle source
# File lib/modulesync/source_code.rb, line 26
def repository_name
  @repository_name ||= given_name
end
repository_namespace() click to toggle source
# File lib/modulesync/source_code.rb, line 30
def repository_namespace
  @repository_namespace ||= @options[:namespace] || ModuleSync.options[:namespace]
end
repository_path() click to toggle source
# File lib/modulesync/source_code.rb, line 34
def repository_path
  @repository_path ||= "#{repository_namespace}/#{repository_name}"
end
repository_remote() click to toggle source
# File lib/modulesync/source_code.rb, line 38
def repository_remote
  @repository_remote ||= @options[:remote] || _repository_remote
end
working_directory() click to toggle source
# File lib/modulesync/source_code.rb, line 42
def working_directory
  @working_directory ||= File.join(ModuleSync.options[:project_root], repository_path)
end

Private Instance Methods

_repository_remote() click to toggle source
# File lib/modulesync/source_code.rb, line 52
def _repository_remote
  git_base = ModuleSync.options[:git_base]
  git_base.start_with?('file://') ? "#{git_base}#{repository_path}" : "#{git_base}#{repository_path}.git"
end