Sha256: 4bf2eb4e15fb7e47068a957d6b744ddb4351a120a0d85a7030bed2a0cc0dfa1d
Contents?: true
Size: 1023 Bytes
Versions: 1
Compression:
Stored size: 1023 Bytes
Contents
require 'xcprofiler' require 'pathname' module Danger class DangerReporter < Xcprofiler::AbstractReporter def initialize(dangerfile, thresholds, inline_mode, working_dir) super({}) @dangerfile = dangerfile @thresholds = thresholds @inline_mode = inline_mode @working_dir = working_dir end def report!(executions) executions.each do |execution| options = {} if @inline_mode options[:file] = relative_path(execution.path) options[:line] = execution.line end message = "`#{execution.method_name}` takes #{execution.time} ms to build" if execution.time >= @thresholds[:fail] @dangerfile.fail(message, options) elsif execution.time >= @thresholds[:warn] @dangerfile.warn(message, options) end end end private def relative_path(path) working_dir = Pathname.new(@working_dir) Pathname.new(path).relative_path_from(working_dir).to_s end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
danger-xcprofiler-0.1.0 | lib/xcprofiler/danger_reporter.rb |