File: pcaprub.rb

package info (click to toggle)
ruby-pcaprub 0.13.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 244 kB
  • sloc: ansic: 846; ruby: 308; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 774 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module PCAPRUB
  $:.unshift(File.dirname(__FILE__))
  require 'pcaprub/common'
  require 'pcaprub/version'

  add_dll_path = proc do |path, &block|
    if RUBY_PLATFORM =~/(mswin|mingw)/i && path && File.exist?(path)
      begin
        require 'ruby_installer/runtime'
        RubyInstaller::Runtime.add_dll_directory(path, &block)
      rescue LoadError
        old_path = ENV['PATH']
        ENV['PATH'] = "#{path};#{old_path}"
        begin
          block.call
        ensure
          ENV['PATH'] = old_path
        end
      end
    else
      block.call
    end
  end

  npcap_path = "C:\\Windows\\System32\\Npcap"
  add_dll_path.call(npcap_path) do
    require 'pcaprub/ext'
  end

end

#Force Include to allow backwards compatibility to ::PCAP.new
include PCAPRUB