class SmartTodo::Parser::MetadataParser
This class is used to parse the ruby TODO() comment.
Public Class Methods
parse(source)
click to toggle source
@param source [String] the actual Ruby code
# File lib/smart_todo/parser/metadata_parser.rb, line 22 def self.parse(source) sexp = new(source).parse Visitor.new.tap { |v| v.process(sexp) } end
Public Instance Methods
on_args_add(list, arg)
click to toggle source
@param list [nil, Array] @param arg [String] @return [Array]
# File lib/smart_todo/parser/metadata_parser.rb, line 48 def on_args_add(list, arg) Array(list) << arg end
on_assoc_new(key, value)
click to toggle source
@param key [String] @param value [String, Integer, MethodNode]
# File lib/smart_todo/parser/metadata_parser.rb, line 60 def on_assoc_new(key, value) key.tr!(':', '') case key when 'on' [:on_todo_event, value] when 'to' [:on_todo_assignee, value] else [:unknown, value] end end
on_bare_assoc_hash(data)
click to toggle source
@param data [Hash] @return [Hash]
# File lib/smart_todo/parser/metadata_parser.rb, line 75 def on_bare_assoc_hash(data) data end
on_method_add_arg(method, args)
click to toggle source
@param method [String] the name of the method
when the parser hits one.
@param args [Array] @return [Array, MethodNode]
# File lib/smart_todo/parser/metadata_parser.rb, line 37 def on_method_add_arg(method, args) if method == 'TODO' args else MethodNode.new(method, args) end end
on_stmts_add(_, data)
click to toggle source
@return [Array] an Array of Array
the first element from each inner array is a token
# File lib/smart_todo/parser/metadata_parser.rb, line 29 def on_stmts_add(_, data) data end
on_string_add(_, string_content)
click to toggle source
@param string_content [String] @return [String]
# File lib/smart_todo/parser/metadata_parser.rb, line 54 def on_string_add(_, string_content) string_content end