Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@BrainScraps
Forked from janester/quickly.rb
Last active December 19, 2015 12:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrainScraps/5952463 to your computer and use it in GitHub Desktop.
Save BrainScraps/5952463 to your computer and use it in GitHub Desktop.
Added .env operations and the two dependency files (lots more documentation)
development:
adapter: postgresql
encoding: unicode
database: abcd_development
pool: 5
host: localhost
username: <%= ENV['psqluser'] %>
password: <%= ENV['psqlpass'] %>
test:
adapter: postgresql
encoding: unicode
database: abcd_test
pool: 5
host: localhost
username: <%= ENV['psqluser'] %>
password: <%= ENV['psqlpass'] %>
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'pg'
gem 'nokogiri', '~> 1.5.0'
group :development do
gem 'pry-rails'
gem 'pry-debugger'
gem 'binding_of_caller'
gem 'better_errors'
gem 'meta_request'
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'haml-rails'
gem 'uglifier', '>= 1.0.3'
gem 'twitter-bootstrap-rails'
end
gem 'jquery-rails'
group :test, :development do
gem 'spork-rails'
gem 'guard-rspec'
gem 'dotenv-rails'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'capybara'
end
#!/usr/bin/ruby
# This is a script that @brainscraps made for quickly creating a new directory, GitHub repository,
# local respository, and linking the two up - all with one command!
# Usage:
# First, edit the script to include your GitHub username and password.
# Second, read through the code to see which options you want to use. Comment out what you don't want
# Third, if you've opted to use dependency files like database.yml and Gemfile, make sure that they're
# in the same directory as this ruby file
# Fourth: Run it like this: ruby quickly.rb [name_of_new_app_without_brackets]
# for example:
# ruby quickly.rb blogapp
# Dependencies:
# git
# github account & credentials
# the 'octokit' gem (gem install octokit)
#
# Optional (see modules below):
# database.yml file to be used by the new Rails app
# Gemfile to be used by the new Rails app
require "octokit"
require "fileutils"
user = "your_username" #replace this with your info
pw = "yourpassword" #replace this with your info
client = Octokit::Client.new(:login => user, :password => pw)
system "echo waiting for Github authentication"
sleep 2
response = client.create_repository(ARGV[0])
system "echo waiting for creation of new respository"
sleep 3
system "rails new #{ARGV[0]} -d postgresql"
system "echo #{response["ssh_url"]}"
Dir.chdir(ARGV[0]) do
system "git init"
system "git remote add origin #{response["ssh_url"]}"
end
# Personalization code found below
# jane & isaac personalization modules ---------------
sleep 2
system "echo personalizing your #{ARGV[0]} Rails app"
system "touch #{ARGV[0]}/app/assets/stylesheets/#{ARGV[0]}.scss"
system "touch #{ARGV[0]}/app/assets/javascripts/#{ARGV[0]}.js"
sleep 1
# this code assumes that you have a sort of *prototype* Gemfile in the same directory as this script
# you can customize it as you like to meet your needs.
system "rm #{ARGV[0]}/Gemfile"
system "cp Gemfile #{ARGV[0]}/Gemfile"
# also, you can pull a prototype Gemfile from a location on the web, like Github:
# (be sure to comment out the cp Gemfile.... line above )
# system "curl https://gist.github.com/BrainScraps/5970767/raw/fe0ef1456cd416b73b69e02468aed965e1a6e22f/Gemfile --output #{ARGV[0]}/Gemfile"
# this following code relies on a
# file called 'database.yml' being in the same directory as this file. That db.yml file is one that
# has my username and 'abcd' in place of the app name.
system "echo \"config/database.yml\" >> #{ARGV[0]}/.gitignore"
system "rm #{ARGV[0]}/config/database.yml"
system "sed 's/abcd/#{ARGV[0]}/g' database.yml > #{ARGV[0]}/config/database.yml"
# if you don't know what .env files are used for, it's likely that you don't need the following lines. You can
# comment them out if you like. Also, you can get rid of the gem 'dotenv-rails' in the Gemfile
system "echo \".env\" >> #{ARGV[0]}/.gitignore"
system "echo cp .env #{ARGV[0]}/.env"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment