Class: Depot::Inspector

Inherits:
Object
  • Object
show all
Defined in:
lib/depot/inspector.rb

Constant Summary collapse

APPIMAGE_EXT =
/\.appimage\z/i
DEB_EXT =
/\.deb\z/i
RPM_EXT =
/\.rpm\z/i
FLATPAKREF_EXT =
/\.flatpakref\z/i
ARCHIVE_EXT =
/\.(tar\.gz|tgz|tar\.xz|txz|tar\.zst|tzst)\z/i
ELF_MAGIC =
"\x7FELF".b.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inspect(input, checksum: true) ⇒ Object



21
22
23
# File 'lib/depot/inspector.rb', line 21

def self.inspect(input, checksum: true)
  new.inspect(input, checksum:)
end

Instance Method Details

#inspect(input, checksum: true) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/depot/inspector.rb', line 25

def inspect(input, checksum: true)
  source = input.to_s
  uri = parse_uri(source)
  return inspect_url(uri) if uri&.absolute?
  return Result.err("Path does not exist: #{source}") unless File.exist?(source)
  return Result.err("Input is not a regular file: #{source}") unless File.file?(source)

  Result.ok(file_inspection(source, checksum:))
end