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.



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

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.



24
25
26
# File 'lib/docker_rack/container_template.rb', line 24

def name
  @name
end

#patternObject

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



32
33
34
# File 'lib/docker_rack/container_template.rb', line 32

def pattern
  @pattern
end

#templates_pathObject

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



28
29
30
# File 'lib/docker_rack/container_template.rb', line 28

def templates_path
  @templates_path
end

Instance Method Details

#contains?(task_name) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/docker_rack/container_template.rb', line 67

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

#invoke(name) ⇒ Object



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

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

#optionsObject



56
57
58
59
60
61
# File 'lib/docker_rack/container_template.rb', line 56

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

#process(params) ⇒ Object



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

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



63
64
65
# File 'lib/docker_rack/container_template.rb', line 63

def tasks
  Rake.application.tasks()
end