Class: Reacco::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/reacco/extractor.rb,
lib/reacco/extractor/block.rb

Overview

Reacco::Extractor [class] Extracts comments from list of files.

#### Instantiating Call the constructor with a list of files.

ex = Extractor.new(Dir['./**/*.rb'])

Defined Under Namespace

Classes: Block

Instance Method Summary collapse

Constructor Details

#initialize(files, root = nil, options = {}) ⇒ Extractor

Returns a new instance of Extractor.



17
18
19
20
# File 'lib/reacco/extractor.rb', line 17

def initialize(files, root=nil, options={})
  @files = files.sort
  @root  = File.realpath(root || Dir.pwd)
end

Instance Method Details

#blocksObject

blocks [method] Returns an array of ‘Block` instances.

ex.blocks
ex.blocks.map { |b| puts "file: #{b.file}" }


28
29
30
31
32
33
34
35
36
37
# File 'lib/reacco/extractor.rb', line 28

def blocks
  @blocks ||= begin
    @files.map do |file|
      if File.file?(file)
        input = File.read(file)
        get_blocks(input, unroot(file))
      end
    end.compact.flatten
  end
end