class BioDSL::HtmlReport

Class for creating HTML reports from an executed BioDSL pipeline.

Public Class Methods

new(pipeline) click to toggle source

Constructor for HtmlReport.

@param pipeline [BioPeices::Pipeline] Pipeline object

# File lib/BioDSL/html_report.rb, line 40
def initialize(pipeline)
  @pipeline = pipeline
  @commands = pipeline.commands
end

Public Instance Methods

to_html() click to toggle source

Render HTML output.

# File lib/BioDSL/html_report.rb, line 46
def to_html
  render('layout.html.haml', self, pipeline: @pipeline.to_s,
                                   commands: @commands)
end

Private Instance Methods

help_url(command) click to toggle source

Return the help URL for a given command.

@param command [Symbol] Command name.

@return [String] HTML link.

# File lib/BioDSL/html_report.rb, line 193
def help_url(command)
  camel = command.to_s.split('_').map(&:capitalize).join

  'http://www.rubydoc.info/gems/BioDSL/' \
  "#{BioDSL::VERSION}/BioDSL/#{camel}"
end
input?(options) click to toggle source

Detect if any input options are set.

@param options [Hash] Options hash. @option options [String] :input File glob expression.

@return [Boolean]

# File lib/BioDSL/html_report.rb, line 141
def input?(options)
  if options[:input]
    true
  else
    false
  end
end
output?(options) click to toggle source

Detect if any output options are set.

@param options [Hash] Options hash. @option options [String] :output Path to output file.

@return [Boolean]

# File lib/BioDSL/html_report.rb, line 155
def output?(options)
  if options[:output]
    true
  else
    false
  end
end
png?(options) click to toggle source

Detect if any PNG file is available.

@param options [Hash] Options hash. @option options [String] :output Path to output file. @option options [Symbol] :terminal Plot type.

@return [Boolean]

# File lib/BioDSL/html_report.rb, line 170
def png?(options)
  if options[:output]   &&
     options[:terminal] &&
     options[:terminal] == :png &&
     File.exist?(options[:output])
    true
  else
    false
  end
end
render(template, scope, args = {}) click to toggle source

Render HTML templates.

@param template [Path] Path to template file. @param scope [Object] Scope. @param args [Hash] Argument hash.

# File lib/BioDSL/html_report.rb, line 58
def render(template, scope, args = {})
  Tilt.new(File.join(root_dir, template)).render(scope, args)
end
render_command(command, index) click to toggle source

Render HTML command section.

@param command [BioDSL::Command] Command object.

# File lib/BioDSL/html_report.rb, line 86
def render_command(command, index)
  render('command.html.haml', self, command: command, index: index)
end
render_css() click to toggle source

Render HTML CSS section.

# File lib/BioDSL/html_report.rb, line 63
def render_css
  render('css.html.haml', self)
end
render_input_files(options) click to toggle source

Render HTML input files section.

@param options [Hash] Command options hash.

# File lib/BioDSL/html_report.rb, line 109
def render_input_files(options)
  render('input_files.html.haml', self,
         files: options_glob(options[:input]))
end
render_output_files(options) click to toggle source

Render HTML output file section.

@param options [Hash] Command options hash.

# File lib/BioDSL/html_report.rb, line 117
def render_output_files(options)
  render('output_files.html.haml', self, options: options)
end
render_overview(commands) click to toggle source

Render HTML overview section.

@param commands [Array] List of commands from a pipeline.

# File lib/BioDSL/html_report.rb, line 79
def render_overview(commands)
  render('overview.html.haml', self, commands: commands)
end
render_pipeline(pipeline) click to toggle source

Render HTML pipeline section

@param pipeline [String] String from BioDSL::Pipeline#to_s

# File lib/BioDSL/html_report.rb, line 70
def render_pipeline(pipeline)
  pipeline = pipeline.scan(/[^.]+\(.*?\)|[^.(]+/).join(".\n").sub(/\n/, '')

  render('pipeline.html.haml', self, pipeline: pipeline)
end
render_png(options) click to toggle source

Render PNG data.

@param options [Hash] Command options hash.

# File lib/BioDSL/html_report.rb, line 124
def render_png(options)
  path = options[:output]
  png_data = 'data:image/png;base64,'

  File.open(path, 'r') do |ios|
    png_data << Base64.encode64(ios.read)
  end

  render('png.html.haml', self, path: path, png_data: png_data)
end
render_status(command) click to toggle source

Render HTML status section.

@param command [BioDSL::Command] Command object.

# File lib/BioDSL/html_report.rb, line 93
def render_status(command)
  stats = command.status.reject { |k, _| k.to_s[0..3] == 'time' }
  render('status.html.haml', self, exit_status: command.run_status,
                                   statsus: stats)
end
render_time(status) click to toggle source

Render HTML time section.

@param status [BioDSL::Status] Status object.

# File lib/BioDSL/html_report.rb, line 102
def render_time(status)
  render('time.html.haml', self, status: status)
end
root_dir() click to toggle source

Return the path of the HTML root dir.

@return [String] Root dir.

# File lib/BioDSL/html_report.rb, line 184
def root_dir
  File.join(File.dirname(__FILE__), '..', '..', 'www')
end