Sha256: 8c901c2e232165cb67827327df360be15c2753537aeb0fc82a91a4879013fca9

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

module RedpenRuby
  class FormatMessage
    attr_reader :error_status, :message_list, :redpen_version
    private :error_status, :message_list

    def initialize(raw_message, version)
      @message_list = raw_message.split(/\n/)
      @redpen_version = version
      @error_status = get_error_status

      remove_unneeded_messages
    end

    def valid?
      return true if error_status
      false
    end

    def messages
      message_list
    end

    def version
      redpen_version
    end

  private

    def get_error_status
      message_list.each do |msg|
        return false if msg.match(/ValidationError/)
      end
      true
    end

    def remove_unneeded_messages
      message_list.delete_if { |msg| msg.match(/\A[0-9]+:[0-9]+:[0-9]+\.[0-9]+ \[main\].*\Z/) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redpen_ruby-0.2 lib/redpen_ruby/format_message.rb
redpen_ruby-0.1 lib/redpen_ruby/format_message.rb