Module: Oqs::Wrapper::ClassMethods

Defined in:
lib/oqs/wrapper.rb

Instance Method Summary collapse

Instance Method Details

#detect_osObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/oqs/wrapper.rb', line 17

def detect_os
  plat = RUBY_PLATFORM
  if plat =~ /linux/
    :linux
  elsif plat =~ /darwin/
    :macos
  elsif plat =~ /mingw/
    :windows
  else
    raise WrapperError, "Unknown platform detected. [#{plat}]"
  end
end

#load_arch_lib(os) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/oqs/wrapper.rb', line 30

def load_arch_lib(os)
  plat = RUBY_PLATFORM
  pplat = plat.split('-')[0]
  logger.tdebug :wrapper, "OS architecture is #{pplat}"
  drvDir = File.join(File.dirname(__FILE__),"..","..","native","#{os}",pplat)
  if File.exist?(drvDir)
    Dir.glob(File.join(drvDir,"liboqs*")) do |f|
      logger.tdebug :wrapper, "Loading #{f} from system"
      dlload f
    end
  else
    raise WrapperError, "Directory '#{pplat}' not found at #{drvDir}"
  end
end

#load_oqs_libObject



11
12
13
14
15
# File 'lib/oqs/wrapper.rb', line 11

def load_oqs_lib
  os = detect_os
  logger.tdebug :wrapper, "Found OS #{os}"
  load_arch_lib(os)          
end

#loggerObject



45
46
47
# File 'lib/oqs/wrapper.rb', line 45

def logger
  Oqs::Global.instance.logger
end