module Vagrant::BoxMetadata::Remote
This module enables the BoxMetadata
for server mode
Attributes
description[RW]
name[RW]
Public Class Methods
new(io, url: nil, client: nil)
click to toggle source
@param [IO] io An IO object to read the metadata from.
# File lib/vagrant/box_metadata/remote.rb, line 18 def initialize(io, url: nil, client: nil) @logger = Log4r::Logger.new("vagrant::box") if !client.nil? # Use client if available @client = client else # If client is not available, then try to load from url if url.nil? raise ArgumentError, "Metadata URL is required for `#{self.class.name}' if a client is not provided" end @client = Vagrant.plugin("2").remote_manager.core_plugin_manager.get_plugin("boxmetadata") @client.load_metadata(url) end @name = @client.name end
prepended(klass)
click to toggle source
Add an attribute reader for the client when applied to the BoxMetadata
class
# File lib/vagrant/box_metadata/remote.rb, line 8 def self.prepended(klass) klass.class_eval do attr_reader :client end end
Public Instance Methods
version(version, **opts)
click to toggle source
# File lib/vagrant/box_metadata/remote.rb, line 36 def version(version, **opts) providers = nil providers = Array(opts[:provider]) || [] v = @client.version(version, providers) Version.new(v, ver: v[:version], client: @client) end
versions(**opts)
click to toggle source
# File lib/vagrant/box_metadata/remote.rb, line 44 def versions(**opts) provider = nil provider = opts[:provider].to_sym if opts[:provider] v = @client.list_versions(provider) # Sort so the last element of the list is the latest version. v.sort.map(&:to_s) end