lib/berkshelf/locations/site_location.rb in berkshelf-1.4.0 vs lib/berkshelf/locations/site_location.rb in berkshelf-1.4.1

- old
+ new

@@ -7,10 +7,12 @@ set_location_key :site def_delegator :conn, :api_uri attr_accessor :version_constraint + SHORTNAMES = {opscode: CommunityREST::V1_API}.freeze + # @param [#to_s] name # @param [Solve::Constraint] version_constraint # @param [Hash] options # # @option options [String, Symbol] :site @@ -18,11 +20,13 @@ # be provided to initialize a SiteLocation pointing to the Opscode Community Site. def initialize(name, version_constraint, options = {}) @name = name @version_constraint = version_constraint - api_uri = if options[:site].nil? || options[:site] == :opscode - CommunityREST::V1_API + api_uri = if options[:site].nil? || SHORTNAMES.has_key?(options[:site]) + SHORTNAMES[options[:site]] + elsif options[:site].kind_of?(Symbol) + raise InvalidSiteShortnameError.new(options[:site]) else options[:site] end @conn = Berkshelf::CommunityREST.new(api_uri)