class Fontist::Utils::UI
Constants
- ALL_LEVELS
Public Class Methods
ask(message, options = {})
click to toggle source
# File lib/fontist/utils/ui.rb, line 46 def self.ask(message, options = {}) new.ask(message, options) rescue Errno::EBADF say(<<~MSG.chomp) ERROR: Fontist is unable to obtain agreement without an interactive prompt. Please provide explicit agreement at execution or re-run Fontist with an interactive prompt. MSG "error" end
debug(message)
click to toggle source
# File lib/fontist/utils/ui.rb, line 60 def self.debug(message) new.say(message) if debug? end
debug?()
click to toggle source
# File lib/fontist/utils/ui.rb, line 26 def self.debug? log_levels.include?(:debug) end
default_level()
click to toggle source
# File lib/fontist/utils/ui.rb, line 30 def self.default_level :fatal end
env_level()
click to toggle source
# File lib/fontist/utils/ui.rb, line 22 def self.env_level ENV["FONTIST_LOG"]&.to_sym end
error(message)
click to toggle source
# File lib/fontist/utils/ui.rb, line 38 def self.error(message) new.say(message, :red) if log_levels.include?(:warn) end
level()
click to toggle source
# File lib/fontist/utils/ui.rb, line 18 def self.level @level ||= env_level || default_level end
level=(level)
click to toggle source
# File lib/fontist/utils/ui.rb, line 8 def self.level=(level) unless ALL_LEVELS.include?(level) raise Errors::GeneralError, "Unknown log level: #{level.inspect}. " \ "Supported levels are #{ALL_LEVELS.map(&:inspect).join(', ')}." end @level = level end
log_levels()
click to toggle source
# File lib/fontist/utils/ui.rb, line 64 def self.log_levels @log_levels ||= {} @log_levels[@level] ||= ALL_LEVELS.drop_while { |l| l != level } end
print(message)
click to toggle source
Calls superclass method
# File lib/fontist/utils/ui.rb, line 56 def self.print(message) super if log_levels.include?(:info) end
say(message)
click to toggle source
# File lib/fontist/utils/ui.rb, line 42 def self.say(message) new.say(message) if log_levels.include?(:info) end
success(message)
click to toggle source
# File lib/fontist/utils/ui.rb, line 34 def self.success(message) new.say(message, :green) if log_levels.include?(:info) end