Class: Indocker::Artifacts::Git

Inherits:
Base
  • 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:, files: [], source_path: nil, target_path: nil) ⇒ Git

Returns a new instance of Git.



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

def initialize(name:, remote_name:, remote_url:, branch:, files: [], source_path: nil, target_path: nil)
  @name        = name
  @remote_name = remote_name
  @remote_url  = remote_url
  @branch      = branch

  @files = build_all_files(
    files:       files,
    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

#filesObject (readonly)

Returns the value of attribute files.



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

def files
  @files
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

Instance Method Details

#build_source_path(path) ⇒ Object



34
35
36
# File 'lib/indocker/artifacts/git.rb', line 34

def build_source_path(path)
  File.join(self.repository.clone_path, path)
end

#is_git?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/indocker/artifacts/git.rb', line 30

def is_git?
  true
end

#project_name(url) ⇒ Object



26
27
28
# File 'lib/indocker/artifacts/git.rb', line 26

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

#repositoryObject



17
18
19
20
21
22
23
24
# File 'lib/indocker/artifacts/git.rb', line 17

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