Class: MetaCommit::Extension::RubySupport::Diffs::ClassCreation
- Inherits:
-
Diff
- Object
- Contracts::Diff
- Diff
- MetaCommit::Extension::RubySupport::Diffs::ClassCreation
- Defined in:
- lib/meta_commit_ruby_support/diffs/class_creation.rb
Constant Summary
Constants inherited from Diff
Instance Method Summary collapse
Methods inherited from Diff
#inspect, #supports_parser?, #to_s, #type_addition?, #type_deletion?, #type_replace?
Methods included from Helpers::ContextualAstAccessor
#contextual_ast_has_target_node, #is_in_context_of_class?, #is_in_context_of_method?, #is_in_context_of_module?, #is_name_of_class?, #is_name_of_module?, #name_of_context_class, #name_of_context_method, #name_of_context_module, #path_to_component
Instance Method Details
#string_representation ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/meta_commit_ruby_support/diffs/class_creation.rb', line 9 def string_representation if change_context.new_contextual_ast.target_node.is_class? if is_in_context_of_module?(change_context.new_contextual_ast) return "create #{name_of_context_module(change_context.new_contextual_ast)}::#{change_context.new_contextual_ast.target_node.class_name}" end return "create class #{change_context.new_contextual_ast.target_node.class_name}" end if is_in_context_of_module?(change_context.new_contextual_ast) return "create #{name_of_context_module(change_context.new_contextual_ast)}::#{name_of_context_class(change_context.new_contextual_ast)}" end "create class #{name_of_context_class(change_context.new_contextual_ast)}" end |
#supports_change(context) ⇒ Object
3 4 5 6 7 |
# File 'lib/meta_commit_ruby_support/diffs/class_creation.rb', line 3 def supports_change(context) context.type == MetaCommit::Extension::RubySupport::Diffs::Diff::TYPE_ADDITION && contextual_ast_has_target_node(context.new_contextual_ast) && (context.new_contextual_ast.target_node.is_class? || is_name_of_class?(context.new_contextual_ast)) end |