Sha256: 61145d297bd6b03f29959cbfc5007f2f884a3256f43f12c5da9a24bf66499012

Contents?: true

Size: 572 Bytes

Versions: 2

Compression:

Stored size: 572 Bytes

Contents

module Codependency
  class Parser

    def initialize( options={} )
      @options = options
      @comment = options.delete( :comment ) || '#'
    end

    ##
    # determines a file's dependencies based on the configured comment pattern.
    def parse( file )
      IO.readlines( file ).take_while do |line|
        line =~ pattern
      end.map { |line| line[ pattern, 1 ] }
    end

    protected

    ##
    # the comment pattern to use.
    # TODO allow this to be more configurable
    def pattern
      @pattern ||= /^#{@comment} require (.+)$/
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codependency-0.3.1 lib/codependency/parser.rb
codependency-0.3.0 lib/codependency/parser.rb