Class: Derelict::Parser::BoxList

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

Overview

Parses the output of “vagrant box list”

Defined Under Namespace

Classes: InvalidFormat

Constant Summary collapse

NO_BOXES =

Output from “vagrant box list” if there are no boxes installed

<<-END.gsub(/^ {6}/, '')
  There are no installed boxes! Use `vagrant box add` to add some.
END
PARSE_BOX =

Regexp to parse a box line into a box name and provider

Capture groups:

1. Box name, as listed in the output
2. Name of the provider for that box
%r[
  ^(.*?)   # Box name starts at the start of the line
  \ +\(    # Provider is separated by spaces and open-parenthesis
    (.*)   # Provider name
  \)$      # Ends with close-parenthesis and end-of-line
]x

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

#boxesObject

Retrieves a Set containing all the boxes from the output



28
29
30
# File 'lib/derelict/parser/box_list.rb', line 28

def boxes
  box_lines.map {|l| parse_line l.match(PARSE_BOX) }.to_set
end

#descriptionObject

Provides a description of this Parser

Mainly used for log messages.



35
36
37
# File 'lib/derelict/parser/box_list.rb', line 35

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