-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimal.rb
101 lines (88 loc) · 2.98 KB
/
minimal.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
run "pgrep spring | xargs kill -9"
run "rm Gemfile"
file 'Gemfile', <<-RUBY
source 'https://rubygems.org'
ruby '#{RUBY_VERSION}'
gem 'rails', '#{Rails.version}' # Rails framework, with specific version
gem 'puma' # HTTP 1.1 server
gem 'sqlite3' # database
gem 'sass-rails' # RoR integration of Sass stylesheet language (CSS)
gem 'jquery-rails' # jQuery libs (JS)
gem 'bootstrap-sass' # Sass-powered version of Bootstrap (CSS / JS libs)
gem 'font-awesome-sass' # Sass-powered version of font-awesome : iconic font & css toolkit
gem 'autoprefixer-rails' # parse CSS and add vendor prefixes to CSS rules
group :development, :test do
gem 'better_errors' # Improve error page by adding console + better readability
gem 'pry-byebug' # Adds step-by-step debugging and stack navigation capabilities to pry
gem 'pry-rails' # Use pry instead of standard console
gem 'spring' # Rails application preloader
end
group :production do
gem 'rails_12factor' # Better logging & static assets serving
end
RUBY
file ".ruby-version", RUBY_VERSION
file 'Procfile', <<-YAML
web: bundle exec puma -C config/puma.rb
YAML
if Rails.version < "5"
puma_file_content = <<-RUBY
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
RUBY
file 'config/puma.rb', puma_file_content, force: true
end
run "rm -rf app/assets/stylesheets"
run "curl -L https://github.com/lewagon/stylesheets/archive/master.zip > stylesheets.zip"
run "unzip stylesheets.zip -d app/assets && rm stylesheets.zip && mv app/assets/rails-stylesheets-master app/assets/stylesheets"
run 'rm app/assets/javascripts/application.js'
file 'app/assets/javascripts/application.js', <<-JS
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require_tree .
JS
gsub_file('config/environments/development.rb', /config\.assets\.debug.*/, 'config.assets.debug = false')
run 'rm app/views/layouts/application.html.erb'
file 'app/views/layouts/application.html.erb', <<-HTML
<!DOCTYPE html>
<html>
<head>
<title>TODO</title>
<%= csrf_meta_tags %>
#{Rails.version >= "5" ? "<%= action_cable_meta_tag %>" : nil}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<%= stylesheet_link_tag 'application', media: 'all' %>
</head>
<body>
<%= yield %>
<%= javascript_include_tag 'application' %>
</body>
</html>
HTML
run "rm README.rdoc"
markdown_file_content = <<-MARKDOWN
Rails App
MARKDOWN
file 'README.md', markdown_file_content, force: true
after_bundle do
rake 'db:drop db:create db:migrate'
generate(:controller, 'curiosities', 'index', '--no-helper', '--no-assets', '--skip-routes')
route "root to: 'curiosities#index'"
run "rm .gitignore"
file '.gitignore', <<-TXT
.bundle
log/*.log
tmp/**/*
tmp/*
*.swp
.DS_Store
public/assets
TXT
git :init
git add: "."
git commit: %Q{ -m 'Initial commit' }
end