| Class | Rails::Generator::Commands::Update |
| In: |
vendor/rails/railties/lib/rails_generator/commands.rb
|
| Parent: | Create |
Update generator‘s action manifest.
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 564
564: def complex_template(relative_source, relative_destination, template_options = {})
565:
566: begin
567: dest_file = destination_path(relative_destination)
568: source_to_update = File.readlines(dest_file).join
569: rescue Errno::ENOENT
570: logger.missing relative_destination
571: return
572: end
573:
574: logger.refreshing "#{template_options[:insert].gsub(/\.erb/,'')} inside #{relative_destination}"
575:
576: begin_mark = Regexp.quote(template_part_mark(template_options[:begin_mark], template_options[:mark_id]))
577: end_mark = Regexp.quote(template_part_mark(template_options[:end_mark], template_options[:mark_id]))
578:
579: # Refreshing inner part of the template with freshly rendered part.
580: rendered_part = render_template_part(template_options)
581: source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part)
582:
583: File.open(dest_file, 'w') { |file| file.write(source_to_update) }
584: end
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 586
586: def directory(relative_path)
587: # logger.directory "#{destination_path(relative_path)}/"
588: end
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 556
556: def file(relative_source, relative_destination, options = {})
557: # logger.file relative_destination
558: end