Class: Blogelator::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Blogelator::InstallGenerator
- Defined in:
- lib/generators/blocky/install_generator.rb
Instance Method Summary collapse
- #ask_questions ⇒ Object
- #configure_application ⇒ Object
- #copy_variables_file ⇒ Object
- #create_initializer_file ⇒ Object
- #create_overrides_directory ⇒ Object
- #create_stylesheets ⇒ Object
- #install_migrations ⇒ Object
- #mount_engine ⇒ Object
Instance Method Details
#ask_questions ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/generators/blocky/install_generator.rb', line 5 def ask_questions @site_name = ask("What is the name of your blog? [Blogelator]") if @site_name.blank? @site_name = "Blogelator" end @blogelator_route = ask("What route should be used to access the blog? [/blog]") if @blogelator_route.blank? @blogelator_route = "/blog" end @user_class = ask("What class is used for user authentication? [User]") if @user_class.blank? @user_class = "User" end end |
#configure_application ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/generators/blocky/install_generator.rb', line 60 def configure_application application "\nconfig.to_prepare do\n # Load application's model / class decorators\n Dir.glob(File.join(File.dirname(__FILE__), \"../app/**/*_decorator*.rb\")) do |c|\n Rails.configuration.cache_classes ? require(c) : load(c)\n end\n\n # Load application's view overrides\n Dir.glob(File.join(File.dirname(__FILE__), \"../app/overrides/*.rb\")) do |c|\n Rails.configuration.cache_classes ? require(c) : load(c)\n end\nend\n APP\nend\n" |
#copy_variables_file ⇒ Object
49 50 51 52 53 54 |
# File 'lib/generators/blocky/install_generator.rb', line 49 def copy_variables_file puts File.("../../../..", __FILE__) source = "lib/assets/stylesheets/blogelator/_variables_sample.scss" destination = "app/assets/stylesheets/blogelator/_variables.scss" copy_file source, destination end |
#create_initializer_file ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/blocky/install_generator.rb', line 22 def create_initializer_file create_file "config/initializers/blogelator.rb", "Blogelator.posts_per_page = 5\nBlogelator.site_name = \"\#{@site_name}\"\nBlogelator.user_class = \"\#{@user_class}\"\nBlogelator.s3_access_key_id = ENV[\"BLOGELATOR_S3_KEY\"]\nBlogelator.s3_secret_access_key = ENV[\"BLOGELATOR_S3_SECRET\"]\nBlogelator.s3_bucket = ENV[\"BLOGELATOR_S3_BUCKET\"]\n" end |
#create_overrides_directory ⇒ Object
56 57 58 |
# File 'lib/generators/blocky/install_generator.rb', line 56 def create_overrides_directory empty_directory "app/overrides" end |
#create_stylesheets ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/blocky/install_generator.rb', line 33 def create_stylesheets create_file "app/assets/stylesheets/blogelator/application.css.scss", "/*\n *= require blogelator/application/all\n *= require_self\n */\n" create_file "app/assets/stylesheets/blogelator/admin.css.scss", "/*\n *= require blogelator/admin/all\n *= require_self\n */\n" end |
#install_migrations ⇒ Object
77 78 79 |
# File 'lib/generators/blocky/install_generator.rb', line 77 def install_migrations rake "blogelator:install:migrations" end |
#mount_engine ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/generators/blocky/install_generator.rb', line 81 def mount_engine insert_into_file(File.join("config", "routes.rb"), :after => "Application.routes.draw do\n") do " # This line mounts Blogelator's routes to the path '\#{@blogelator_route}'.\n # This means, any requests to '\#{@blogelator_route}', will go to Blogelator::PostsController.\n # If you would like to change where this engine is mounted, simply change the :at option to something different.\n #\n # We ask that you don't use the :as option here, as Blogelator relies on it being the default of \"blogelator\"\n mount Blogelator::Engine, at: \"\#{@blogelator_route}\"\n MOUNTENGINE\n end\nend\n" |