Class: GitCompound::Builder

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

Overview

Builder class, responsible for building project from manifest or lockfile

Instance Method Summary collapse

Constructor Details

#initialize(manifest, lock, opts) ⇒ Builder



6
7
8
9
10
# File 'lib/git_compound/builder.rb', line 6

def initialize(manifest, lock, opts)
  @manifest = manifest
  @lock     = lock
  @opts     = opts
end

Instance Method Details

#components_showObject



42
43
44
45
46
47
48
# File 'lib/git_compound/builder.rb', line 42

def components_show
  Logger.info 'Processing components list ...'
  @manifest.process(
    Worker::CircularDependencyChecker.new,
    Worker::PrettyPrint.new)
  self
end

#dependencies_checkObject



32
33
34
35
36
37
38
39
40
# File 'lib/git_compound/builder.rb', line 32

def dependencies_check
  Logger.info 'Checking dependencies ...'

  @manifest.process(
    Worker::CircularDependencyChecker.new,
    Worker::NameConstraintChecker.new,
    Worker::ConflictingDependencyChecker.new)
  self
end

#locked_components_buildObject



69
70
71
72
73
# File 'lib/git_compound/builder.rb', line 69

def locked_components_build
  Logger.info 'Building components from lockfile ...'
  @lock.process(Worker::ComponentDispatcher.new(@lock))
  self
end

#locked_components_guardObject



75
76
77
78
# File 'lib/git_compound/builder.rb', line 75

def locked_components_guard
  @lock.process(Worker::LocalChangesGuard.new(@lock))
  self
end

#locked_dormant_components_removeObject

Raises:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/git_compound/builder.rb', line 80

def locked_dormant_components_remove
  raise GitCompoundError, 'No new lockfile !' unless @lock_new

  dormant_components = @lock.components.reject do |component|
    @lock_new.find(component) ? true : false
  end

  dormant_components.each do |component|
    Logger.warn "Removing dormant component `#{component.name}` " \
                "from `#{component.path}` !"

    component.remove!
  end
end

#locked_manifest_verifyObject

Raises:



63
64
65
66
67
# File 'lib/git_compound/builder.rb', line 63

def locked_manifest_verify
  return self if @manifest.md5sum == @lock.manifest
  raise GitCompoundError,
        'Manifest md5sum has changed ! Use `update` command.'
end

#manifest_buildObject



12
13
14
15
16
# File 'lib/git_compound/builder.rb', line 12

def manifest_build
  Logger.info 'Building components ...'
  @manifest.process(Worker::ComponentBuilder.new(@lock))
  self
end

#manifest_lockObject



25
26
27
28
29
30
# File 'lib/git_compound/builder.rb', line 25

def manifest_lock
  lock = @lock_new ? @lock_new : @lock
  lock.lock_manifest(@manifest)
  lock.write
  self
end

#manifest_updateObject



18
19
20
21
22
23
# File 'lib/git_compound/builder.rb', line 18

def manifest_update
  Logger.info 'Updating components ...'
  @lock_new = Lock.new.clean
  @manifest.process(Worker::ComponentDispatcher.new(@lock_new))
  self
end

#tasks_executeObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git_compound/builder.rb', line 50

def tasks_execute
  Logger.info 'Running tasks ...'

  if @opts.include?(:allow_nested_subtasks)
    @manifest.process(Worker::TaskRunner.new)
  else
    @manifest.tasks.each_value do |task|
      Worker::TaskRunner.new.visit_task(task)
    end
  end
  self
end