Class: Rigor::SignaturePathAudit::Entry

Inherits:
Data
  • Object
show all
Defined in:
lib/rigor/signature_path_audit.rb

Overview

One configured signature_paths: entry's resolution status.

status is one of:

  • :ok — a directory containing at least one .rbs.
  • :missing — the path does not exist.
  • :not_directory — the path exists but is not a directory (the loader only adds directories, so a .rbs file passed directly is silently ignored).
  • :empty — a directory with no .rbs file (recursive).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



28
29
30
# File 'lib/rigor/signature_path_audit.rb', line 28

def path
  @path
end

#rbs_file_countObject (readonly)

Returns the value of attribute rbs_file_count

Returns:

  • (Object)

    the current value of rbs_file_count



28
29
30
# File 'lib/rigor/signature_path_audit.rb', line 28

def rbs_file_count
  @rbs_file_count
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



28
29
30
# File 'lib/rigor/signature_path_audit.rb', line 28

def status
  @status
end

Instance Method Details

#messageObject

One-line, human-facing reason. The wording matches the loader's actual behaviour ("loaded nothing from it") rather than the filesystem error, so the message points at the consequence.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rigor/signature_path_audit.rb', line 40

def message
  case status
  when :missing
    "signature_paths: #{path.inspect} does not exist (no signatures loaded from it)"
  when :not_directory
    "signature_paths: #{path.inspect} is not a directory (no signatures loaded from it)"
  when :empty
    "signature_paths: #{path.inspect} matched 0 signature files"
  else
    "signature_paths: #{path.inspect} loaded #{rbs_file_count} signature file(s)"
  end
end

#ok?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rigor/signature_path_audit.rb', line 29

def ok?
  status == :ok
end

#to_hObject



53
54
55
# File 'lib/rigor/signature_path_audit.rb', line 53

def to_h
  { "path" => path, "status" => status.to_s, "rbs_file_count" => rbs_file_count, "message" => message }
end

#warning?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/rigor/signature_path_audit.rb', line 33

def warning?
  !ok?
end