super_diff 0.4.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +23 -10
 - data/lib/super_diff.rb +20 -11
 - data/lib/super_diff/active_record.rb +20 -24
 - data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +3 -3
 - data/lib/super_diff/active_record/differs/active_record_relation.rb +3 -5
 - data/lib/super_diff/active_record/object_inspection/inspectors/active_record_model.rb +32 -22
 - data/lib/super_diff/active_record/object_inspection/inspectors/active_record_relation.rb +17 -7
 - data/lib/super_diff/active_record/operation_tree_builders.rb +14 -0
 - data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_model.rb +2 -2
 - data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_relation.rb +4 -4
 - data/lib/super_diff/active_record/{operation_sequences.rb → operation_trees.rb} +2 -2
 - data/lib/super_diff/active_record/{operation_sequences → operation_trees}/active_record_relation.rb +2 -2
 - data/lib/super_diff/active_support.rb +16 -19
 - data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +3 -3
 - data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +3 -5
 - data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +17 -7
 - data/lib/super_diff/active_support/operation_tree_builders.rb +10 -0
 - data/lib/super_diff/active_support/{operational_sequencers → operation_tree_builders}/hash_with_indifferent_access.rb +2 -2
 - data/lib/super_diff/active_support/{operation_sequences.rb → operation_trees.rb} +2 -2
 - data/lib/super_diff/active_support/{operation_sequences → operation_trees}/hash_with_indifferent_access.rb +2 -2
 - data/lib/super_diff/configuration.rb +60 -0
 - data/lib/super_diff/diff_formatters.rb +3 -3
 - data/lib/super_diff/diff_formatters/array.rb +3 -3
 - data/lib/super_diff/diff_formatters/base.rb +3 -2
 - data/lib/super_diff/diff_formatters/collection.rb +2 -2
 - data/lib/super_diff/diff_formatters/custom_object.rb +3 -3
 - data/lib/super_diff/diff_formatters/default_object.rb +6 -8
 - data/lib/super_diff/diff_formatters/defaults.rb +10 -0
 - data/lib/super_diff/diff_formatters/hash.rb +3 -3
 - data/lib/super_diff/diff_formatters/main.rb +41 -0
 - data/lib/super_diff/diff_formatters/multiline_string.rb +3 -3
 - data/lib/super_diff/differs.rb +4 -11
 - data/lib/super_diff/differs/array.rb +2 -11
 - data/lib/super_diff/differs/base.rb +20 -3
 - data/lib/super_diff/differs/custom_object.rb +2 -11
 - data/lib/super_diff/differs/default_object.rb +2 -8
 - data/lib/super_diff/differs/defaults.rb +12 -0
 - data/lib/super_diff/differs/hash.rb +2 -11
 - data/lib/super_diff/differs/main.rb +48 -0
 - data/lib/super_diff/differs/multiline_string.rb +2 -14
 - data/lib/super_diff/differs/time_like.rb +15 -0
 - data/lib/super_diff/equality_matchers.rb +3 -9
 - data/lib/super_diff/equality_matchers/array.rb +1 -7
 - data/lib/super_diff/equality_matchers/base.rb +1 -1
 - data/lib/super_diff/equality_matchers/default.rb +1 -7
 - data/lib/super_diff/equality_matchers/defaults.rb +12 -0
 - data/lib/super_diff/equality_matchers/hash.rb +1 -7
 - data/lib/super_diff/equality_matchers/main.rb +21 -0
 - data/lib/super_diff/equality_matchers/multiline_string.rb +1 -7
 - data/lib/super_diff/errors.rb +16 -0
 - data/lib/super_diff/errors/no_diff_formatter_available_error.rb +21 -0
 - data/lib/super_diff/errors/no_differ_available_error.rb +24 -0
 - data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +22 -0
 - data/lib/super_diff/implementation_checks.rb +19 -0
 - data/lib/super_diff/object_inspection.rb +1 -10
 - data/lib/super_diff/object_inspection/inspection_tree.rb +6 -2
 - data/lib/super_diff/object_inspection/inspectors.rb +5 -1
 - data/lib/super_diff/object_inspection/inspectors/array.rb +20 -10
 - data/lib/super_diff/object_inspection/inspectors/base.rb +36 -0
 - data/lib/super_diff/object_inspection/inspectors/custom_object.rb +24 -14
 - data/lib/super_diff/object_inspection/inspectors/default_object.rb +44 -30
 - data/lib/super_diff/object_inspection/inspectors/defaults.rb +15 -0
 - data/lib/super_diff/object_inspection/inspectors/hash.rb +20 -10
 - data/lib/super_diff/object_inspection/inspectors/main.rb +35 -0
 - data/lib/super_diff/object_inspection/inspectors/primitive.rb +20 -5
 - data/lib/super_diff/object_inspection/inspectors/string.rb +15 -5
 - data/lib/super_diff/object_inspection/inspectors/time_like.rb +23 -0
 - data/lib/super_diff/object_inspection/nodes/inspection.rb +9 -2
 - data/lib/super_diff/operation_tree_builders.rb +18 -0
 - data/lib/super_diff/{operational_sequencers → operation_tree_builders}/array.rb +38 -59
 - data/lib/super_diff/operation_tree_builders/base.rb +98 -0
 - data/lib/super_diff/{operational_sequencers → operation_tree_builders}/custom_object.rb +3 -3
 - data/lib/super_diff/{operational_sequencers → operation_tree_builders}/default_object.rb +8 -3
 - data/lib/super_diff/operation_tree_builders/defaults.rb +5 -0
 - data/lib/super_diff/operation_tree_builders/hash.rb +226 -0
 - data/lib/super_diff/operation_tree_builders/main.rb +42 -0
 - data/lib/super_diff/{operational_sequencers → operation_tree_builders}/multiline_string.rb +3 -3
 - data/lib/super_diff/operation_tree_builders/time_like.rb +34 -0
 - data/lib/super_diff/operation_trees.rb +13 -0
 - data/lib/super_diff/{operation_sequences → operation_trees}/array.rb +5 -1
 - data/lib/super_diff/{operation_sequences → operation_trees}/base.rb +9 -1
 - data/lib/super_diff/{operation_sequences → operation_trees}/custom_object.rb +5 -1
 - data/lib/super_diff/{operation_sequences → operation_trees}/default_object.rb +10 -8
 - data/lib/super_diff/operation_trees/defaults.rb +5 -0
 - data/lib/super_diff/{operation_sequences → operation_trees}/hash.rb +5 -1
 - data/lib/super_diff/operation_trees/main.rb +35 -0
 - data/lib/super_diff/operation_trees/multiline_string.rb +18 -0
 - data/lib/super_diff/operations/unary_operation.rb +3 -0
 - data/lib/super_diff/recursion_guard.rb +2 -0
 - data/lib/super_diff/rspec.rb +45 -13
 - data/lib/super_diff/rspec/augmented_matcher.rb +1 -1
 - data/lib/super_diff/rspec/differ.rb +2 -17
 - data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +2 -7
 - data/lib/super_diff/rspec/differs/collection_including.rb +2 -7
 - data/lib/super_diff/rspec/differs/hash_including.rb +2 -7
 - data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -7
 - data/lib/super_diff/rspec/matcher_text_builders/match.rb +1 -1
 - data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +1 -1
 - data/lib/super_diff/rspec/matcher_text_template.rb +1 -1
 - data/lib/super_diff/rspec/monkey_patches.rb +4 -2
 - data/lib/super_diff/rspec/object_inspection.rb +0 -1
 - data/lib/super_diff/rspec/object_inspection/inspectors.rb +16 -0
 - data/lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb +17 -8
 - data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +15 -9
 - data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +20 -10
 - data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +23 -0
 - data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +23 -0
 - data/lib/super_diff/rspec/object_inspection/inspectors/object_having_attributes.rb +20 -11
 - data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +13 -0
 - data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +29 -0
 - data/lib/super_diff/rspec/operation_tree_builders.rb +22 -0
 - data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_containing_exactly.rb +5 -5
 - data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_including.rb +2 -2
 - data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/hash_including.rb +3 -11
 - data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/object_having_attributes.rb +4 -8
 - data/lib/super_diff/version.rb +1 -1
 - data/spec/integration/rspec/have_attributes_matcher_spec.rb +354 -227
 - data/spec/integration/rspec/include_matcher_spec.rb +2 -2
 - data/spec/integration/rspec/match_array_matcher_spec.rb +42 -0
 - data/spec/integration/rspec/unhandled_errors_spec.rb +68 -12
 - data/spec/support/command_runner.rb +3 -0
 - data/spec/support/integration/helpers.rb +12 -96
 - data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +14 -29
 - data/spec/support/integration/test_programs/base.rb +120 -0
 - data/spec/support/integration/test_programs/plain.rb +13 -0
 - data/spec/support/integration/test_programs/rspec_active_record.rb +17 -0
 - data/spec/support/integration/test_programs/rspec_rails.rb +17 -0
 - data/spec/support/models/active_record/person.rb +4 -11
 - data/spec/support/models/active_record/shipping_address.rb +10 -14
 - data/spec/support/object_id.rb +6 -5
 - data/spec/unit/{equality_matcher_spec.rb → equality_matchers/main_spec.rb} +157 -1
 - data/spec/unit/object_inspection_spec.rb +77 -1
 - data/spec/unit/rspec/matchers/raise_error_spec.rb +16 -0
 - data/super_diff.gemspec +2 -1
 - metadata +74 -53
 - data/lib/super_diff/active_record/object_inspection/map_extension.rb +0 -18
 - data/lib/super_diff/active_record/operational_sequencers.rb +0 -14
 - data/lib/super_diff/active_support/object_inspection/map_extension.rb +0 -15
 - data/lib/super_diff/active_support/operational_sequencers.rb +0 -10
 - data/lib/super_diff/diff_formatter.rb +0 -32
 - data/lib/super_diff/differ.rb +0 -51
 - data/lib/super_diff/differs/time.rb +0 -24
 - data/lib/super_diff/equality_matcher.rb +0 -32
 - data/lib/super_diff/no_differ_available_error.rb +0 -22
 - data/lib/super_diff/no_operational_sequencer_available_error.rb +0 -20
 - data/lib/super_diff/object_inspection/inspector.rb +0 -27
 - data/lib/super_diff/object_inspection/inspectors/time.rb +0 -13
 - data/lib/super_diff/object_inspection/map.rb +0 -30
 - data/lib/super_diff/operation_sequences.rb +0 -9
 - data/lib/super_diff/operational_sequencer.rb +0 -48
 - data/lib/super_diff/operational_sequencers.rb +0 -17
 - data/lib/super_diff/operational_sequencers/base.rb +0 -89
 - data/lib/super_diff/operational_sequencers/hash.rb +0 -85
 - data/lib/super_diff/operational_sequencers/time_like.rb +0 -30
 - data/lib/super_diff/rspec/configuration.rb +0 -31
 - data/lib/super_diff/rspec/object_inspection/map_extension.rb +0 -23
 - data/lib/super_diff/rspec/operational_sequencers.rb +0 -22
 
