Class: NotificationCis::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/generators/notification_cis/install/install_generator.rb', line 27

def add_assets
  if detect_js_format.nil?
    copy_file "images/notification_top_alert.png", "app/assets/images/notification_top_alert.png"
    copy_file "images/notification_top_error.png", "app/assets/images/notification_top_error.png"
    copy_file "images/notification_top_ok.png", "app/assets/images/notification_top_ok.png"
    copy_file "javascripts/jquery.notifications.min.js", "app/assets/javascripts/jquery.nested.min.js"
  else
    insert_into_file "app/assets/javascripts/application#{detect_js_format[0]}", "#{detect_js_format[1]} require jquery.notifications.min\n", :after => "jquery_ujs\n"
  end
  if detect_css_format.nil?
    copy_file "stylesheets/jquery.notifications.css", "app/assets/stylesheets/jquery.notifications.css"
  else
    insert_into_file "app/assets/stylesheets/application#{detect_css_format[0]}", "#{detect_css_format[1]} require jquery.notifications\n", :after => "require_self\n"
  end

end

#copy_jquery_nestedObject



11
12
13
14
15
16
17
# File 'lib/generators/notification_cis/install/install_generator.rb', line 11

def copy_jquery_nested
  copy_file "javascripts/jquery.notifications.min.js", "public/javascripts/jquery.notifications.min.js"
  copy_file "stylesheets/jquery.notifications.css", "public/stylesheets/jquery.notifications.css"
  copy_file "images/notification_top_alert.png", "public/images/notification_top_alert.png"
  copy_file "images/notification_top_error.png", "public/images/notification_top_error.png"
  copy_file "images/notification_top_ok.png", "public/images/notification_top_ok.png"
end

#detect_css_formatObject



48
49
50
# File 'lib/generators/notification_cis/install/install_generator.rb', line 48

def detect_css_format
  return ['.css', '*='] if File.exist?('app/assets/stylesheets/application.css')
end

#detect_js_formatObject



44
45
46
47
# File 'lib/generators/notification_cis/install/install_generator.rb', line 44

def detect_js_format
  return ['.js.coffee', '#='] if File.exist?('app/assets/javascripts/application.js.coffee')
  return ['.js', '//='] if File.exist?('app/assets/javascripts/application.js')
end