Class: LogicalConstruct::GroundControl::Tools

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

Instance Method Summary collapse

Instance Method Details

#defineObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/logical-construct/ground-control/tools.rb', line 21

def define
  in_namespace do
    namespace :create_plan do
      rule %r{\A#{plans_dir}/[^/]*\Z} do |task, args|
        cmd("mkdir", "-p", task.name).must_succeed! #ok
      end

      rule(%r{\A#{plans_dir}/[^/]*/plan\.rake\Z}, [:name] => ['%d']) do |task, args|
        require 'logical-construct/target/implementation'

        File::open(task.name, "w") do |file|
          indent = 16
          file.write(<<-EOR.gsub(/^#{" "*indent}/,''))
          require 'logical-construct/plan'
          include LogicalConstruct::Plan

          core = Core.new do |core|
            core.namespace_name = :#{args[:name]}
            core.plan_rakefile.absolute_path = __FILE__
          end

          core.in_namespace do
            #Plan tasks go here
            #
            #Important tasks to make dependencies to:

          EOR

          Target::Implementation.task_list.each do |task_name|
            file.puts("  #task :#{task_name}")
          end

          file.puts("end")
        end
      end
    end

    desc "Create a new plan to be part of a provisioning"
    task :create_plan, [:name] do |task, args|
      Rake::Task[File::join(plans_dir, args[:name], "plan.rake")].invoke(args[:name])
    end
  end
end

#plans_dirObject



17
18
19
# File 'lib/logical-construct/ground-control/tools.rb', line 17

def plans_dir
  plans.absolute_path.sub(%r{/$},'')
end

#resolve_configurationObject



12
13
14
15
# File 'lib/logical-construct/ground-control/tools.rb', line 12

def resolve_configuration
  resolve_paths
  super
end