Module: Onotole::BeforeBundlePatch

Included in:
AppBuilder
Defined in:
lib/onotole/add_user_gems/before_bundle_patch.rb

Instance Method Summary collapse

Instance Method Details

#add_active_admin_import_gemObject



212
213
214
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 212

def add_active_admin_import_gem
  inject_into_file('Gemfile', "\ngem 'active_admin_import'", after: '# user_choice')
end

#add_active_admin_simple_life_gemObject



307
308
309
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 307

def add_active_admin_simple_life_gem
  inject_into_file('Gemfile', "\ngem 'active_admin_simple_life'", after: '# user_choice')
end

#add_active_admin_theme_gemObject



216
217
218
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 216

def add_active_admin_theme_gem
  inject_into_file('Gemfile', "\ngem 'active_admin_theme'", after: '# user_choice')
end

#add_active_record_doctor_gemObject



350
351
352
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 350

def add_active_record_doctor_gem
  inject_into_file('Gemfile', "\n  gem 'active_record_doctor'", after: 'group :development do')
end

#add_active_skin_gemObject



228
229
230
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 228

def add_active_skin_gem
  inject_into_file('Gemfile', "\ngem 'active_skin'", after: '# user_choice')
end

#add_activeadmin_gemObject



164
165
166
167
168
169
170
171
172
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 164

def add_activeadmin_gem
  inject_into_file('Gemfile', "\ngem 'activeadmin', github: 'activeadmin'", after: '# user_choice')
  inject_into_file('Gemfile', "\ngem 'kaminari-i18n'", after: '# user_choice')
  copy_file 'activeadmin.en.yml', 'config/locales/activeadmin.en.yml'
  copy_file 'activeadmin.ru.yml', 'config/locales/activeadmin.ru.yml'
  # it still live https://github.com/Prelang/feedback/issues/14 and this patch helps
  run 'mkdir app/inputs'
  copy_file 'inet_input.rb', 'app/inputs/inet_input.rb'
end

#add_activerecord_import_gemObject



160
161
162
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 160

def add_activerecord_import_gem
  inject_into_file('Gemfile', "\ngem 'activerecord-import'", after: '# user_choice')
end

#add_airbrake_gemObject



84
85
86
87
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 84

def add_airbrake_gem
  inject_into_file('Gemfile', "\ngem 'airbrake'",
                   after: '# user_choice')
end

#add_annotate_gemObject



136
137
138
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 136

def add_annotate_gem
  inject_into_file('Gemfile', "\n  gem 'annotate'", after: 'group :development do')
end

#add_axlsx_gemObject



256
257
258
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 256

def add_axlsx_gem
  inject_into_file('Gemfile', "\ngem 'axlsx'", after: '# user_choice')
end

#add_axlsx_rails_gemObject



252
253
254
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 252

def add_axlsx_rails_gem
  inject_into_file('Gemfile', "\ngem 'axlsx_rails'", after: '# user_choice')
end

#add_bootstrap3_gemObject



89
90
91
92
93
94
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 89

def add_bootstrap3_gem
  inject_into_file('Gemfile', "\ngem 'twitter-bootstrap-rails'",
                   after: '# user_choice')
  inject_into_file('Gemfile', "\ngem 'devise-bootstrap-views'",
                   after: '# user_choice') if user_choose?(:devise)
end

#add_bootstrap3_sass_gemObject



79
80
81
82
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 79

def add_bootstrap3_sass_gem
  inject_into_file('Gemfile', "\ngem 'bootstrap-sass', '~> 3.3.6'",
                   after: '# user_choice')
end

#add_bundler_audit_gemObject



74
75
76
77
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 74

def add_bundler_audit_gem
  copy_file 'bundler_audit.rake', 'lib/tasks/bundler_audit.rake'
  append_file 'Rakefile', %(\ntask default: "bundler:audit"\n)
end

#add_carrierwave_gemObject



331
332
333
334
335
336
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 331

def add_carrierwave_gem
  inject_into_file('Gemfile', "\ngem 'carrierwave', '~> 0.10.0'", after: '# user_choice')
  inject_into_file('Gemfile',
                   "\ngem 'mini_magick', '~> 4.5.0'",
                   after: '# user_choice') if AppBuilder.file_storage_name
end

#add_ckeditor_gemObject



244
245
246
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 244

def add_ckeditor_gem
  inject_into_file('Gemfile', "\ngem 'ckeditor'", after: '# user_choice')
end

#add_cyrillizer_gemObject



240
241
242
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 240