| 
         @@ -2,8 +2,8 @@ module SuperDiff 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module ActiveSupport
         
     | 
| 
       3 
3 
     | 
    
         
             
                module DiffFormatters
         
     | 
| 
       4 
4 
     | 
    
         
             
                  class HashWithIndifferentAccess < SuperDiff::DiffFormatters::Base
         
     | 
| 
       5 
     | 
    
         
            -
                    def self.applies_to?( 
     | 
| 
       6 
     | 
    
         
            -
                       
     | 
| 
      
 5 
     | 
    
         
            +
                    def self.applies_to?(operation_tree)
         
     | 
| 
      
 6 
     | 
    
         
            +
                      operation_tree.is_a?(OperationTrees::HashWithIndifferentAccess)
         
     | 
| 
       7 
7 
     | 
    
         
             
                    end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                    def call
         
     | 
| 
         @@ -25,7 +25,7 @@ module SuperDiff 
     | 
|
| 
       25 
25 
     | 
    
         
             
                            "#{key.inspect} => "
         
     | 
| 
       26 
26 
     | 
    
         
             
                          end
         
     | 
| 
       27 
27 
     | 
    
         
             
                        },
         
     | 
| 
       28 
     | 
    
         
            -
                         
     | 
| 
      
 28 
     | 
    
         
            +
                        operation_tree: operation_tree,
         
     | 
