Class: Thredded::MarkdownKatex::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/thredded/markdown_katex/install_generator.rb

Overview

Installs Thredded Katex plugin

Instance Method Summary collapse

Instance Method Details

#installObject

rubocop:disable Metrics/MethodLength


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/thredded/markdown_katex/install_generator.rb', line 10

def install # rubocop:disable Metrics/MethodLength
  %w[application.scss _deps.scss].each do |scss_file|
    scss_path = File.join('app', 'assets', 'stylesheets', scss_file)
    next unless File.exist? scss_path

    append_to_file scss_path, "\n" + '@import "_katex";' + "\n"
  end
  sass_path = 'app/assets/stylesheets/application.sass'
  if File.exist? sass_path
    append_to_file sass_path, "\n" + '@import "_katex"' + "\n"
  end
  css_path = 'app/assets/stylesheets/application.css'
  if File.exist? css_path # rubocop:disable Style/GuardClause
    append_to_file css_path, "\n" + '//= require katex' + "\n"
  end
end