Class: CoderCompanion::Ruby::RubyTreeWalker

Inherits:
TreeWalker
  • Object
show all
Defined in:
lib/codercompanion/ruby/ruby_tree_walker.rb

Instance Method Summary collapse

Instance Method Details

#build(results, cache_handler) ⇒ Hash

Parameters:

  • results (Array<Hash>)

    the results from parsing the code

Returns:

  • (Hash)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/codercompanion/ruby/ruby_tree_walker.rb', line 14

def build(results, cache_handler)
    obj = {}
    results.each do |source|
        modified = cache_handler.is_file_modified?(source[:file_path])
        cache_handler.update_cache_path(source[:file_path])

        if source[:body][0].root?
            source[:body][0].children.each do |child|

                # puts child
                if (child.type == :class || child.type == :module)
                    child_name = child.path
                    obj[child_name] = build_class_or_module(child, modified, obj)
                end
            end
        end
        # puts res

    end

    post_process_object(obj)
    #ap obj
    return obj
end

#create_uploadable(results, cache_handler) ⇒ Hash

Parameters:

Returns:

  • (Hash)


8
9
10
# File 'lib/codercompanion/ruby/ruby_tree_walker.rb', line 8

def create_uploadable(results, cache_handler)
    return build(results, cache_handler) 
end