Class: Derelict::Parser::Version

Inherits:
Derelict::Parser show all
Extended by:
Memoist
Defined in:
lib/derelict/parser/version.rb,
lib/derelict/parser/version/invalid_format.rb

Overview

Parses the output of “vagrant –version”

Defined Under Namespace

Classes: InvalidFormat

Constant Summary collapse

PARSE_VERSION_FROM_OUTPUT =

Regexp to extract the version from the “vagrant –version” output

/^Vagrant (?:v(?:ersion )?)?(.*)?$/

Instance Attribute Summary

Attributes inherited from Derelict::Parser

#output

Instance Method Summary collapse

Methods inherited from Derelict::Parser

#initialize

Methods included from Utils::Logger

#logger

Constructor Details

This class inherits a constructor from Derelict::Parser

Instance Method Details

#descriptionObject

Provides a description of this Parser

Mainly used for log messages.



24
25
26
# File 'lib/derelict/parser/version.rb', line 24

def description
  "Derelict::Parser::Version instance"
end

#versionObject

Determines the version of Vagrant based on the output



13
14
15
16
17
18
# File 'lib/derelict/parser/version.rb', line 13

def version
  logger.debug "Parsing version from output using #{description}"
  matches = output.match PARSE_VERSION_FROM_OUTPUT
  raise InvalidFormat.new output if matches.nil?
  matches.captures[0]
end