Module: Onotole::AfterInstallPatch
- Included in:
- AppBuilder
- Defined in:
- lib/onotole/add_user_gems/after_install_patch.rb
Instance Method Summary collapse
- #after_install_acive_skin ⇒ Object
- #after_install_active_admin_bootstrap ⇒ Object
- #after_install_active_admin_theme ⇒ Object
- #after_install_activeadmin ⇒ Object
- #after_install_annotate ⇒ Object
- #after_install_bootstrap3 ⇒ Object
- #after_install_bootstrap3_sass ⇒ Object
- #after_install_carrierwave ⇒ Object
- #after_install_ckeditor ⇒ Object
- #after_install_create_github_repo ⇒ Object
- #after_install_devise ⇒ Object
- #after_install_devise_bootstrap_views ⇒ Object
- #after_install_face_of_active_admin ⇒ Object
- #after_install_flattened_active_admin ⇒ Object
- #after_install_font_awesome_sass ⇒ Object
- #after_install_fotoramajs ⇒ Object
- #after_install_gmaps4rails ⇒ Object
- #after_install_guard ⇒ Object
- #after_install_guard_rubocop ⇒ Object
- #after_install_image_optim ⇒ Object
- #after_install_mailcatcher ⇒ Object
- #after_install_materialize_sass ⇒ Object
- #after_install_normalize ⇒ Object
- #after_install_overcommit ⇒ Object
- #after_install_paper_trail ⇒ Object
- #after_install_pundit ⇒ Object
- #after_install_rack_cors ⇒ Object
- #after_install_rails_admin ⇒ Object
- #after_install_redis ⇒ Object
- #after_install_redis_namespace ⇒ Object
- #after_install_redis_rails ⇒ Object
- #after_install_responders ⇒ Object
- #after_install_rubocop ⇒ Object
- #after_install_sitemap_generator ⇒ Object
- #after_install_tinymce ⇒ Object
- #after_install_typus ⇒ Object
- #after_install_underscore_rails ⇒ Object
- #after_install_validates_timeliness ⇒ Object
- #post_init ⇒ Object
Instance Method Details
#after_install_acive_skin ⇒ Object
202 203 204 205 206 207 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 202 def after_install_acive_skin return unless user_choose? :activeadmin File.open('app/assets/stylesheets/active_admin.scss', 'a') do |f| f.write "\n@import 'active_skin';\n\\\\$skinLogo: url('admin_logo.png') no-repeat 0 0;" end end |
#after_install_active_admin_bootstrap ⇒ Object
187 188 189 190 191 192 193 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 187 def after_install_active_admin_bootstrap return unless user_choose?(:bootstrap3_sass) || user_choose?(:activeadmin) AppBuilder.use_asset_pipelline = false copy_file 'admin_bootstrap.scss', 'vendor/assets/stylesheets/active_admin/admin_bootstrap.scss' copy_file 'active_admin.scss', 'vendor/assets/stylesheets/active_admin.scss' remove_file 'app/assets/stylesheets/active_admin.scss' end |
#after_install_active_admin_theme ⇒ Object
195 196 197 198 199 200 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 195 def after_install_active_admin_theme return unless user_choose? :activeadmin File.open('app/assets/stylesheets/active_admin.scss', 'a') do |f| f.write "\n@import 'wigu/active_admin_theme';" end end |
#after_install_activeadmin ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 142 def after_install_activeadmin if user_choose? :devise rails_generator 'active_admin:install' else rails_generator 'active_admin:install --skip-users' end end |
#after_install_annotate ⇒ Object
132 133 134 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 132 def after_install_annotate rails_generator 'annotate:install' end |
#after_install_bootstrap3 ⇒ Object
100 101 102 103 104 105 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 100 def after_install_bootstrap3 AppBuilder.use_asset_pipelline = true remove_file 'app/views/layouts/application.html.erb' rails_generator 'bootstrap:install static' rails_generator 'bootstrap:layout' end |
#after_install_bootstrap3_sass ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 88 def after_install_bootstrap3_sass setup_stylesheets AppBuilder.use_asset_pipelline = false touch AppBuilder.app_file_scss append_file(AppBuilder.app_file_scss, "\n@import 'bootstrap-sprockets'; \n@import 'bootstrap';") inject_into_file(AppBuilder.js_file, "\n//= require bootstrap-sprockets", after: '//= require jquery_ujs') copy_file 'bootstrap_flash_helper.rb', 'app/helpers/bootstrap_flash_helper.rb' end |
#after_install_carrierwave ⇒ Object
333 334 335 336 337 338 339 340 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 333 def after_install_carrierwave copy_file 'carrierwave.rb', 'config/initializers/carrierwave.rb' return unless AppBuilder.file_storage_name rails_generator "uploader #{AppBuilder.file_storage_name}" uploader_path = "app/uploaders/#{AppBuilder.file_storage_name}_uploader.rb" config = "\n include CarrierWave::MiniMagick\n" inject_into_class uploader_path, "#{AppBuilder.file_storage_name.classify}Uploader", config end |
#after_install_ckeditor ⇒ Object
284 285 286 287 288 289 290 291 292 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 284 def after_install_ckeditor inject_into_file(AppBuilder.js_file, "\n//= require ckeditor/init", after: '//= require jquery_ujs') append_file('config/initializers/assets.rb', "\nRails.application.config.assets.precompile += %w( ckeditor/* )") rails_generator 'ckeditor:install --orm=active_record '\ '--backend=carrierwave' if user_choose? :carrierwave end |
#after_install_create_github_repo ⇒ Object
128 129 130 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 128 def after_install_create_github_repo create_github_repo(app_name) end |
#after_install_devise ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 39 def after_install_devise rails_generator 'devise:install' if AppBuilder.devise_model rails_generator "devise #{AppBuilder.devise_model.titleize}" inject_into_file('app/controllers/application_controller.rb', "\n# before_action :authenticate_#{AppBuilder.devise_model.downcase}!", after: 'before_action :configure_permitted_parameters, if: :devise_controller?') end if user_choose?(:bootstrap3) rails_generator 'devise:views:bootstrap_templates' else rails_generator 'devise:views' end end |
#after_install_devise_bootstrap_views ⇒ Object
180 181 182 183 184 185 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 180 def after_install_devise_bootstrap_views return if AppBuilder.use_asset_pipelline touch AppBuilder.app_file_scss append_file(AppBuilder.app_file_scss, "\n@import 'devise_bootstrap_views';") rails_generator 'devise:views:bootstrap_templates' end |
#after_install_face_of_active_admin ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 219 def after_install_face_of_active_admin return unless user_choose? :activeadmin File.open('app/assets/stylesheets/active_admin.scss', 'w') do |f| f.write "\n@import 'face_of_active_admin_variables'; \n@import 'face_of_active_admin/mixins'; \n@import 'face_of_active_admin/base';" end append_file 'app/assets/javascripts/active_admin.js.coffee', "\n#= require face_of_active_admin/base" rails_generator 'face_of_active_admin:variables' end |
#after_install_flattened_active_admin ⇒ Object
209 210 211 212 213 214 215 216 217 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 209 def after_install_flattened_active_admin return unless user_choose? :activeadmin File.open('app/assets/stylesheets/active_admin.scss', 'w') do |f| f.write "\n@import 'flattened_active_admin/variables'; \n@import 'flattened_active_admin/mixins'; \n@import 'flattened_active_admin/base';" end rails_generator 'flattened_active_admin:variables' end |
#after_install_font_awesome_sass ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 168 def after_install_font_awesome_sass if AppBuilder.use_asset_pipelline inject_into_file(AppBuilder.app_file_css, " *= require font-awesome-sprockets\n *= require font-awesome\n", after: " * file per style scope.\n *\n") else touch AppBuilder.app_file_scss append_file(AppBuilder.app_file_scss, "\n@import 'font-awesome-sprockets';\n@import 'font-awesome';") end end |
#after_install_fotoramajs ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 231 def after_install_fotoramajs if AppBuilder.use_asset_pipelline inject_into_file(AppBuilder.app_file_css, " *= require fotorama\n", after: " * file per style scope.\n *\n") else touch AppBuilder.app_file_scss append_file(AppBuilder.app_file_scss, "\n@import 'fotorama';") end inject_into_file(AppBuilder.js_file, "\n//= require fotorama", after: '//= require jquery_ujs') end |
#after_install_gmaps4rails ⇒ Object
248 249 250 251 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 248 def after_install_gmaps4rails inject_into_file(AppBuilder.js_file, "\n//= require gmaps/google", after: '//= require underscore') end |
#after_install_guard ⇒ Object
67 68 69 70 71 72 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 67 def after_install_guard bundle_command "exec guard init #{quiet_suffix}" replace_in_file 'Guardfile', "guard 'puma' do", 'guard :puma, port: 3000 do', quiet_err = true end |
#after_install_guard_rubocop ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 74 def after_install_guard_rubocop if user_choose?(:guard) && user_choose?(:rubocop) cover_def_by 'Guardfile', 'guard :rubocop do', 'group :red_green_refactor, halt_on_fail: true do' cover_def_by 'Guardfile', 'guard :rspec, ', 'group :red_green_refactor, halt_on_fail: true do' replace_in_file 'Guardfile', 'guard :rubocop do', 'guard :rubocop, all_on_start: false do', quiet_err = true replace_in_file 'Guardfile', 'guard :rspec, cmd: "bundle exec rspec" do', "guard :rspec, cmd: 'bundle exec rspec', failed_mode: :keep do", quiet_err = true end end |
#after_install_image_optim ⇒ Object
294 295 296 297 298 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 294 def after_install_image_optim File.open('config/initializers/image_optim.rb', 'w') do |f| f.write 'Rails.application.config.assets.image_optim = {svgo: false, pngout: false}' end end |
#after_install_mailcatcher ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 253 def after_install_mailcatcher config = <<-RUBY if system ('lsof -i :1025 | grep mailcatch > /dev/null') config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: "localhost", port: 1025 } else config.action_mailer.delivery_method = :file end RUBY replace_in_file 'config/environments/development.rb', 'config.action_mailer.delivery_method = :file', config end |
#after_install_materialize_sass ⇒ Object
362 363 364 365 366 367 368 369 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 362 def after_install_materialize_sass setup_stylesheets AppBuilder.use_asset_pipelline = false touch AppBuilder.app_file_scss append_file(AppBuilder.app_file_scss, "\n@import 'materialize';") inject_into_file(AppBuilder.js_file, "\n//= require materialize-sprockets", after: '//= require jquery_ujs') end |
#after_install_normalize ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 107 def after_install_normalize if AppBuilder.use_asset_pipelline touch AppBuilder.app_file_css inject_into_file(AppBuilder.app_file_css, " *= require normalize-rails\n", after: " * file per style scope.\n *\n") else touch AppBuilder.app_file_scss inject_into_file(AppBuilder.app_file_scss, "\n@import 'normalize-rails';", after: '@charset "utf-8";') end end |
#after_install_overcommit ⇒ Object
136 137 138 139 140 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 136 def after_install_overcommit bundle_command 'exec overcommit --install' bundle_command 'exec overcommit --sign' inject_into_file('bin/setup', "\novercommit --install\novercommit --sign", after: '# User addons installation') end |
#after_install_paper_trail ⇒ Object
160 161 162 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 160 def after_install_paper_trail rails_generator 'paper_trail:install' end |
#after_install_pundit ⇒ Object
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 346 def after_install_pundit rails_generator 'pundit:install' if user_choose? :activeadmin initializer_path = 'config/initializers/active_admin.rb' config = %( config.authentication_method = :authenticate_admin_user! config.authorization_adapter = ActiveAdmin::PunditAdapter config.pundit_default_policy = "ApplicationPolicy" ) inject_into_file initializer_path, config, after: 'ActiveAdmin.setup do |config|' mkdir_and_touch 'app/policies/active_admin' copy_file 'pundit/active_admin/comment_policy.rb', 'app/policies/active_admin/comment_policy.rb' copy_file 'pundit/active_admin/page_policy.rb', 'app/policies/active_admin/page_policy.rb' end end |
#after_install_rack_cors ⇒ Object
269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 269 def after_install_rack_cors config = <<-RUBY config.middleware.insert_before 0, "Rack::Cors" do allow do origins '*' resource '*', :headers => :any, :methods => [:get, :post, :options] end end RUBY inject_into_class 'config/application.rb', 'Application', config end |
#after_install_rails_admin ⇒ Object
150 151 152 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 150 def after_install_rails_admin rails_generator 'rails_admin:install' end |
#after_install_redis ⇒ Object
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 300 def after_install_redis config = %q( config.cache_store = :redis_store, "#{ENV['REDIS_PATH']}/cache", { expires_in: 90.minutes } ) File.open('config/initializers/redis.rb', 'w') { |f| f.write "$redis = Redis.new\n" } %w(development production).each do |env| inject_into_file "config/environments/#{env}.rb", config, after: "Rails.application.configure do\n" end append_file '.env', 'REDIS_PATH=redis://localhost:6379/0' append_file '.env.production', 'REDIS_PATH=redis://localhost:6379/0' copy_file 'redis.rake', 'lib/tasks/redis.rake' rubocop_conf = <<-DATA Style/GlobalVars: Enabled: false DATA File.open('.rubocop.yml', 'a') { |f| f.write rubocop_conf } if user_choose? :rubocop end |
#after_install_redis_namespace ⇒ Object
320 321 322 323 324 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 320 def after_install_redis_namespace return unless user_choose? :redis append_file 'config/initializers/redis.rb', br("$ns_redis = Redis::Namespace.new(:#{app_name}, redis: $redis)") end |
#after_install_redis_rails ⇒ Object
326 327 328 329 330 331 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 326 def after_install_redis_rails return unless user_choose? :redis append_file 'config/initializers/redis.rb', br(app_name.classify.to_s) append_file 'config/initializers/redis.rb', %q(::Application.config.session_store :redis_store, servers: "#{ENV['REDIS_PATH']}/session") end |
#after_install_responders ⇒ Object
124 125 126 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 124 def after_install_responders rails_generator 'responders:install' end |
#after_install_rubocop ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 54 def after_install_rubocop run 'touch .rubocop_todo.yml' t = <<-TEXT if ENV['RACK_ENV'] == 'test' || ENV['RACK_ENV'] == 'development' require 'rubocop/rake_task' RuboCop::RakeTask.new end TEXT append_file 'Rakefile', t clean_by_rubocop end |
#after_install_sitemap_generator ⇒ Object
342 343 344 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 342 def after_install_sitemap_generator bundle_command 'exec sitemap:install' end |
#after_install_tinymce ⇒ Object
119 120 121 122 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 119 def after_install_tinymce inject_into_file(AppBuilder.js_file, "\n//= require tinymce-jquery", after: '//= require jquery_ujs') end |
#after_install_typus ⇒ Object
154 155 156 157 158 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 154 def after_install_typus rails_generator 'typus' rails_generator 'typus:migration' rails_generator 'typus:views' end |
#after_install_underscore_rails ⇒ Object
243 244 245 246 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 243 def after_install_underscore_rails inject_into_file(AppBuilder.js_file, "\n//= require underscore", after: '//= require jquery_ujs') end |
#after_install_validates_timeliness ⇒ Object
164 165 166 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 164 def after_install_validates_timeliness rails_generator 'validates_timeliness:install' end |
#post_init ⇒ Object
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 |
# File 'lib/onotole/add_user_gems/after_install_patch.rb', line 4 def post_init install_queue = [:redis, :redis_rails, :redis_namespace, :carrierwave, :sitemap_generator, :ckeditor, :materialize_sass, :fotoramajs, :underscore_rails, :gmaps4rails, :mailcatcher, :rack_cors, :image_optim, :devise, :validates_timeliness, :paper_trail, :responders, :typus, :annotate, :overcommit, :activeadmin, :active_admin_theme, :acive_skin, :flattened_active_admin, :face_of_active_admin, :active_admin_bootstrap, :rails_admin, :pundit, :guard, :guard_rubocop, :bootstrap3_sass, :bootstrap3, :devise_bootstrap_views, :active_admin_theme, :font_awesome_sass, :normalize, :tinymce, :rubocop, :create_github_repo] install_queue.each { |g| send "after_install_#{g}" if user_choose? g } delete_comments end |