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/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, 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, 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.



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

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.



84
85
86
# File 'lib/transpec/syntax.rb', line 84

def node
  @node
end

#reportObject (readonly)

Returns the value of attribute report.



84
85
86
# File 'lib/transpec/syntax.rb', line 84

def report
  @report
end

#runtime_dataObject (readonly)

Returns the value of attribute runtime_data.



84
85
86
# File 'lib/transpec/syntax.rb', line 84

def runtime_data
  @runtime_data
end

#source_rewriterObject (readonly)

Returns the value of attribute source_rewriter.



84
85
86
# File 'lib/transpec/syntax.rb', line 84

def source_rewriter
  @source_rewriter
end

Class Method Details

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

Returns:

  • (Boolean)


103
104
105
# File 'lib/transpec/syntax.rb', line 103

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

.snake_case_nameObject



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

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)


86
87
88
# File 'lib/transpec/syntax.rb', line 86

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)


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

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

Instance Method Details

#expression_rangeObject



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

def expression_range
  @node.loc.expression
end

#parent_nodeObject



118
119
120
# File 'lib/transpec/syntax.rb', line 118

def parent_node
  @node.parent_node
end

#static_context_inspectorObject



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

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