Module: Funchook

Extended by:
Contrast::Components::Logger::InstanceMethods
Defined in:
lib/contrast/funchook/funchook.rb,
ext/cs__common/cs__common.c

Overview

This module is used to find funchook library and determine availability

Constant Summary collapse

ACCEPTABLE_FILES =

Possible platform library files

%w[libfunchook.dylib libfunchook.so].cs__freeze
SEARCH_DIRS =

Top level agent directories that should have the funchook libraries

[File.join('ext'), File.join('shared_libraries'), File.join('funchook', 'src')].cs__freeze
AGENT_ROOT =
File.join(__dir__, '..', '..', '..')

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Contrast::Components::Logger::InstanceMethods

cef_logger, logger

Instance Attribute Details

#pathObject

Returns the value of attribute path.



10
11
12
# File 'lib/contrast/funchook/funchook.rb', line 10

def path
  @path
end

Class Method Details

.absolute_path(path_array) ⇒ Object



35
36
37
# File 'lib/contrast/funchook/funchook.rb', line 35

def absolute_path path_array
  File.absolute_path(File.join(AGENT_ROOT, *path_array))
end

.available?Boolean

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/contrast/funchook/funchook.rb', line 39

def available?
  @_available = !!resolve_path! if @_available.nil?
  @_available
end

.resolve_path!Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/contrast/funchook/funchook.rb', line 21

def resolve_path!
  actual_path_segments = SEARCH_DIRS.product(ACCEPTABLE_FILES).find do |potential_funchook_path|
    load_path = absolute_path(potential_funchook_path)
    File.exist?(load_path)
  end

  if actual_path_segments.nil?
    logger.warn('Unable to find funchook')
  else
    @path = absolute_path(actual_path_segments)
  end
  @path
end