def add_cyrillizer_gem
  inject_into_file('Gemfile', "\ngem 'cyrillizer'", after: '# user_choice')
end

#add_devise_bootstrap_views_gemObject



248
249
250
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 248

def add_devise_bootstrap_views_gem
  inject_into_file('Gemfile', "\ngem 'devise-bootstrap-views'", after: '# user_choice')
end

#add_devise_gemObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 96

def add_devise_gem
  devise_conf = <<-TEXT

  # v.3.5 syntax. will be deprecated in 4.0
  def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_in) do |user_params|
  user_params.permit(:email, :password, :remember_me)
end

devise_parameter_sanitizer.permit(:sign_up) do |user_params|
  user_params.permit(:email, :password, :password_confirmation)
end
  end
  protected :configure_permitted_parameters
TEXT
  inject_into_file('Gemfile', "\ngem 'devise'", after: '# user_choice')
  inject_into_file('app/controllers/application_controller.rb',
                   "\nbefore_action :configure_permitted_parameters, if: :devise_controller?",
                   after: 'class ApplicationController < ActionController::Base')

  inject_into_file('app/controllers/application_controller.rb', devise_conf,
                   after: 'protect_from_forgery with: :exception')
  copy_file 'devise_rspec.rb', 'spec/support/devise.rb'
  copy_file 'devise.ru.yml', 'config/locales/devise.ru.yml'
end

#add_dotenv_heroku_gemObject



19
20
21
22
23
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 19

def add_dotenv_heroku_gem
  inject_into_file('Gemfile', "\n  gem 'dotenv-heroku'",
                   after: 'group :development do')
  append_file 'Rakefile', %(\nrequire 'dotenv-heroku/tasks' if ENV['RACK_ENV'] == 'test' || ENV['RACK_ENV'] == 'development'\n)
end

#add_face_of_active_admin_gemObject



260
261
262
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 260

def add_face_of_active_admin_gem
  inject_into_file('Gemfile', "\ngem 'face_of_active_admin'", after: '# user_choice')
end

#add_faker_gemObject



70
71
72
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 70

def add_faker_gem
  inject_into_file('Gemfile', "\n  gem 'faker'", after: 'group :development, :test do')
end

#add_flamegraph_gemObject



311
312
313
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 311

def add_flamegraph_gem
  inject_into_file('Gemfile', "\n  gem 'flamegraph'", after: 'group :development do')
end

#add_flattened_active_admin_gemObject



232
233
234
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 232

def add_flattened_active_admin_gem
  inject_into_file('Gemfile', "\ngem 'flattened_active_admin'", after: '# user_choice')
end

#add_font_awesome_sass_gemObject



236
237
238
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 236

def add_font_awesome_sass_gem
  inject_into_file('Gemfile', "\ngem 'font-awesome-sass', '~> 4.5.0'", after: '# user_choice')
end

#add_fotoramajs_gemObject



269
270
271
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 269

def add_fotoramajs_gem
  inject_into_file('Gemfile', "\ngem 'fotoramajs'", after: '# user_choice')
end

#add_geocoder_gemObject



273
274
275
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 273

def add_geocoder_gem
  inject_into_file('Gemfile', "\ngem 'geocoder'", after: '# user_choice')
end

#add_git_up_gemObject



362
363
364
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 362

def add_git_up_gem
  inject_into_file('Gemfile', "\n  gem 'git-up'", after: 'group :development do')
end

#add_gmaps4rails_gemObject



277
278
279
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 277

def add_gmaps4rails_gem
  inject_into_file('Gemfile', "\ngem 'gmaps4rails'", after: '# user_choice')
end

#add_guard_gemObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 40

def add_guard_gem
  t = <<-TEXT.chomp

  gem 'guard'
  gem 'guard-livereload', '~> 2.4', require: false
  gem 'guard-puma', require: false
  gem 'guard-migrate', require: false
  gem 'guard-rspec', require: false
  gem 'guard-bundler', require: false
  TEXT
  inject_into_file('Gemfile', t, after: 'group :development do')
end

#add_guard_rubocop_gemObject



53
54
55
56
57
58
59
60
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 53

def add_guard_rubocop_gem
  if user_choose?(:guard) && user_choose?(:rubocop)
    inject_into_file('Gemfile', "\n  gem 'guard-rubocop'",
                     after: 'group :development do')
  else
    say_color RED, 'You need Guard & Rubocop gems for this add-on'
  end
end

#add_haml_gemObject



15
16
17
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 15

def add_haml_gem
  inject_into_file('Gemfile', "\ngem 'haml-rails'", after: '# user_choice')
