Class: ThreddedCreateApp::Tasks::AddInvisibleCaptcha

Inherits:
Base
  • Object
show all
Defined in:
lib/thredded_create_app/tasks/add_invisible_captcha.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, #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

#initialize(simple_form: true, **_args) ⇒ AddInvisibleCaptcha

Returns a new instance of AddInvisibleCaptcha.



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

def initialize(simple_form: true, **_args)
  super
  @simple_form = simple_form
end

Instance Method Details

#after_bundleObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/thredded_create_app/tasks/add_invisible_captcha.rb', line 20

def after_bundle
  inject_into_file 'app/controllers/users/registrations_controller.rb',
                   after: "::Devise::RegistrationsController\n",
                   content: "    invisible_captcha only: %i[create], honeypot: :name\n                   RUBY\n\n  form_view_path = 'app/views/devise/registrations/new.html.erb'\n  form_view_captcha = '<%= invisible_captcha :name %>'\n  inject_into_file form_view_path,\n                   after: devise_form_fields_begin_pattern,\n                   content: if @simple_form\n                              \"    \#{form_view_captcha}\\n\"\n                            else\n                              \"  \#{form_view_captcha}\\n\\n\"\n                            end\n  inject_into_file form_view_path,\n                   before: ') do |f|',\n                   content: \", html: {autocomplete: 'off'}\"\n\n  git_commit 'Add invisible_captcha to the sign up form'\nend\n"

#before_bundleObject



16
17
18
# File 'lib/thredded_create_app/tasks/add_invisible_captcha.rb', line 16

def before_bundle
  add_gem 'invisible_captcha'
end

#summaryObject



12
13
14
# File 'lib/thredded_create_app/tasks/add_invisible_captcha.rb', line 12

def summary
  'Add an invisible captcha to the sign up form'
end