Class: Indocker::Artifacts::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/indocker/artifacts/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, remote_name:, remote_url:, branch:, source_path:, target_path:) ⇒ Git

Returns a new instance of Git.



4
5
6
7
8
9
10
11
# File 'lib/indocker/artifacts/git.rb', line 4

def initialize(name:, remote_name:, remote_url:, branch:, source_path:, target_path:)
  @name        = name
  @remote_name = remote_name
  @remote_url  = remote_url
  @branch      = branch
  @source_path = source_path
  @target_path = target_path
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



2
3
4
# File 'lib/indocker/artifacts/git.rb', line 2

def branch
  @branch
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/indocker/artifacts/git.rb', line 2

def name
  @name
end

#remote_nameObject (readonly)

Returns the value of attribute remote_name.



2
3
4
# File 'lib/indocker/artifacts/git.rb', line 2

def remote_name
  @remote_name
end

#remote_urlObject (readonly)

Returns the value of attribute remote_url.



2
3
4
# File 'lib/indocker/artifacts/git.rb', line 2

def remote_url
  @remote_url
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



2
3
4
# File 'lib/indocker/artifacts/git.rb', line 2

def source_path
  @source_path
end

#target_pathObject (readonly)

Returns the value of attribute target_path.



2
3
4
# File 'lib/indocker/artifacts/git.rb', line 2

def target_path
  @target_path
end

Instance Method Details

#project_name(url) ⇒ Object



22
23
24
# File 'lib/indocker/artifacts/git.rb', line 22

def project_name(url)
  url.split('/').last.gsub('.git', '')
end

#repositoryObject



13
14
15
16
17
18
19
20
# File 'lib/indocker/artifacts/git.rb', line 13

def repository
  @repository ||= Indocker::Repositories::Git.new(@name).setup(
    remote_name: remote_name,
    remote_url:  remote_url,
    branch:      branch,
    clone_path:  "/tmp/#{Indocker.configuration.name}/artifacts/git/#{project_name(remote_url)}/#{branch}"
  )
end