Sha256: f6940223fa25551332770603479c5c94f12406ab70e45109347a1cf1368a1fc7
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
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 = message(execution) if execution.time >= @thresholds[:fail] @dangerfile.fail(message, options) elsif execution.time >= @thresholds[:warn] @dangerfile.warn(message, options) end end end private def message(execution) message = "`#{execution.method_name}` takes #{execution.time} ms to build" return message if @inline_mode "[#{execution.filename}] #{message}" end 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.2.0 | lib/xcprofiler/danger_reporter.rb |