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 580 580: def complex_template(relative_source, relative_destination, template_options = {}) 581: 582: begin 583: dest_file = destination_path(relative_destination) 584: source_to_update = File.readlines(dest_file).join 585: rescue Errno::ENOENT 586: logger.missing relative_destination 587: return 588: end 589: 590: logger.refreshing "#{template_options[:insert].gsub(/\.erb/,'')} inside #{relative_destination}" 591: 592: begin_mark = Regexp.quote(template_part_mark(template_options[:begin_mark], template_options[:mark_id])) 593: end_mark = Regexp.quote(template_part_mark(template_options[:end_mark], template_options[:mark_id])) 594: 595: # Refreshing inner part of the template with freshly rendered part. 596: rendered_part = render_template_part(template_options) 597: source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part) 598: 599: File.open(dest_file, 'w') { |file| file.write(source_to_update) } 600: end
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 602 602: def directory(relative_path) 603: # logger.directory "#{destination_path(relative_path)}/" 604: end
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 572 572: def file(relative_source, relative_destination, options = {}) 573: # logger.file relative_destination 574: end