Class: Ufo::Tasks::Builder

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Builder

Returns a new instance of Builder.



14
15
16
17
# File 'lib/ufo/tasks/builder.rb', line 14

def initialize(options={})
  @options = options
  @project_root = options[:project_root] || '.'
end

Class Method Details

.register(task_definition, options) ⇒ Object

build and registers together



4
5
6
7
8
9
10
11
12
# File 'lib/ufo/tasks/builder.rb', line 4

def self.register(task_definition, options)
  # task definition and deploy logic are coupled in the Ship class.
  # Example: We need to know if the task defintion is a web service to see if we need to
  # add the elb target group.  The web service information is in the Tasks::Builder
  # and the elb target group gets set in the Ship class.
  # So we always call these together.
  Tasks::Builder.new(options).build
  Tasks::Register.register(task_definition, options)
end

Instance Method Details

#buildObject



19
20
21
22
23
24
25
# File 'lib/ufo/tasks/builder.rb', line 19

def build
  puts "Building Task Definitions...".green unless @options[:mute]
  check_templates_definitions_path
  dsl = DSL.new(template_definitions_path, @options.merge(quiet: false, mute: true))
  dsl.run
  puts "Task Definitions built in ufo/output." unless @options[:mute]
end

#check_templates_definitions_pathObject



27
28
29
30
31
32
33
# File 'lib/ufo/tasks/builder.rb', line 27

def check_templates_definitions_path
  unless File.exist?(template_definitions_path)
    pretty_path = template_definitions_path.sub("#{@project_root}/", '')
    puts "ERROR: #{pretty_path} does not exist.  Run: `ufo init` to create a starter file" unless @options[:mute]
    exit 1
  end
end

#template_definitions_pathObject



35
36
37
# File 'lib/ufo/tasks/builder.rb', line 35

def template_definitions_path
  "#{@project_root}/ufo/task_definitions.rb"
end