Class: RailsBlogEngine::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_routeObject



8
9
10
# File 'lib/generators/rails_blog_engine/install/install_generator.rb', line 8

def add_route
  route 'mount RailsBlogEngine::Engine => "/blog"'
end

#copy_initializer_fileObject



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

def copy_initializer_file
  copy_file "rails_blog_engine.rb", "config/initializers/rails_blog_engine.rb"
end

#copy_localesObject



19
20
21
# File 'lib/generators/rails_blog_engine/install/install_generator.rb', line 19

def copy_locales
  copy_matching_files_from_gem('config/locales/rails_blog_engine.*.yml')
end

#copy_migrationsObject



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

def copy_migrations
  # Normally, we'd just call 'rake
  # "rails_blog_engine:install:migrations"' to do this for us, but it's
  # much more difficult to test.  So we roll our own version.
  copy_matching_files_from_gem('db/migrate/*.rb')
end

#copy_sidebarObject



23
24
25
# File 'lib/generators/rails_blog_engine/install/install_generator.rb', line 23

def copy_sidebar
  copy_matching_files_from_gem('app/views/layouts/rails_blog_engine/_sidebar.html.haml')
end

#copy_stylesheetsObject



27
28
29
30
31
# File 'lib/generators/rails_blog_engine/install/install_generator.rb', line 27

def copy_stylesheets
  copy_matching_files_from_gem('lib/assets/stylesheets/rails_blog_engine/_config.css.scss')
  copy_matching_files_from_gem('lib/assets/stylesheets/rails_blog_engine/layout.css.scss')
  copy_matching_files_from_gem('lib/assets/stylesheets/rails_blog_engine/customizations.css.scss')
end

#register_javascriptsObject



33
34
35
36
37
38
39
# File 'lib/generators/rails_blog_engine/install/install_generator.rb', line 33

def register_javascripts
  in_root do
    append_file("app/assets/javascripts/application.js",
                "//= require rails_blog_engine\n",
                :before => /^\/\/= require/)
  end
end

#register_stylesheetsObject



41
42
43
44
45
46
47
# File 'lib/generators/rails_blog_engine/install/install_generator.rb', line 41

def register_stylesheets
  in_root do
    inject_into_file("app/assets/stylesheets/application.css",
                     " *= require rails_blog_engine\n",
                     :before => /^\*\//)
  end
end