Class: Mutest::Context Private
- Inherits:
-
Object
- Object
- Mutest::Context
- Extended by:
- AST::Sexp
- Includes:
- Adamantium::Flat
- Defined in:
- lib/mutest/context.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An abstract context where mutations can be applied to.
Constant Summary collapse
- NAMESPACE_DELIMITER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'::'.freeze
Instance Attribute Summary collapse
-
#scope ⇒ Module, Class
readonly
private
Scope wrapped by context.
Class Method Summary collapse
-
.wrap(scope, node) ⇒ Parser::AST::Class, Parser::AST::Module
private
Wrap node into ast node.
Instance Method Summary collapse
-
#identification ⇒ String
private
Identification string.
- #ignore?(node) ⇒ Boolean private
-
#match_expressions ⇒ Enumerable<Expression>
private
Match expressions for scope.
-
#nesting ⇒ Enumerable<Class,Module>
private
Nesting of scope.
-
#root(node) ⇒ Parser::AST::Node
private
Return root node for mutation.
- #source_path ⇒ Object private
-
#unqualified_name ⇒ String
private
Unqualified name of scope.
Instance Attribute Details
#scope ⇒ Module, Class (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Scope wrapped by context
79 80 81 |
# File 'lib/mutest/context.rb', line 79 def scope @scope end |
Class Method Details
.wrap(scope, node) ⇒ Parser::AST::Class, Parser::AST::Module
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wrap node into ast node
36 37 38 39 40 41 42 43 44 |
# File 'lib/mutest/context.rb', line 36 def self.wrap(scope, node) name = s(:const, nil, scope.name.split(NAMESPACE_DELIMITER).last.to_sym) case scope when Class s(:class, name, nil, node) when Module s(:module, name, node) end end |
Instance Method Details
#identification ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Identification string
22 23 24 |
# File 'lib/mutest/context.rb', line 22 def identification scope.name end |
#ignore?(node) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 |
# File 'lib/mutest/context.rb', line 81 def ignore?(node) source_file.ignore?(node) end |
#match_expressions ⇒ Enumerable<Expression>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Match expressions for scope
67 68 69 70 71 72 73 |
# File 'lib/mutest/context.rb', line 67 def match_expressions name_nesting.each_index.reverse_each.map do |index| Expression::Namespace::Recursive.new( scope_name: name_nesting.take(index.succ).join(NAMESPACE_DELIMITER) ) end end |
#nesting ⇒ Enumerable<Class,Module>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Nesting of scope
49 50 51 52 53 54 |
# File 'lib/mutest/context.rb', line 49 def nesting const = Object name_nesting.map do |name| const = const.const_get(name) end end |
#root(node) ⇒ Parser::AST::Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return root node for mutation
13 14 15 16 17 |
# File 'lib/mutest/context.rb', line 13 def root(node) nesting.reverse.reduce(node) do |current, scope| self.class.wrap(scope, current) end end |
#source_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/mutest/context.rb', line 85 def source_path source_file.path end |
#unqualified_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Unqualified name of scope
60 61 62 |
# File 'lib/mutest/context.rb', line 60 def unqualified_name name_nesting.last end |