Class: Travis::CLI::Setup
- Inherits:
-
RepoCommand
- Object
- Command
- ApiCommand
- RepoCommand
- Travis::CLI::Setup
- Defined in:
- lib/travis/cli/setup.rb
Constant Summary
Constants inherited from RepoCommand
Instance Attribute Summary
Attributes inherited from RepoCommand
Attributes inherited from ApiCommand
Attributes inherited from Command
#arguments, #config, #force_interactive, #formatter, #input, #output
Instance Method Summary collapse
- #run(service) ⇒ Object
- #setup_heroku ⇒ Object
- #setup_nodejitsu ⇒ Object
- #setup_openshift ⇒ Object
- #setup_sauce_connect ⇒ Object (also: #setup_sauce_lab, #setup_sauce)
Methods inherited from RepoCommand
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, #build, #explicit_api_endpoint?, #github_auth, #job, #repo, #repos, #restart, #user, #worker, #workers
Methods inherited from Command
abstract, abstract?, #check_ruby, #check_version, command_name, #command_name, #debug, #execute, #help, #initialize, #parse, #say, #setup, skip, #terminal, #usage, #write_to
Methods included from Parser
Constructor Details
This class inherits a constructor from Travis::CLI::ApiCommand
Instance Method Details
#run(service) ⇒ Object
9 10 11 12 |
# File 'lib/travis/cli/setup.rb', line 9 def run(service) error "unknown service #{service}" unless respond_to? "setup_#{service}" public_send "setup_#{service}" end |
#setup_heroku ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/travis/cli/setup.rb', line 14 def setup_heroku configure 'deploy', 'provider' => 'heroku' do |config| config['api_key'] = `heroku auth:token 2>/dev/null`.strip config['api_key'] = ask("Heroku API token: ") { |q| q.echo = "*" }.to_s if config['api_key'].empty? config['app'] = `heroku apps:info 2>/dev/null`.scan(/^=== (.+)$/).flatten.first config['app'] = ask("Heroku application name: ") { |q| q.default = repository.name }.to_s if config['app'].nil? config['on'] = { 'repo' => repository.slug } if agree("Deploy only from #{repository.slug}? ") { |q| q.default = 'yes' } encrypt(config, 'api_key') if agree("Encrypt API key? ") { |q| q.default = 'yes' } end end |
#setup_nodejitsu ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/travis/cli/setup.rb', line 36 def setup_nodejitsu configure 'deploy', 'provider' => 'nodejitsu' do |config| jitsu_file = File.('.jitsuconf', ENV['HOME']) if File.exist? jitsu_file jitsu_conf = JSON.parse(File.read(jitsu_file)) config['user'] = jitsu_conf['username'] config['api_key'] = jitsu_conf['apiToken'] end config['user'] ||= ask("Nodejitsu user: ").to_s config['api_key'] ||= ask("Nodejitsu API token: ") { |q| q.echo = "*" }.to_s config['on'] = { 'repo' => repository.slug } if agree("Deploy only from #{repository.slug}? ") { |q| q.default = 'yes' } encrypt(config, 'api_key') if agree("Encrypt API key? ") { |q| q.default = 'yes' } end end |
#setup_openshift ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/travis/cli/setup.rb', line 25 def setup_openshift configure 'deploy', 'provider' => 'openshift' do |config| config['user'] = ask("OpenShift user: ").to_s config['password'] = ask("OpenShift password: ") { |q| q.echo = "*" }.to_s config['app'] = ask("OpenShift application name: ") { |q| q.default = repository.name }.to_s config['domain'] = ask("OpenShift domain: ").to_s config['on'] = { 'repo' => repository.slug } if agree("Deploy only from #{repository.slug}? ") { |q| q.default = 'yes' } encrypt(config, 'password') if agree("Encrypt password? ") { |q| q.default = 'yes' } end end |
#setup_sauce_connect ⇒ Object Also known as: setup_sauce_lab, setup_sauce
53 54 55 56 57 58 59 60 |
# File 'lib/travis/cli/setup.rb', line 53 def setup_sauce_connect travis_config['addons'] ||= {} configure 'sauce_connect', {}, travis_config['addons'] do |config| config['username'] = ask("Sauce Labs user: ").to_s config['access_key'] = ask("Sauce Labs access key: ") { |q| q.echo = "*" }.to_s encrypt(config, 'access_key') if agree("Encrypt access key? ") { |q| q.default = 'yes' } end end |