Module: Bloc::Command::Tasks::Formatter
- Defined in:
- lib/bloc/command/tasks/formatter.rb
Class Method Summary collapse
- .format(tests) ⇒ Object
- .format_failed(test, index) ⇒ Object
- .format_passed(test, index) ⇒ Object
- .indent(text, options = {}) ⇒ Object
Class Method Details
.format(tests) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bloc/command/tasks/formatter.rb', line 7 def self.format(tests) output = "" tests.each_with_index do |test, index| if test["passed"] output << format_passed(test, index) else output << format_failed(test, index) end end output end |
.format_failed(test, index) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bloc/command/tasks/formatter.rb', line 27 def self.format_failed(test, index) %Q( #{index+1}. #{indent(test["name"].red)} #{indent(test["description"])} #{indent(test["failed_line"])} #{indent(test["backtrace"].join("\n"))} #{indent(test["code"].light_cyan)} #{indent(test["stdout"])} ) end |
.format_passed(test, index) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/bloc/command/tasks/formatter.rb', line 20 def self.format_passed(test, index) %Q( #{index+1}. #{indent(test["name"].green)} #{indent(test["description"])} ) end |
.indent(text, options = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/bloc/command/tasks/formatter.rb', line 39 def self.indent(text, ={}) tab_level = [:level] || 1 tabs = "\t"*tab_level lines = text.split("\n") lines.map {|line| tabs + line }.join("\n") end |