Class: Transpec::Syntax

Inherits:
Object
  • Object
show all
Extended by:
Collection
Includes:
DynamicAnalysis, Rewritable
Defined in:
lib/transpec/syntax.rb,
lib/transpec/syntax.rb,
lib/transpec/syntax.rb,
lib/transpec/syntax.rb,
lib/transpec/syntax/its.rb,
lib/transpec/syntax/have.rb,
lib/transpec/syntax/double.rb,
lib/transpec/syntax/expect.rb,
lib/transpec/syntax/should.rb,
lib/transpec/syntax/example.rb,
lib/transpec/syntax/be_close.rb,
lib/transpec/syntax/be_boolean.rb,
lib/transpec/syntax/mixin/send.rb,
lib/transpec/syntax/method_stub.rb,
lib/transpec/syntax/raise_error.rb,
lib/transpec/syntax/should_receive.rb,
lib/transpec/syntax/oneliner_should.rb,
lib/transpec/syntax/rspec_configure.rb,
lib/transpec/syntax/operator_matcher.rb,
lib/transpec/syntax/mixin/should_base.rb,
lib/transpec/syntax/matcher_definition.rb,
lib/transpec/syntax/mixin/any_instance.rb,
lib/transpec/syntax/mixin/expectizable.rb,
lib/transpec/syntax/mixin/monkey_patch.rb,
lib/transpec/syntax/mixin/allow_no_message.rb,
lib/transpec/syntax/mixin/have_matcher_owner.rb

Defined Under Namespace

Modules: Collection, DynamicAnalysis, Mixin, Rewritable Classes: BeBoolean, BeClose, Double, Example, Expect, Have, Its, MatcherDefinition, MethodStub, OnelinerShould, OperatorMatcher, RSpecConfigure, RaiseError, Should, ShouldReceive

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Collection

all_syntaxes, inherited, require_all, standalone_syntaxes

Methods included from DynamicAnalysis

#register_request_for_dynamic_analysis

Constructor Details

#initialize(node, source_rewriter = nil, runtime_data = nil, report = nil) ⇒ Syntax

Returns a new instance of Syntax.



114
115
116
117
118
119
# File 'lib/transpec/syntax.rb', line 114

def initialize(node, source_rewriter = nil, runtime_data = nil, report = nil)
  @node = node
  @source_rewriter = source_rewriter
  @runtime_data = runtime_data
  @report = report || Report.new
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



91
92
93
# File 'lib/transpec/syntax.rb', line 91

def node
  @node
end

#reportObject (readonly)

Returns the value of attribute report.



91
92
93
# File 'lib/transpec/syntax.rb', line 91

def report
  @report
end

#runtime_dataObject (readonly)

Returns the value of attribute runtime_data.



91
92
93
# File 'lib/transpec/syntax.rb', line 91

def runtime_data
  @runtime_data
end

#source_rewriterObject (readonly)

Returns the value of attribute source_rewriter.



91
92
93
# File 'lib/transpec/syntax.rb', line 91

def source_rewriter
  @source_rewriter
end

Class Method Details

.conversion_target_node?(node, runtime_data = nil) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/transpec/syntax.rb', line 110

def self.conversion_target_node?(node, runtime_data = nil)
  target_node?(node, runtime_data)
end

.snake_case_nameObject



97
98
99
100
101
102
# File 'lib/transpec/syntax.rb', line 97

def self.snake_case_name
  @snake_cake_name ||= begin
    class_name = name.split('::').last
    class_name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
  end
end

.standalone?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/transpec/syntax.rb', line 93

def self.standalone?
  true
end

.target_node?(node, runtime_data = nil) ⇒ Boolean

The default common method for .conversion_target_node? and .dynamic_analysis_target_node?. If they should behave differently, override either or both.

Returns:

  • (Boolean)


106
107
108
# File 'lib/transpec/syntax.rb', line 106

def self.target_node?(node, runtime_data = nil)
  false
end

Instance Method Details

#expression_rangeObject



129
130
131
# File 'lib/transpec/syntax.rb', line 129

def expression_range
  @node.loc.expression
end

#parent_nodeObject



125
126
127
# File 'lib/transpec/syntax.rb', line 125

def parent_node
  @node.parent_node
end

#static_context_inspectorObject



121
122
123
# File 'lib/transpec/syntax.rb', line 121

def static_context_inspector
  @static_context_inspector ||= StaticContextInspector.new(@node)
end