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



214
215
216
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 214

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

#add_active_admin_simple_life_gemObject



309
310
311
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 309

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



218
219
220
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 218

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

#add_active_skin_gemObject



230
231
232
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 230

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

#add_activeadmin_gemObject



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

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



162
163
164
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 162

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

#add_airbrake_gemObject



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

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

#add_annotate_gemObject



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

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

#add_axlsx_gemObject



258
259
260
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 258

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

#add_axlsx_rails_gemObject



254
255
256
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 254

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

#add_bootstrap3_gemObject



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

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



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

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

#add_bundler_audit_gemObject



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

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_ckeditor_gemObject



246
247
248
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 246

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

#add_cyrillizer_gemObject



242
243
244
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 242

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

#add_devise_bootstrap_views_gemObject



250
251
252
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 250

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

#add_devise_gemObject



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

def add_devise_gem
  devise_conf = <<-TEXT

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

devise_parameter_sanitizer.for(: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



262
263
264
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 262

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

#add_faker_gemObject



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

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

#add_flamegraph_gemObject



313
314
315
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 313

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

#add_flattened_active_admin_gemObject



234
235
236
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 234

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

#add_font_awesome_sass_gemObject



238
239
240
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 238

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

#add_fotoramajs_gemObject



271
272
273
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 271

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

#add_geocoder_gemObject



275
276
277
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 275

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

#add_gmaps4rails_gemObject



279
280
281
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 279

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
52
# 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'
  gem 'guard-migrate'
  gem 'guard-rspec', require: false
  gem 'guard-bundler', require: false
  gem 'rb-inotify', github: 'kvokka/rb-inotify'
  TEXT
  inject_into_file('Gemfile', t, after: 'group :development do')
end

#add_guard_rubocop_gemObject



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

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



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

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

#add_image_optim_gemObject



287
288
289
290
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 287

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

#add_kaminari_gemObject



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

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



292
293
294
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 292

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

#add_meta_request_gemObject



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

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



305
306
307
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 305

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

#add_overcommit_gemObject



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

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: ture
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



222
223
224
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 222

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

#add_prawn_gemObject



266
267
268
269
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 266

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_rack_cors_gemObject



296
297
298
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 296

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

#add_rack_mini_profiler_gemObject



300
301
302
303
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 300

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



189
190
191
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 189

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



180
181
182
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 180

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_responders_gemObject



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

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



184
185
186
187
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 184

def add_rubycritic_gem
  inject_into_file('Gemfile', "\n  gem 'rubycritic', :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



317
318
319
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 317

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

#add_tinymce_gemObject



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

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



193
194
195
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 193

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

#add_underscore_rails_gemObject



283
284
285
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 283

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



226
227
228
# File 'lib/onotole/add_user_gems/before_bundle_patch.rb', line 226

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

#add_will_paginate_gemObject



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

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