Class: Txgh::Config::ConfigPair

Inherits:
Object
  • Object
show all
Defined in:
lib/txgh/config/config_pair.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_config, repo_config) ⇒ ConfigPair

Returns a new instance of ConfigPair.



6
7
8
9
# File 'lib/txgh/config/config_pair.rb', line 6

def initialize(project_config, repo_config)
  @project_config = project_config
  @repo_config = repo_config
end

Instance Attribute Details

#project_configObject (readonly)

Returns the value of attribute project_config.



4
5
6
# File 'lib/txgh/config/config_pair.rb', line 4

def project_config
  @project_config
end

#repo_configObject (readonly)

Returns the value of attribute repo_config.



4
5
6
# File 'lib/txgh/config/config_pair.rb', line 4

def repo_config
  @repo_config
end

Instance Method Details

#git_repoObject



11
12
13
14
15
16
17
# File 'lib/txgh/config/config_pair.rb', line 11

def git_repo
  @git_repo ||= if @repo_config['git_repo_source'] == 'gitlab'
                  Txgh::GitlabRepo.new(repo_config, gitlab_api)
                else
                  Txgh::GithubRepo.new(repo_config, github_api)
                end
end

#github_apiObject



31
32
33
34
35
# File 'lib/txgh/config/config_pair.rb', line 31

def github_api
  @github_api ||= Txgh::GithubApi.create_from_credentials(
    repo_config['api_username'], repo_config['api_token'], repo_config['name']
  )
end

#gitlab_apiObject



37
38
39
40
41
# File 'lib/txgh/config/config_pair.rb', line 37

def gitlab_api
  @gitlab_api ||= Txgh::GitlabApi.create_from_credentials(
    nil, repo_config['api_token'], repo_config['name']
  )
end

#transifex_apiObject



25
26
27
28
29
# File 'lib/txgh/config/config_pair.rb', line 25

def transifex_api
  @transifex_api ||= Txgh::TransifexApi.create_from_credentials(
    project_config['api_username'], project_config['api_password']
  )
end

#transifex_projectObject



19
20
21
22
23
# File 'lib/txgh/config/config_pair.rb', line 19

def transifex_project
  @transifex_project ||= Txgh::TransifexProject.new(
    project_config, transifex_api
  )
end