Class: Krane::RenderTask
- Inherits:
-
Object
- Object
- Krane::RenderTask
- Defined in:
- lib/krane/render_task.rb
Overview
Render templates
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(logger: nil, current_sha:, template_dir: nil, template_paths: [], bindings:) ⇒ RenderTask
constructor
Initializes the render task.
-
#run(*args) ⇒ Boolean
Runs the task, returning a boolean representing success or failure.
-
#run!(stream, only_filenames = []) ⇒ nil
Runs the task, raising exceptions in case of issues.
Constructor Details
#initialize(logger: nil, current_sha:, template_dir: nil, template_paths: [], bindings:) ⇒ RenderTask
Initializes the render task
18 19 20 21 22 23 24 |
# File 'lib/krane/render_task.rb', line 18 def initialize(logger: nil, current_sha:, template_dir: nil, template_paths: [], bindings:) @logger = logger || Krane::FormattedLogger.build @template_dir = template_dir @template_paths = template_paths.map { |path| File.(path) } @bindings = bindings @current_sha = current_sha end |
Instance Method Details
#run(*args) ⇒ Boolean
Runs the task, returning a boolean representing success or failure
29 30 31 32 33 34 |
# File 'lib/krane/render_task.rb', line 29 def run(*args) run!(*args) true rescue Krane::FatalDeploymentError false end |
#run!(stream, only_filenames = []) ⇒ nil
Runs the task, raising exceptions in case of issues
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/krane/render_task.rb', line 42 def run!(stream, only_filenames = []) @logger.reset @logger.phase_heading("Initializing render task") ts = TemplateSets.from_dirs_and_files(paths: template_sets_paths(only_filenames), logger: @logger) validate_configuration(ts, only_filenames) count = render_templates(stream, ts) @logger.summary.add_action("Successfully rendered #{count} template(s)") @logger.print_summary(:success) rescue Krane::FatalDeploymentError @logger.print_summary(:failure) raise end |