Class: XcodeBuild::Formatters::ProgressFormatter

Inherits:
Object
  • Object
show all
Includes:
Utilities::Colorize
Defined in:
lib/xcode_build/formatters/progress_formatter.rb

Instance Method Summary collapse

Methods included from Utilities::Colorize

#blue, #bold, #color, #cyan, #green, #magenta, #red, #short_padding, #white, #yellow

Constructor Details

#initialize(output = STDOUT) ⇒ ProgressFormatter

Returns a new instance of ProgressFormatter.



9
10
11
12
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 9

def initialize(output = STDOUT)
  @output = output
  @action_count = 0
end

Instance Method Details

#build_action_starting(action_type) ⇒ Object



14
15
16
17
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 14

def build_action_starting(action_type)
  puts cyan("=> Running xcodebuild #{action_type}")
  @action_count = 0
end

#build_finished(build) ⇒ Object



41
42
43
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 41

def build_finished(build)
  report_finished(build)
end

#build_started(build) ⇒ Object



32
33
34
35
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 32

def build_started(build)
  report_started("Building", build)
  @action_count += 1
end

#build_step_finished(step) ⇒ Object



37
38
39
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 37

def build_step_finished(step)
  report_step_finished(step)
end

#clean_finished(clean) ⇒ Object



28
29
30
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 28

def clean_finished(clean)
  report_finished(clean)
end

#clean_started(clean) ⇒ Object



19
20
21
22
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 19

def clean_started(clean)
  report_started("Cleaning", clean)
  @action_count += 1
end

#clean_step_finished(step) ⇒ Object



24
25
26
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 24

def clean_step_finished(step)
  report_step_finished(step)
end

#report_finished(object) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 49

def report_finished(object)
  puts
  report_warnings(object)
  puts
  puts "Finished in #{object.duration} seconds."
  
  if object.successful?
    if object.has_warnings?
      puts green("#{object.label} succeeded.") + yellow(" (#{object.warnings.length} warnings)")
    else
      puts green("#{object.label} succeeded.")
    end
  else
    puts red("#{object.label} failed. (#{object.error_count} errors)")
    puts
    puts "Failed #{object.label.downcase} steps:"
    puts
    error_counter = 1
    object.steps_completed.each do |step|
      next unless step.has_errors?

      puts indent("#{error_counter}) #{step.type} #{step.arguments.join(" ")}")

      step.errors.each do |err|
        puts indent(indent(red(err.message.capitalize)))
        if err.error_detail
          puts indent(indent(cyan(err.error_detail))) 
        else
          puts
        end
        puts
      end
      
      error_counter += 1
    end
  end
  puts
end

#report_warnings(object) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 88

def report_warnings(object)
  return unless object.respond_to?(:warnings)
  return unless object.warnings.count > 0
  
  puts
  puts "The following warnings were reported:"
  puts
  
  object.warnings.each_with_index do |warning, index|
    puts indent(yellow("#{index+1}) #{warning.message}"))
    puts indent(cyan(warning.warning_detail))
    puts
  end
end

#warning_detectedObject



45
46
47
# File 'lib/xcode_build/formatters/progress_formatter.rb', line 45

def warning_detected
  print yellow("x")
end