instance method directory

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

directory(relative_path)

Remove each directory in the given path from right to left. Remove each subdirectory if it exists and is a directory.

Parameters

relative_path req
Source
# File railties/lib/rails_generator/commands.rb, line 471
        def directory(relative_path)
          parts = relative_path.split('/')
          until parts.empty?
            partial = File.join(parts)
            path = destination_path(partial)
            if File.exist?(path)
              if Dir[File.join(path, '*')].empty?
                logger.rmdir partial
                unless options[:pretend]
                  if options[:svn]
                    # If the directory has been marked to be added
                    # but has not yet been checked in, revert and delete
                    if options[:svn][relative_path]
                      system("svn revert #{path}")
                      FileUtils.rmdir(path)
                    else
                    # If the directory is not in the status list, it
                    # has no modifications so we can simply remove it
                      system("svn rm #{path}")
                    end
                  # I don't think git needs to remove directories?..
                  # or maybe they have special consideration...
                  else
                    FileUtils.rmdir(path)
                  end
                end
              else
                logger.notempty partial
              end
            else
              logger.missing partial
            end
            parts.pop
          end
        end

Defined in railties/lib/rails_generator/commands.rb line 471 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Generator::Commands::Destroy

Type at least 2 characters to search.

↑↓ navigate · open · esc close