Sha256: 458ba78c116e8845dcd11bb4b65e45c6321b14bcf896c50111bc2b0b12188b82

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

#!/usr/bin/env ruby

require 'erb'

DADDY_HOME = File.dirname(File.dirname(__FILE__))

case action = ARGV[0]
when 'new'
  RAILS_VERSION = '4.2.6'
  puts "using rails #{RAILS_VERSION}"

  APP_NAME = ARGV[1]

  [
    "sudo gem install rails -v #{RAILS_VERSION} --no-document",
    "rails _#{RAILS_VERSION}_ new #{APP_NAME} -d mysql --skip-bundle",
  ].each do |command|
    puts command
    exit 1 unless system(command)
  end

  # Gemfile
  template = File.join(DADDY_HOME, 'templates', 'Gemfile.erb')
  gemfile = File.join(APP_NAME, 'Gemfile')
  File.write(gemfile, ERB.new(File.read(template)).result)

  [
    "bundle install --quiet",
    "bundle exec rake dad:mysql:install",
    "bundle exec rake dad:install",
    "bundle exec rake dad:db:config",
    "bundle exec rake dad:db:create",
    "bundle exec rake db:migrate",
    "bundle exec rails g controller welcome index --no-helper --no-assets",
    "echo '<h1>Welcome to #{APP_NAME}</h1>' > #{File.join('app', 'views', 'welcome', 'index.html.erb')}"
  ].each do |command|
    puts command
    exit 1 unless system("cd #{APP_NAME} && #{command}")
  end

  # routes
  template = File.join(DADDY_HOME, 'templates', 'config', 'routes.rb.erb')
  routes = File.join(APP_NAME, 'config', 'routes.rb')
  File.write(routes, ERB.new(File.read(template)).result)
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
daddy-0.5.12 bin/dad
daddy-0.5.11 bin/dad
daddy-0.5.10 bin/dad
daddy-0.5.9 bin/dad
daddy-0.5.8 bin/dad
daddy-0.5.7 bin/dad
daddy-0.5.6 bin/dad