/
backbone_and_bootstrap.rb
107 lines (81 loc) · 2.22 KB
/
backbone_and_bootstrap.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# template.rb
# Helpful links:
# Templates doc
# http://guides.rubyonrails.org/rails_application_templates.html
# Generator docs - in particular section 9
# http://guides.rubyonrails.org/generators.html
#-------------------
## database.yml
#-------------------
old_yml = Regexp.new("^(.*){1}", Regexp::IGNORECASE | Regexp::MULTILINE)
new_yml = <<-NEW
development:
adapter: postgresql
database: #{@app_name}_dev
host: localhost
pool: 5
timeout: 5000
test:
adapter: postgresql
database: #{@app_name}_test
host: localhost
pool: 5
timeout: 5000
production:
adapter: postgresql
database: #{@app_name}_prod
host: localhost
pool: 5
timeout: 5000
NEW
gsub_file 'config/database.yml', old_yml, new_yml
#-------------------
## GEMS
#-------------------
gsub_file 'Gemfile', "gem 'sqlite3'", ""
gem 'bcrypt'
gem 'pg'
gem 'pry-rails'
gem 'backbone-on-rails'
# gem 'jbuilder'
gem 'ejs'
gem 'bootstrap-sass'
gem_group :development do
gem 'annotate'
gem 'better_errors'
gem 'binding_of_caller'
end
run "bundle install"
#-------------------
## rake
#-------------------
puts("------------------------------------------------------------------")
puts("------------------------------------------------------------------")
rake("db:create:all") if yes?("Create DB? ('y' only if psql is running):")
#-------------------
## bootstrap
#-------------------
run "mv ./app/assets/stylesheets/application.css ./app/assets/stylesheets/application.css.scss"
append_to_file "./app/assets/stylesheets/application.css.scss", "\n@import \"bootstrap\";\n"
append_to_file "./app/assets/javascripts/application.js", "\n//= require bootstrap\n"
header_text = <<-HEADER
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
HEADER
inject_into_file "./app/views/layouts/application.html.erb", after: "</title>\n" do
header_text
end
#----------------------------
## Backbone
#----------------------------
generate "backbone:install --javascript"
generate "backbone:scaffold #{@app_name} --javascript"
#-------------------
## git
#-------------------
git :init
append_to_file '.gitignore', ".DS_Store\nconfig/database.yml\n.env\n"
git add: "-A"
git commit: %Q{ -m 'Initial commit' }
run "mate ."