Created
February 16, 2014 22:14
-
-
Save delba/9041398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'bootstrap-sass' | |
gem 'bcrypt-ruby', '~> 3.1.2' | |
gem_group :development, :test do | |
gem 'debugger' | |
end | |
gem_group :development do | |
gem 'commands' | |
gem 'guard' | |
gem 'guard-minitest' | |
gem 'terminal-notifier-guard' | |
gem 'guard-livereload', require: false | |
gem 'rack-livereload' | |
gem 'quiet_assets' | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
end | |
gem_group :test do | |
gem 'capybara' | |
gem 'poltergeist' | |
gem 'launchy' | |
end | |
gem_group :doc do | |
gem 'redcarpet', '~> 2.1.1' | |
end | |
# Use single quotes | |
gsub_file 'Gemfile', '"', "'" | |
# Remove comments | |
gsub_file 'Gemfile', /^#.*$\n/, '' | |
# Remove blank lines | |
gsub_file 'Gemfile', /^$\n/, '' | |
inject_into_file 'Gemfile', "\n", before: /$group.*/ | |
application do | |
"""config.generators do |generate| | |
generate.assets false | |
generate.helper false | |
end""" | |
end | |
application nil, env: 'development' do | |
"config.middleware.insert_before Rack::Lock, Rack::LiveReload" | |
end | |
# Edit stylesheet | |
remove_file 'app/assets/stylesheets/application.css' | |
create_file 'app/assets/stylesheets/application.scss' do | |
""" | |
@import 'variables'; | |
@import 'mixins'; | |
@import 'bootstrap'; | |
""".lstrip | |
end | |
create_file 'app/assets/stylesheets/_variables.scss' | |
create_file 'app/assets/stylesheets/_mixins.scss' | |
# Edit javascript | |
gsub_file 'app/assets/javascripts/application.js', /^\/\/[^=].*$\n/, '' | |
insert_into_file 'app/assets/javascripts/application.js', before: '//= require_tree .' do | |
"\n//= require bootstrap\n\n" | |
end | |
# Edit Guardfile | |
create_file "Guardfile" do | |
%q(guard :minitest do | |
watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" } | |
watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' } | |
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" } | |
watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" } | |
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" } | |
watch(%r{^test/.+_test\.rb$}) | |
watch(%r{^test/test_helper\.rb$}) { 'test' } | |
end | |
guard 'livereload' do | |
watch(%r{app/views/.+\.(erb|haml|slim)$}) | |
watch(%r{app/helpers/.+\.rb}) | |
watch(%r{public/.+\.(css|js|html)}) | |
watch(%r{config/locales/.+\.yml}) | |
# Rails Assets Pipeline | |
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" } | |
watch(%r{(app|vendor)(/assets/\w+/(.+\.(scss)))}) { |m| "/assets/application.css" } | |
end) | |
end | |
# Edit test_helper.rb | |
inject_into_file 'test/test_helper.rb', after: "require 'rails/test_help'\n" do | |
""" | |
require 'minitest/pride' | |
require 'capybara/rails' | |
require 'capybara/poltergeist' | |
""" | |
end | |
append_to_file 'test/test_helper.rb' do | |
""" | |
class ActionDispatch::IntegrationTest | |
include Capybara::DSL | |
Capybara.javascript_driver = :poltergeist | |
setup do | |
Capybara.current_driver = Capybara.javascript_driver | |
end | |
teardown do | |
Capybara.use_default_driver | |
end | |
end | |
class ActiveRecord::Base | |
mattr_accessor :shared_connection | |
@@shared_connection = nil | |
def self.connection | |
@@shared_connection || retrieve_connection | |
end | |
end | |
# Forces all threads to share the same connection. This works on | |
# Capybara because it starts the web server in a thread. | |
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection | |
""" | |
end | |
run 'powder link' | |
run "open http://#@app_name.dev/" | |
# run "tail -f #@app_name/log/development.log" | |
run 'bundle exec guard' | |
run 'mvim .' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment