class YardJunk::Logger
Constants
- DEFAULT_IGNORE
Public Instance Methods
clear()
click to toggle source
# File lib/yard-junk/logger.rb, line 39 def clear messages.clear @format = Message::DEFAULT_FORMAT @ignore = DEFAULT_IGNORE end
format=(fmt)
click to toggle source
# File lib/yard-junk/logger.rb, line 45 def format=(fmt) @format = fmt.to_s end
ignore=(list)
click to toggle source
# File lib/yard-junk/logger.rb, line 49 def ignore=(list) @ignore = Array(list).map(&:to_s).each do |type| Message.valid_type?(type) or fail(ArgumentError, "Unrecognized message type to ignore: #{type}") end end
messages()
click to toggle source
# File lib/yard-junk/logger.rb, line 16 def messages @messages ||= [] end
notify(msg)
click to toggle source
# File lib/yard-junk/logger.rb, line 29 def notify(msg) case msg when /Parsing (\w\S+)$/ # TODO: fragile regexp; cleanup it after everything is parsed. @current_parsed_file = Regexp.last_match(1) when /^Generating/ # end of parsing of any file @current_parsed_file = nil end end
register(msg, severity = :warn)
click to toggle source
# File lib/yard-junk/logger.rb, line 20 def register(msg, severity = :warn) message = Message.registry.filter_map { |t| t.try_parse(msg, severity: severity, file: @current_parsed_file) }.first || Message.new(message: msg, file: @current_parsed_file) messages << message puts message.to_s(@format) if output?(message) end
Private Instance Methods
output?(message)
click to toggle source
# File lib/yard-junk/logger.rb, line 58 def output?(message) !@format.empty? && !@ignore.include?(message.type) end