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 605 605: def complex_template(relative_source, relative_destination, template_options = {}) 606: 607: begin 608: dest_file = destination_path(relative_destination) 609: source_to_update = File.readlines(dest_file).join 610: rescue Errno::ENOENT 611: logger.missing relative_destination 612: return 613: end 614: 615: logger.refreshing "#{template_options[:insert].gsub(/\.erb/,'')} inside #{relative_destination}" 616: 617: begin_mark = Regexp.quote(template_part_mark(template_options[:begin_mark], template_options[:mark_id])) 618: end_mark = Regexp.quote(template_part_mark(template_options[:end_mark], template_options[:mark_id])) 619: 620: # Refreshing inner part of the template with freshly rendered part. 621: rendered_part = render_template_part(template_options) 622: source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part) 623: 624: File.open(dest_file, 'w') { |file| file.write(source_to_update) } 625: end
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 627 627: def directory(relative_path) 628: # logger.directory "#{destination_path(relative_path)}/" 629: end
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 597 597: def file(relative_source, relative_destination, options = {}) 598: # logger.file relative_destination 599: end