class Travis::CLI::Setup::Service

def self.description(description = nil)

def self.description(description = nil)
  @description ||= ""
  @description = description if description
  @description
end

def self.known_as?(name)

def self.known_as?(name)
  normalized_name(service_name) == normalized_name(name)
end

def self.normalized_name(string)

def self.normalized_name(string)
  string.to_s.downcase.gsub(/[^a-z\d]/, '')
end

def self.service_name(service_name = nil)

def self.service_name(service_name = nil)
  @service_name ||= normalized_name(name[/[^:]+$/])
  @service_name = service_name if service_name
  @service_name
end

def branch

def branch
  @branch ||= `git rev-parse --symbolic-full-name --abbrev-ref HEAD`.chomp
end

def configure(key, value = {}, config = travis_config)

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

def deploy(provider, verb = "deploy")

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

def encrypt(config, key)

def encrypt(config, key)
  encrypted   = repository.encrypt(config.fetch(key))
  config[key] = { 'secure' => encrypted }
end

def initialize(command)

def initialize(command)
  @command = command
end

def method_missing(*args, &block)

def method_missing(*args, &block)
  @command.send(*args, &block)
end

def on(question, config, condition)

def on(question, config, condition)
  return unless agree(question) { |q| q.default = 'yes' }
  config['on'] ||= {}
  config['on'].merge! condition
end