Class: Cliver::Dependency

Inherits:
Object
  • Object
show all
Includes:
Sys
Defined in:
lib/cliver/dependency_ext.rb

Instance Method Summary collapse

Instance Method Details

#detected_pathObject Also known as: path

Memoized shortcut for detect Returns the path to the detected dependency Raises an error if the dependency was not satisfied



12
13
14
# File 'lib/cliver/dependency_ext.rb', line 12

def detected_path
  @detected_path ||= detect!
end

#major_versionObject



33
34
35
# File 'lib/cliver/dependency_ext.rb', line 33

def major_version
  version.split('.').first if version
end

#open?Boolean

Is the detected dependency currently open?

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/cliver/dependency_ext.rb', line 18

def open?
  ProcTable.ps.any? { |p| p.comm == path }
# See https://github.com/djberg96/sys-proctable/issues/44
rescue ArgumentError
  false
end

#versionObject

Returns the version of the resolved dependency



26
27
28
29
30
31
# File 'lib/cliver/dependency_ext.rb', line 26

def version
  return @detected_version if defined? @detected_version
  return if Gem.win_platform?
  version = installed_versions.find { |p, _v| p == path }
  @detected_version = version.nil? ? nil : version[1]
end