class Derelict::Parser::BoxList
Parses the output of “vagrant box list”
Constants
- NO_BOXES
Output from “vagrant box list” if there are no boxes installed
- 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
Public Instance Methods
boxes()
click to toggle source
Retrieves a Set containing all the boxes from the output
# File lib/derelict/parser/box_list.rb, line 29 def boxes box_lines.map {|l| parse_line l.match(PARSE_BOX) }.to_set end
description()
click to toggle source
Provides a description of this Parser
Mainly used for log messages.
# File lib/derelict/parser/box_list.rb, line 36 def description "Derelict::Parser::BoxList instance" end
Private Instance Methods
box_lines()
click to toggle source
Retrieves an array of the box lines in the output
# File lib/derelict/parser/box_list.rb, line 42 def box_lines return [] if output.match NO_BOXES output.lines end
parse_line(match)
click to toggle source
Parses a single line of the output into a Box
object
# File lib/derelict/parser/box_list.rb, line 48 def parse_line(match) raise InvalidFormat.new "Couldn't parse box list" if match.nil? Derelict::Box.new *match.captures[0..1] end