class Berkshelf::SourceURI

Constants

VALID_SCHEMES

Public Class Methods

parse(uri) click to toggle source

Returns a URI object based on the parsed string.

@param [String, Addressable::URI, to_str] uri

The URI string to parse.
No parsing is performed if the object is already an
<code>Addressable::URI</code>.

@raise [Berkshelf::InvalidSourceURI]

@return [Berkshelf::SourceURI]

Calls superclass method
# File lib/berkshelf/source_uri.rb, line 16
def parse(uri)
  parsed_uri = super(uri)
  parsed_uri.send(:validate)
  parsed_uri
rescue TypeError, ArgumentError => ex
  raise InvalidSourceURI.new(uri, ex)
end

Public Instance Methods

validate() click to toggle source

@raise [Berkshelf::InvalidSourceURI]

Calls superclass method
# File lib/berkshelf/source_uri.rb, line 28
def validate
  super

  unless VALID_SCHEMES.include?(scheme)
    raise InvalidSourceURI.new(self, "invalid URI scheme '#{scheme}'. Valid schemes: #{VALID_SCHEMES}")
  end
rescue Addressable::URI::InvalidURIError => ex
  raise InvalidSourceURI.new(self, ex)
end