lib/coffeelint.rb in coffeelint-0.0.1 vs lib/coffeelint.rb in coffeelint-0.0.2

- old
+ new

@@ -26,6 +26,38 @@ retval[name] = Coffeelint.lint_file(name) yield name, retval[name] end retval end + + def self.display_test_results(name, errors) + name = name[2..-1] + + good = "\u2713" + bad = "\u2717" + + if errors.length == 0 + puts " #{good} \e[1m\e[32m#{name}\e[0m" + return true + else + puts " #{bad} \e[1m\e[31m#{name}\e[0m" + errors.each do |error| + puts " #{bad} \e[31m##{error["lineNumber"]}\e[0m: #{error["message"]}, #{error["context"]}." + end + return false + end + end + + def self.run_test(file) + result = Coffeelint.lint_file(file) + Coffeelint.display_test_results(file, result) + end + + def self.run_test_suite(directory) + success = true + Coffeelint.lint_dir(directory) do |name, errors| + result = Coffeelint.display_test_results(name, errors) + success = false if not result + end + success + end end