Class: LayerChecker::Violation
- Inherits:
-
Object
- Object
- LayerChecker::Violation
- Defined in:
- lib/layer_checker/violation.rb
Instance Attribute Summary collapse
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
-
#source_module ⇒ Object
readonly
Returns the value of attribute source_module.
-
#target_constant ⇒ Object
readonly
Returns the value of attribute target_constant.
-
#target_module ⇒ Object
readonly
Returns the value of attribute target_module.
-
#violation_type ⇒ Object
readonly
Returns the value of attribute violation_type.
Instance Method Summary collapse
-
#initialize(source_file:, source_module:, target_constant:, target_module:, line_number: nil, violation_type: :dependency) ⇒ Violation
constructor
A new instance of Violation.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(source_file:, source_module:, target_constant:, target_module:, line_number: nil, violation_type: :dependency) ⇒ Violation
Returns a new instance of Violation.
8 9 10 11 12 13 14 15 16 |
# File 'lib/layer_checker/violation.rb', line 8 def initialize(source_file:, source_module:, target_constant:, target_module:, line_number: nil, violation_type: :dependency) @source_file = source_file @source_module = source_module @target_constant = target_constant @target_module = target_module @line_number = line_number @violation_type = violation_type end |
Instance Attribute Details
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
5 6 7 |
# File 'lib/layer_checker/violation.rb', line 5 def line_number @line_number end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
5 6 7 |
# File 'lib/layer_checker/violation.rb', line 5 def source_file @source_file end |
#source_module ⇒ Object (readonly)
Returns the value of attribute source_module.
5 6 7 |
# File 'lib/layer_checker/violation.rb', line 5 def source_module @source_module end |
#target_constant ⇒ Object (readonly)
Returns the value of attribute target_constant.
5 6 7 |
# File 'lib/layer_checker/violation.rb', line 5 def target_constant @target_constant end |
#target_module ⇒ Object (readonly)
Returns the value of attribute target_module.
5 6 7 |
# File 'lib/layer_checker/violation.rb', line 5 def target_module @target_module end |
#violation_type ⇒ Object (readonly)
Returns the value of attribute violation_type.
5 6 7 |
# File 'lib/layer_checker/violation.rb', line 5 def violation_type @violation_type end |
Instance Method Details
#to_h ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/layer_checker/violation.rb', line 23 def to_h { source_file: @source_file, source_module: @source_module&.to_s, target_constant: @target_constant, target_module: @target_module&.to_s, line_number: @line_number, violation_type: @violation_type } end |
#to_s ⇒ Object
18 19 20 21 |
# File 'lib/layer_checker/violation.rb', line 18 def to_s location = @line_number ? "#{@source_file}:#{@line_number}" : @source_file "#{location}: #{@source_module} cannot depend on #{@target_module} (#{@target_constant})" end |