class GitCompound::Component

GitCompound component class

Component

Attributes

destination[RW]
name[R]
source[RW]

Public Class Methods

new(name, parent = nil, &block) click to toggle source
# File lib/git_compound/component.rb, line 15
def initialize(name, parent = nil, &block)
  @name   = name
  @parent = parent
  DSL::ComponentDSL.new(self, &block) if block
  raise CompoundSyntaxError, "No block given for component `#{@name}`" unless block
  raise GitCompoundError, "Component `#{@name}` invalid" unless valid?
end

Public Instance Methods

==(other) click to toggle source
# File lib/git_compound/component.rb, line 61
def ==(other)
  origin == other.origin || manifest == other.manifest
end
build!() click to toggle source
# File lib/git_compound/component.rb, line 36
def build!
  @source.clone(path)
  @destination.repository do |repo|
    repo.checkout(@source.ref)
  end
end
manifest() click to toggle source
# File lib/git_compound/component.rb, line 32
def manifest
  @manifest ||= @source.manifest
end
process(*workers) click to toggle source
# File lib/git_compound/component.rb, line 27
def process(*workers)
  workers.each { |worker| worker.visit_component(self) }
  @manifest.process(*workers) if manifest
end
remove!() click to toggle source
# File lib/git_compound/component.rb, line 52
def remove!
  raise GitCompoundError, 'Risky directory !' if
    path.start_with?('/') || path.include?('..')
  raise GitCompoundError, 'Not a directory !' unless
    File.directory?(path)

  FileUtils.remove_entry_secure(path)
end
to_hash() click to toggle source
# File lib/git_compound/component.rb, line 65
def to_hash
  { name: @name,
    sha:  @source.sha,
    source: @source.origin,
    destination: @destination.path
  }
end
update!() click to toggle source
# File lib/git_compound/component.rb, line 43
def update!
  @destination.repository do |repo|
    repo.fetch
    repo.checkout(@source.ref)
    repo.fetch
    repo.merge if repo.branch?(@source.ref)
  end
end
valid?() click to toggle source
# File lib/git_compound/component.rb, line 23
def valid?
  [@name, @source, @destination].all?
end