Sha256: 9d9c7fe604133051269860ba0f429e001f4bfaa27b683756f2163c68c48f3adb
Contents?: true
Size: 598 Bytes
Versions: 6
Compression:
Stored size: 598 Bytes
Contents
module Codependency class Parser PATTERNS = Hash.new { |hash, key| raise "Unknown extension '#{key}'. Known extensions are #{hash.keys.inspect}." } PATTERNS[ '.rb' ] = /^#= require ([\w\/]+)$/ PATTERNS[ '.js' ] = /^\/\/= require ([\w\/]+)$/ ## # Determines a file's dependencies based on the file's extension. def parse( file ) pattern = PATTERNS[ File.extname( file ) ] IO.readlines( file ).take_while do |line| line =~ pattern end.map { |line| line[ pattern, 1 ] } end def extensions PATTERNS.keys end end end
Version data entries
6 entries across 6 versions & 1 rubygems