instance method directory

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

directory(relative_path)

Create a directory including any missing parent directories. Always skips directories which exist.

Parameters

relative_path req
Source
# File railties/lib/rails_generator/commands.rb, line 318
        def directory(relative_path)
          path = destination_path(relative_path)
          if File.exist?(path)
            logger.exists relative_path
          else
            logger.create relative_path
            unless options[:pretend]
              FileUtils.mkdir_p(path)
              # git doesn't require adding the paths, adding the files later will
              # automatically do a path add.

              # Subversion doesn't do path adds, so we need to add
              # each directory individually.
              # So stack up the directory tree and add the paths to
              # subversion in order without recursion.
              if options[:svn]
                stack = [relative_path]
                until File.dirname(stack.last) == stack.last # dirname('.') == '.'
                  stack.push File.dirname(stack.last)
                end
                stack.reverse_each do |rel_path|
                  svn_path = destination_path(rel_path)
                  system("svn add -N #{svn_path}") unless File.directory?(File.join(svn_path, '.svn'))
                end
              end
            end
          end
        end

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

Defined in Rails::Generator::Commands::Create

Type at least 2 characters to search.

↑↓ navigate · open · esc close