end

#add_hirbunicode_gemObject



126
127
128
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 126

def add_hirbunicode_gem
  inject_into_file('Gemfile', "\ngem 'hirb-unicode'", after: '# user_choice')
end

#add_image_optim_gemObject



285
286
287
288
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 285

def add_image_optim_gem
  inject_into_file('Gemfile', "\n  gem 'image_optim_pack'", after: 'group :development do')
  inject_into_file('Gemfile', "\n  gem 'image_optim'", after: 'group :development do')
end

#add_invisible_captcha_gemObject



338
339
340
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 338

def add_invisible_captcha_gem
  inject_into_file('Gemfile', "\ngem 'invisible_captcha'", after: '# user_choice')
end

#add_kaminari_gemObject



203
204
205
206
207
208
209
210
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 203

def add_kaminari_gem
  inject_into_file('Gemfile', "\ngem 'kaminari'", after: '# user_choice')
  inject_into_file('Gemfile', "\ngem 'kaminari-i18n'", after: '# user_choice')
  copy_file 'kaminari.rb', 'config/initializers/kaminari.rb'
  inject_into_file('Gemfile', "\ngem 'bootstrap-kaminari-views'",
                   after: '# user_choice') if user_choose?(:bootstrap3) ||
                                              user_choose?(:bootstrap3_sass)
end

#add_mailcatcher_gemObject



290
291
292
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 290

def add_mailcatcher_gem
  inject_into_file('Gemfile', "\n  gem 'mailcatcher'", after: 'group :development do')
end

#add_materialize_sass_gemObject



346
347
348
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 346

def add_materialize_sass_gem
  inject_into_file('Gemfile', "\ngem 'materialize-sass'", after: '# user_choice')
end

#add_meta_request_gemObject



62
63
64
65
66
67
68
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 62

def add_meta_request_gem
  inject_into_file('Gemfile',
                   "\n  gem 'meta_request' # link for chrome add-on. "\
                   'https://chrome.google.com/webstore/detail/'\
                   'railspanel/gjpfobpafnhjhbajcjgccbbdofdckggg',
                   after: 'group :development do')
end

#add_newrelic_rpm_gemObject



303
304
305
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 303

def add_newrelic_rpm_gem
  inject_into_file('Gemfile', "\ngem 'newrelic_rpm'", after: '# user_choice')
end

#add_overcommit_gemObject



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 140

def add_overcommit_gem
  inject_into_file('Gemfile', "\n  gem 'overcommit'", after: 'group :development do')
  copy_file 'onotole_overcommit.yml', '.overcommit.yml'
  rubocop_overcommit = <<-OVER
  RuboCop:
enabled: true
description: 'Analyzing with RuboCop'
required_executable: 'rubocop'
flags: ['--format=emacs', '--force-exclusion', '--display-cop-names']
install_command: 'gem install rubocop'
include:
  - '**/*.gemspec'
  - '**/*.rake'
  - '**/*.rb'
  - '**/Gemfile'
  - '**/Rakefile'
  OVER
  append_file '.overcommit.yml', rubocop_overcommit if user_choose?(:rubocop)
end

#add_paper_trail_gemObject



220
221
222
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 220

def add_paper_trail_gem
  inject_into_file('Gemfile', "\ngem 'paper_trail'", after: '# user_choice')
end

#add_prawn_gemObject



264
265
266
267
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 264

def add_prawn_gem
  inject_into_file('Gemfile', "\ngem 'prawn'", after: '# user_choice')
  inject_into_file('Gemfile', "\ngem 'prawn-table'", after: '# user_choice')
end

#add_pundit_gemObject



358
359
360
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 358

def add_pundit_gem
  inject_into_file('Gemfile', "\n  gem 'pundit'", after: '# user_choice')
end

#add_rack_cors_gemObject



294
295
296
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 294

def add_rack_cors_gem
  inject_into_file('Gemfile', "\ngem 'rack-cors', :require => 'rack/cors'", after: '# user_choice')
end

#add_rack_mini_profiler_gemObject



298
299
300
301
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 298

def add_rack_mini_profiler_gem
  inject_into_file('Gemfile', "\n  gem 'rack-mini-profiler', require: false", after: '# user_choice')
  copy_file 'rack_mini_profiler.rb', 'config/initializers/rack_mini_profiler.rb'
end

#add_railroady_gemObject



187
188
189
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 187

def add_railroady_gem
  inject_into_file('Gemfile', "\n  gem 'railroady'", after: 'group :development do')
end

