Undo the actions performed by a generator. Rewind the action manifest and attempt to completely erase the results of each action.
# File lib/rubigen/commands.rb, line 575 575: def complex_template(*args) 576: # nothing should be done here 577: end
Remove each directory in the given path from right to left. Remove each subdirectory if it exists and is a directory.
# File lib/rubigen/commands.rb, line 539 539: def directory(relative_path) 540: parts = relative_path.split('/') 541: until parts.empty? 542: partial = File.join(parts) 543: path = destination_path(partial) 544: if File.exist?(path) 545: if Dir[File.join(path, '*')].empty? 546: logger.rmdir partial 547: unless options[:pretend] 548: if options[:svn] 549: # If the directory has been marked to be added 550: # but has not yet been checked in, revert and delete 551: if options[:svn][relative_path] 552: system("svn revert #{path}") 553: FileUtils.rmdir(path) 554: else 555: # If the directory is not in the status list, it 556: # has no modifications so we can simply remove it 557: system("svn rm #{path}") 558: end 559: # I don't think git needs to remove directories?.. 560: # or maybe they have special consideration... 561: else 562: FileUtils.rmdir(path) 563: end 564: end 565: else 566: logger.notempty partial 567: end 568: else 569: logger.missing partial 570: end 571: parts.pop 572: end 573: end
Remove a file if it exists and is a file.
# File lib/rubigen/commands.rb, line 494 494: def file(relative_source, relative_destination, file_options = {}) 495: destination = destination_path(relative_destination) 496: if File.exist?(destination) 497: logger.rm relative_destination 498: unless options[:pretend] 499: if options[:svn] 500: # If the file has been marked to be added 501: # but has not yet been checked in, revert and delete 502: if options[:svn][relative_destination] 503: system("svn revert #{destination}") 504: FileUtils.rm(destination) 505: else 506: # If the directory is not in the status list, it 507: # has no modifications so we can simply remove it 508: system("svn rm #{destination}") 509: end 510: elsif options[:git] 511: if options[:git][:new][relative_destination] 512: # file has been added, but not committed 513: system("git reset HEAD #{relative_destination}") 514: FileUtils.rm(destination) 515: elsif options[:git][:modified][relative_destination] 516: # file is committed and modified 517: system("git rm -f #{relative_destination}") 518: else 519: # If the directory is not in the status list, it 520: # has no modifications so we can simply remove it 521: system("git rm #{relative_destination}") 522: end 523: else 524: FileUtils.rm(destination) 525: end 526: end 527: else 528: logger.missing relative_destination 529: return 530: end 531: end
When deleting a migration, it knows to delete every file named “[0-9]*_#{file_name}”.
# File lib/rubigen/commands.rb, line 580 580: def migration_template(relative_source, relative_destination, template_options = {}) 581: migration_directory relative_destination 582: 583: migration_file_name = template_options[:migration_file_name] || file_name 584: unless migration_exists?(migration_file_name) 585: stdout.puts "There is no migration named #{migration_file_name}" 586: return 587: end 588: 589: 590: existing_migrations(migration_file_name).each do |file_path| 591: file(relative_source, file_path, template_options) 592: end 593: end
# File lib/rubigen/commands.rb, line 595 595: def route_resources(*resources) 596: resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') 597: look_for = "\n map.resources #{resource_list}\n" 598: logger.route "map.resources #{resource_list}" 599: gsub_file 'config/routes.rb', /(#{look_for})/i, '' 600: end
Templates are deleted just like files and the actions take the same parameters, so simply alias the file method.
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.