Class: XCPretty::Printer::Simple

Inherits:
Object
  • Object
show all
Includes:
XCPretty::Printer
Defined in:
lib/xcpretty/printers/simple.rb

Constant Summary collapse

PASS =
""
FAIL =
""
ASCII_PASS =
"."
ASCII_FAIL =
"x"
COMPLETION =
""
ASCII_COMPLETION =
">"

Constants included from Matchers

Matchers::EXECUTED_MATCHER, Matchers::FAILING_TEST_MATCHER, Matchers::PASSING_TEST_MATCHER, Matchers::TESTS_RUN_COMPLETION_MATCHER, Matchers::TESTS_RUN_START_MATCHER, Matchers::TEST_SUITE_START_MATCHER

Constants included from ANSI

ANSI::COLORS, ANSI::EFFECT, ANSI::FORMATTED_MATCHER

Instance Attribute Summary

Attributes included from ANSI

#colorize

Instance Method Summary collapse

Methods included from XCPretty::Printer

#failures_per_suite, #format_test_summary, #pretty_print, #project_build_info, #store_failure, #test_summary, #update_test_state, #use_unicode=, #use_unicode?

Methods included from ANSI

#ansi_parse, #applied_effects, #colorize?, #cyan, #green, #red, #strip, #white, #yellow

Instance Method Details

#format(command, argument_text = "", success = true) ⇒ Object



130
131
132
133
# File 'lib/xcpretty/printers/simple.rb', line 130

def format(command, argument_text="", success=true)
  command_text = colorize? ? white(command) : command
  [status_symbol(success ? :completion : :fail), command_text, argument_text].join(" ").strip
end

#format_test(test_case, success = true) ⇒ Object



135
136
137
# File 'lib/xcpretty/printers/simple.rb', line 135

def format_test(test_case, success=true)
  [status_symbol(success ? :pass : :fail), test_case].join(" ").strip
end

#heading(prefix, text, description) ⇒ Object



125
126
127
128
# File 'lib/xcpretty/printers/simple.rb', line 125

def heading(prefix, text, description)
  heading_text = colorize? ? white(text) : text
  [prefix, heading_text, description].join(" ").strip
end

#optional_newlineObject



59
60
61
# File 'lib/xcpretty/printers/simple.rb', line 59

def optional_newline
  "\n"
end

#pretty_format(text) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/xcpretty/printers/simple.rb', line 18

def pretty_format(text)
  case text
  when /^ProcessPCH/
    print_pch(text)
  when /^CompileC/
    print_compiling(text)
  when /^Clean.Remove/
    ""
  when /^Check dependencies/
    ""
  when /^=== CLEAN TARGET/
    print_clean_target(text)
  when /^=== BUILD TARGET/
    print_build_target(text)
  when /^PhaseScriptExecution/
    print_run_script(text)
  when /^Libtool/
    print_libtool(text)
  when /^CpResource/
    print_cpresource(text)
  when /^CopyStringsFile/
    print_copy_strings_file(text)
  when /^GenerateDSYMFile/
    print_generating_dsym(text)
  when /^ProcessInfoPlistFile/
    print_processing_info_plist(text)
  when /^Ld/
    print_linking(text)
  when PASSING_TEST_MATCHER
    print_passing_test($1, $2)
  when FAILING_TEST_MATCHER
    print_failing_test($3, $4)
  when TESTS_RUN_START_MATCHER
    print_test_run_start($1)
  when TEST_SUITE_START_MATCHER
    print_suite_start($1)
  else
    ""
  end
end


92
93
94
95
# File 'lib/xcpretty/printers/simple.rb', line 92

def print_build_target(text)
  info = project_build_info(text)
  format("Building", "#{info[:project]}/#{info[:target]} [#{info[:configuration]}]")
end


87
88
89
90
# File 'lib/xcpretty/printers/simple.rb', line 87

def print_clean_target(text)
  info = project_build_info(text)
  format("Cleaning", "#{info[:project]}/#{info[:target]} [#{info[:configuration]}]")
end


83
84
85
# File 'lib/xcpretty/printers/simple.rb', line 83

def print_compiling(text)
  format("Compiling", text.shellsplit[2].split('/').last)
end


109
110
111
# File 'lib/xcpretty/printers/simple.rb', line 109

def print_copy_strings_file(text)
  format("Copying", text.shellsplit.last.split('/').last)
end


105
106
107
# File 'lib/xcpretty/printers/simple.rb', line 105

def print_cpresource(text)
  format("Copying", text.shellsplit[1])
end


63
64
65
# File 'lib/xcpretty/printers/simple.rb', line 63

def print_failing_test(test_case, reason)
  format_test("#{test_case}, #{reason}", false)
end


113
114
115
# File 'lib/xcpretty/printers/simple.rb', line 113

def print_generating_dsym(text)
  format("Generating DSYM file")
end


101
102
103
# File 'lib/xcpretty/printers/simple.rb', line 101

def print_libtool(text)
  format("Building library", text.shellsplit[1].split('/').last)
end


71
72
73
# File 'lib/xcpretty/printers/simple.rb', line 71

def print_linking(text)
  format("Linking", text.shellsplit[1].split('/').last)
end


67
68
69
# File 'lib/xcpretty/printers/simple.rb', line 67

def print_passing_test(test_case, time)
  format_test("#{test_case} (#{time} seconds)")
end


75
76
77
# File 'lib/xcpretty/printers/simple.rb', line 75

def print_pch(text)
  format("Precompiling", Shellwords.shellsplit(text)[2])
end


79
80
81
# File 'lib/xcpretty/printers/simple.rb', line 79

def print_processing_info_plist(text)
  format("Processing", text.lines.first.shellsplit.last.split('/').last)
end


97
98
99
# File 'lib/xcpretty/printers/simple.rb', line 97

def print_run_script(text)
  format("Running script", "'#{text.lines.first.shellsplit[1..-2].join(' ').gsub('\ ',' ')}'")
end


121
122
123
# File 'lib/xcpretty/printers/simple.rb', line 121

def print_suite_start(name)
  heading("", name, "")
end


117
118
119
# File 'lib/xcpretty/printers/simple.rb', line 117

def print_test_run_start(name)
  heading("Test Suite", name, "started")  
end

#status_symbol(status) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/xcpretty/printers/simple.rb', line 139

def status_symbol(status)
  case status
  when :pass
    green(use_unicode? ? PASS : ASCII_PASS)
  when :fail
    red(use_unicode? ? FAIL : ASCII_FAIL)
  when :completion
    yellow(use_unicode? ? COMPLETION : ASCII_COMPLETION)
  else
    ""
  end
end