Class: Codependency::Parser
- Inherits:
-
Object
- Object
- Codependency::Parser
- Defined in:
- lib/codependency/parser.rb
Constant Summary collapse
- PATTERNS =
Hash.new { |hash, key| raise "Unknown extension '#{key}'. Known extensions are #{hash.keys.inspect}." }
Instance Method Summary collapse
- #extensions ⇒ Object
-
#parse(file) ⇒ Object
Determines a file’s dependencies based on the file’s extension.
Instance Method Details
#extensions ⇒ Object
20 21 22 |
# File 'lib/codependency/parser.rb', line 20 def extensions PATTERNS.keys end |
#parse(file) ⇒ Object
Determines a file’s dependencies based on the file’s extension.
12 13 14 15 16 17 18 |
# File 'lib/codependency/parser.rb', line 12 def parse( file ) pattern = PATTERNS[ File.extname( file ) ] IO.readlines( file ).take_while do |line| line =~ pattern end.map { |line| line[ pattern, 1 ] } end |