Module: RubyLens::ArtifactMarker

Defined in:
lib/rubylens/artifact_marker.rb

Overview

Recognizes RubyLens's own artifacts by scanning the head of a file for a format marker, so default output paths are only ever replaced in kind.

Constant Summary collapse

HEAD_BYTES =
2048

Class Method Summary collapse

Class Method Details

.present?(path, marker, head_bytes: HEAD_BYTES) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/rubylens/artifact_marker.rb', line 11

def present?(path, marker, head_bytes: HEAD_BYTES)
  File.file?(path) && File.open(path, "rb") { |file| file.read(head_bytes).to_s.include?(marker) }
rescue Errno::ENOENT, Errno::EACCES
  false
end