class PmdTester::PmdReportDetail

This class represents all details about report of pmd

Attributes

execution_time[RW]
timestamp[RW]
working_dir[RW]

Public Class Methods

convert_seconds(seconds) click to toggle source

convert seconds into HH::MM::SS

# File lib/pmdtester/pmd_report_detail.rb, line 40
def self.convert_seconds(seconds)
  Time.at(seconds.abs).utc.strftime('%H:%M:%S')
end
load(report_info_path) click to toggle source
# File lib/pmdtester/pmd_report_detail.rb, line 25
def self.load(report_info_path)
  if File.exist?(report_info_path)
    hash = JSON.parse(File.read(report_info_path), symbolize_names: true)
    PmdReportDetail.new(**hash)
  else
    PmdTester.logger.warn("#{report_info_path} doesn't exist")
    PmdReportDetail.new
  end
end
new(execution_time: 0, timestamp: '', working_dir: Dir.getwd) click to toggle source
# File lib/pmdtester/pmd_report_detail.rb, line 12
def initialize(execution_time: 0, timestamp: '', working_dir: Dir.getwd)
  @execution_time = execution_time
  @timestamp = timestamp
  @working_dir = working_dir
end

Public Instance Methods

format_execution_time() click to toggle source
# File lib/pmdtester/pmd_report_detail.rb, line 35
def format_execution_time
  self.class.convert_seconds(@execution_time)
end
save(report_info_path) click to toggle source
# File lib/pmdtester/pmd_report_detail.rb, line 18
def save(report_info_path)
  hash = { execution_time: @execution_time, timestamp: @timestamp, working_dir: @working_dir }
  file = File.new(report_info_path, 'w')
  file.puts JSON.generate(hash)
  file.close
end