Class: Ufo::TasksBuilder

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TasksBuilder

Returns a new instance of TasksBuilder.



5
6
7
8
# File 'lib/ufo/tasks_builder.rb', line 5

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

Instance Method Details

#buildObject



10
11
12
13
14
15
16
# File 'lib/ufo/tasks_builder.rb', line 10

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



18
19
20
21
22
23
24
# File 'lib/ufo/tasks_builder.rb', line 18

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



26
27
28
# File 'lib/ufo/tasks_builder.rb', line 26

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