Class: Unparser::CLI::Source

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium::Flat, NodeHelpers
Defined in:
lib/unparser/cli/source.rb

Overview

Source representation for CLI sources

ignore :reek:TooManyMethods

Direct Known Subclasses

File, Node, String

Defined Under Namespace

Classes: File, Generated, Node, String

Instance Method Summary collapse

Methods included from NodeHelpers

#n, #s

Instance Method Details

#reportString

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 error report

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/unparser/cli/source.rb', line 55

def report
  if original_ast && generated_ast
    report_with_ast_diff
  elsif !original_ast
    report_original
  elsif !generated.success?
    report_unparser
  elsif !generated_ast
    report_generated
  else
    raise
  end
end

#success?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.

Test if source could be unparsed successfully

Returns:

  • (Boolean)


45
46
47
# File 'lib/unparser/cli/source.rb', line 45

def success?
  generated.success? && original_ast && generated_ast && original_ast.eql?(generated_ast)
end