Class: Harbinger::Analyzers::RustDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/harbinger/analyzers/rust_detector.rb

Instance Method Summary collapse

Constructor Details

#initialize(project_path) ⇒ RustDetector

Returns a new instance of RustDetector.



8
9
10
# File 'lib/harbinger/analyzers/rust_detector.rb', line 8

def initialize(project_path)
  @project_path = project_path
end

Instance Method Details

#detectObject



12
13
14
15
16
17
# File 'lib/harbinger/analyzers/rust_detector.rb', line 12

def detect
  detect_from_rust_toolchain ||
    detect_from_cargo_toml ||
    detect_from_docker_compose ||
    (rust_detected? ? detect_from_shell : nil)
end

#rust_detected?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
# File 'lib/harbinger/analyzers/rust_detector.rb', line 19

def rust_detected?
  File.exist?(File.join(project_path, "Cargo.toml")) ||
    File.exist?(File.join(project_path, "Cargo.lock")) ||
    File.exist?(File.join(project_path, "rust-toolchain")) ||
    File.exist?(File.join(project_path, "rust-toolchain.toml")) ||
    (File.directory?(File.join(project_path, "src")) && has_rust_files?)
rescue StandardError
  false
end