Class: Danger::DangerReporter

Inherits:
Xcprofiler::AbstractReporter
  • Object
show all
Defined in:
lib/xcprofiler/danger_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(dangerfile, thresholds, inline_mode, working_dir) ⇒ DangerReporter

Returns a new instance of DangerReporter.



6
7
8
9
10
11
12
# File 'lib/xcprofiler/danger_reporter.rb', line 6

def initialize(dangerfile, thresholds, inline_mode, working_dir)
  super({})
  @dangerfile = dangerfile
  @thresholds = thresholds
  @inline_mode = inline_mode
  @working_dir = working_dir
end

Instance Method Details

#report!(executions) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/xcprofiler/danger_reporter.rb', line 14

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