bin/xcpretty in xcpretty-0.1.12 vs bin/xcpretty in xcpretty-0.2.0

- old
+ new

@@ -1,29 +1,29 @@ #!/usr/bin/env ruby -if RUBY_VERSION < '1.8.7' - abort "error: XCPretty requires Ruby 1.8.7 or higher." +if RUBY_VERSION < '2.0.0' + abort "error: XCPretty requires Ruby 2.0.0 or higher." end -if $0 == __FILE__ - $:.unshift File.expand_path('../../lib', __FILE__) +if $PROGRAM_NAME == __FILE__ + $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) end require 'xcpretty' require 'optparse' report_options = [] report_classes = [] report_formats = { "junit" => XCPretty::JUnit, "html" => XCPretty::HTML, - "json-compilation-database" => XCPretty::JSONCompilationDatabase, + "json-compilation-database" => XCPretty::JSONCompilationDatabase } printer_opts = { - :unicode => true, - :colorize => false, - :formatter => XCPretty::Simple + unicode: XCPretty::Term.unicode?, + colorize: XCPretty::Term.color?, + formatter: XCPretty::Simple } OptionParser.new do |opts| opts.banner = "Usage: xcodebuild [options] | xcpretty" opts.on('-t', '--test', 'Use RSpec style output') do @@ -39,18 +39,18 @@ printer_opts[:formatter] = XCPretty::TestAnything end opts.on('-f', '--formatter PATH', 'Use formatter returned from evaluating the specified Ruby file') do |path| printer_opts[:formatter] = XCPretty.load_custom_formatter(path) end - opts.on('-c', '--color', 'Use colorized output') do - printer_opts[:colorize] = true + opts.on('--[no-]color', 'Use colorized output. Defaults is auto') do |value| + printer_opts[:colorize] = value end - opts.on('--no-utf', 'Disable unicode characters in output') do - printer_opts[:unicode] = false + opts.on('--[no-]utf', 'Use unicode characters in output. Default is auto.') do |value| + printer_opts[:unicode] = value end opts.on("-r", "--report FORMAT", "Run FORMAT reporter", - " Choices: #{report_formats.keys.join(', ')}") do |format| + " Choices: #{report_formats.keys.join(', ')}") do |format| report_classes << report_formats[format] report_options << {} end opts.on('-o', '--output PATH', 'Write report output to PATH') do |path| unless opts = report_options.last @@ -72,10 +72,10 @@ XCPretty.exit_with_error(opts.help) end end printer = XCPretty::Printer.new(printer_opts) -reporters = report_classes.compact.each_with_index.map {|k,i| k.new(report_options[i])} +reporters = report_classes.compact.each_with_index.map { |k, i| k.new(report_options[i]) } STDIN.each_line do |line| printer.pretty_print(line) reporters.each { |r| r.handle(line) } end