| 
       29 
29 
     | 
    
         
             
                        indent_level: indent_level,
         
     | 
| 
       30 
30 
     | 
    
         
             
                        add_comma: add_comma?,
         
     | 
| 
       31 
31 
     | 
    
         
             
                      )
         
     | 
| 
         @@ -15,19 +15,17 @@ module SuperDiff 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                    def call
         
     | 
| 
       17 
17 
     | 
    
         
             
                      DiffFormatters::HashWithIndifferentAccess.call(
         
     | 
| 
       18 
     | 
    
         
            -
                         
     | 
| 
      
 18 
     | 
    
         
            +
                        operation_tree,
         
     | 
| 
       19 
19 
     | 
    
         
             
                        indent_level: indent_level,
         
     | 
| 
       20 
20 
     | 
    
         
             
                      )
         
     | 
| 
       21 
21 
     | 
    
         
             
                    end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                    private
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                    def  
     | 
| 
       26 
     | 
    
         
            -
                       
     | 
| 
      
 25 
     | 
    
         
            +
                    def operation_tree
         
     | 
| 
      
 26 
     | 
    
         
            +
                      OperationTreeBuilders::HashWithIndifferentAccess.call(
         
     | 
| 
       27 
27 
     | 
    
         
             
                        expected: expected,
         
     | 
| 
       28 
28 
     | 
    
         
             
                        actual: actual,
         
     | 
| 
       29 
     | 
    
         
            -
                        extra_operational_sequencer_classes: extra_operational_sequencer_classes,
         
     | 
| 
       30 
     | 
    
         
            -
                        extra_diff_formatter_classes: extra_diff_formatter_classes,
         
     | 
| 
       31 
29 
     | 
    
         
             
                      )
         
     | 
