lib/xcpretty.rb in xcpretty-0.0.9 vs lib/xcpretty.rb in xcpretty-0.1.0
- old
+ new
@@ -5,11 +5,11 @@
require "xcpretty/formatters/simple"
require "xcpretty/formatters/rspec"
require "xcpretty/reporters/junit"
module XCPretty
- class ExitStatus
+ module ExitStatus
include XCPretty::Matchers
POSSIBLE_FAILURES = [
FAILING_TEST_MATCHER,
@@ -25,7 +25,29 @@
$exit_status = 1 if text =~ failure
end
end
end
+
+ def self.class_from_path(path)
+ source = File.read(path)
+ klass = eval(source, nil, path)
+ raise unless klass.is_a?(Class)
+ klass
+ end
+
+ def self.load_custom_formatter(path)
+ begin
+ $:.unshift File.dirname(path)
+ class_from_path(path)
+ rescue SyntaxError => e
+ exit_with_error("Expected formatter source file to return a class. #{e}")
+ end
+ end
+
+ def self.exit_with_error(message)
+ $stderr.puts "[!] #{message}"
+ exit 1
+ end
+
end