Class: NativePackageInstaller::ExecutableFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/native-package-installer/executable-finder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(basename) ⇒ ExecutableFinder

Returns a new instance of ExecutableFinder.



30
31
32
33
# File 'lib/native-package-installer/executable-finder.rb', line 30

def initialize(basename)
  @basename = basename
  @appended_paths = []
end

Class Method Details

.exist?(basename) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/native-package-installer/executable-finder.rb', line 25

def exist?(basename)
  new(basename).exist?
end

.find(basename) ⇒ Object



21
22
23
# File 'lib/native-package-installer/executable-finder.rb', line 21

def find(basename)
  new(basename).find
end

Instance Method Details

#append_path(path) ⇒ Object



54
55
56
# File 'lib/native-package-installer/executable-finder.rb', line 54

def append_path(path)
  @appended_paths << path
end

#exist?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/native-package-installer/executable-finder.rb', line 50

def exist?
  not find.nil?
end

#findObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/native-package-installer/executable-finder.rb', line 35

def find
  extensions = detect_extensions
  paths.each do |path|
    executable_file = File.join(path, @basename)
    return executable_file if executable?(executable_file)
    extensions.each do |extension|
      executable_file_with_extension = executable_file + extension
      if executable?(executable_file_with_extension)
        return executable_file_with_extension
      end
    end
  end
  nil
end