Class: RbTags::Rake::Tasks::Tags

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/rbtags/rake/tasks/tags.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(libs = nil, requires = nil) {|_self| ... } ⇒ Tags

Returns a new instance of Tags.

Yields:

  • (_self)

Yield Parameters:



4
5
6
7
8
9
10
11
# File 'lib/rbtags/rake/tasks/tags.rb', line 4

def initialize(libs = nil, requires = nil)
  @libs = libs || 'lib'
  @requires = requires || @libs.map{ |lib|
    FileList[lib + '/**/*.rb'].map{ |path| path.sub(%r{\A#{Regexp.escape(lib)}/}, '') }
  }.flatten.sort
  yield self if block_given?
  define
end

Instance Attribute Details

#libsObject

Returns the value of attribute libs.



30
31
32
# File 'lib/rbtags/rake/tasks/tags.rb', line 30

def libs
  @libs
end

#requiresObject

Returns the value of attribute requires.



30
31
32
# File 'lib/rbtags/rake/tasks/tags.rb', line 30

def requires
  @requires
end

Instance Method Details

#defineObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rbtags/rake/tasks/tags.rb', line 13

def define
  desc 'Generate TAGS'
  task :tags do
    require 'rbtags'
    libs.each do |lib|
      $LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
    end
    File.open('TAGS', 'wb') do |tags|
      RbTags.with_format RbTags::Formats::Extended.new(tags) do
        requires.each do |path|
          require path
        end
      end
    end
  end
end