module ModuleSync::GitService::Factory

Git service’s factory

Public Class Methods

instantiate(type:, endpoint:, token:) click to toggle source
# File lib/modulesync/git_service/factory.rb, line 5
      def self.instantiate(type:, endpoint:, token:)
        raise MissingCredentialsError, <<~MESSAGE if token.nil?
          A token is required to use services from #{type}:
            Please set environment variable: "#{type.upcase}_TOKEN" or set the token entry in module options.
        MESSAGE

        klass(type: type).new token, endpoint
      end
klass(type:) click to toggle source
# File lib/modulesync/git_service/factory.rb, line 14
def self.klass(type:)
  case type
  when :github
    require 'modulesync/git_service/github'
    ModuleSync::GitService::GitHub
  when :gitlab
    require 'modulesync/git_service/gitlab'
    ModuleSync::GitService::GitLab
  else
    raise NotImplementedError, "Unknown git service: '#{type}'"
  end
end