dgerbs
9/12/2013 - 3:23 PM

.rails_aliases

.rails_aliases

export EDITOR=subl
export PGHOST=127.0.0.1
#export NOKOGIRI_USE_SYSTEM_LIBRARIES=true

function rails_new() { rails new $1 && cd $1 && git init && git add . && git commit -m 'Initial commit'; }


alias migrate='rake db:migrate && rake db:rollback && rake db:migrate'


function rebuild_db_and_test() { rake db:drop && rake db:create && rake db:migrate && rake db:test:prepare && rspec spec; }


function rails_pg() {
  rails new $1 -T -B --database=postgresql
  cd $1

  # setup rails filesystem
  echo $1 > .ruby-gemset
  echo ruby-2.0 > .ruby-version

  # configure postgres
  echo /config/database.yml >> .gitignore
  mv config/database.yml config/database.example.yml
  sed "s/username: "$1"/username: /g" config/database.example.yml > config/database.yml
  rake db:create

  remove_turbolinks
  add_rails_gems

  cd .. && cd $1
  bundle
  cd .. && cd $1
  rails generate rspec:install

  # save progress
  git init
  git add .
  git commit -m 'initial commit'

  subl .
}


function add_rails_gems() {

  echo "
#gem 'acts-as-taggable-on'
#gem 'carrierwave'
#gem 'devise'
#gem 'kaminari'
#gem 'ransack'
#gem 'simple_form'
#gem 'state_machine'
#gem 'stringex'

group :test, :development do
  gem 'capybara'
  #gem 'factory_girl'
  gem 'factory_girl_rails'
  gem 'launchy'
  gem 'pry-rails'
  gem 'quiet_assets'
  gem 'rspec-rails'
  gem 'shoulda-matchers'
  gem 'valid_attribute'
end

" >> Gemfile

}

function add_bootstrap3() {
  cp ~/Dropbox/launch/bootstrap3.0.0/css/bootstrap-theme.min.css vendor/assets/stylesheets/
  cp ~/Dropbox/launch/bootstrap3.0.0/css/bootstrap.min.css vendor/assets/stylesheets/
  cp ~/Dropbox/launch/bootstrap3.0.0/js/bootstrap.min.js vendor/assets/javascripts/
  sed -i '' '$d' app/assets/stylesheets/application.css
  echo " *= require bootstrap.min\n *= require bootstrap-theme.min\n */" >> app/assets/stylesheets/application.css
  echo "//= require bootstrap.min" >> app/assets/javascripts/application.js
}

function remove_turbolinks() {
  sed -i '' '/turbolinks/,/^$/d' Gemfile
  sed -i '' '/turbolinks/d' app/assets/javascripts/application.js
  sed -i '' 's@, "data-turbolinks-track" => true@@' app/views/layouts/application.html.erb
}


function add_foundation() {

  echo "

gem 'compass-rails'
gem 'zurb-foundation', '~> 4.0.0'

  " >> Gemfile

  bundle
  rails g foundation:install
}