Sha256: d3afc9a430c2600da320234e9e65cbc990c210fb9ab07a23abd221686c92a644

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8
module RailsBestPractices
  module Core
    # Error is the violation to rails best practice.
    #
    # it indicates the filenname, line number and error message for the violation.
    class Error
      attr_reader :filename, :line_number, :message, :type, :url
      attr_accessor :git_commit, :git_username, :hg_commit, :hg_username

      def initialize(options={})
        @filename = options[:filename]
        @line_number = options[:line_number].to_s
        @message = options[:message]
        @type = options[:type]
        @url = options[:url]
        @git_commit = options[:git_commit]
        @git_username = options[:git_username]
        @hg_commit = options[:hg_commit]
        @hg_username = options[:hg_username]
      end

      def short_filename
        File.expand_path(filename)[File.expand_path(Core::Runner.base_path).size..-1].sub(/^\//, '')
      end

      def first_line_number
        line_number.split(',').first
      end

      def to_s
        "#{@filename}:#{@line_number} - #{@message}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rails_best_practices-gorgeouscode-1.0.0 lib/rails_best_practices/core/error.rb
rails_best_practices-1.9.0 lib/rails_best_practices/core/error.rb
rails_best_practices-1.8.0 lib/rails_best_practices/core/error.rb