class Travis::CLI::Setup::Service
Attributes
command[RW]
Public Class Methods
description(description = nil)
click to toggle source
# File lib/travis/cli/setup/service.rb, line 11 def self.description(description = nil) @description ||= "" @description = description if description @description end
known_as?(name)
click to toggle source
# File lib/travis/cli/setup/service.rb, line 23 def self.known_as?(name) normalized_name(service_name) == normalized_name(name) end
new(command)
click to toggle source
# File lib/travis/cli/setup/service.rb, line 29 def initialize(command) @command = command end
normalized_name(string)
click to toggle source
# File lib/travis/cli/setup/service.rb, line 7 def self.normalized_name(string) string.to_s.downcase.gsub(/[^a-z\d]/, '') end
service_name(service_name = nil)
click to toggle source
# File lib/travis/cli/setup/service.rb, line 17 def self.service_name(service_name = nil) @service_name ||= normalized_name(name[/[^:]+$/]) @service_name = service_name if service_name @service_name end
Public Instance Methods
method_missing(*args, &block)
click to toggle source
# File lib/travis/cli/setup/service.rb, line 33 def method_missing(*args, &block) @command.send(*args, &block) end
Private Instance Methods
branch()
click to toggle source
# File lib/travis/cli/setup/service.rb, line 55 def branch @branch ||= %x`git rev-parse --symbolic-full-name --abbrev-ref HEAD`.chomp end
configure(key, value = {}, config = travis_config) { |config = value| ... }
click to toggle source
# File lib/travis/cli/setup/service.rb, line 50 def configure(key, value = {}, config = travis_config) error "#{key} section already exists in .travis.yml, run with --force to override" if config.include? key and not force? yield(config[key] = value) end
deploy(provider, verb = "deploy") { |config| ... }
click to toggle source
# File lib/travis/cli/setup/service.rb, line 59 def deploy(provider, verb = "deploy") configure('deploy', 'provider' => provider) do |config| yield config on("#{verb.capitalize} only from #{repository.slug}? ", config, 'repo' => repository.slug) on("#{verb.capitalize} from #{branch} branch? ", config, 'branch' => branch) if branch != 'master' and branch != 'HEAD' encrypt(config, 'password') if config['password'] and agree("Encrypt Password? ") { |q| q.default = 'yes' } encrypt(config, 'api_key') if config['api_key'] and agree("Encrypt API key? ") { |q| q.default = 'yes' } end end
encrypt(config, key)
click to toggle source
# File lib/travis/cli/setup/service.rb, line 45 def encrypt(config, key) encrypted = repository.encrypt(config.fetch(key)) config[key] = { 'secure' => encrypted } end
on(question, config, condition)
click to toggle source
# File lib/travis/cli/setup/service.rb, line 39 def on(question, config, condition) return unless agree(question) { |q| q.default = 'yes' } config['on'] ||= {} config['on'].merge! condition end