class Docks::Parsers::JavaScript
Public Class Methods
new()
click to toggle source
# File lib/docks/parsers/javascript_parser.rb, line 6 def initialize @comment_pattern = /(?:\/\/|\/\*|\*\/?)/ @first_non_code_line_pattern = /[\w\$]/ setup_regexes end
Public Instance Methods
symbol_details_from_first_line(first_code_line)
click to toggle source
# File lib/docks/parsers/javascript_parser.rb, line 12 def symbol_details_from_first_line(first_code_line) first_code_line.strip! type = case first_code_line when /^class/ then Docks::Types::Symbol::CLASS when /(?:function|=>)/ then Docks::Types::Symbol::FUNCTION else Docks::Types::Symbol::VARIABLE end clean_first_line = first_code_line.split(/[=:,\(]/).first.split(/[\.\s]/).last.strip bracket_check = clean_first_line.split(/['"]/) name = bracket_check.length > 1 ? bracket_check[-2] : clean_first_line { name: name, symbol_type: type } end