Class: Buildable

Inherits:
Object
  • Object
show all
Defined in:
lib/buildable.rb

Direct Known Subclasses

Image, Site

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, repository:, commit:) ⇒ Buildable

Returns a new instance of Buildable.



5
6
7
8
9
# File 'lib/buildable.rb', line 5

def initialize(name:, repository:, commit:)
  @name = name.downcase
  @repository = repository
  @commit = commit
end

Instance Attribute Details

#commitObject

Returns the value of attribute commit.



2
3
4
# File 'lib/buildable.rb', line 2

def commit
  @commit
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/buildable.rb', line 2

def name
  @name
end

#repositoryObject (readonly)

Returns the value of attribute repository.



2
3
4
# File 'lib/buildable.rb', line 2

def repository
  @repository
end

Instance Method Details

#checkoutObject

:yields: source directory



11
12
13
14
15
16
# File 'lib/buildable.rb', line 11

def checkout  # :yields: source directory
  Dir.mktmpdir("#{name}-build") do |dir|
    system("git -C #{repository} archive #{commit} | tar -x -C #{dir}") or raise "Git error"
    yield dir
  end
end