Class: Docks::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/docks/parser.rb

Class Method Summary collapse

Class Method Details

.parse(files) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/docks/parser.rb', line 3

def self.parse(files)
  files = Array(files).select { |file| File.exists?(file) }

  pattern = Containers::Pattern.new(name: Docks.pattern_id(files.first))
  pattern.files = files
  pattern.modified = files.map { |file| File.mtime(file) }.max

  files.each do |file|
    next unless parseable?(file)
    pattern.add(Languages.file_type(file), parse_file(file))
  end

  Process.process(pattern)
  pattern
end

.parse_block(content, language) ⇒ Object



24
25
26
27
28
29
# File 'lib/docks/parser.rb', line 24

def self.parse_block(content, language)
  store_current_details("foo.#{language}") do
    symbol = Docks.current_parser.parse_comment_block(content)
    Process.process(symbol)
  end
end

.register(parser, options) ⇒ Object



19
20
21
22
# File 'lib/docks/parser.rb', line 19

def self.register(parser, options)
  match = options.delete(:for) || options.delete(:match)
  @custom_parsers.push(parser: parser, for: match)
end