Class: RailsBestPractices::Core::Error

Inherits:
CodeAnalyzer::Warning
  • Object
show all
Defined in:
lib/rails_best_practices/core/error.rb

Overview

Error is the violation to rails best practice.

it indicates the filenname, line number and error message for the violation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Error

Returns a new instance of Error.



12
13
14
15
16
17
18
19
20
# File 'lib/rails_best_practices/core/error.rb', line 12

def initialize(options = {})
  super
  @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

Instance Attribute Details

#git_commitObject

Returns the value of attribute git_commit.



10
11
12
# File 'lib/rails_best_practices/core/error.rb', line 10

def git_commit
  @git_commit
end

#git_usernameObject

Returns the value of attribute git_username.



10
11
12
# File 'lib/rails_best_practices/core/error.rb', line 10

def git_username
  @git_username
end

#hg_commitObject

Returns the value of attribute hg_commit.



10
11
12
# File 'lib/rails_best_practices/core/error.rb', line 10

def hg_commit
  @hg_commit
end

#hg_usernameObject

Returns the value of attribute hg_username.



10
11
12
# File 'lib/rails_best_practices/core/error.rb', line 10

def hg_username
  @hg_username
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/rails_best_practices/core/error.rb', line 9

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/rails_best_practices/core/error.rb', line 9

def url
  @url
end

Instance Method Details

#first_line_numberObject



26
27
28
# File 'lib/rails_best_practices/core/error.rb', line 26

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

#short_filenameObject



22
23
24
# File 'lib/rails_best_practices/core/error.rb', line 22

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