class Shuttle::Generator

Constants

STRATEGIES

Attributes

git[R]
name[R]
path[R]
strategy[R]

Public Class Methods

new(strategy='static') click to toggle source
# File lib/shuttle/generator.rb, line 10
def initialize(strategy='static')
  unless STRATEGIES.include?(strategy)
    raise ArgumentError, "Invalid strategy: #{strategy}"
  end

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

Public Instance Methods

run() click to toggle source
# File lib/shuttle/generator.rb, line 19
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 Instance Methods

generate_rails() click to toggle source
# File lib/shuttle/generator.rb, line 57
def generate_rails
  # TODO
end
generate_static() click to toggle source
# File lib/shuttle/generator.rb, line 34
def generate_static
  {
    'app' => {
      'name' => name,
      'git'  => git
    },
    'target' => {
      'host'      => "mysite.com",
      'user'      => "deployer",
      'password'  => "password",
      'deploy_to' => "/home/deployer/#{name}"
    }
  }
end
generate_wordpress() click to toggle source
# File lib/shuttle/generator.rb, line 49
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