Class: Xezat::Detector::Python39

Inherits:
Object
  • Object
show all
Defined in:
lib/xezat/detector/python39.rb

Instance Method Summary collapse

Instance Method Details

#detect(variables) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xezat/detector/python39.rb', line 8

def detect(variables)
  return true if File.directory?(File.join(variables[:D], 'usr', 'lib', 'python3.9'))

  Find.find(variables[:D]) do |file|
    next unless file.end_with?('.py')

    first_line = File.readlines(file).first
    return true if %r{^#!\s*/usr/bin/env\s*python\s*$}.match?(first_line)
    return true if %r{^#!\s*/usr/bin/env\s*python3\s*$}.match?(first_line)
    return true if %r{^#!\s*/usr/bin/env\s*python3.9\s*$}.match?(first_line)
    return true if %r{^#!\s*/usr/bin/python\s*$}.match?(first_line)
    return true if %r{^#!\s*/usr/bin/python3\s*$}.match?(first_line)
    return true if %r{^#!\s*/usr/bin/python3.9\s*$}.match?(first_line)
  end
  false
end