Class: LogicalConstruct::GroundControl::BuildPlan

Inherits:
Mattock::Tasklib
  • Object
show all
Includes:
Mattock::CommandLineDSL
Defined in:
lib/logical-construct/ground-control/build-plan.rb

Instance Method Summary collapse

Instance Method Details

#archive_pathObject



54
55
56
# File 'lib/logical-construct/ground-control/build-plan.rb', line 54

def archive_path
  @pack.archive.absolute_path
end

#default_configuration(provisioning) ⇒ Object



25
26
27
28
29
30
# File 'lib/logical-construct/ground-control/build-plan.rb', line 25

def default_configuration(provisioning)
  super
  provisioning.copy_settings_to(self)

  self.manifest_task = provisioning[:manifest]
end

#defineObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/logical-construct/ground-control/build-plan.rb', line 58

def define
  super

  in_namespace do
    task :compile do
      (cmd("cd", plan.absolute_path) & cmd("rake", "--rakefile", plan_rakefile.absolute_path, "construct:compile")).must_succeed!
    end

    file_create synced.absolute_path do |dir|
      cmd("mkdir", "-p", dir.name).must_succeed! #ok
    end

    #This looks absurd, but otherwise we need to make sure that no compile
    #task creates a new file it doesn't need. `bundle standalone` already
    #does, so...
    task :rsync_artifacts => [synced.absolute_path, :compile] do
      from_dir = plan.absolute_path
      from_dir += "/" unless from_dir =~ %r"/$"

      to_dir = synced.absolute_path
      to_dir += "/" unless to_dir =~ %r"/$"

      cmd("rsync", "-v", "-rlpgo", "--checksum", from_dir, to_dir).must_succeed!
    end

    synced_files.each do |path|
      file path => :rsync_artifacts
    end

    @pack = ::LogicalConstruct::PackTarball.new do |pack|
      copy_settings_to(pack)
      pack.source_files = synced_files
      pack.unpacked_dir.absolute_path = synced.absolute_path
    end
  end
end

#resolve_configurationObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/logical-construct/ground-control/build-plan.rb', line 32

def resolve_configuration
  fail_unless_set(:basename)
  plan.relative_path ||= basename
  plan_temp.relative_path ||= basename

  resolve_paths

  self.synced_files =
    begin
      pattern = File::join(plan.absolute_path, source_pattern)
      list = FileList[pattern]
      exclude_patterns.each do |pattern|
        list.exclude(pattern)
      end
      list.map do |path|
        synced.pathname.join(Pathname.new(path).relative_path_from(plan.pathname)).to_s
      end
    end

  super
end