Class: Hiiro::Bins

Inherits:
Object
  • Object
show all
Defined in:
lib/hiiro/bins.rb

Constant Summary collapse

PATH =
ENV['PATH']

Class Method Summary collapse

Class Method Details

.allObject



15
16
17
# File 'lib/hiiro/bins.rb', line 15

def self.all
  Dir[glob('*')].select(&File.method(:executable?))
end

.glob(*names) ⇒ Object



8
9
10
11
12
13
# File 'lib/hiiro/bins.rb', line 8

def self.glob(*names)
  path_glob = [?{, paths.join(?,), ?}].join
  name_glob = [?{, names.flatten.compact.join(?,), ?}].join

  Dir[File.join(path_glob, name_glob)].select(&File.method(:executable?))
end

.pathObject



5
# File 'lib/hiiro/bins.rb', line 5

def self.path = PATH

.pathsObject



6
# File 'lib/hiiro/bins.rb', line 6

def self.paths = path.split(?:).map(&:strip).uniq