Class: PmdTester::PmdReportDetail
- Inherits:
-
Object
- Object
- PmdTester::PmdReportDetail
- Defined in:
- lib/pmdtester/pmd_report_detail.rb
Overview
This class represents all details about report of pmd
Instance Attribute Summary collapse
-
#execution_time ⇒ Object
Returns the value of attribute execution_time.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#working_dir ⇒ Object
Returns the value of attribute working_dir.
Class Method Summary collapse
-
.convert_seconds(seconds) ⇒ Object
convert seconds into HH::MM::SS.
- .load(report_info_path) ⇒ Object
Instance Method Summary collapse
- #format_execution_time ⇒ Object
-
#initialize(execution_time: 0, timestamp: '', working_dir: Dir.getwd) ⇒ PmdReportDetail
constructor
A new instance of PmdReportDetail.
- #save(report_info_path) ⇒ Object
Constructor Details
#initialize(execution_time: 0, timestamp: '', working_dir: Dir.getwd) ⇒ PmdReportDetail
Returns a new instance of PmdReportDetail.
12 13 14 15 16 |
# File 'lib/pmdtester/pmd_report_detail.rb', line 12 def initialize(execution_time: 0, timestamp: '', working_dir: Dir.getwd) @execution_time = execution_time @timestamp = @working_dir = working_dir end |
Instance Attribute Details
#execution_time ⇒ Object
Returns the value of attribute execution_time.
8 9 10 |
# File 'lib/pmdtester/pmd_report_detail.rb', line 8 def execution_time @execution_time end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
9 10 11 |
# File 'lib/pmdtester/pmd_report_detail.rb', line 9 def @timestamp end |
#working_dir ⇒ Object
Returns the value of attribute working_dir.
10 11 12 |
# File 'lib/pmdtester/pmd_report_detail.rb', line 10 def working_dir @working_dir end |
Class Method Details
.convert_seconds(seconds) ⇒ Object
convert seconds into HH::MM::SS
40 41 42 |
# 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) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# 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 |
Instance Method Details
#format_execution_time ⇒ Object
35 36 37 |
# File 'lib/pmdtester/pmd_report_detail.rb', line 35 def format_execution_time self.class.convert_seconds(@execution_time) end |
#save(report_info_path) ⇒ Object
18 19 20 21 22 23 |
# 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 |