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.



17
18
19
# File 'lib/ufo/tasks/builder.rb', line 17

def initialize(options={})
  @options = options
end

Class Method Details

.build(options) ⇒ Object

ship: build and registers task definitions together



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

def self.build(options)
  Tasks::Builder.new(options).build
end

.ship(task_definition, options) ⇒ Object

ship: build and registers task definitions together



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

def self.ship(task_definition, options)
  # When handling task definitions in with the ship command and class, we always want to
  # build and register task definitions. There is little point of running them independently
  # This method helps us do that.
  build(options)
  Tasks::Register.register(task_definition, options)
end

Instance Method Details

#buildObject



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

def build
  puts "Building Task Definitions...".color(: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



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

def check_templates_definitions_path
  unless File.exist?(template_definitions_path)
    pretty_path = template_definitions_path.sub("#{Ufo.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



37
38
39
# File 'lib/ufo/tasks/builder.rb', line 37

def template_definitions_path
  "#{Ufo.root}/.ufo/task_definitions.rb"
end