Class: Container::Templates::RakeTask

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/docker_rack/container_template.rb

Overview

< ::Rake::TaskLib

Constant Summary collapse

DEFAULT_PATTERN =

Default pattern for template files. DEFAULT_PATTERN = ‘container_templates/**,/<strong>/*</strong>/*.yml,yaml’

'**/*.{yml,yaml}'
DEFAULT_PATH =
'container_templates'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRakeTask

Returns a new instance of RakeTask.



36
37
38
39
40
41
42
# File 'lib/docker_rack/container_template.rb', line 36

def initialize
  options = Rake.application.options
  options.trace = false
  options.dryrun = false

  Rake::TaskManager. = true
end

Instance Attribute Details

#nameObject

Name of task. Defaults to :container_templates.



26
27
28
# File 'lib/docker_rack/container_template.rb', line 26

def name
  @name
end

#patternObject

Files matching this pattern will be loaded. Defaults to ‘’*/.yml,yaml‘`.



34
35
36
# File 'lib/docker_rack/container_template.rb', line 34

def pattern
  @pattern
end

#templates_pathObject

Path to Container templates. Defaults to the absolute path to the relative location of container templates.



30
31
32
# File 'lib/docker_rack/container_template.rb', line 30

def templates_path
  @templates_path
end

Instance Method Details

#contains?(task_name) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/docker_rack/container_template.rb', line 69

def contains?(task_name)
  tasks.any? { |task| task.name == task_name }
end

#invoke(name) ⇒ Object



73
74
75
# File 'lib/docker_rack/container_template.rb', line 73

def invoke(name)
  Rake.application[name].invoke
end

#optionsObject



58
59
60
61
62
63
# File 'lib/docker_rack/container_template.rb', line 58

def options
  options = OpenStruct.new
  options.trace = false
  options.dryrun = false
  options
end

#process(params) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/docker_rack/container_template.rb', line 44

def process(params)
  @templates_path = params[:path] || DEFAULT_PATH
  @pattern        = params[:pattern] || DEFAULT_PATTERN

  load_templates @templates_path, @pattern

  scripts_path = File.join(@templates_path, 'scripts/*.rake')
  puts "Loading scripts from '#{scripts_path}'" if LOG_LEVEL == 'DEBUG'

  Dir.glob(scripts_path).each do |r|
    load r
  end
end

#tasksObject



65
66
67
# File 'lib/docker_rack/container_template.rb', line 65

def tasks
  Rake.application.tasks()
end