Class: Fdlint::Rule::Validation
- Defined in:
- lib/fdlint/rule/validation.rb
Defined Under Namespace
Classes: Runner
Instance Attribute Summary collapse
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#group ⇒ Object
Returns the value of attribute group.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#validate_block ⇒ Object
Returns the value of attribute validate_block.
Instance Method Summary collapse
- #exec(node, source, file = nil, parser = nil) ⇒ Object
- #inspect ⇒ Object
- #long_desc ⇒ Object
- #to_s ⇒ Object
- #to_visitor(opt = {}) ⇒ Object
Instance Attribute Details
#desc ⇒ Object
Returns the value of attribute desc.
5 6 7 |
# File 'lib/fdlint/rule/validation.rb', line 5 def desc @desc end |
#group ⇒ Object
Returns the value of attribute group.
5 6 7 |
# File 'lib/fdlint/rule/validation.rb', line 5 def group @group end |
#scope ⇒ Object
Returns the value of attribute scope
3 4 5 |
# File 'lib/fdlint/rule/validation.rb', line 3 def scope @scope end |
#uri ⇒ Object
Returns the value of attribute uri.
5 6 7 |
# File 'lib/fdlint/rule/validation.rb', line 5 def uri @uri end |
#validate_block ⇒ Object
Returns the value of attribute validate_block
3 4 5 |
# File 'lib/fdlint/rule/validation.rb', line 3 def validate_block @validate_block end |
Instance Method Details
#exec(node, source, file = nil, parser = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fdlint/rule/validation.rb', line 30 def exec( node, source, file = nil, parser = nil ) Runner.new.exec( node, source, file, parser, validate_block ) do |results| results.map do |msg, level, opt| pos = if node.respond_to?( :position ) && node.position node.position else opt[:pos] end if pos pos.column += opt[:column_offset] if opt[:column_offset] pos.row += opt[:row_offset] if opt[:row_offset] row, column = pos.row, pos.column end LogEntry.new( msg, level, row, column ).tap do |entry| entry.validation = self end end end end |
#inspect ⇒ Object
17 18 19 |
# File 'lib/fdlint/rule/validation.rb', line 17 def inspect to_s end |
#long_desc ⇒ Object
7 8 9 10 11 |
# File 'lib/fdlint/rule/validation.rb', line 7 def long_desc if desc uri ? desc + ", more info: #{uri}" : desc end end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/fdlint/rule/validation.rb', line 13 def to_s "<Validation #{scope} #{long_desc}>" end |
#to_visitor(opt = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/fdlint/rule/validation.rb', line 21 def to_visitor( opt={} ) [ scope, proc { |node, source, parser| exec( node, source, opt[:file], parser ) } ] end |