Module: Opener::BuildTools::Requirements
- Defined in:
- lib/opener/build-tools/requirements.rb
Overview
Module that provides various helper methods for ensuring certain executables exist, version requirements are met and so on.
Class Method Summary collapse
-
.require_executable(name) ⇒ Object
Checks if a given executable can be found in $PATH and aborts if this isn’t the case.
-
.require_version(name, current, required) ⇒ Object
Checks if the version specified in ‘current` is greater than or equal to the version specified in `requirement`.
-
.version_greater_than(left, right) ⇒ TrueClass|FalseClass
Checks if the version string to the left is greater or equal to the version string on the right.
Class Method Details
.require_executable(name) ⇒ Object
Checks if a given executable can be found in $PATH and aborts if this isn’t the case.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/opener/build-tools/requirements.rb', line 19 def require_executable(name) print "Checking for #{name}... " exists = false ENV['PATH'].split(File::PATH_SEPARATOR).each do |directory| path = File.join(directory, name) if File.executable?(path) exists = true break end end if exists puts 'yes' else abort 'no' end end |
.require_version(name, current, required) ⇒ Object
Checks if the version specified in ‘current` is greater than or equal to the version specified in `requirement`.
51 52 53 54 55 56 57 58 59 |
# File 'lib/opener/build-tools/requirements.rb', line 51 def require_version(name, current, required) print "Checking for #{name} >= #{required}... " if version_greater_than(current, required) puts 'yes' else abort 'no' end end |
.version_greater_than(left, right) ⇒ TrueClass|FalseClass
Checks if the version string to the left is greater or equal to the version string on the right.
69 70 71 |
# File 'lib/opener/build-tools/requirements.rb', line 69 def version_greater_than(left, right) return Gem::Version.new(left) >= Gem::Version.new(right) end |