Class: MarkdownRecordGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MarkdownRecordGenerator
- Defined in:
- lib/generators/markdown_record_generator.rb
Instance Method Summary collapse
- #copy_demo_or_base ⇒ Object
- #copy_initializer ⇒ Object
- #copy_thor_tasks ⇒ Object
- #copy_thorfile ⇒ Object
- #create_directories ⇒ Object
- #mount_engine ⇒ Object
Instance Method Details
#copy_demo_or_base ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/generators/markdown_record_generator.rb', line 16 def copy_demo_or_base if [:demo] directory "demo/models", "app/models" directory "demo/content", "markdown_record/content" directory "demo/layouts", "markdown_record/layouts" directory "demo/assets/images", "app/assets/images" elsif [:tests] directory "tests/content", "markdown_record/content" directory "tests/layouts", "markdown_record/layouts" directory "tests/assets/images", "app/assets/images" else directory "base/content", "markdown_record/content" directory "base/layouts", "markdown_record/layouts" end end |
#copy_initializer ⇒ Object
32 33 34 |
# File 'lib/generators/markdown_record_generator.rb', line 32 def copy_initializer copy_file "markdown_record_initializer.rb", "config/initializers/markdown_record.rb" end |
#copy_thor_tasks ⇒ Object
40 41 42 |
# File 'lib/generators/markdown_record_generator.rb', line 40 def copy_thor_tasks copy_file "render_content.thor", "lib/tasks/render_content.thor" end |
#copy_thorfile ⇒ Object
36 37 38 |
# File 'lib/generators/markdown_record_generator.rb', line 36 def copy_thorfile copy_file "Thorfile", "Thorfile" end |
#create_directories ⇒ Object
10 11 12 13 14 |
# File 'lib/generators/markdown_record_generator.rb', line 10 def create_directories empty_directory "markdown_record/content" empty_directory "markdown_record/layouts" empty_directory "markdown_record/rendered" end |
#mount_engine ⇒ Object
44 45 46 47 |
# File 'lib/generators/markdown_record_generator.rb', line 44 def mount_engine gsub_file "config/routes.rb", "\n # Do not change this mount path here! Instead change it in the MarkdownRecord initializer.\n mount MarkdownRecord::Engine, at: MarkdownRecord.config.mount_path, as: \"markdown_record\"", "" gsub_file "config/routes.rb", /Rails.application.routes.draw do/, "Rails.application.routes.draw do\n # Do not change this mount path here! Instead change it in the MarkdownRecord initializer.\n mount MarkdownRecord::Engine, at: MarkdownRecord.config.mount_path, as: \"markdown_record\"" end |