colored text!
parent
871674c909
commit
51d425caa7
|
|
@ -2,12 +2,14 @@ require 'logger'
|
|||
require 'cairo'
|
||||
require 'pango'
|
||||
require 'rsvg2'
|
||||
require 'rainbow/refinement'
|
||||
require_relative 'squib/version'
|
||||
require_relative 'squib/commands/cli'
|
||||
require_relative 'squib/deck'
|
||||
require_relative 'squib/card'
|
||||
|
||||
module Squib
|
||||
using Rainbow # we can colorize strings now!
|
||||
|
||||
# Access the internal logger that Squib uses. By default, Squib configure the logger to the WARN level
|
||||
# Use this to suppress or increase output levels.
|
||||
|
|
@ -22,7 +24,7 @@ module Squib
|
|||
@logger = Logger.new($stdout)
|
||||
@logger.level = Logger::WARN
|
||||
@logger.formatter = proc do |severity, datetime, m_progname, msg|
|
||||
"#{datetime} #{severity}: #{msg}\n"
|
||||
"[#{datetime.strftime('%F %H:%M:%S')} #{severity.red}] #{msg}\n"
|
||||
end
|
||||
end
|
||||
@logger
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
require 'rainbow/refinement'
|
||||
|
||||
module Squib::ErrorContext
|
||||
using Rainbow # we can colorize strings now!
|
||||
|
||||
# When we throw an error, we want to be able to find and report:
|
||||
# (a) the DSL method we called, e.g. 'background'
|
||||
# (b) the line number from the user's source file
|
||||
def error_context
|
||||
"in Squib DSL method #{dsl_method.to_s.aliceblue} from #{user_loc}"
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
require_relative 'caller_finder'
|
||||
require_relative 'error_context'
|
||||
require 'rainbow/refinement'
|
||||
|
||||
module Squib::WarnUnexpectedParam
|
||||
using Rainbow # we can colorize strings now!
|
||||
def warn_unexpected_params(opts)
|
||||
unexpected = opts.keys - accepted_params
|
||||
unexpected.each do |key|
|
||||
Squib.logger.warn do
|
||||
"Unexpected option '#{key}' #{@error_cxt} ...ignoring"
|
||||
"Unexpected option '#{key.to_s.yellow}' #{@error_cxt} ...ignoring"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
|
|||
spec.add_runtime_dependency 'mercenary', '0.4.0'
|
||||
spec.add_runtime_dependency 'nokogiri', '~> 1.10'
|
||||
spec.add_runtime_dependency 'pango', '~> 3.4'
|
||||
spec.add_runtime_dependency 'rainbow', '~> 3.0'
|
||||
spec.add_runtime_dependency 'roo', '~> 2.8'
|
||||
spec.add_runtime_dependency 'rsvg2', '~> 3.4'
|
||||
spec.add_runtime_dependency 'ruby-progressbar', '~> 1.10'
|
||||
|
|
|
|||
Loading…
Reference in New Issue