Class: Rails::Generator::Commands::Update
- Defined in:
- lib/rails_generator/commands.rb
Overview
Update generator’s action manifest.
Instance Attribute Summary
Attributes inherited from Base
#args, #destination_root, #source_root
Instance Method Summary collapse
- #complex_template(relative_source, relative_destination, template_options = {}) ⇒ Object
- #directory(relative_path) ⇒ Object
- #file(relative_source, relative_destination, options = {}) ⇒ Object
- #template(relative_source, relative_destination, options = {}) ⇒ Object
Methods inherited from Create
Methods inherited from Base
#class_collisions, #dependency, #invoke!, #readme
Methods inherited from Base
#destination_path, #initialize, #manifest, #source_path
Constructor Details
This class inherits a constructor from Rails::Generator::Base
Instance Method Details
#complex_template(relative_source, relative_destination, template_options = {}) ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/rails_generator/commands.rb', line 380 def complex_template(relative_source, relative_destination, = {}) begin dest_file = destination_path(relative_destination) source_to_update = File.readlines(dest_file).join rescue Errno::ENOENT logger.missing relative_destination return end logger.refreshing "#{[:insert].gsub(/\.rhtml/,'')} inside #{relative_destination}" begin_mark = Regexp.quote(template_part_mark([:begin_mark], [:mark_id])) end_mark = Regexp.quote(template_part_mark([:end_mark], [:mark_id])) # Refreshing inner part of the template with freshly rendered part. rendered_part = render_template_part() source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part) File.open(dest_file, 'w') { |file| file.write(source_to_update) } end |
#directory(relative_path) ⇒ Object
402 403 404 |
# File 'lib/rails_generator/commands.rb', line 402 def directory(relative_path) # logger.directory "#{destination_path(relative_path)}/" end |
#file(relative_source, relative_destination, options = {}) ⇒ Object
372 373 374 |
# File 'lib/rails_generator/commands.rb', line 372 def file(relative_source, relative_destination, = {}) # logger.file relative_destination end |
#template(relative_source, relative_destination, options = {}) ⇒ Object
376 377 378 |
# File 'lib/rails_generator/commands.rb', line 376 def template(relative_source, relative_destination, = {}) # logger.template relative_destination end |