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) ⇒ RakeTask



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

def initialize(name = :notes)
  @name = name
  @tags = [:optimize, :fixme, :todo]
  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



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/annotations/rake_task.rb', line 21

def define
  desc "Enumerate all annotations"
  task name do
    Annotations::Extractor.enumerate(tags_to_pattern, :tag => true)
  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, :tag => true)
      end
    end

    desc "Enumerate a custom annotation, specify with ANNOTATION=CUSTOM"
    task :custom, :annotation do |annotation|
      puts annotation
      SourceAnnotationExtractor.enumerate ENV['ANNOTATION']
    end
  end

  # desc name == :notes ? "Compile assets" : "Compile #{name} assets"
  # desc "Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)"
  # task name do
  #   with_logger do
  #     manifest.compile(assets)
  #   end
  # end

  # desc name == :assets ? "Remove all assets" : "Remove all #{name} assets"
  # task "clobber_#{name}" do
  #   with_logger do
  #     manifest.clobber
  #   end
  # end

  # task :clobber => ["clobber_#{name}"]

  # desc name == :assets ? "Clean old assets" : "Clean old #{name} assets"
  # task "clean_#{name}" do
  #   with_logger do
  #     manifest.clean(keep)
  #   end
  # end

  # task :clean => ["clean_#{name}"]
end

#tags_to_patternObject



16
17
18
# File 'lib/annotations/rake_task.rb', line 16

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