Class: Container::Templates::RakeTask
- Inherits:
-
Object
- Object
- Container::Templates::RakeTask
- 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
-
#name ⇒ Object
Name of task.
-
#pattern ⇒ Object
Files matching this pattern will be loaded.
-
#templates_path ⇒ Object
Path to Container templates.
Instance Method Summary collapse
- #contains?(task_name) ⇒ Boolean
- #environment ⇒ Object
-
#initialize ⇒ RakeTask
constructor
A new instance of RakeTask.
- #invoke(name) ⇒ Object
- #process(params) ⇒ Object
- #tasks ⇒ Object
Constructor Details
#initialize ⇒ RakeTask
Returns a new instance of RakeTask.
38 39 40 41 42 43 44 45 46 |
# File 'lib/docker_rack/container_template.rb', line 38 def initialize = Rake.application. .trace = false .dryrun = false Rake::TaskManager. = true $environment = environment end |
Instance Attribute Details
#name ⇒ Object
Name of task. Defaults to ‘:container_templates`.
28 29 30 |
# File 'lib/docker_rack/container_template.rb', line 28 def name @name end |
#pattern ⇒ Object
Files matching this pattern will be loaded. Defaults to ‘’*/.yml,yaml‘`.
36 37 38 |
# File 'lib/docker_rack/container_template.rb', line 36 def pattern @pattern end |
#templates_path ⇒ Object
Path to Container templates. Defaults to the absolute path to the relative location of container templates.
32 33 34 |
# File 'lib/docker_rack/container_template.rb', line 32 def templates_path @templates_path end |
Instance Method Details
#contains?(task_name) ⇒ Boolean
66 67 68 |
# File 'lib/docker_rack/container_template.rb', line 66 def contains?(task_name) tasks.any? { |task| task.name == task_name } end |
#environment ⇒ Object
74 75 76 77 78 79 |
# File 'lib/docker_rack/container_template.rb', line 74 def environment { dockerhost: Docker::Utils.dockerhost, work_dir: Environment.work_dir } end |
#invoke(name) ⇒ Object
70 71 72 |
# File 'lib/docker_rack/container_template.rb', line 70 def invoke(name) Rake.application[name].invoke end |
#process(params) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/docker_rack/container_template.rb', line 48 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 |
#tasks ⇒ Object
62 63 64 |
# File 'lib/docker_rack/container_template.rb', line 62 def tasks Rake.application.tasks() end |