Class: Transpec::DynamicAnalyzer::Rewriter
Constant Summary
collapse
- EVAL_TARGET_TYPES =
[:object, :context]
Constants included
from Util
Util::LITERAL_TYPES, Util::WHITESPACES
Instance Method Summary
collapse
Methods included from NodeUtil
#node_id
Methods included from Util
beginning_of_line_range, block_node_taken_by_method, chainable_source, const_name, contain_here_document?, each_backward_chained_node, each_forward_chained_node, each_line_range, expand_range_to_adjacent_whitespaces, find_consecutive_whitespace_position, first_block_arg_name, here_document?, in_explicit_parentheses?, indentation_of_line, line_range, literal?, proc_literal?, range_from_arg
#rewrite, #rewrite_file!, #rewrite_source
Instance Method Details
#clear_requests! ⇒ Object
31
32
33
|
# File 'lib/transpec/dynamic_analyzer/rewriter.rb', line 31
def clear_requests!
@requests = nil
end
|
#process(ast, source_rewriter) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/transpec/dynamic_analyzer/rewriter.rb', line 18
def process(ast, source_rewriter)
clear_requests!
collect_requests(ast)
process_requests(source_rewriter)
end
|
#register_request(node, key, instance_eval_string, eval_target_type = :object) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/transpec/dynamic_analyzer/rewriter.rb', line 35
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
|
#requests ⇒ Object
25
26
27
28
29
|
# File 'lib/transpec/dynamic_analyzer/rewriter.rb', line 25
def requests
@requests ||= {}.compare_by_identity
end
|