Class: Annotations::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/annotations/rake_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :notes) {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
15
16
# File 'lib/annotations/rake_task.rb', line 10

def initialize(name = :notes)
  @name = name
  @tags = [:optimize, :fixme, :todo]
  @extensions = ENV["ext"]
  yield self if block_given?
  define
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/annotations/rake_task.rb', line 8

def name
  @name
end

#tagsObject

Returns the value of attribute tags.



8
9
10
# File 'lib/annotations/rake_task.rb', line 8

def tags
  @tags
end

Instance Method Details

#defineObject

Define tasks



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/annotations/rake_task.rb', line 23

def define
  desc "Enumerate all annotations"
  task name do
    Annotations::Extractor.enumerate(tags_to_pattern, :show_tag => true, :extensions => @extensions)
  end

  namespace name do
    tags.each do |tagname|
      desc "Enumerate all #{tagname.to_s.upcase} annotations"
      task tagname.to_sym do
        Annotations::Extractor.enumerate(tagname.to_s.upcase, :show_tag => true, :extensions => @extensions)
      end
    end

    desc "Enumerate a custom annotation, specify with ANNOTATION=CUSTOM"
    task :custom, :annotation do |annotation|
      puts annotation
      Annotations::Extractor.enumerate(ENV['ANNOTATION'], :extensions => @extensions)
    end
  end
end

#tags_to_patternObject



18
19
20
# File 'lib/annotations/rake_task.rb', line 18

def tags_to_pattern
  @tags.map { |t| t.to_s.upcase }.join("|")
end