Class: ThreddedCreateApp::Tasks::AddJquery

Inherits:
Base
  • Object
show all
Defined in:
lib/thredded_create_app/tasks/add_jquery.rb

Instance Attribute Summary

Attributes inherited from Base

#app_hostname, #app_name, #app_path, #gems

Instance Method Summary collapse

Methods inherited from Base

#devise_form_fields_begin_pattern, #initialize, #webpack_js?

Methods included from RunCommand

#run

Methods included from Logging

#log_command, #log_error, #log_info, #log_stderr, #log_verbose, #log_warn, #program_name

Constructor Details

This class inherits a constructor from ThreddedCreateApp::Tasks::Base

Instance Method Details

#after_bundleObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/thredded_create_app/tasks/add_jquery.rb', line 15

def after_bundle
  if replace 'app/assets/javascripts/application.js',
             %r{^//= require jquery$},
             '//= require jquery3',
             optional: true
    git_commit 'Use jQuery v3 instead of jQuery v1'
  else
    inject_into_file 'app/assets/javascripts/application.js',
                     content: "//= require jquery3\n",
                     before: '//='
    git_commit 'Add jQuery'
  end
end

#before_bundleObject



11
12
13
# File 'lib/thredded_create_app/tasks/add_jquery.rb', line 11

def before_bundle
  add_gem 'jquery-rails'
end

#summaryObject



7
8
9
# File 'lib/thredded_create_app/tasks/add_jquery.rb', line 7

def summary
  'Add jQuery v3'
end