Class: Tetra::Kit

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/tetra/kit.rb

Overview

encapsulates a Tetra kit directory

Instance Method Summary collapse

Methods included from Logging

#log

Constructor Details

#initialize(project) ⇒ Kit

Returns a new instance of Kit.



8
9
10
# File 'lib/tetra/kit.rb', line 8

def initialize(project)
  @project = project
end

Instance Method Details

#find_executable(name) ⇒ Object

finds an executable in a bin/ subdirectory of kit returns nil if executable cannot be found



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tetra/kit.rb', line 14

def find_executable(name)
  @project.from_directory do
    # The pattern `**/*bin/#{name}` matches:
    #   - kit/bin/mvn
    #   - kit/usr/local/bin/ant
    #   - kit/sbin/service (matches your original regex .*bin)
    Dir.glob(File.join("kit", "**", "*bin", name)).each do |path|
      next unless File.executable?(path)

      # Your original regex captured the directory part (.*bin)
      dir = File.dirname(path)

      log.debug("found #{name} executable in #{dir}")
      return dir
    end
  end

  nil
end