Class: Inventory::Rake::Tasks::Clean

Inherits:
Object
  • Object
show all
Extended by:
Rake::DSL
Includes:
Rake::DSL
Defined in:
lib/inventory-rake-1.0/tasks/clean.rb

Overview

Tasks for cleaning up a project directory.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, files = []) {|?| ... } ⇒ Clean

Sets up a cleaning task #name that’ll delete #files, optionally yields the task for further customization, then #defines the task.

Parameters:

  • name (Symbol)
  • files (Array<String>) (defaults to: [])

Yields:

  • (?)

Yield Parameters:

  • task (self)


44
45
46
47
48
# File 'lib/inventory-rake-1.0/tasks/clean.rb', line 44

def initialize(name, files = [])
  @name, @files = name, files
  yield self if block_given?
  define
end

Instance Attribute Details

#filesArray<String>

Returns The files to delete.

Returns:

  • (Array<String>)

    The files to delete



61
62
63
# File 'lib/inventory-rake-1.0/tasks/clean.rb', line 61

def files
  @files
end

#nameSymbol

Returns The name of the task.

Returns:

  • (Symbol)

    The name of the task



58
59
60
# File 'lib/inventory-rake-1.0/tasks/clean.rb', line 58

def name
  @name
end

Class Method Details

.defineObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/inventory-rake-1.0/tasks/clean.rb', line 10

def define
  # Defines the following tasks:
  #
  # <dl>
  #   <dt>mostlyclean</dt>
  #   <dd>Delete targets built by rake that are ofter rebuilt.</dd>
  #
  #   <dt>clean</dt>
  #   <dd>Delete targets builty by rake; depends on mostlyclean.</dd>
  #
  #   <dt>distclean</dt>
  #   <dd>Delete all files not meant for distribution; depends on
  #   clean.</dd>
  # </dl>
  desc 'Delete targets built by rake that are often rebuilt'
  new :mostlyclean, Inventory::Rake::Tasks.mostlycleanfiles

  desc 'Delete targets built by rake'
  new :clean, Inventory::Rake::Tasks.cleanfiles
  task :clean => :mostlyclean

  desc 'Delete all files not meant for distribution'
  new :distclean, Inventory::Rake::Tasks.distcleanfiles
  task :distclean => :clean
end

Instance Method Details

#defineObject

Defines the task #name that’ll delete #files.



51
52
53
54
55
# File 'lib/inventory-rake-1.0/tasks/clean.rb', line 51

def define
  task name do
    rm files, :force => true unless files.empty?
  end
end