#add_rails_admin_gemObject

def add_administrate_gem

inject_into_file('Gemfile', "\ngem 'administrate'", after: '# user_choice')

end



178
179
180
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 178

def add_rails_admin_gem
  inject_into_file('Gemfile', "\ngem 'rails_admin'", after: '# user_choice')
end

#add_rails_db_gemObject



30
31
32
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 30

def add_rails_db_gem
  inject_into_file('Gemfile', "\n  gem 'rails_db'\n  gem 'axlsx_rails'", after: '# user_choice')
end

#add_redis_gemObject



319
320
321
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 319

def add_redis_gem
  inject_into_file('Gemfile', "\ngem 'redis', '~>3.2'", after: '# user_choice')
end

#add_redis_namespace_gemObject



327
328
329
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 327

def add_redis_namespace_gem
  inject_into_file('Gemfile', "\ngem 'redis-namespace'", after: '# user_choice')
end

#add_redis_rails_gemObject



323
324
325
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 323

def add_redis_rails_gem
  inject_into_file('Gemfile', "\ngem 'redis-rails'", after: '# user_choice')
end

#add_responders_gemObject



122
123
124
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 122

def add_responders_gem
  inject_into_file('Gemfile', "\ngem 'responders'", after: '# user_choice')
end

#add_rubocop_gemObject



34
35
36
37
38
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 34

def add_rubocop_gem
  inject_into_file('Gemfile', "\n  gem 'rubocop', require: false",
                   after: 'group :development do')
  copy_file 'rubocop.yml', '.rubocop.yml'
end

#add_rubycritic_gemObject



182
183
184
185
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 182

def add_rubycritic_gem
  inject_into_file('Gemfile', "\n  gem 'rubycritic', :require => false",
                   after: 'group :development do')
end

#add_sitemap_generator_gemObject



342
343
344
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 342

def add_sitemap_generator_gem
  inject_into_file('Gemfile', "\n  gem 'sitemap_generator', :require => false", after: 'group :development do')
end

#add_slim_gemObject



25
26
27
28
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 25

def add_slim_gem
  inject_into_file('Gemfile', "\ngem 'slim-rails'", after: '# user_choice')
  inject_into_file('Gemfile', "\n  gem 'html2slim'", after: 'group :development do')
end

#add_stackprof_gemObject



315
316
317
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 315

def add_stackprof_gem
  inject_into_file('Gemfile', "\n  gem 'stackprof'", after: 'group :development do')
end

#add_therubyracer_gemObject



354
355
356
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 354

def add_therubyracer_gem
  inject_into_file('Gemfile', "\n  gem 'therubyracer'", after: '# user_choice')
end

#add_tinymce_gemObject



130
131
132
133
134
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 130

def add_tinymce_gem
  inject_into_file('Gemfile', "\ngem 'tinymce-rails'", after: '# user_choice')
  inject_into_file('Gemfile', "\ngem 'tinymce-rails-langs'", after: '# user_choice')
  copy_file 'tinymce.yml', 'config/tinymce.yml'
end

#add_typus_gemObject



191
192
193
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 191

def add_typus_gem
  inject_into_file('Gemfile', "\n  gem 'typus', github: 'typus/typus'", after: '# user_choice')
end

#add_underscore_rails_gemObject



281
282
283
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 281

def add_underscore_rails_gem
  inject_into_file('Gemfile', "\ngem 'underscore-rails'", after: '# user_choice')
end

#add_user_gemsObject



4
5
6
7
8
9
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 4

def add_user_gems
  add_to_user_choise(:devise_bootstrap_views) if user_choose?(:bootstrap3_sass) && user_choose?(:devise)
  GEMPROCLIST.each do |g|
    send "add_#{g}_gem" if user_choose? g.to_sym
  end
end

#add_validates_timeliness_gemObject



224
225
226
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 224

def add_validates_timeliness_gem
  inject_into_file('Gemfile', "\ngem 'validates_timeliness'", after: '# user_choice')
end

#add_will_paginate_gemObject



195
196
197
198
199
200
201
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 195

def add_will_paginate_gem
  inject_into_file('Gemfile', "\ngem 'will_paginate', '~> 3.0.6'",
                   after: '# user_choice')
  inject_into_file('Gemfile', "\ngem 'will_paginate-bootstrap'",
                   after: '# user_choice') if user_choose?(:bootstrap3) ||
                                              user_choose?(:bootstrap3_sass)
end

#setup_default_gemsObject



11
12
13
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 11

def setup_default_gems
  add_to_user_choise(:normalize)
end