Class: Fdlint::Rule::Validation

Inherits:
Struct
  • Object
show all
Defined in:
lib/fdlint/rule/validation.rb

Defined Under Namespace

Classes: Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descObject

Returns the value of attribute desc.



5
6
7
# File 'lib/fdlint/rule/validation.rb', line 5

def desc
  @desc
end

#groupObject

Returns the value of attribute group.



5
6
7
# File 'lib/fdlint/rule/validation.rb', line 5

def group
  @group
end

#scopeObject

Returns the value of attribute scope

Returns:

  • (Object)

    the current value of scope



3
4
5
# File 'lib/fdlint/rule/validation.rb', line 3

def scope
  @scope
end

#uriObject

Returns the value of attribute uri.



5
6
7
# File 'lib/fdlint/rule/validation.rb', line 5

def uri
  @uri
end

#validate_blockObject

Returns the value of attribute validate_block

Returns:

  • (Object)

    the current value of 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

#inspectObject



17
18
19
# File 'lib/fdlint/rule/validation.rb', line 17

def inspect
  to_s
end

#long_descObject



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_sObject



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