| 
       32 
30 
     | 
    
         
             
                    end
         
     | 
| 
       33 
31 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb
    CHANGED
    
    | 
         @@ -2,15 +2,25 @@ module SuperDiff 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module ActiveSupport
         
     | 
| 
       3 
3 
     | 
    
         
             
                module ObjectInspection
         
     | 
| 
       4 
4 
     | 
    
         
             
                  module Inspectors
         
     | 
| 
       5 
     | 
    
         
            -
                    HashWithIndifferentAccess  
     | 
| 
       6 
     | 
    
         
            -
                       
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                      nested do |hash|
         
     | 
| 
       9 
     | 
    
         
            -
                        insert_hash_inspection_of(hash)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    class HashWithIndifferentAccess < SuperDiff::ObjectInspection::Inspectors::Base
         
     | 
| 
      
 6 
     | 
    
         
            +
                      def self.applies_to?(value)
         
     | 
| 
      
 7 
     | 
    
         
            +
                        value.is_a?(::HashWithIndifferentAccess)
         
     | 
| 
       10 
8 
     | 
    
         
             
                      end
         
     | 
| 
       11 
9 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                       
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
                      protected
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                      def inspection_tree
         
     | 
| 
      
 13 
     | 
    
         
            +
                        SuperDiff::ObjectInspection::InspectionTree.new do
         
     | 
| 
      
 14 
     | 
    
         
            +
                          add_text "#<HashWithIndifferentAccess {"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                          nested do |hash|
         
     | 
| 
      
 17 
     | 
    
         
            +
                            insert_hash_inspection_of(hash)
         
     | 
| 
      
 18 
     | 
    
         
            +
                          end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                          add_break " "
         
     | 
| 
      
 21 
     | 
    
         
            +
                          add_text "}>"
         
     | 
| 
      
 22 
     | 
    
         
            +
                        end
         
     | 
| 
      
 23 
     | 
    
         
            +
                      end
         
     | 
| 
       14 
24 
     | 
    
         
             
                    end
         
     | 
| 
       15 
25 
     | 
    
         
             
                  end
         
     | 
| 
       16 
26 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module ActiveSupport
         
     | 
| 
       3 
     | 
    
         
            -
                module  
     | 
| 
       4 
     | 
    
         
            -
                  class HashWithIndifferentAccess < SuperDiff:: 
     | 
| 
      
 3 
     | 
    
         
            +
                module OperationTreeBuilders
         
     | 
| 
      
 4 
     | 
    
         
            +
                  class HashWithIndifferentAccess < SuperDiff::OperationTreeBuilders::Hash
         
     | 
| 
       5 
5 
     | 
    
         
             
                    def initialize(expected:, actual:, **rest)
         
     | 
| 
       6 
6 
     | 
    
         
             
                      super
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
         @@ -1,9 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module ActiveSupport
         
     | 
| 
       3 
     | 
    
         
            -
                module  
     | 
| 
      
 3 
     | 
    
         
            +
                module OperationTrees
         
     | 
| 
       4 
4 
     | 
    
         
             
                  autoload(
         
     | 
| 
       5 
5 
     | 
    
         
             
                    :HashWithIndifferentAccess,
         
     | 
| 
       6 
     | 
    
         
            -
                    "super_diff/active_support/ 
     | 
| 
      
 6 
     | 
    
         
            +
                    "super_diff/active_support/operation_trees/hash_with_indifferent_access",
         
     | 
| 
       7 
7 
     | 
    
         
             
                  )
         
     | 
| 
       8 
8 
     | 
    
         
             
                end
         
     | 
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module ActiveSupport
         
     | 
| 
       3 
     | 
    
         
            -
                module  
     | 
| 
       4 
     | 
    
         
            -
                  class HashWithIndifferentAccess < SuperDiff:: 
     | 
| 
      
 3 
     | 
    
         
            +
                module OperationTrees
         
     | 
| 
      
 4 
     | 
    
         
            +
                  class HashWithIndifferentAccess < SuperDiff::OperationTrees::Base
         
     | 
| 
       5 
5 
     | 
    
         
             
                    def to_diff(indent_level:, collection_prefix:, add_comma:)
         
     | 
| 
       6 
