class AdLint::AdLint
Attributes
msg_catalog[R]
traits[R]
verbose[R]
Public Class Methods
new(traits_fpath, output_dpath = nil, verbose = false, cmd_name = File.basename($0))
click to toggle source
# File lib/adlint/driver.rb, line 40 def initialize(traits_fpath, output_dpath = nil, verbose = false, cmd_name = File.basename($0)) @cmd_name = cmd_name @traits = load_traits(traits_fpath) @msg_catalog = load_message_catalog(@traits) @output_dpath = output_dpath @verbose = verbose if verbose $stdout.sync = true at_exit { print_elapsed_time($stdout) } end end
Public Instance Methods
met_fpaths_of(src_fpaths, strip_num)
click to toggle source
# File lib/adlint/driver.rb, line 76 def met_fpaths_of(src_fpaths, strip_num) src_fpaths.map do |fpath| if @output_dpath @output_dpath.join(fpath.strip(strip_num)).add_ext(".met.csv") else fpath.strip(strip_num).add_ext(".met.csv") end end end
run_chk!(src_fpath, strip_num = 0)
click to toggle source
# File lib/adlint/driver.rb, line 70 def run_chk!(src_fpath, strip_num = 0) FileUtils.mkdir_p(sma_output_dpath(src_fpath, strip_num, @output_dpath)) ConfigurationValidator.new(@traits, @msg_catalog, src_fpath, strip_num, @output_dpath, @verbose).run end
run_cma!(met_fpaths)
click to toggle source
# File lib/adlint/driver.rb, line 64 def run_cma!(met_fpaths) FileUtils.mkdir_p(@output_dpath) if @output_dpath CrossModuleAnalyzer.new(@traits, @msg_catalog, met_fpaths, @output_dpath, @verbose).run end
run_sma!(src_fpath, strip_num = 0)
click to toggle source
# File lib/adlint/driver.rb, line 58 def run_sma!(src_fpath, strip_num = 0) FileUtils.mkdir_p(sma_output_dpath(src_fpath, strip_num, @output_dpath)) SingleModuleAnalyzer.new(@traits, @msg_catalog, src_fpath, strip_num, @output_dpath, @verbose).run end
Private Instance Methods
load_message_catalog(traits)
click to toggle source
# File lib/adlint/driver.rb, line 111 def load_message_catalog(traits) begin MessageCatalog.new(traits) rescue Psych::SyntaxError, StandardError => ex $stderr.puts "#{@cmd_name}: Failed to read the message catalog for " + "`#{traits.of_message.language}'." $stderr.puts $stderr.puts "Detailed message is below;" $stderr.puts ex.message, ex.backtrace $stderr.puts exit 2 end end
load_traits(traits_fpath)
click to toggle source
# File lib/adlint/driver.rb, line 87 def load_traits(traits_fpath) begin traits = Traits.new(traits_fpath) unless traits.valid? $stderr.puts "#{@cmd_name}: Failed to read `#{traits_fpath}'." $stderr.puts $stderr.puts "Detailed message is below;" traits.errors.each_with_index do |err, idx| $stderr.puts "#{idx + 1}. #{err}" end $stderr.puts exit 3 end traits rescue Psych::SyntaxError, StandardError => ex $stderr.puts "#{@cmd_name}: Failed to read `#{traits_fpath}'." $stderr.puts $stderr.puts "Detailed message is below;" $stderr.puts ex.message, ex.backtrace $stderr.puts exit 2 end end
print_elapsed_time(io)
click to toggle source
# File lib/adlint/driver.rb, line 129 def print_elapsed_time(io) tms = Process.times io.print " %.3fs user, %.3fs system, " % [tms.utime, tms.stime] total = tms.utime + tms.stime h = total / 3600 m = total / 60 % 60 s = (total % 60).floor io.puts "%02d:%02d:%02d.%02d total" % [h, m, s, ((total % 60) - s) * 100] end
sma_output_dpath(src_fpath, strip_num, output_dpath)
click to toggle source
# File lib/adlint/driver.rb, line 125 def sma_output_dpath(src_fpath, strip_num, output_dpath) src_fpath.strip(strip_num).expand_path(output_dpath).dirname end