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
108
|
# File 'lib/railsbricks/gemfile_builder.rb', line 30
def self.build_gemfile(app_dir, options)
new_line(2)
wputs "----> Generating Gemfile ...", :info
rbricks_dir = File.dirname(__FILE__)
add_gem = ""
FileUtils.cp_r(rbricks_dir + "/assets/gemfile/Gemfile", app_dir)
FileHelpers.replace_string(/BRICK_RUBY_VERSION/, options[:ruby_version], app_dir + "/Gemfile")
if options[:development_db] == "sqlite"
add_gem = "# SQLite 3\ngroup :development, :test do\n gem 'sqlite3', 'BRICK_SQLITE3_VERSION'\nend"
else
add_gem = "# PostgreSQL\ngem 'pg'"
end
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
if options[:devise]
add_gem = "# Devise: https://github.com/plataformatec/devise\ngem 'devise', 'BRICK_DEVISE_VERSION'"
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
end
if options[:post_resources]
add_gem = "# Redcarpet: https://github.com/vmg/redcarpet\ngem 'redcarpet', 'BRICK_REDCARPET_VERSION'"
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
end
if options[:production_settings][:target] == "heroku"
add_gem = "# Rails 12factor for Heroku: https://github.com/heroku/rails_12factor\ngroup :production do\n gem 'rails_12factor'\nend"
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
if options[:development_db] == "sqlite"
add_gem = "# PostgreSQL gem for Heroku\ngroup :production do\n gem 'pg'\nend"
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
end
end
if options[:production_settings][:unicorn]
add_gem = "# Unicorn: http://unicorn.bogomips.org\ngroup :production do\n gem 'unicorn'\nend"
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
end
FileHelpers.replace_string(/BRICK_ANNOTATE_VERSION/, ANNOTATE, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_BCRYPT_VERSION/, BCRYPT, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_BOOTSTRAP_SASS_VERSION/, BOOTSTRAP_SASS, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_BYEBUG_VERSION/, BYEBUG, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_COFFEE_RAILS_VERSION/, COFFEE_RAILS, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_DEVISE_VERSION/, DEVISE, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_FIGARO_VERSION/, FIGARO, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_FONT_AWESOME_SASS_VERSION/, FONT_AWESOME_SASS, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_FRIENDLY_ID_VERSION/, FRIENDLY_ID, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_JBUILDER_VERSION/, JBUILDER, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_JQUERY_RAILS_VERSION/, JQUERY_RAILS, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_KAMINARI_VERSION/, KAMINARI, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_RAILS_VERSION/, options[:rails_version], app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_REDCARPET_VERSION/, REDCARPET, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_SASS_RAILS_VERSION/, SASS_RAILS, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_SQLITE3_VERSION/, SQLITE3, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_SPRING_VERSION/, SPRING, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_TURBOLINKS_VERSION/, TURBOLINKS, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_UGLIFIER_VERSION/, UGLIFIER, app_dir + "/Gemfile")
FileHelpers.replace_string(/BRICK_WEB_CONSOLE_VERSION/, WEB_CONSOLE, app_dir + "/Gemfile")
new_line
wputs "----> Gemfile generated.", :info
rescue
Errors.display_error("Something went wrong and the Gemfile couldn't be generated. Stopping app creation.", true)
abort
end
|