Sha256: 207c122408755f00fb6a30ebbe0c6b60378a2877abaef04d8edb4dee54058ab0
Contents?: true
Size: 985 Bytes
Versions: 3
Compression:
Stored size: 985 Bytes
Contents
# frozen_string_literal: true module Bundler module Alive # Represents a source code repository class SourceCodeRepositoryUrl DOMAIN_WITH_SERVICES = { "github.com" => SourceCodeRepository::Service::GITHUB }.freeze private_constant :DOMAIN_WITH_SERVICES # No supported URL Error class UnSupportedUrl < StandardError def initialize(url) message = "UnSupported URL: #{url}" super(message) end end attr_reader :url, :service_name # # Creates a `SourceCodeRepositoryUrl` # # @param [String] url # # @raise [UnSupportedUrl] # def initialize(url) @url = url @service_name = service(url) end private def service(url) uri = URI.parse(url) host = uri.host raise UnSupportedUrl, url unless DOMAIN_WITH_SERVICES.key?(host) DOMAIN_WITH_SERVICES[host] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems