Module: Transpec::Syntax::Mixin::Send
- Extended by:
- ActiveSupport::Concern
- Included in:
- BeBoolean, BeClose, Double, Example, Expect, Have, Its, Transpec::Syntax::MatcherDefinition, Transpec::Syntax::MethodStub, OnelinerShould, OperatorMatcher, RaiseError, Should, ShouldReceive
- Defined in:
- lib/transpec/syntax/mixin/send.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #arg_node ⇒ Object
- #arg_nodes ⇒ Object
- #arg_range ⇒ Object
- #args_range ⇒ Object
- #method_name ⇒ Object
- #parentheses_range ⇒ Object
- #range_after_arg ⇒ Object
- #range_in_between_receiver_and_selector ⇒ Object
- #range_in_between_selector_and_arg ⇒ Object
- #receiver_node ⇒ Object
- #receiver_range ⇒ Object
- #selector_range ⇒ Object
Class Method Details
.included(syntax) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/transpec/syntax/mixin/send.rb', line 47 def self.included(syntax) syntax.add_dynamic_analysis_request do |rewriter| if receiver_node target_node = receiver_node target_object_type = :object else target_node = @node target_object_type = :context end key = self.class.source_location_key(method_name) code = "method(#{method_name.inspect}).source_location" rewriter.register_request(target_node, key, code, target_object_type) end end |
Instance Method Details
#arg_node ⇒ Object
71 72 73 |
# File 'lib/transpec/syntax/mixin/send.rb', line 71 def arg_node @node.children[2] end |
#arg_nodes ⇒ Object
75 76 77 |
# File 'lib/transpec/syntax/mixin/send.rb', line 75 def arg_nodes @node.children[2..-1] end |
#arg_range ⇒ Object
87 88 89 |
# File 'lib/transpec/syntax/mixin/send.rb', line 87 def arg_range arg_node.loc.expression end |
#args_range ⇒ Object
91 92 93 |
# File 'lib/transpec/syntax/mixin/send.rb', line 91 def args_range arg_nodes.first.loc.expression.begin.join(arg_nodes.last.loc.expression.end) end |
#method_name ⇒ Object
67 68 69 |
# File 'lib/transpec/syntax/mixin/send.rb', line 67 def method_name @node.children[1] end |
#parentheses_range ⇒ Object
95 96 97 |
# File 'lib/transpec/syntax/mixin/send.rb', line 95 def parentheses_range selector_range.end.join(expression_range.end) end |
#range_after_arg ⇒ Object
107 108 109 |
# File 'lib/transpec/syntax/mixin/send.rb', line 107 def range_after_arg arg_range.end.join(expression_range.end) end |
#range_in_between_receiver_and_selector ⇒ Object
99 100 101 |
# File 'lib/transpec/syntax/mixin/send.rb', line 99 def range_in_between_receiver_and_selector receiver_range.end.join(selector_range.begin) end |
#range_in_between_selector_and_arg ⇒ Object
103 104 105 |
# File 'lib/transpec/syntax/mixin/send.rb', line 103 def range_in_between_selector_and_arg selector_range.end.join(arg_range.begin) end |
#receiver_node ⇒ Object
63 64 65 |
# File 'lib/transpec/syntax/mixin/send.rb', line 63 def receiver_node @node.children[0] end |
#receiver_range ⇒ Object
83 84 85 |
# File 'lib/transpec/syntax/mixin/send.rb', line 83 def receiver_range receiver_node.loc.expression end |
#selector_range ⇒ Object
79 80 81 |
# File 'lib/transpec/syntax/mixin/send.rb', line 79 def selector_range @node.loc.selector end |