Sha256: db14f10decccbc142fe217361a5262d4259b87413642642d5174aa99f594e05b
Contents?: true
Size: 1013 Bytes
Versions: 2
Compression:
Stored size: 1013 Bytes
Contents
require "forwardable" module WarningsLogger class Reader extend Forwardable attr_reader :warning_groups def initialize(filesystem) @filesystem = filesystem @current_group = [] @warning_groups = [] end def read warnings_file.rewind warnings_file.each_line do |line| process_line(line) end add_group(current_group) end private attr_reader :filesystem, :current_group def_delegators :filesystem, :warnings_file def process_line(line) if start_of_group?(line) add_group(current_group) @current_group = [] end current_group << line end def start_of_group?(line) line =~ /^\S/ end def add_group(group) unless group.empty? || group_already_added?(group) warning_groups << group end end def group_already_added?(group_to_be_added) warning_groups.any? do |group| group == group_to_be_added end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
warnings_logger-0.1.1 | lib/warnings_logger/reader.rb |
warnings_logger-0.1.0 | lib/warnings_logger/reader.rb |