Class: CaseCheck::Reference

Inherits:
Struct
  • Object
show all
Defined in:
lib/case_check/reference.rb

Overview

abstract base class

Direct Known Subclasses

Cfc, Cfinclude, Cfmodule, CustomTag

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



9
10
11
# File 'lib/case_check/reference.rb', line 9

def line
  @line
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



9
10
11
# File 'lib/case_check/reference.rb', line 9

def source
  @source
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



9
10
11
# File 'lib/case_check/reference.rb', line 9

def text
  @text
end

Class Method Details

.substitutionsObject



11
12
13
# File 'lib/case_check/reference.rb', line 11

def substitutions
  @substitutions ||= []
end

Instance Method Details

#messageObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/case_check/reference.rb', line 30

def message
  start = 
    case resolution
    when :exact
      "Exactly resolved"
    when :case_insensitive
      "Case-insensitively resolved"
    else
      "Unresolved"
    end
  msg = "#{start} #{type_name} on line #{line}"
  if resolution
    "#{msg} from #{text} to #{resolved_to}"
  else
    "#{msg}: #{text}"
  end
end

#resolutionObject

Returns :exact, :case_insensitive, or nil depending on whether the reference could be resolved on a case_sensitive FS, only on a case_insensitive FS, or not at all



25
26
27
28
# File 'lib/case_check/reference.rb', line 25

def resolution
  return nil unless resolved_to
  case_sensitive_match? ? :exact : :case_insensitive
end

#substituted_textObject



52
53
54
55
56
57
58
59
# File 'lib/case_check/reference.rb', line 52

def substituted_text
  re, sub = CaseCheck::Reference.substitutions.detect { |expr, _| expr =~ text }
  if re
    text.sub(re, sub)
  else
    text
  end
end

#type_nameObject



48
49
50
# File 'lib/case_check/reference.rb', line 48

def type_name
  self.class.name.split('::').last.underscore.gsub('_', ' ')
end