Class: Cliver::Dependency
- Inherits:
-
Object
- Object
- Cliver::Dependency
- Includes:
- Sys
- Defined in:
- lib/cliver/dependency_ext.rb
Instance Method Summary collapse
- #major_version ⇒ Object
-
#open? ⇒ Boolean
Is the detected dependency currently open?.
-
#path ⇒ Object
Memoized shortcut for detect Returns the path to the detected dependency Raises an error if the dependency was not satisfied.
-
#version ⇒ Object
Returns the version of the resolved dependency.
Instance Method Details
#major_version ⇒ Object
31 32 33 |
# File 'lib/cliver/dependency_ext.rb', line 31 def major_version version.split(".").first if version end |
#open? ⇒ Boolean
Is the detected dependency currently open?
16 17 18 19 20 21 |
# File 'lib/cliver/dependency_ext.rb', line 16 def open? ProcTable.ps.any? { |p| p.comm == path } # See https://github.com/djberg96/sys-proctable/issues/44 rescue ArgumentError false end |
#path ⇒ Object
Memoized shortcut for detect Returns the path to the detected dependency Raises an error if the dependency was not satisfied
11 12 13 |
# File 'lib/cliver/dependency_ext.rb', line 11 def path @detected_path ||= detect! end |
#version ⇒ Object
Returns the version of the resolved dependency
24 25 26 27 28 29 |
# File 'lib/cliver/dependency_ext.rb', line 24 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 |