Class: SharingTags::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SharingTags::Generators::InstallGenerator
- Defined in:
- lib/generators/sharing_tags/install/install_generator.rb
Instance Method Summary collapse
- #add_javascripts ⇒ Object
- #add_layout ⇒ Object
- #add_styles ⇒ Object
- #copy_initializer_file ⇒ Object
- #display_post_install ⇒ Object
Instance Method Details
#add_javascripts ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/generators/sharing_tags/install/install_generator.rb', line 25 def add_javascripts source_file = "app/assets/javascripts/application.js" match_string = "sharing_tags" insert_into_file_if source_file, match_string, after: /\z/ do "\n//= require #{match_string}" end end |
#add_layout ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/generators/sharing_tags/install/install_generator.rb', line 48 def add_layout ## slim source_file = "app/views/layouts/application.html.slim" = "sharing_meta_tags" = "sharing_tags_buttons" insert_into_file_if(source_file, , before: "body") do " \n = #{}\n\n " end insert_into_file_if(source_file, , after: "body") do "\n = #{}\n" end ## erb source_file = "app/views/layouts/application.html.erb" insert_into_file_if(source_file, , before: "</head>") do " <%= #{} %>\n" end insert_into_file_if(source_file, , after: "<body>") do "\n <%= #{} %>\n" end ## TODO: haml end |
#add_styles ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/sharing_tags/install/install_generator.rb', line 34 def add_styles source_file = "app/assets/stylesheets/application.css" match_string = "sharing_tags" insert_into_file_if source_file, "#{match_string}\n", before: "*/" do "*= require #{match_string}\n " end match_string = "sharing_tags/icons" insert_into_file_if source_file, match_string, before: "*/" do "*= require #{match_string}\n " end end |
#copy_initializer_file ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/generators/sharing_tags/install/install_generator.rb', line 17 def copy_initializer_file if File.exist?("config/initializers/sharing_tags.rb") say_skipped("create initializer sharing_tags.rb") else template 'initializer.rb', 'config/initializers/sharing_tags.rb' end end |
#display_post_install ⇒ Object
75 76 77 |
# File 'lib/generators/sharing_tags/install/install_generator.rb', line 75 def display_post_install readme "POST_INSTALL" if behavior == :invoke end |