Class: Travis::CLI::Setup

Inherits:
RepoCommand show all
Defined in:
lib/travis/cli/setup.rb,
lib/travis/cli/setup/heroku.rb,
lib/travis/cli/setup/service.rb,
lib/travis/cli/setup/nodejitsu.rb,
lib/travis/cli/setup/ruby_gems.rb,
lib/travis/cli/setup/open_shift.rb,
lib/travis/cli/setup/engine_yard.rb,
lib/travis/cli/setup/cloud_control.rb,
lib/travis/cli/setup/cloud_foundry.rb,
lib/travis/cli/setup/sauce_connect.rb

Defined Under Namespace

Classes: CloudControl, CloudFoundry, EngineYard, Heroku, Nodejitsu, OpenShift, RubyGems, SauceConnect, Service

Constant Summary

Constants inherited from RepoCommand

RepoCommand::GIT_REGEX

Instance Attribute Summary

Attributes inherited from RepoCommand

#slug

Attributes inherited from ApiCommand

#session

Attributes inherited from Command

#arguments, #config, #force_interactive, #formatter, #input, #output

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RepoCommand

#repository, #setup

Methods inherited from ApiCommand

#authenticate, #detected_endpoint?, #endpoint_config, #initialize, #org?, #pro?, #setup, #sync

Methods included from Travis::Client::Methods

#access_token, #access_token=, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #job, #listen, #repo, #repos, #restart, #user, #worker, #workers

Methods inherited from Command

abstract, abstract?, #check_ruby, #check_version, #command_name, command_name, #debug, description, #execute, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, #terminal, #usage, #write_to

Methods included from Parser

#new, #on, #on_initialize

Constructor Details

This class inherits a constructor from Travis::CLI::ApiCommand

Class Method Details

.service(name) ⇒ Object



19
20
21
22
23
24
# File 'lib/travis/cli/setup.rb', line 19

def self.service(name)
  normal_name = Service.normalized_name(name)
  const_name  = constants(false).detect { |c| Service.normalized_name(c) == normal_name }
  constant    = const_get(const_name) if const_name
  constant if constant and constant < Service and constant.known_as? name
end

.servicesObject



26
27
28
# File 'lib/travis/cli/setup.rb', line 26

def self.services
  constants(false).sort.map { |c| const_get(c) }.select { |c| c < Service }
end

Instance Method Details

#helpObject



30
31
32
33
# File 'lib/travis/cli/setup.rb', line 30

def help
  services = self.class.services.map { |s| "\t" << color(s.service_name.ljust(20), :command) << color(s.description, :info) }.join("\n")
  super("\nAvailable services:\n\n#{services}\n\n")
end

#run(service, file = travis_yaml) ⇒ Object



35
36
37
38
# File 'lib/travis/cli/setup.rb', line 35

def run(service, file = travis_yaml)
  service(service).run
  save_travis_config(file)
end

#service(name) ⇒ Object



40
41
42
43
44
# File 'lib/travis/cli/setup.rb', line 40

def service(name)
  factory = self.class.service(name)
  error("unknown service #{name}") unless factory
  factory.new(self)
end