Class: ExecCache

Inherits:
Object
  • Object
show all
Defined in:
lib/srsh/runner.rb

Overview

exec cache to keep tab completion fast

Instance Method Summary collapse

Constructor Details

#initializeExecCache

Returns a new instance of ExecCache.



2035
2036
2037
2038
2039
# File 'lib/srsh/runner.rb', line 2035

def initialize
  @path = nil
  @entries = []
  @built_at = 0.0
end

Instance Method Details

#listObject



2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
# File 'lib/srsh/runner.rb', line 2041

def list
  p = ENV['PATH'].to_s
  now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  if @path != p || (now - @built_at) > 2.5
    @path = p
    @built_at = now
    @entries = build_execs(p)
  end
  @entries
end