class Bricolage::LogFilePath

Constants

Params
STD_TEMPLATE

Public Class Methods

default() click to toggle source
# File lib/bricolage/logfilepath.rb, line 3
def LogFilePath.default
  if dir = ENV['BRICOLAGE_LOG_DIR']
    new("#{dir}/%{std}.log")
  elsif path = ENV['BRICOLAGE_LOG_PATH']
    new(path)
  else
    nil
  end
end
new(template) click to toggle source
# File lib/bricolage/logfilepath.rb, line 13
def initialize(template)
  @template = template
end

Public Instance Methods

fill_template(template, params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 25
def fill_template(template, params)
  template.gsub(/%\{\w+\}/) {|var|
    case var
    when '%{std}' then standard_format(params)
    when '%{jobnet_start_date}' then jobnet_start_date(params)
    when '%{jobnet_start_time}' then jobnet_start_time(params)
    when '%{job_start_date}' then job_start_date(params)
    when '%{job_start_time}' then job_start_time(params)
    when '%{jobnet}', '%{net}', '%{jobnet_id}', '%{net_id}', '%{flow}', '%{flow_id}' then jobnet_id(params)
    when '%{subsystem}' then subsystem_name(params)
    when '%{job}', '%{job_id}' then job_name(params)
    else
      raise ParameterError, "bad log path variable: #{var}"
    end
  }
end
format(job_ref:, jobnet_id:, job_start_time:, jobnet_start_time:) click to toggle source
# File lib/bricolage/logfilepath.rb, line 17
def format(job_ref:, jobnet_id:, job_start_time:, jobnet_start_time:)
  return nil unless @template
  params = Params.new(job_ref, jobnet_id, job_start_time, jobnet_start_time)
  fill_template(@template, params)
end
job_name(params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 72
def job_name(params)
  params.job_ref.name
end
job_start_date(params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 56
def job_start_date(params)
  params.start_time.strftime('%Y%m%d')
end
job_start_time(params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 60
def job_start_time(params)
  params.start_time.strftime('%Y%m%d_%H%M%S%L')
end
jobnet_id(params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 64
def jobnet_id(params)
  params.jobnet_id.gsub('/', '::')
end
jobnet_start_date(params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 48
def jobnet_start_date(params)
  params.jobnet_start_time.strftime('%Y%m%d')
end
jobnet_start_time(params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 52
def jobnet_start_time(params)
  params.jobnet_start_time.strftime('%Y%m%d_%H%M%S%L')
end
standard_format(params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 44
def standard_format(params)
  fill_template(STD_TEMPLATE, params)
end
subsystem_name(params) click to toggle source
# File lib/bricolage/logfilepath.rb, line 68
def subsystem_name(params)
  params.job_ref.subsystem
end