Class: GitTest::Notify

Inherits:
Object
  • Object
show all
Defined in:
lib/git_test/notify.rb

Defined Under Namespace

Classes: TextFormat

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output = STDOUT) ⇒ Notify

Returns a new instance of Notify.



59
60
61
# File 'lib/git_test/notify.rb', line 59

def initialize(output = STDOUT)
  self.output = output
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



57
58
59
# File 'lib/git_test/notify.rb', line 57

def output
  @output
end

Instance Method Details

#critical_error(msg, exit_code = -1)) ⇒ Object



79
80
81
82
# File 'lib/git_test/notify.rb', line 79

def critical_error(msg, exit_code = -1)
  write(msg, :red)
  exit! exit_code
end

#done(msg, passed = true) ⇒ Object



71
72
73
# File 'lib/git_test/notify.rb', line 71

def done(msg, passed = true)
  sentiment(msg, passed)
end

#raw(msg) ⇒ Object



84
85
86
# File 'lib/git_test/notify.rb', line 84

def raw(msg)
  output.puts(msg)
end

#sentiment(msg, bool = true) ⇒ Object



67
68
69
# File 'lib/git_test/notify.rb', line 67

def sentiment(msg, bool = true)
  write(msg, bool ? :green : :red)
end

#start(msg) ⇒ Object



63
64
65
# File 'lib/git_test/notify.rb', line 63

def start(msg)
  write(msg, :light_blue)
end

#warn(msg) ⇒ Object



75
76
77
# File 'lib/git_test/notify.rb', line 75

def warn(msg)
  write("WARNING: #{msg}", :red)
end

#write(msg, color = :light_yellow, truncate = 80) ⇒ Object



88
89
90
91
# File 'lib/git_test/notify.rb', line 88

def write(msg, color = :light_yellow, truncate = 80)
  msg = TextFormat.new(msg, truncate).normalize
  output.puts "#{msg}".send color
end