Class: Cliver::Dependency
- Inherits:
-
Object
- Object
- Cliver::Dependency
- Includes:
- Sys
- Defined in:
- lib/cliver/dependency_ext.rb
Instance Method Summary collapse
-
#detected_path ⇒ Object
(also: #path)
Memoized shortcut for detect Returns the path to the detected dependency Raises an error if the dependency was not satisfied.
- #major_version ⇒ Object
-
#open? ⇒ Boolean
Is the detected dependency currently open?.
-
#version ⇒ Object
Returns the version of the resolved dependency.
Instance Method Details
#detected_path ⇒ Object 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_version ⇒ Object
34 35 36 |
# File 'lib/cliver/dependency_ext.rb', line 34 def major_version version&.split('.')&.first end |
#open? ⇒ Boolean
Is the detected dependency currently open?
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 |
#version ⇒ Object
Returns the version of the resolved dependency
26 27 28 29 30 31 32 |
# File 'lib/cliver/dependency_ext.rb', line 26 def version return @version if defined? @version return if Gem.win_platform? version = installed_versions.find { |p, _v| p == path } @version = version.nil? ? nil : version[1] end |