Class: MetaCommit::Extension::RubySupport::Diffs::ModuleCreation

Inherits:
Diff
  • Object
show all
Defined in:
lib/meta_commit_ruby_support/diffs/module_creation.rb

Constant Summary

Constants inherited from Diff

Diff::SUPPORTED_PARSERS, Diff::TYPE_ADDITION, Diff::TYPE_DELETION, Diff::TYPE_REPLACE

Instance Attribute Summary

Attributes inherited from Diff

#commit_new, #commit_old, #diff_type, #new_ast_path, #new_file, #new_lineno, #old_ast_path, #old_file, #old_lineno

Instance Method Summary collapse

Methods inherited from Diff

#inspect, #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, #supports_parser?, #to_s, #type_addition?, #type_deletion?, #type_replace?

Instance Method Details

#string_representationObject



7
8
9
10
11
12
# File 'lib/meta_commit_ruby_support/diffs/module_creation.rb', line 7

def string_representation
  if @new_ast_path.target_node.is_module?
    return "created module #{new_ast_path.target_node.module_name}"
  end
  "created module #{name_of_context_module(new_ast_path)}"
end

#supports_change(type, old_file_name, new_file_name, old_ast_path, new_ast_path) ⇒ Object



3
4
5
# File 'lib/meta_commit_ruby_support/diffs/module_creation.rb', line 3

def supports_change(type, old_file_name, new_file_name, old_ast_path, new_ast_path)
  type == MetaCommit::Extension::RubySupport::Diffs::Diff::TYPE_ADDITION && !new_ast_path.target_node.empty_ast? && (new_ast_path.target_node.is_module? || is_name_of_module?(new_ast_path))
end