Module: GoDbscanFilterBinary

Defined in:
lib/go_dbscan_filter_binary.rb,
lib/go_dbscan_filter_binary/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
'0.1.4'

Class Method Summary collapse

Class Method Details

.binary!Object

Returns the binary path or raises an error if it doesn’t exist

Raises:



54
55
56
57
# File 'lib/go_dbscan_filter_binary.rb', line 54

def self.binary!
  raise Error, "go_dbscan_filter binary not found at #{binary_path}" unless binary_exists?
  binary_path
end

.binary_exists?Boolean

Returns true if the binary exists

Returns:

  • (Boolean)


49
50
51
# File 'lib/go_dbscan_filter_binary.rb', line 49

def self.binary_exists?
  File.exist?(binary_path) && File.executable?(binary_path)
end

.binary_pathObject

Returns the path to the go_dbscan_filter binary



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
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/go_dbscan_filter_binary.rb', line 9

def self.binary_path
  @binary_path ||= begin
    # Find the gem's root directory
    # __dir__ points to lib/go_dbscan_filter_binary, so go up two levels to gem root
    gem_root = File.expand_path('../..', __dir__)

    # Construct binary path (actual binary is in lib/go_dbscan_filter_binary/bin/)
    binary_name = 'go_dbscan_filter'
    binary_name += '.exe' if Gem.win_platform?
    bin_path = File.join(__dir__, 'bin', binary_name)

    # Verify the path exists, if not try alternative methods
    unless File.exist?(bin_path)
      # Try using Gem to find the gem path (works for installed gems)
      begin
        spec = Gem::Specification.find_by_name('go_dbscan_filter_binary')
        if spec
          bin_path = File.join(spec.gem_dir, 'lib', 'go_dbscan_filter_binary', 'bin', binary_name)
        end
      rescue Gem::LoadError
        # Gem not found via Gem, try Bundler
        begin
          require 'bundler'
          if defined?(Bundler)
            spec = Bundler.rubygems.find_name('go_dbscan_filter_binary').first
            if spec
              bin_path = File.join(spec.full_gem_path, 'lib', 'go_dbscan_filter_binary', 'bin', binary_name)
            end
          end
        rescue
          # Fallback to original calculation
        end
      end
    end

    bin_path
  end
end