Class: Berkshelf::SourceURI
- Inherits:
-
Addressable::URI
- Object
- Addressable::URI
- Berkshelf::SourceURI
- Defined in:
- lib/berkshelf/source_uri.rb
Constant Summary collapse
- VALID_SCHEMES =
%w{http https file}.freeze
Class Method Summary collapse
-
.parse(uri) ⇒ Berkshelf::SourceURI
Returns a URI object based on the parsed string.
Instance Method Summary collapse
Class Method Details
.parse(uri) ⇒ Berkshelf::SourceURI
Returns a URI object based on the parsed string.
16 17 18 19 20 21 22 |
# 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 |
Instance Method Details
#validate ⇒ Object
28 29 30 31 32 33 34 35 36 |
# 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 |