lib/coveralls/output.rb in coveralls_reborn-0.9.0 vs lib/coveralls/output.rb in coveralls_reborn-0.10.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Coveralls
#
# Public: Methods for formatting strings with Term::ANSIColor.
# Does not utilize monkey-patching and should play nicely when
# included with other libraries.
@@ -30,20 +32,23 @@
# To disable color completely:
#
# Coveralls::Output.no_color = true
module Output
- attr_accessor :silent, :no_color
- attr_writer :output
- extend self
+ class << self
+ attr_accessor :silent, :no_color
+ attr_writer :output
+ end
+ module_function
+
def output
(defined?(@output) && @output) || $stdout
end
def no_color?
- (defined?(@no_color)) && @no_color
+ defined?(@no_color) && @no_color
end
# Public: Formats the given string with the specified color
# through Term::ANSIColor
#
@@ -85,11 +90,11 @@
# Coveralls::Output.puts("Hello World", :color => "cyan")
#
# Returns nil.
def puts(string, options = {})
return if silent?
- (options[:output] || output).puts self.format(string, options)
+ (options[:output] || output).puts format(string, options)
end
# Public: Passes .format to Kernel#print
#
# string - the text to be formatted
@@ -102,13 +107,13 @@
# Coveralls::Output.print("Hello World!", :color => "underline")
#
# Returns nil.
def print(string, options = {})
return if silent?
- (options[:output] || output).print self.format(string, options)
+ (options[:output] || output).print format(string, options)
end
def silent?
- ENV["COVERALLS_SILENT"] || (defined?(@silent) && @silent)
+ ENV['COVERALLS_SILENT'] || (defined?(@silent) && @silent)
end
end
end