Class: CheckstyleReports::Entity::FoundFile
- Inherits:
-
Object
- Object
- CheckstyleReports::Entity::FoundFile
- Defined in:
- lib/checkstyle_reports/entity/found_file.rb
Instance Attribute Summary collapse
-
#errors ⇒ Array<FoundError>
readonly
Errors which were detected in this file.
-
#path ⇒ String
readonly
A absolute path to this file.
-
#relative_path ⇒ String
readonly
A relative path to this file.
Instance Method Summary collapse
-
#initialize(node, prefix:) ⇒ FoundFile
constructor
A new instance of FoundFile.
Constructor Details
#initialize(node, prefix:) ⇒ FoundFile
Returns a new instance of FoundFile.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/checkstyle_reports/entity/found_file.rb', line 20 def initialize(node, prefix:) raise "Wrong node was passed. expected file but #{node.name}" if node.name != "file" if prefix.end_with?(file_separator) @prefix = prefix else @prefix = prefix + file_separator end name = node.attributes["name"] if Pathname.new(name).absolute? raise "Bad prefix was found for #{name}. #{@prefix} was a prefix." unless name.start_with?(@prefix) # Use delete_prefix when min support version becomes ruby 2.5 @relative_path = name[@prefix.length, name.length - @prefix.length] else @relative_path = name end @path = @prefix + @relative_path @path = node.attributes["name"] @errors = [] node.elements.each("error") { |n| @errors << FoundError.new(n) } end |
Instance Attribute Details
#errors ⇒ Array<FoundError> (readonly)
Errors which were detected in this file
18 19 20 |
# File 'lib/checkstyle_reports/entity/found_file.rb', line 18 def errors @errors end |
#path ⇒ String (readonly)
A absolute path to this file
8 9 10 |
# File 'lib/checkstyle_reports/entity/found_file.rb', line 8 def path @path end |
#relative_path ⇒ String (readonly)
A relative path to this file
13 14 15 |
# File 'lib/checkstyle_reports/entity/found_file.rb', line 13 def relative_path @relative_path end |