Class: Pact::Matchers::UnixDiffFormatter
- Inherits:
-
Object
- Object
- Pact::Matchers::UnixDiffFormatter
- Includes:
- JRubySupport
- Defined in:
- lib/pact/matchers/unix_diff_formatter.rb
Defined Under Namespace
Classes: NoDifferenceDecorator, RegexpDecorator
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(diff, options = {}) ⇒ UnixDiffFormatter
constructor
A new instance of UnixDiffFormatter.
- #to_s ⇒ Object
Methods included from JRubySupport
#fix_blank_lines_in_empty_hashes
Constructor Details
#initialize(diff, options = {}) ⇒ UnixDiffFormatter
Returns a new instance of UnixDiffFormatter.
11 12 13 14 15 16 |
# File 'lib/pact/matchers/unix_diff_formatter.rb', line 11 def initialize diff, = {} @diff = diff @colour = .fetch(:colour, false) @include_explanation = .fetch(:include_explanation, true) @differ = Pact::Matchers::Differ.new(@colour) end |
Class Method Details
.call(diff, options = {colour: Pact.configuration.color_enabled}) ⇒ Object
18 19 20 |
# File 'lib/pact/matchers/unix_diff_formatter.rb', line 18 def self.call diff, = {colour: Pact.configuration.color_enabled} new(diff, ).call end |
Instance Method Details
#call ⇒ Object
22 23 24 |
# File 'lib/pact/matchers/unix_diff_formatter.rb', line 22 def call to_s end |
#to_s ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/pact/matchers/unix_diff_formatter.rb', line 26 def to_s expected = generate_string(diff, :expected) actual = generate_string(diff, :actual) suffix = @include_explanation ? "\n" + key : '' string_diff = remove_comma_from_end_of_arrays(@differ.diff_as_string(actual, expected).lstrip) string_diff + suffix end |