Class: RailsBestPractices::Core::Error
- Inherits:
-
Object
- Object
- RailsBestPractices::Core::Error
- 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
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#git_commit ⇒ Object
Returns the value of attribute git_commit.
-
#git_username ⇒ Object
Returns the value of attribute git_username.
-
#hg_commit ⇒ Object
Returns the value of attribute hg_commit.
-
#hg_username ⇒ Object
Returns the value of attribute hg_username.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #first_line_number ⇒ Object
-
#initialize(options = {}) ⇒ Error
constructor
A new instance of Error.
- #short_filename ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Error
Returns a new instance of Error.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rails_best_practices/core/error.rb', line 11 def initialize(={}) @filename = [:filename] @line_number = [:line_number].to_s @message = [:message] @type = [:type] @url = [:url] @git_commit = [:git_commit] @git_username = [:git_username] @hg_commit = [:hg_commit] @hg_username = [:hg_username] end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/rails_best_practices/core/error.rb', line 8 def filename @filename end |
#git_commit ⇒ Object
Returns the value of attribute git_commit.
9 10 11 |
# File 'lib/rails_best_practices/core/error.rb', line 9 def git_commit @git_commit end |
#git_username ⇒ Object
Returns the value of attribute git_username.
9 10 11 |
# File 'lib/rails_best_practices/core/error.rb', line 9 def git_username @git_username end |
#hg_commit ⇒ Object
Returns the value of attribute hg_commit.
9 10 11 |
# File 'lib/rails_best_practices/core/error.rb', line 9 def hg_commit @hg_commit end |
#hg_username ⇒ Object
Returns the value of attribute hg_username.
9 10 11 |
# File 'lib/rails_best_practices/core/error.rb', line 9 def hg_username @hg_username end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
8 9 10 |
# File 'lib/rails_best_practices/core/error.rb', line 8 def line_number @line_number end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/rails_best_practices/core/error.rb', line 8 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/rails_best_practices/core/error.rb', line 8 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/rails_best_practices/core/error.rb', line 8 def url @url end |
Instance Method Details
#first_line_number ⇒ Object
27 28 29 |
# File 'lib/rails_best_practices/core/error.rb', line 27 def first_line_number line_number.split(',').first end |
#short_filename ⇒ Object
23 24 25 |
# File 'lib/rails_best_practices/core/error.rb', line 23 def short_filename File.(filename)[File.(Core::Runner.base_path).size..-1].sub(/^\//, '') end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/rails_best_practices/core/error.rb', line 31 def to_s "#{@filename}:#{@line_number} - #{@message}" end |