Class: Transpec::DynamicAnalyzer::Rewriter

Inherits:
BaseRewriter show all
Includes:
Util
Defined in:
lib/transpec/dynamic_analyzer/rewriter.rb

Constant Summary

Constants included from Util

Util::LITERAL_TYPES

Instance Method Summary collapse

Methods included from Util

const_name, contain_here_document?, here_document?, in_parentheses?, indentation_of_line, literal?, proc_literal?

Methods inherited from BaseRewriter

#rewrite, #rewrite_file!

Instance Method Details

#clear_requests!Object



22
23
24
# File 'lib/transpec/dynamic_analyzer/rewriter.rb', line 22

def clear_requests!
  @requests = nil
end

#process(ast, source_rewriter) ⇒ Object



11
12
13
14
15
16
# File 'lib/transpec/dynamic_analyzer/rewriter.rb', line 11

def process(ast, source_rewriter)
  # TODO: Currently multitheading is not considered...
  clear_requests!
  collect_requests(ast)
  process_requests(source_rewriter)
end

#register_request(node, key, instance_eval_string, eval_target_type = :object) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/transpec/dynamic_analyzer/rewriter.rb', line 26

def register_request(node, key, instance_eval_string, eval_target_type = :object)
  unless EVAL_TARGET_TYPES.include?(eval_target_type)
    fail "Target type must be any of #{EVAL_TARGET_TYPES}"
  end

  requests[node] ||= {}
  requests[node][key] = [eval_target_type, instance_eval_string]
end

#requestsObject



18
19
20
# File 'lib/transpec/dynamic_analyzer/rewriter.rb', line 18

def requests
  @requests ||= {}
end