Class: CookiesEu::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_javascriptsObject


4
5
6
# File 'lib/generators/cookies_eu/install/install_generator.rb', line 4

def add_javascripts
  append_file 'app/assets/javascripts/application.js', "//= require cookies_eu\n"
end

#add_stylesheetsObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/cookies_eu/install/install_generator.rb', line 8

def add_stylesheets
  file = 'app/assets/stylesheets/application'
  css_file = "#{file}.css"
  scss_file = "#{file}.scss"
  css_scss_file = "#{file}.css.scss"

  if File.exists?(css_file)
    inject_into_file css_file, "*= require cookies_eu\n", before: /\*\//, verbose: true
  elsif File.exists?(scss_file)
    append_file scss_file, "@import 'cookies_eu';\n"
  else
    append_file css_scss_file, "@import 'cookies_eu';\n"
  end
end