Sha256: c0912721f6e501499330b048144fec79bcfea94152866df0a61388d03badca89

Contents?: true

Size: 1.35 KB

Versions: 16

Compression:

Stored size: 1.35 KB

Contents

module Shuttle
  class Generator
    include TerminalHelpers

    STRATEGIES = %w(static wordpress rails)

    attr_reader :strategy
    attr_reader :name, :git, :path

    def initialize(strategy='static')
      unless STRATEGIES.include?(strategy)
        raise ArgumentError, "Invalid strategy: #{strategy}"
      end

      @strategy = strategy
      @path = File.join(Dir.pwd, 'shuttle.yml')
    end

    def run
      @name = ask('Application name', :required => true)
      @git  = ask('Git repository', :required => true)

      hash = send("generate_#{strategy}")

      File.open(path, 'w') do |f|
        f.write(YAML.dump(hash))
      end

      display "New shuttle config has been generated at ./shuttle.yml"
    end

    private

    def generate_static
      {
        'app' => {
          'name' => name,
          'git'  => git
        },
        'target' => {
          'host'      => "mysite.com",
          'user'      => "deployer",
          'password'  => "password",
          'deploy_to' => "/home/deployer/#{name}"
        }
      }
    end

    def generate_wordpress
      base = generate_static

      base['environment']       = ask('Rails env:', 'production')
      base['precompile_assets'] = ask('Precompile assets', 'yes')
      base['start_server']      = ask('Start server', true)
    end

    def generate_rails
      # TODO
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
shuttle-deploy-0.4.0 lib/shuttle/generator.rb
shuttle-deploy-0.3.3 lib/shuttle/generator.rb
shuttle-deploy-0.3.2 lib/shuttle/generator.rb
shuttle-deploy-0.3.1 lib/shuttle/generator.rb
shuttle-deploy-0.3.0 lib/shuttle/generator.rb
shuttle-deploy-0.3.0.beta1 lib/shuttle/generator.rb
shuttle-deploy-0.2.3 lib/shuttle/generator.rb
shuttle-deploy-0.2.2 lib/shuttle/generator.rb
shuttle-deploy-0.2.1 lib/shuttle/generator.rb
shuttle-deploy-0.2.0 lib/shuttle/generator.rb
shuttle-deploy-0.2.0.beta16 lib/shuttle/generator.rb
shuttle-deploy-0.2.0.beta15 lib/shuttle/generator.rb
shuttle-deploy-0.2.0.beta14 lib/shuttle/generator.rb
shuttle-deploy-0.2.0.beta13 lib/shuttle/generator.rb
shuttle-deploy-0.2.0.beta12 lib/shuttle/generator.rb
shuttle-deploy-0.2.0.beta11 lib/shuttle/generator.rb