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 `add`s 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



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

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



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

def rbs_file_count
  @rbs_file_count
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



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

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.



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rigor/signature_path_audit.rb', line 44

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)


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

def ok?
  status == :ok
end

#to_hObject



57
58
59
# File 'lib/rigor/signature_path_audit.rb', line 57

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

#warning?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rigor/signature_path_audit.rb', line 37

def warning?
  !ok?
end