Module: ModuleSync::GitService::Factory

Defined in:
lib/modulesync/git_service/factory.rb

Overview

Git service’s factory

Class Method Summary collapse

Class Method Details

.instantiate(type:, endpoint:, token:) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/modulesync/git_service/factory.rb', line 7

def self.instantiate(type:, endpoint:, token:)
  raise MissingCredentialsError, "    A token is required to use services from \#{type}:\n      Please set environment variable: \"\#{type.upcase}_TOKEN\" or set the token entry in module options.\n  MESSAGE\n\n  klass(type: type).new token, endpoint\nend\n" if token.nil?

.klass(type:) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/modulesync/git_service/factory.rb', line 16

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