class ArelConverter::Formatter
Constants
- BOLD
- CLEAR
Terminal colors, borrowed from Thor
- CYAN
- RED
- WHITE
- YELLOW
Public Class Methods
alert(title, culprits, errors=nil)
click to toggle source
Show an upgrade alert to the user
# File lib/arel_converter/formatter.rb, line 13 def self.alert(title, culprits, errors=nil) if RbConfig::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/ Formatter.basic_alert(title, culprits) else Formatter.color_alert(title, culprits) end end
basic_alert(title, culprits)
click to toggle source
Show an upgrade alert to the user. If we’re on Windows, we can’t use terminal colors, hence this method.
# File lib/arel_converter/formatter.rb, line 23 def self.basic_alert(title, culprits) puts "** " + title Array(culprits).each do |c| puts c.valid? ? " FROM: #{c.old_content}\n TO: #{c.new_content}\n" : "** ERROR - #{c.error}" end puts end
color_alert(file, culprits )
click to toggle source
Show a colorful alert to the user
# File lib/arel_converter/formatter.rb, line 33 def self.color_alert(file, culprits ) puts "#{RED}#{BOLD}#{file}#{CLEAR}" Array(culprits).each do |c| puts c.valid? ? "#{YELLOW} FROM: #{c.old_content}\n TO: #{c.new_content}\n" : "#{CYAN}#{BOLD} - #{c.error}#{CLEAR}" end ensure puts "#{CLEAR}" end