lib/berkshelf/locations/site_location.rb in berkshelf-0.4.0 vs lib/berkshelf/locations/site_location.rb in berkshelf-0.5.0.rc1
- old
+ new
@@ -1,11 +1,13 @@
+require 'chef/rest'
+
module Berkshelf
# @author Jamie Winsor <jamie@vialstudios.com>
class SiteLocation
include Location
- location_key :site
+ set_location_key :site
attr_reader :api_uri
attr_accessor :version_constraint
class << self
@@ -24,11 +26,11 @@
#
# @option options [String, Symbol] :site
# a URL pointing to a community API endpoint. Alternatively the symbol :opscode can
# be provided to initialize a SiteLocation pointing to the Opscode Community Site.
def initialize(name, version_constraint, options = {})
- @name = name
+ @name = name
@version_constraint = version_constraint
@api_uri = if options[:site].nil? || options[:site] == :opscode
Location::OPSCODE_COMMUNITY_API
else
@@ -108,11 +110,15 @@
else
raise
end
end
+ def to_hash
+ super.merge(value: self.api_uri)
+ end
+
def to_s
- "site: '#{api_uri}'"
+ "#{self.class.location_key}: '#{api_uri}'"
end
private
attr_reader :rest