core: use symbol names for providers everywhere

This commit is contained in:
Mitchell Hashimoto 2014-01-24 10:02:16 -08:00
parent e316e10552
commit f2c4adc4ee
2 changed files with 7 additions and 7 deletions

View File

@ -51,7 +51,7 @@ module Vagrant
end
providers = nil
providers = Array(opts[:provider]) if opts[:provider]
providers = Array(opts[:provider]).map(&:to_sym) if opts[:provider]
@version_map.keys.sort.reverse.each do |v|
next if !requirements.all? { |r| r.satisfied_by?(v) }
@ -84,7 +84,7 @@ module Vagrant
@version = raw["version"]
@provider_map = (raw["providers"] || []).map do |p|
[p["name"], p]
[p["name"].to_sym, p]
end
@provider_map = Hash[@provider_map]
end
@ -92,7 +92,7 @@ module Vagrant
# Returns a [Provider] for the given name, or nil if it isn't
# supported by this version.
def provider(name)
p = @provider_map[name]
p = @provider_map[name.to_sym]
return nil if !p
Provider.new(p)
end
@ -100,9 +100,9 @@ module Vagrant
# Returns the providers that are available for this version
# of the box.
#
# @return [Provider]
# @return [Array<Symbol>]
def providers
@provider_map.keys
@provider_map.keys.map(&:to_sym)
end
end

View File

@ -77,7 +77,7 @@ describe Vagrant::BoxMetadata do
end
it "matches the constraint that has the given provider" do
result = subject.version(">= 0", provider: "vmware")
result = subject.version(">= 0", provider: :vmware)
expect(result).to_not be_nil
expect(result).to be_kind_of(Vagrant::BoxMetadata::Version)
expect(result.version).to eq("1.1.0")
@ -131,7 +131,7 @@ describe Vagrant::BoxMetadata::Version do
describe "#providers" do
it "returns the providers available" do
expect(subject.providers.sort).to eq(
["virtualbox", "vmware"])
[:virtualbox, :vmware])
end
end
end