Class: Gitomator::Context

Inherits:
BaseContext show all
Defined in:
lib/gitomator/context.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  'git'     => { 'provider' => 'shell'},
  'hosting' => { 'provider' => 'local'}
}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseContext

#register_service

Constructor Details

#initialize(config = {}) ⇒ Context

Returns a new instance of Context.



69
70
71
# File 'lib/gitomator/context.rb', line 69

def initialize(config={})
  super(DEFAULT_CONFIG.merge(config))
end

Class Method Details

.from_file(config_file) ⇒ Object

Convenience function to create Context instances from configuration files.

Parameters:

  • config_file (String/File)
    • YAML configuration file.



57
58
59
# File 'lib/gitomator/context.rb', line 57

def self.from_file(config_file)
  return new(Gitomator::Util.load_config(config_file))
end

Instance Method Details

#create_github_hosting_service(config) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/gitomator/context.rb', line 99

def create_github_hosting_service(config)
  require 'gitomator/service/hosting'
  require 'gitomator/github/hosting_provider'

  return Gitomator::Service::Hosting.new (
    Gitomator::GitHub::HostingProvider.from_config(config))
end

#create_github_tagging_service(config) ⇒ Object



121
122
123
124
125
126
127
# File 'lib/gitomator/context.rb', line 121

def create_github_tagging_service(config)
  require 'gitomator/service/tagging'
  require 'gitomator/github/tagging_provider'

  return Gitomator::Service::Tagging.new (
    Gitomator::GitHub::TaggingProvider.from_config(config))
end

#create_local_hosting_service(config) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# File 'lib/gitomator/context.rb', line 74

def create_local_hosting_service(config)
  require 'gitomator/service/hosting'
  require 'gitomator/service_provider/hosting_local'
  require 'tmpdir'

  dir = config['dir'] || Dir.mktmpdir('Gitomator_')
  return Gitomator::Service::Hosting.new (
    Gitomator::ServiceProvider::HostingLocal.new(git, dir)
  )
end

#create_shell_git_service(_) ⇒ Object



86
87
88
89
90
# File 'lib/gitomator/context.rb', line 86

def create_shell_git_service(_)
  require 'gitomator/service/git'
  require 'gitomator/service_provider/git_shell'
  Gitomator::Service::Git.new(Gitomator::ServiceProvider::GitShell.new())
end

#create_travis_ci_service(config) ⇒ Object



108
109
110
111
112
113
114
# File 'lib/gitomator/context.rb', line 108

def create_travis_ci_service(config)
  require 'gitomator/service/ci'
  require 'gitomator/travis/ci_provider'

  return Gitomator::Service::CI.new(
    Gitomator::Travis::CIProvider.from_config(config))
end

#create_travis_pro_ci_service(config) ⇒ Object



116
117
118
# File 'lib/gitomator/context.rb', line 116

def create_travis_pro_ci_service(config)
  create_travis_ci_service(config)
end