Sha256: 0b92fd6fd61d1c826c14ee54fdccb8249ac13003a2ab3749994b36f2773a6a42

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'reap/task'
require 'facet/gem/self/gempath'

class Reap::Scaffold < Reap::Task

  task_desc "Generate a project directory layout."

  task_help %{

    reap scaffold [type]

    Generates a project directory layout within the current
    directory. The scaffolding includes all the standard
    features such as directories lib/ bin/ doc/
    and files such as README.

    To use this task you should first create an empty
    directory and than change into it. It will not generate
    a scaffolding into a directory with any files already in
    it unless you use the -f (force) option. Also, the scaffold
    task is not available if a ProjectInfo file exists.

    There are currently two types of supported scaffoldings:
    'standard', which is the default if no type is given,
    and 'subversion' which creates a "trunk" hierarchy.

  }

  task_available { ! Reap.projectfile? }

  def run( type=nil )
    content = Dir.entries('.') - [ '.', '..' ]
    if not content.empty? and not $FORCE
      tell "Directory already has content. Use -f option to force scaffolding."
      return nil
    end
    type ||= 'standard'
    type = 'standard' if type == 'std'
    type = 'subversion' if type == 'svn'
    # gems workaround
    if dir = Gem.gempath('reap')
      dir = File.join( dir, 'data', 'reap', 'scaffold', type )
    else
      dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold', type )
    end
    #
    unless File.directory?( dir )
      tell "Unrecognized project type."
    else
      #FileUtils.mkdir_p( name )
      FileUtils.cp_r( File.join( dir, '.'), '.' )
      tell "Project ready."
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reap-4.5.2 lib/reap/task/scaffold.rb