Class: Evilution::Mutator::Base Private
- Inherits:
-
Prism::Visitor
- Object
- Prism::Visitor
- Evilution::Mutator::Base
- Defined in:
- lib/evilution/mutator/base.rb
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.
Direct Known Subclasses
Operator::ArgumentMethodCallReplacement, Operator::ArgumentNilSubstitution, Operator::ArgumentRemoval, Operator::ArithmeticReplacement, Operator::ArrayLiteral, Operator::BangMethod, Operator::BeginUnwrap, Operator::BitwiseComplement, Operator::BitwiseReplacement, Operator::BlockParamRemoval, Operator::BlockPassRemoval, Operator::BlockRemoval, Operator::BooleanLiteralReplacement, Operator::BooleanOperatorReplacement, Operator::BreakStatement, Operator::CaseWhen, Operator::ClassVariableWrite, Operator::CollectionReplacement, Operator::CollectionReturn, Operator::ComparisonReplacement, Operator::CompoundAssignment, Operator::ConditionalBranch, Operator::ConditionalFlip, Operator::ConditionalNegation, Operator::DefinedCheck, Operator::EnsureRemoval, Operator::EqualityToIdentity, Operator::ExplicitSuperMutation, Operator::FloatLiteral, Operator::GlobalVariableWrite, Operator::HashLiteral, Operator::IndexAssignmentRemoval, Operator::IndexToAt, Operator::IndexToDig, Operator::IndexToFetch, Operator::InlineRescue, Operator::InstanceVariableWrite, Operator::IntegerLiteral, Operator::KeywordArgument, Operator::LambdaBody, Operator::LastExpressionRemoval, Operator::LocalVariableAssignment, Operator::LoopFlip, Operator::MethodBodyReplacement, Operator::MethodCallRemoval, Operator::MixinRemoval, Operator::MultipleAssignment, Operator::NegationInsertion, Operator::NextStatement, Operator::NilReplacement, Operator::PatternMatchingAlternative, Operator::PatternMatchingArray, Operator::PatternMatchingGuard, Operator::PredicateReplacement, Operator::PredicateToNil, Operator::RangeReplacement, Operator::ReceiverReplacement, Operator::RedoStatement, Operator::RegexCapture, Operator::RegexSimplification, Operator::RegexpMutation, Operator::RescueBodyReplacement, Operator::RescueRemoval, Operator::RetryRemoval, Operator::ReturnValueRemoval, Operator::ScalarReturn, Operator::SendMutation, Operator::SplatOperator, Operator::StatementDeletion, Operator::StringInterpolation, Operator::StringLiteral, Operator::SuperclassRemoval, Operator::SymbolLiteral, Operator::YieldStatement, Operator::ZsuperRemoval
Instance Attribute Summary collapse
- #mutations ⇒ Object readonly private
Class Method Summary collapse
- .clear_parse_cache! ⇒ Object private
- .operator_name ⇒ Object private
- .parsed_tree_for(file_path, file_source) ⇒ Object private
Instance Method Summary collapse
- #call(subject, filter: nil) ⇒ Object private
-
#initialize(**_options) ⇒ Base
constructor
private
A new instance of Base.
Constructor Details
#initialize(**_options) ⇒ Base
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.
Returns a new instance of Base.
26 27 28 29 30 31 |
# File 'lib/evilution/mutator/base.rb', line 26 def initialize(**) @mutations = [] @subject = nil @file_source = nil @body_call_neutralizer = Evilution::Integration::Loading::BodyCallNeutralizer.new end |
Instance Attribute Details
#mutations ⇒ Object (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.
24 25 26 |
# File 'lib/evilution/mutator/base.rb', line 24 def mutations @mutations end |
Class Method Details
.clear_parse_cache! ⇒ 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.
160 161 162 |
# File 'lib/evilution/mutator/base.rb', line 160 def self.clear_parse_cache! Evilution::Mutator::Base.instance_variable_set(:@parse_cache, {}) end |
.operator_name ⇒ 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.
140 141 142 143 144 145 146 |
# File 'lib/evilution/mutator/base.rb', line 140 def self.operator_name class_name = name || "anonymous" class_name.split("::").last .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .downcase end |
.parsed_tree_for(file_path, file_source) ⇒ 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.
150 151 152 153 154 155 156 157 158 |
# File 'lib/evilution/mutator/base.rb', line 150 def self.parsed_tree_for(file_path, file_source) cache = Evilution::Mutator::Base.instance_variable_get(:@parse_cache) entry = cache[file_path] return entry[:tree] if entry && entry[:source_hash] == file_source.hash tree = Prism.parse(file_source).value cache[file_path] = { source_hash: file_source.hash, tree: tree } tree end |
Instance Method Details
#call(subject, filter: nil) ⇒ 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.
33 34 35 36 37 38 39 40 |
# File 'lib/evilution/mutator/base.rb', line 33 def call(subject, filter: nil) @subject = subject @file_source = File.read(subject.file_path) @mutations = [] @filter = filter visit(subject.node) @mutations end |