lib/boppers/notifier/stdout.rb in boppers-0.0.3 vs lib/boppers/notifier/stdout.rb in boppers-0.0.4

- old
+ new

@@ -6,22 +6,29 @@ COLORS = { green: "\e[32m", red: "\e[31m" }.freeze + NO_COLOR = "\e[0m" + attr_reader :subscribe def initialize(subscribe: nil) @subscribe = subscribe end def call(title, message, options) - color = COLORS.fetch(options[:color], "\e[0m") + color = COLORS.fetch(options[:color], NO_COLOR) + message = message + .gsub(/^/m, " ") + .lines + .map {|line| "#{color}#{line}#{NO_COLOR}" } + .join puts [ - "#{color}## #{title}", - message.gsub(/^/m, " "), - "\e[0m\n" + "#{color}## #{title}#{NO_COLOR}", + message, + "\n" ].join("\n") end end end end