6 
     | 
    
         
             
                      DiffFormatters::HashWithIndifferentAccess.call(
         
     | 
| 
       7 
7 
     | 
    
         
             
                        self,
         
     | 
| 
         @@ -0,0 +1,60 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module SuperDiff
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Configuration
         
     | 
| 
      
 3 
     | 
    
         
            +
                attr_reader(
         
     | 
| 
      
 4 
     | 
    
         
            +
                  :extra_differ_classes,
         
     | 
| 
      
 5 
     | 
    
         
            +
                  :extra_operation_tree_builder_classes,
         
     | 
| 
      
 6 
     | 
    
         
            +
                  :extra_operation_tree_classes,
         
     | 
| 
      
 7 
     | 
    
         
            +
                  :extra_diff_formatter_classes,
         
     | 
| 
      
 8 
     | 
    
         
            +
                  :extra_inspector_classes,
         
     | 
| 
      
 9 
     | 
    
         
            +
                )
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @extra_differ_classes = [].freeze
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @extra_operation_tree_builder_classes = [].freeze
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @extra_operation_tree_classes = [].freeze
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @extra_diff_formatter_classes = [].freeze
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @extra_inspector_classes = [].freeze
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                def add_extra_differ_classes(*classes)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @extra_differ_classes = (@extra_differ_classes + classes).freeze
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
                alias_method :add_extra_differ_class, :add_extra_differ_classes
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def add_extra_operation_tree_builder_classes(*classes)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @extra_operation_tree_builder_classes =
         
     | 
| 
      
 26 
     | 
    
         
            +
                    (@extra_operation_tree_builder_classes + classes).freeze
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
                alias_method(
         
     | 
| 
      
 29 
     | 
    
         
            +
                  :add_extra_operation_tree_builder_class,
         
     | 
| 
      
 30 
     | 
    
         
            +
                  :add_extra_operation_tree_builder_classes,
         
     | 
| 
      
 31 
     | 
    
         
            +
                )
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def add_extra_operation_tree_classes(*classes)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @extra_operation_tree_classes =
         
     | 
| 
      
 35 
     | 
    
         
            +
                    (@extra_operation_tree_classes + classes).freeze
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
                alias_method(
         
     | 
| 
      
 38 
     | 
    
         
            +
                  :add_extra_operation_tree_class,
         
     | 
| 
      
 39 
     | 
    
         
            +
                  :add_extra_operation_tree_classes,
         
     | 
| 
      
 40 
     | 
    
         
            +
                )
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                def add_extra_diff_formatter_classes(*classes)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @extra_diff_formatter_classes =
         
     | 
| 
      
 44 
     | 
    
         
            +
                    (@extra_diff_formatter_classes + classes).freeze
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
                alias_method(
         
     | 
| 
      
 47 
     | 
    
         
            +
                  :add_extra_diff_formatter_class,
         
     | 
| 
      
 48 
     | 
    
         
            +
                  :add_extra_diff_formatter_classes,
         
     | 
| 
      
 49 
     | 
    
         
            +
                )
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                def add_extra_inspector_classes(*classes)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  @extra_inspector_classes =
         
     | 
| 
      
 53 
     | 
    
         
            +
                    (@extra_inspector_classes + classes).freeze
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
                alias_method(
         
     | 
| 
      
 56 
     | 
    
         
            +
                  :add_extra_inspector_class,
         
     | 
| 
      
 57 
     | 
    
         
            +
                  :add_extra_inspector_classes,
         
     | 
| 
      
 58 
     | 
    
         
            +
                )
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -6,9 +6,9 @@ module SuperDiff 
     | 
|
| 
       6 
6 
     | 
    
         
             
                autoload :CustomObject, "super_diff/diff_formatters/custom_object"
         
     | 
| 
       7 
7 
     | 
    
         
             
                autoload :DefaultObject, "super_diff/diff_formatters/default_object"
         
     | 
| 
       8 
8 
     | 
    
         
             
                autoload :Hash, "super_diff/diff_formatters/hash"
         
     | 
| 
      
 9 
     | 
    
         
            +
                autoload :Main, "super_diff/diff_formatters/main"
         
     | 
| 
       9 
10 
     | 
    
         
             
                autoload :MultilineString, "super_diff/diff_formatters/multiline_string"
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                # TODO: Why doesn't this include CustomObject and DefaultObject?
         
     | 
| 
       12 
     | 
    
         
            -
                DEFAULTS = [Array, Hash, MultilineString].freeze
         
     | 
| 
       13 
11 
     | 
    
         
             
              end
         
     | 
| 
       14 
12 
     | 
    
         
             
            end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            require "super_diff/diff_formatters/defaults"
         
     | 
| 
         @@ -1,8 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module DiffFormatters
         
     | 
| 
       3 
3 
     | 
    
         
             
                class Array < Base
         
     | 
| 
       4 
     | 
    
         
            -
                  def self.applies_to?( 
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
      
 4 
     | 
    
         
            +
                  def self.applies_to?(operation_tree)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    operation_tree.is_a?(OperationTrees::Array)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def call
         
     | 
| 
         @@ -11,7 +11,7 @@ module SuperDiff 
     | 
|
| 
       11 
11 
     | 
    
         
             
                      close_token: "]",
         
     | 
| 
       12 
12 
     | 
    
         
             
                      collection_prefix: collection_prefix,
         
     | 
| 
       13 
13 
     | 
    
         
             
                      build_item_prefix: proc { "" },
         
     | 
| 
       14 
     | 
    
         
            -
                       
     | 
| 
      
 14 
     | 
    
         
            +
                      operation_tree: operation_tree,
         
     | 
| 
       15 
15 
     | 
    
         
             
                      indent_level: indent_level,
         
     | 
| 
       16 
16 
     | 
    
         
             
                      add_comma: add_comma?,
         
     | 
| 
       17 
17 
     | 
    
         
             
                    )
         
     | 
| 
         @@ -1,14 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module DiffFormatters
         
     | 
| 
       3 
3 
     | 
    
         
             
                class Base
         
     | 
| 
       4 
     | 
    
         
            -
                  def self.applies_to?( 
     | 
| 
      
 4 
     | 
    
         
            +
                  def self.applies_to?(*)
         
     | 
| 
       5 
5 
     | 
    
         
             
                    raise NotImplementedError
         
     | 
| 
       6 
6 
     | 
    
         
             
                  end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
                  include ImplementationChecks
         
     | 
| 
       8 
9 
     | 
    
         
             
                  extend AttrExtras.mixin
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
                  method_object(
         
     | 
| 
       11 
     | 
    
         
            -
                    : 
     | 
| 
      
 12 
     | 
    
         
            +
                    :operation_tree,
         
     | 
| 
       12 
13 
     | 
    
         
             
                    [
         
     | 
| 
       13 
14 
     | 
    
         
             
                      :indent_level!,
         
     | 
| 
       14 
15 
     | 
    
         
             
                      collection_prefix: "",
         
     | 
| 
         @@ -10,7 +10,7 @@ module SuperDiff 
     | 
|
| 
       10 
10 
     | 
    
         
             
                    [
         
     | 
| 
       11 
11 
     | 
    
         
             
                      :open_token!,
         
     | 
| 
       12 
12 
     | 
    
         
             
                      :close_token!,
         
     | 
| 
       13 
     | 
    
         
            -
                      : 
     | 
| 
      
 13 
     | 
    
         
            +
                      :operation_tree!,
         
     | 
| 
       14 
14 
     | 
    
         
             
                      :indent_level!,
         
     | 
| 
       15 
15 
     | 
    
         
             
                      :add_comma!,
         
     | 
| 
       16 
16 
     | 
    
         
             
                      :collection_prefix!,
         
     | 
| 
         @@ -35,7 +35,7 @@ module SuperDiff 
     | 
|
| 
       35 
35 
     | 
    
         
             
                  end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                  def contents
         
     | 
| 
       38 
     | 
    
         
            -
                     
     | 
| 
      
 38 
     | 
    
         
            +
                    operation_tree.map do |operation|
         
     | 
| 
       39 
39 
     | 
    
         
             
                      if operation.name == :change
         
     | 
| 
       40 
40 
     | 
    
         
             
                        handle_change_operation(operation)
         
     | 
| 
       41 
41 
     | 
    
         
             
                      else
         
     | 
| 
         @@ -1,8 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module DiffFormatters
         
     | 
| 
       3 
3 
     | 
    
         
             
                class CustomObject < DefaultObject
         
     | 
| 
       4 
     | 
    
         
            -
                  def self.applies_to?( 
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
      
 4 
     | 
    
         
            +
                  def self.applies_to?(operation_tree)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    operation_tree.is_a?(OperationTrees::CustomObject)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def call
         
     | 
| 
         @@ -20,7 +20,7 @@ module SuperDiff 
     | 
|
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                        "#{key}: "
         
     | 
| 
       22 
22 
     | 
    
         
             
                      },
         
     | 
| 
       23 
     | 
    
         
            -
                       
     | 
| 
      
 23 
     | 
    
         
            +
                      operation_tree: operation_tree,
         
     | 
| 
       24 
24 
     | 
    
         
             
                      indent_level: indent_level,
         
     | 
| 
       25 
25 
     | 
    
         
             
                      add_comma: add_comma?,
         
     | 
| 
       26 
26 
     | 
    
         
             
                    )
         
     | 
| 
         @@ -1,12 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module DiffFormatters
         
     | 
| 
       3 
3 
     | 
    
         
             
                class DefaultObject < Base
         
     | 
| 
       4 
     | 
    
         
            -
                  def self.applies_to?( 
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
      
 4 
     | 
    
         
            +
                  def self.applies_to?(operation_tree)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    operation_tree.is_a?(OperationTrees::DefaultObject)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                  def initialize( 
     | 
| 
       9 
     | 
    
         
            -
                    super( 
     | 
| 
      
 8 
     | 
    
         
            +
                  def initialize(operation_tree, value_class: nil, **rest)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    super(operation_tree, **rest)
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
                    @value_class = value_class
         
     | 
| 
       12 
12 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -26,7 +26,7 @@ module SuperDiff 
     | 
|
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
                        "@#{key}="
         
     | 
| 
       28 
28 
     | 
    
         
             
                      },
         
     | 
| 
       29 
     | 
    
         
            -
                       
     | 
| 
      
 29 
     | 
    
         
            +
                      operation_tree: operation_tree,
         
     | 
| 
       30 
30 
     | 
    
         
             
                      indent_level: indent_level,
         
     | 
| 
       31 
31 
     | 
    
         
             
                      add_comma: add_comma?,
         
     | 
| 
       32 
32 
     | 
    
         
             
                    )
         
     | 
| 
         @@ -38,9 +38,7 @@ module SuperDiff 
     | 
|
| 
       38 
38 
     | 
    
         
             
                    if @value_class
         
     | 
| 
       39 
39 
     | 
    
         
             
                      @value_class
         
     | 
| 
       40 
40 
     | 
    
         
             
                    else
         
     | 
| 
       41 
     | 
    
         
            -
                       
     | 
| 
       42 
     | 
    
         
            -
                        "You must override #value_class in your subclass.",
         
     | 
| 
       43 
     | 
    
         
            -
                      )
         
     | 
| 
      
 41 
     | 
    
         
            +
                      unimplemented_instance_method!
         
     | 
| 
       44 
42 
     | 
    
         
             
                    end
         
     | 
| 
       45 
43 
     | 
    
         
             
                  end
         
     | 
| 
       46 
44 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,8 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module DiffFormatters
         
     | 
| 
       3 
3 
     | 
    
         
             
                class Hash < Base
         
     | 
| 
       4 
     | 
    
         
            -
                  def self.applies_to?( 
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
      
 4 
     | 
    
         
            +
                  def self.applies_to?(operation_tree)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    operation_tree.is_a?(OperationTrees::Hash)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def call
         
     | 
| 
         @@ -24,7 +24,7 @@ module SuperDiff 
     | 
|
| 
       24 
24 
     | 
    
         
             
                          "#{key.inspect} => "
         
     | 
| 
       25 
25 
     | 
    
         
             
                        end
         
     | 
| 
       26 
26 
     | 
    
         
             
                      },
         
     | 
| 
       27 
     | 
    
         
            -
                       
     | 
| 
      
 27 
     | 
    
         
            +
                      operation_tree: operation_tree,
         
     | 
| 
       28 
28 
     | 
    
         
             
                      indent_level: indent_level,
         
     | 
| 
       29 
29 
     | 
    
         
             
                      add_comma: add_comma?,
         
     | 
| 
       30 
30 
     | 
    
         
             
                    )
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module SuperDiff
         
     | 
| 
      
 2 
     | 
    
         
            +
              module DiffFormatters
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Main
         
     | 
| 
      
 4 
     | 
    
         
            +
                  extend AttrExtras.mixin
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  method_object(
         
     | 
| 
      
 7 
     | 
    
         
            +
                    :operation_tree,
         
     | 
| 
      
 8 
     | 
    
         
            +
                    [
         
     | 
| 
      
 9 
     | 
    
         
            +
                      :indent_level!,
         
     | 
| 
      
 10 
     | 
    
         
            +
                      add_comma: false,
         
     | 
| 
      
 11 
     | 
    
         
            +
                      value_class: nil,
         
     | 
| 
      
 12 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 13 
     | 
    
         
            +
                  )
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def call
         
     | 
| 
      
 16 
     | 
    
         
            +
                    if resolved_class
         
     | 
| 
      
 17 
     | 
    
         
            +
                      resolved_class.call(
         
     | 
| 
      
 18 
     | 
    
         
            +
                        operation_tree,
         
     | 
| 
      
 19 
     | 
    
         
            +
                        indent_level: indent_level,
         
     | 
| 
      
 20 
     | 
    
         
            +
                        add_comma: add_comma?,
         
     | 
| 
      
 21 
     | 
    
         
            +
                        value_class: value_class,
         
     | 
| 
      
 22 
     | 
    
         
            +
                      )
         
     | 
| 
      
 23 
     | 
    
         
            +
                    else
         
     | 
| 
      
 24 
     | 
    
         
            +
                      raise NoDiffFormatterAvailableError.create(operation_tree)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  private
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  attr_query :add_comma?
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def resolved_class
         
     | 
| 
      
 33 
     | 
    
         
            +
                    available_classes.find { |klass| klass.applies_to?(operation_tree) }
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  def available_classes
         
     | 
| 
      
 37 
     | 
    
         
            +
                    DEFAULTS + SuperDiff.configuration.extra_diff_formatter_classes
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,8 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module SuperDiff
         
     | 
| 
       2 
2 
     | 
    
         
             
              module DiffFormatters
         
     | 
| 
       3 
3 
     | 
    
         
             
                class MultilineString < Base
         
     | 
| 
       4 
     | 
    
         
            -
                  def self.applies_to?( 
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
      
 4 
     | 
    
         
            +
                  def self.applies_to?(operation_tree)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    operation_tree.is_a?(OperationTrees::MultilineString)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def call
         
     | 
| 
         @@ -12,7 +12,7 @@ module SuperDiff 
     | 
|
| 
       12 
12 
     | 
    
         
             
                  private
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                  def lines
         
     | 
| 
       15 
     | 
    
         
            -
                     
     | 
| 
      
 15 
     | 
    
         
            +
                    operation_tree.reduce([]) do |array, operation|
         
     | 
| 
       16 
16 
     | 
    
         
             
                      case operation.name
         
     | 
| 
       17 
17 
     | 
    
         
             
                      when :change
         
     | 
| 
       18 
18 
     | 
    
         
             
                        array << Helpers.style(:alpha, "- #{operation.left_value}")
         
     | 
    
        data/lib/super_diff/differs.rb
    CHANGED
    
    | 
         @@ -6,17 +6,10 @@ module SuperDiff 
     | 
|
| 
       6 
6 
     | 
    
         
             
                autoload :DefaultObject, "super_diff/differs/default_object"
         
     | 
| 
       7 
7 
     | 
    
         
             
                autoload :Empty, "super_diff/differs/empty"
         
     | 
| 
       8 
8 
     | 
    
         
             
                autoload :Hash, "super_diff/differs/hash"
         
     | 
| 
      
 9 
     | 
    
         
            +
                autoload :Main, "super_diff/differs/main"
         
     | 
| 
       9 
10 
     | 
    
         
             
                autoload :MultilineString, "super_diff/differs/multiline_string"
         
     | 
| 
       10 
     | 
    
         
            -
                autoload : 
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                DEFAULTS = [
         
     | 
| 
       13 
     | 
    
         
            -
                  Array,
         
     | 
| 
       14 
     | 
    
         
            -
                  Hash,
         
     | 
| 
       15 
     | 
    
         
            -
                  Time,
         
     | 
| 
       16 
     | 
    
         
            -
                  MultilineString,
         
     | 
| 
       17 
     | 
    
         
            -
                  CustomObject,
         
     | 
| 
       18 
     | 
    
         
            -
                  DefaultObject,
         
     | 
| 
       19 
     | 
    
         
            -
                  Empty,
         
     | 
| 
       20 
     | 
    
         
            -
                ].freeze
         
     | 
| 
      
 11 
     | 
    
         
            +
                autoload :TimeLike, "super_diff/differs/time_like"
         
     | 
| 
       21 
12 
     | 
    
         
             
              end
         
     | 
| 
       22 
13 
     | 
    
         
             
            end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            require "super_diff/differs/defaults"
         
     | 
| 
         @@ -5,19 +5,10 @@ module SuperDiff 
     | 
|
| 
       5 
5 
     | 
    
         
             
                    expected.is_a?(::Array) && actual.is_a?(::Array)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                  def call
         
     | 
| 
       9 
     | 
    
         
            -
                    DiffFormatters::Array.call(operations, indent_level: indent_level)
         
     | 
| 
       10 
     | 
    
         
            -
                  end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
8 
     | 
    
         
             
                  private
         
     | 
| 
       13 
9 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                  def  
     | 
| 
       15 
     | 
    
         
            -
                     
     | 
| 
       16 
     | 
    
         
            -
                      expected: expected,
         
     | 
| 
       17 
     | 
    
         
            -
                      actual: actual,
         
     | 
| 
       18 
     | 
    
         
            -
                      extra_operational_sequencer_classes: extra_operational_sequencer_classes,
         
     | 
| 
       19 
     | 
    
         
            -
                      extra_diff_formatter_classes: extra_diff_formatter_classes,
         
     | 
| 
       20 
     | 
    
         
            -
                    )
         
     | 
| 
      
 10 
     | 
    
         
            +
                  def operation_tree_builder_class
         
     | 
| 
      
 11 
     | 
    
         
            +
                    OperationTreeBuilders::Array
         
     | 
| 
       21 
12 
     | 
    
         
             
                  end
         
     | 
| 
       22 
13 
     | 
    
         
             
                end
         
     | 
| 
       23 
14 
     | 
    
         
             
              end
         
     |