Sha256: 753ef9ec1ed57533db7733f637e6bbd29057ceac3bb14dd46214fec4d142f676

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require 'travis/cli'

module Travis
  module CLI
    class Setup < RepoCommand
      autoload :CloudControl, 'travis/cli/setup/cloud_control'
      autoload :CloudFoundry, 'travis/cli/setup/cloud_foundry'
      autoload :EngineYard,   'travis/cli/setup/engine_yard'
      autoload :Heroku,       'travis/cli/setup/heroku'
      autoload :Nodejitsu,    'travis/cli/setup/nodejitsu'
      autoload :OpenShift,    'travis/cli/setup/open_shift'
      autoload :RubyGems,     'travis/cli/setup/ruby_gems'
      autoload :SauceConnect, 'travis/cli/setup/sauce_connect'
      autoload :Service,      'travis/cli/setup/service'

      description "sets up an addon or deploy target"
      on('-f', '--force', 'override config section if it already exists')

      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

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

      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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis-1.5.4 lib/travis/cli/setup.rb