Class: Harbinger::Analyzers::MongoDetector

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

Overview

Detects MongoDB version from projects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_path) ⇒ MongoDetector

Returns a new instance of MongoDetector.



11
12
13
# File 'lib/harbinger/analyzers/mongo_detector.rb', line 11

def initialize(project_path)
  @project_path = project_path
end

Instance Attribute Details

#project_pathObject (readonly)

Returns the value of attribute project_path.



9
10
11
# File 'lib/harbinger/analyzers/mongo_detector.rb', line 9

def project_path
  @project_path
end

Instance Method Details

#detectObject

Main detection method - returns version string or nil



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/harbinger/analyzers/mongo_detector.rb', line 16

def detect
  return nil unless mongo_detected?

  # Try docker-compose.yml first
  version = detect_from_docker_compose
  return version if version

  # Try shell command
  version = detect_from_shell
  return version if version

  # Fallback to gem version
  detect_from_gemfile_lock
end

#mongo_detected?Boolean

Check if MongoDB is used in this project

Returns:

  • (Boolean)


32
33
34
# File 'lib/harbinger/analyzers/mongo_detector.rb', line 32

def mongo_detected?
  gemfile_has_mongo? || docker_compose_has_mongo?
end