lookout 2.3.0 → 3.0.0
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 +7 -0
 - data/README +351 -181
 - data/Rakefile +20 -5
 - data/lib/lookout-3.0.rb +138 -0
 - data/lib/lookout-3.0/actual.rb +30 -0
 - data/lib/lookout-3.0/actual/method.rb +31 -0
 - data/lib/lookout-3.0/actual/not.rb +13 -0
 - data/lib/lookout-3.0/actual/not/method.rb +10 -0
 - data/lib/lookout-3.0/aphonic.rb +44 -0
 - data/lib/lookout-3.0/diff.rb +29 -0
 - data/lib/{lookout → lookout-3.0}/diff/algorithms.rb +1 -1
 - data/lib/lookout-3.0/diff/algorithms/difflib.rb +62 -0
 - data/lib/lookout-3.0/diff/algorithms/difflib/position.rb +63 -0
 - data/lib/{lookout/diff/algorithms/difflib/position/to.rb → lookout-3.0/diff/algorithms/difflib/position/new.rb} +8 -17
 - data/lib/lookout-3.0/diff/formats.rb +5 -0
 - data/lib/lookout-3.0/diff/formats/inline.rb +43 -0
 - data/lib/lookout-3.0/diff/formats/set.rb +48 -0
 - data/lib/lookout-3.0/diff/formats/unified.rb +56 -0
 - data/lib/lookout-3.0/diff/group.rb +57 -0
 - data/lib/lookout-3.0/diff/groups.rb +47 -0
 - data/lib/lookout-3.0/diff/match.rb +31 -0
 - data/lib/lookout-3.0/diff/operation.rb +41 -0
 - data/lib/lookout-3.0/diff/operations.rb +35 -0
 - data/lib/lookout-3.0/diff/operations/copy.rb +25 -0
 - data/lib/lookout-3.0/diff/operations/delete.rb +5 -0
 - data/lib/lookout-3.0/diff/operations/insert.rb +5 -0
 - data/lib/lookout-3.0/diff/operations/replace.rb +6 -0
 - data/lib/lookout-3.0/diff/slice.rb +97 -0
 - data/lib/lookout-3.0/difference.rb +10 -0
 - data/lib/lookout-3.0/difference/array.rb +22 -0
 - data/lib/lookout-3.0/difference/exception.rb +40 -0
 - data/lib/lookout-3.0/difference/hash.rb +31 -0
 - data/lib/lookout-3.0/difference/lookout.rb +5 -0
 - data/lib/lookout-3.0/difference/lookout/actual.rb +6 -0
 - data/lib/lookout-3.0/difference/lookout/actual/method.rb +13 -0
 - data/lib/lookout-3.0/difference/lookout/actual/not.rb +6 -0
 - data/lib/lookout-3.0/difference/lookout/actual/not/method.rb +9 -0
 - data/lib/lookout-3.0/difference/lookout/output.rb +8 -0
 - data/lib/lookout-3.0/difference/lookout/reception.rb +21 -0
 - data/lib/lookout-3.0/difference/lookout/warning.rb +9 -0
 - data/lib/lookout-3.0/difference/module.rb +12 -0
 - data/lib/lookout-3.0/difference/object.rb +73 -0
 - data/lib/lookout-3.0/difference/range.rb +12 -0
 - data/lib/lookout-3.0/difference/regexp.rb +12 -0
 - data/lib/lookout-3.0/difference/string.rb +21 -0
 - data/lib/lookout-3.0/difference/symbol.rb +21 -0
 - data/lib/lookout-3.0/encode.rb +20 -0
 - data/lib/lookout-3.0/exception.rb +79 -0
 - data/lib/lookout-3.0/exception/backtrace.rb +65 -0
 - data/lib/lookout-3.0/exception/unknown.rb +25 -0
 - data/lib/lookout-3.0/expect.rb +32 -0
 - data/lib/lookout-3.0/expect/classes.rb +6 -0
 - data/lib/lookout-3.0/expect/classes/exception.rb +27 -0
 - data/lib/lookout-3.0/expect/exception.rb +30 -0
 - data/lib/lookout-3.0/expect/object.rb +54 -0
 - data/lib/lookout-3.0/expect/object/context.rb +149 -0
 - data/lib/lookout-3.0/expectations.rb +69 -0
 - data/lib/lookout-3.0/expectations/context.rb +52 -0
 - data/lib/lookout-3.0/expected.rb +10 -0
 - data/lib/lookout-3.0/expected/array.rb +16 -0
 - data/lib/lookout-3.0/expected/classes.rb +5 -0
 - data/lib/lookout-3.0/expected/classes/exception.rb +14 -0
 - data/lib/lookout-3.0/expected/exception.rb +46 -0
 - data/lib/lookout-3.0/expected/falseclass.rb +9 -0
 - data/lib/lookout-3.0/expected/hash.rb +14 -0
 - data/lib/lookout-3.0/expected/lookout.rb +5 -0
 - data/lib/lookout-3.0/expected/lookout/actual.rb +5 -0
 - data/lib/lookout-3.0/expected/lookout/actual/method.rb +13 -0
 - data/lib/lookout-3.0/expected/lookout/actual/not.rb +6 -0
 - data/lib/lookout-3.0/expected/lookout/actual/not/method.rb +13 -0
 - data/lib/lookout-3.0/expected/lookout/output.rb +26 -0
 - data/lib/lookout-3.0/expected/lookout/reception.rb +24 -0
 - data/lib/lookout-3.0/expected/lookout/warning.rb +29 -0
 - data/lib/lookout-3.0/expected/module.rb +12 -0
 - data/lib/lookout-3.0/expected/object.rb +30 -0
 - data/lib/lookout-3.0/expected/range.rb +12 -0
 - data/lib/lookout-3.0/expected/regexp.rb +12 -0
 - data/lib/lookout-3.0/expected/string.rb +11 -0
 - data/lib/lookout-3.0/expected/symbol.rb +21 -0
 - data/lib/lookout-3.0/expected/trueclass.rb +9 -0
 - data/lib/lookout-3.0/inspect.rb +45 -0
 - data/lib/lookout-3.0/interfaces.rb +5 -0
 - data/lib/lookout-3.0/interfaces/commandline.rb +109 -0
 - data/lib/lookout-3.0/literal.rb +18 -0
 - data/lib/lookout-3.0/mock.rb +24 -0
 - data/lib/lookout-3.0/object.rb +6 -0
 - data/lib/lookout-3.0/object/not.rb +16 -0
 - data/lib/lookout-3.0/object/not/receive.rb +18 -0
 - data/lib/lookout-3.0/object/to.rb +12 -0
 - data/lib/lookout-3.0/object/to/receive.rb +18 -0
 - data/lib/lookout-3.0/output.rb +20 -0
 - data/lib/lookout-3.0/plugins.rb +7 -0
 - data/lib/lookout-3.0/reception.rb +128 -0
 - data/lib/lookout-3.0/reception/arguments.rb +20 -0
 - data/lib/lookout-3.0/reception/arguments/any.rb +16 -0
 - data/lib/lookout-3.0/reception/arguments/error.rb +5 -0
 - data/lib/lookout-3.0/reception/arguments/list.rb +17 -0
 - data/lib/lookout-3.0/reception/arguments/none.rb +6 -0
 - data/lib/lookout-3.0/reception/error.rb +24 -0
 - data/lib/lookout-3.0/result.rb +16 -0
 - data/lib/lookout-3.0/results.rb +5 -0
 - data/lib/lookout-3.0/results/error.rb +18 -0
 - data/lib/lookout-3.0/results/failure.rb +15 -0
 - data/lib/lookout-3.0/results/success.rb +7 -0
 - data/lib/lookout-3.0/stub.rb +55 -0
 - data/lib/lookout-3.0/version.rb +133 -0
 - data/lib/lookout-3.0/warning.rb +40 -0
 - data/test/unit/examples.rb +208 -83
 - data/test/unit/{lookout.rb → lookout-3.0.rb} +0 -0
 - data/test/unit/lookout-3.0/actual.rb +13 -0
 - data/test/unit/lookout-3.0/actual/method.rb +31 -0
 - data/test/unit/lookout-3.0/actual/not.rb +15 -0
 - data/test/unit/lookout-3.0/actual/not/method.rb +7 -0
 - data/test/unit/lookout-3.0/aphonic.rb +31 -0
 - data/test/unit/{lookout → lookout-3.0}/diff.rb +0 -0
 - data/test/unit/{lookout/diff/group.rb → lookout-3.0/diff/algorithms.rb} +0 -0
 - data/test/unit/lookout-3.0/diff/algorithms/difflib.rb +56 -0
 - data/test/unit/lookout-3.0/diff/algorithms/difflib/position.rb +92 -0
 - data/test/unit/{lookout/diff/algorithms/difflib/position/to.rb → lookout-3.0/diff/algorithms/difflib/position/new.rb} +1 -2
 - data/test/unit/{lookout/results.rb → lookout-3.0/diff/formats.rb} +0 -0
 - data/test/unit/{lookout → lookout-3.0}/diff/formats/inline.rb +0 -0
 - data/test/unit/lookout-3.0/diff/formats/set.rb +26 -0
 - data/test/unit/{lookout → lookout-3.0}/diff/formats/unified.rb +0 -0
 - data/test/unit/{lookout/results/error.rb → lookout-3.0/diff/group.rb} +0 -0
 - data/test/unit/lookout-3.0/diff/groups.rb +102 -0
 - data/test/unit/{lookout → lookout-3.0}/diff/match.rb +0 -0
 - data/test/unit/lookout-3.0/diff/operation.rb +17 -0
 - data/test/unit/lookout-3.0/diff/operations.rb +22 -0
 - data/test/unit/lookout-3.0/diff/operations/copy.rb +50 -0
 - data/test/unit/lookout-3.0/diff/operations/delete.rb +45 -0
 - data/test/unit/lookout-3.0/diff/operations/insert.rb +45 -0
 - data/test/unit/lookout-3.0/diff/operations/replace.rb +45 -0
 - data/test/unit/lookout-3.0/diff/slice.rb +56 -0
 - data/test/unit/{lookout/results/failures/behavior.rb → lookout-3.0/difference.rb} +0 -0
 - data/test/unit/lookout-3.0/difference/array.rb +32 -0
 - data/test/unit/lookout-3.0/difference/exception.rb +69 -0
 - data/test/unit/lookout-3.0/difference/hash.rb +30 -0
 - data/test/unit/{lookout/results/failures/state.rb → lookout-3.0/difference/lookout.rb} +0 -0
 - data/test/unit/{lookout/results/fulfilled.rb → lookout-3.0/difference/lookout/actual.rb} +0 -0
 - data/test/unit/lookout-3.0/difference/lookout/actual/method.rb +7 -0
 - data/test/unit/{lookout/runners/console.rb → lookout-3.0/difference/lookout/actual/not.rb} +0 -0
 - data/test/unit/lookout-3.0/difference/lookout/actual/not/method.rb +7 -0
 - data/test/unit/lookout-3.0/difference/lookout/output.rb +11 -0
 - data/test/unit/lookout-3.0/difference/lookout/reception.rb +11 -0
 - data/test/unit/lookout-3.0/difference/lookout/warning.rb +11 -0
 - data/test/unit/lookout-3.0/difference/module.rb +11 -0
 - data/test/unit/lookout-3.0/difference/object.rb +31 -0
 - data/test/unit/lookout-3.0/difference/range.rb +11 -0
 - data/test/unit/lookout-3.0/difference/regexp.rb +11 -0
 - data/test/unit/lookout-3.0/difference/string.rb +29 -0
 - data/test/unit/lookout-3.0/difference/symbol.rb +11 -0
 - data/test/unit/lookout-3.0/encode.rb +28 -0
 - data/test/unit/lookout-3.0/exception.rb +107 -0
 - data/test/unit/lookout-3.0/exception/backtrace.rb +75 -0
 - data/test/unit/lookout-3.0/exception/unknown.rb +23 -0
 - data/test/unit/lookout-3.0/expect.rb +15 -0
 - data/test/unit/{lookout/ui/console.rb → lookout-3.0/expect/classes.rb} +0 -0
 - data/test/unit/lookout-3.0/expect/classes/exception.rb +41 -0
 - data/test/unit/lookout-3.0/expect/exception.rb +63 -0
 - data/test/unit/lookout-3.0/expect/object.rb +55 -0
 - data/test/unit/lookout-3.0/expect/object/context.rb +120 -0
 - data/test/unit/lookout-3.0/expectations.rb +55 -0
 - data/test/unit/lookout-3.0/expectations/context.rb +44 -0
 - data/test/unit/lookout-3.0/expected.rb +4 -0
 - data/test/unit/lookout-3.0/expected/array.rb +19 -0
 - data/test/unit/lookout-3.0/expected/classes.rb +4 -0
 - data/test/unit/lookout-3.0/expected/classes/exception.rb +7 -0
 - data/test/unit/lookout-3.0/expected/exception.rb +24 -0
 - data/test/unit/lookout-3.0/expected/falseclass.rb +23 -0
 - data/test/unit/lookout-3.0/expected/hash.rb +23 -0
 - data/test/unit/lookout-3.0/expected/lookout.rb +4 -0
 - data/test/unit/lookout-3.0/expected/lookout/actual.rb +4 -0
 - data/test/unit/lookout-3.0/expected/lookout/actual/method.rb +11 -0
 - data/test/unit/lookout-3.0/expected/lookout/actual/not.rb +4 -0
 - data/test/unit/lookout-3.0/expected/lookout/actual/not/method.rb +11 -0
 - data/test/unit/lookout-3.0/expected/lookout/output.rb +27 -0
 - data/test/unit/lookout-3.0/expected/lookout/reception.rb +25 -0
 - data/test/unit/lookout-3.0/expected/lookout/warning.rb +48 -0
 - data/test/unit/lookout-3.0/expected/module.rb +23 -0
 - data/test/unit/lookout-3.0/expected/object.rb +24 -0
 - data/test/unit/lookout-3.0/expected/range.rb +19 -0
 - data/test/unit/lookout-3.0/expected/regexp.rb +19 -0
 - data/test/unit/lookout-3.0/expected/string.rb +44 -0
 - data/test/unit/lookout-3.0/expected/symbol.rb +35 -0
 - data/test/unit/lookout-3.0/expected/trueclass.rb +23 -0
 - data/test/unit/lookout-3.0/inspect.rb +39 -0
 - data/test/unit/lookout-3.0/interfaces.rb +4 -0
 - data/test/unit/lookout-3.0/interfaces/commandline.rb +4 -0
 - data/test/unit/lookout-3.0/literal.rb +15 -0
 - data/test/unit/lookout-3.0/mock.rb +22 -0
 - data/test/unit/lookout-3.0/object.rb +4 -0
 - data/test/unit/lookout-3.0/object/not.rb +7 -0
 - data/test/unit/lookout-3.0/object/not/receive.rb +9 -0
 - data/test/unit/lookout-3.0/object/to.rb +7 -0
 - data/test/unit/lookout-3.0/object/to/receive.rb +9 -0
 - data/test/unit/lookout-3.0/output.rb +31 -0
 - data/test/unit/lookout-3.0/plugins.rb +4 -0
 - data/test/unit/lookout-3.0/reception.rb +86 -0
 - data/test/unit/lookout-3.0/reception/arguments.rb +23 -0
 - data/test/unit/lookout-3.0/reception/arguments/any.rb +15 -0
 - data/test/unit/lookout-3.0/reception/arguments/error.rb +4 -0
 - data/test/unit/lookout-3.0/reception/arguments/list.rb +19 -0
 - data/test/unit/lookout-3.0/reception/arguments/none.rb +15 -0
 - data/test/unit/lookout-3.0/reception/error.rb +4 -0
 - data/test/unit/lookout-3.0/result.rb +27 -0
 - data/test/unit/lookout-3.0/results.rb +4 -0
 - data/test/unit/lookout-3.0/results/error.rb +37 -0
 - data/test/unit/lookout-3.0/results/failure.rb +21 -0
 - data/test/unit/lookout-3.0/results/success.rb +4 -0
 - data/test/unit/lookout-3.0/stub.rb +53 -0
 - data/test/unit/lookout-3.0/version.rb +4 -0
 - data/test/unit/lookout-3.0/warning.rb +47 -0
 - metadata +1159 -456
 - data/lib/lookout.rb +0 -30
 - data/lib/lookout/aphonic.rb +0 -40
 - data/lib/lookout/diff.rb +0 -10
 - data/lib/lookout/diff/algorithms/difflib.rb +0 -38
 - data/lib/lookout/diff/algorithms/difflib/position.rb +0 -92
 - data/lib/lookout/diff/formats.rb +0 -7
 - data/lib/lookout/diff/formats/hash.rb +0 -53
 - data/lib/lookout/diff/formats/inline.rb +0 -39
 - data/lib/lookout/diff/formats/unified.rb +0 -57
 - data/lib/lookout/diff/group.rb +0 -61
 - data/lib/lookout/diff/groups.rb +0 -34
 - data/lib/lookout/diff/match.rb +0 -36
 - data/lib/lookout/diff/operation.rb +0 -33
 - data/lib/lookout/diff/operations.rb +0 -36
 - data/lib/lookout/diff/operations/delete.rb +0 -9
 - data/lib/lookout/diff/operations/equal.rb +0 -27
 - data/lib/lookout/diff/operations/insert.rb +0 -9
 - data/lib/lookout/diff/operations/replace.rb +0 -9
 - data/lib/lookout/diff/range.rb +0 -91
 - data/lib/lookout/equalities.rb +0 -13
 - data/lib/lookout/equalities/array.rb +0 -22
 - data/lib/lookout/equalities/boolean.rb +0 -9
 - data/lib/lookout/equalities/hash.rb +0 -25
 - data/lib/lookout/equalities/include.rb +0 -9
 - data/lib/lookout/equalities/object.rb +0 -24
 - data/lib/lookout/equalities/output.rb +0 -19
 - data/lib/lookout/equalities/standarderror.rb +0 -32
 - data/lib/lookout/equalities/string.rb +0 -19
 - data/lib/lookout/equalities/warning.rb +0 -16
 - data/lib/lookout/equality.rb +0 -36
 - data/lib/lookout/expectation.rb +0 -69
 - data/lib/lookout/expectations.rb +0 -49
 - data/lib/lookout/expectations/behavior.rb +0 -20
 - data/lib/lookout/expectations/line.rb +0 -29
 - data/lib/lookout/expectations/state.rb +0 -31
 - data/lib/lookout/expectations/state/warning.rb +0 -26
 - data/lib/lookout/mock.rb +0 -20
 - data/lib/lookout/mock/method.rb +0 -70
 - data/lib/lookout/mock/method/arguments.rb +0 -33
 - data/lib/lookout/mock/method/arguments/any.rb +0 -11
 - data/lib/lookout/mock/method/arguments/anything.rb +0 -11
 - data/lib/lookout/mock/method/arguments/list.rb +0 -15
 - data/lib/lookout/mock/method/arguments/none.rb +0 -11
 - data/lib/lookout/mock/method/arguments/one.rb +0 -11
 - data/lib/lookout/mock/method/calls.rb +0 -11
 - data/lib/lookout/mock/method/calls/class.rb +0 -21
 - data/lib/lookout/mock/method/calls/exactly.rb +0 -28
 - data/lib/lookout/mock/method/calls/instance.rb +0 -25
 - data/lib/lookout/mock/method/calls/lower.rb +0 -22
 - data/lib/lookout/mock/method/calls/upper.rb +0 -22
 - data/lib/lookout/mock/methods.rb +0 -12
 - data/lib/lookout/mock/object.rb +0 -12
 - data/lib/lookout/object.rb +0 -11
 - data/lib/lookout/output.rb +0 -21
 - data/lib/lookout/rake/tasks.rb +0 -36
 - data/lib/lookout/rake/tasks/gem.rb +0 -49
 - data/lib/lookout/rake/tasks/tags.rb +0 -16
 - data/lib/lookout/rake/tasks/test.rb +0 -46
 - data/lib/lookout/rake/tasks/test/loader.rb +0 -22
 - data/lib/lookout/recorder.rb +0 -45
 - data/lib/lookout/recorder/not.rb +0 -11
 - data/lib/lookout/recorder/tape.rb +0 -21
 - data/lib/lookout/recorders.rb +0 -6
 - data/lib/lookout/recorders/reception.rb +0 -47
 - data/lib/lookout/recorders/state.rb +0 -35
 - data/lib/lookout/result.rb +0 -13
 - data/lib/lookout/results.rb +0 -25
 - data/lib/lookout/results/error.rb +0 -18
 - data/lib/lookout/results/error/exception.rb +0 -34
 - data/lib/lookout/results/error/exception/backtrace.rb +0 -50
 - data/lib/lookout/results/failure.rb +0 -16
 - data/lib/lookout/results/failures.rb +0 -6
 - data/lib/lookout/results/failures/behavior.rb +0 -5
 - data/lib/lookout/results/failures/state.rb +0 -5
 - data/lib/lookout/results/fulfilled.rb +0 -5
 - data/lib/lookout/results/unsuccessful.rb +0 -31
 - data/lib/lookout/runners.rb +0 -6
 - data/lib/lookout/runners/console.rb +0 -49
 - data/lib/lookout/runners/trackers.rb +0 -5
 - data/lib/lookout/runners/trackers/failure.rb +0 -14
 - data/lib/lookout/stub.rb +0 -18
 - data/lib/lookout/stub/method.rb +0 -105
 - data/lib/lookout/stub/methods.rb +0 -18
 - data/lib/lookout/stub/object.rb +0 -11
 - data/lib/lookout/ui.rb +0 -7
 - data/lib/lookout/ui/console.rb +0 -19
 - data/lib/lookout/ui/silent.rb +0 -9
 - data/lib/lookout/version.rb +0 -5
 - data/lib/lookout/warning.rb +0 -7
 - data/lib/lookout/xml.rb +0 -17
 - data/test/unit/lookout/diff/algorithms/difflib.rb +0 -56
 - data/test/unit/lookout/diff/algorithms/difflib/position.rb +0 -92
 - data/test/unit/lookout/diff/groups.rb +0 -102
 - data/test/unit/lookout/diff/operations.rb +0 -22
 - data/test/unit/lookout/diff/operations/delete.rb +0 -45
 - data/test/unit/lookout/diff/operations/equal.rb +0 -45
 - data/test/unit/lookout/diff/operations/insert.rb +0 -45
 - data/test/unit/lookout/diff/operations/replace.rb +0 -45
 - data/test/unit/lookout/diff/range.rb +0 -50
 - data/test/unit/lookout/equality.rb +0 -113
 - data/test/unit/lookout/expectation.rb +0 -47
 - data/test/unit/lookout/expectations.rb +0 -36
 - data/test/unit/lookout/expectations/behavior.rb +0 -35
 - data/test/unit/lookout/expectations/line.rb +0 -29
 - data/test/unit/lookout/expectations/state.rb +0 -29
 - data/test/unit/lookout/mock/method.rb +0 -143
 - data/test/unit/lookout/mock/method/arguments.rb +0 -57
 - data/test/unit/lookout/mock/method/arguments/any.rb +0 -11
 - data/test/unit/lookout/recorder.rb +0 -11
 - data/test/unit/lookout/results/error/exception/backtrace.rb +0 -20
 - data/test/unit/lookout/results/unsuccessful.rb +0 -9
 - data/test/unit/lookout/runners/trackers/failure.rb +0 -30
 - data/test/unit/lookout/stub/method.rb +0 -48
 - data/test/unit/lookout/stub/methods.rb +0 -19
 - data/test/unit/lookout/xml.rb +0 -55
 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # -*- coding: utf-8 -*-
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            class Lookout::Diff::Algorithms::Difflib::Position:: 
     | 
| 
       4 
     | 
    
         
            -
                  Lookout::Diff:: 
     | 
| 
      
 3 
     | 
    
         
            +
            class Lookout::Diff::Algorithms::Difflib::Position::New <
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Lookout::Diff::Slice
         
     | 
| 
       5 
5 
     | 
    
         
             
              def initialize(items, range = 0...items.size, indexes = nil)
         
     | 
| 
       6 
6 
     | 
    
         
             
                super items, range
         
     | 
| 
       7 
7 
     | 
    
         
             
                @indexes = indexes
         
     | 
| 
         @@ -29,19 +29,10 @@ class Lookout::Diff::Algorithms::Difflib::Position::To < 
     | 
|
| 
       29 
29 
     | 
    
         
             
                @indexes
         
     | 
| 
       30 
30 
     | 
    
         
             
              end
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
              def begin_after(other)
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
               
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
              def at(range)
         
     | 
| 
       41 
     | 
    
         
            -
                Lookout::Diff::Range.new(items, range)
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              def ==(other)
         
     | 
| 
       45 
     | 
    
         
            -
                super and indexes == other.indexes
         
     | 
| 
       46 
     | 
    
         
            -
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
              def begin_after(other) self.class.new(items, other.end + 1..self.end, indexes) end
         
     | 
| 
      
 33 
     | 
    
         
            +
              def end_before(other) self.class.new(items, self.begin...other.begin, indexes) end
         
     | 
| 
      
 34 
     | 
    
         
            +
              def at(range) Lookout::Diff::Slice.new(items, range) end
         
     | 
| 
      
 35 
     | 
    
         
            +
              def ==(other) super and indexes == other.indexes end
         
     | 
| 
      
 36 
     | 
    
         
            +
              alias eql? ==
         
     | 
| 
      
 37 
     | 
    
         
            +
              def hash; @hash ||= super ^ indexes.hash end
         
     | 
| 
       47 
38 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Formats {Operation}s inline in a String.  Additions are shown as `{+…+}` and
         
     | 
| 
      
 4 
     | 
    
         
            +
            # deletions as `[-…-]`.  Replacements are shown as a deletion followed by an
         
     | 
| 
      
 5 
     | 
    
         
            +
            # insertion.
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            # This format is used by {Difference::String} for single-line Strings.
         
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            # This format is inspired by the plain word “diff” format used by
         
     | 
| 
      
 10 
     | 
    
         
            +
            # [Git](http://git-scm.com/).  That format was surely inspired by something
         
     | 
| 
      
 11 
     | 
    
         
            +
            # before it, but it’s where I first saw it, so that’s what I’m referencing.
         
     | 
| 
      
 12 
     | 
    
         
            +
            class Lookout::Diff::Formats::Inline
         
     | 
| 
      
 13 
     | 
    
         
            +
              # Formats OPERATIONS as they would be applied inline on a String.
         
     | 
| 
      
 14 
     | 
    
         
            +
              # @param [Operations] operations
         
     | 
| 
      
 15 
     | 
    
         
            +
              Value(:operations)
         
     | 
| 
      
 16 
     | 
    
         
            +
              include Enumerable
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 19 
     | 
    
         
            +
              #   Enumerates the formatted operations.
         
     | 
| 
      
 20 
     | 
    
         
            +
              #
         
     | 
| 
      
 21 
     | 
    
         
            +
              #   @yieldparam [String] string
         
     | 
| 
      
 22 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 23 
     | 
    
         
            +
              #   @return [Enumerator<String>] An Enumerator over the formatted operations
         
     | 
| 
      
 24 
     | 
    
         
            +
              def each
         
     | 
| 
      
 25 
     | 
    
         
            +
                return enum_for(__method__) unless block_given?
         
     | 
| 
      
 26 
     | 
    
         
            +
                yield to_s
         
     | 
| 
      
 27 
     | 
    
         
            +
                self
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              # @return The concatenation of the formatted operations
         
     | 
| 
      
 31 
     | 
    
         
            +
              def to_s; @to_s ||= ToS.new(operations).to_s end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              private
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              class ToS
         
     | 
| 
      
 36 
     | 
    
         
            +
                def initialize(operations) @to_s = operations.map{ |o| o.apply(self) }.join('').freeze end
         
     | 
| 
      
 37 
     | 
    
         
            +
                def delete(operation) '[-%s-]' % operation.old.to_items end
         
     | 
| 
      
 38 
     | 
    
         
            +
                def copy(operation) operation.old.to_items end
         
     | 
| 
      
 39 
     | 
    
         
            +
                def insert(operation) '{+%s+}' % operation.new.to_items end
         
     | 
| 
      
 40 
     | 
    
         
            +
                def replace(operation) delete(operation) + insert(operation) end
         
     | 
| 
      
 41 
     | 
    
         
            +
                def to_s; @to_s end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,48 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Formats {Operation}s on an undordered set.  Added subsequences are shown
         
     | 
| 
      
 4 
     | 
    
         
            +
            # having each element prefixed by “+” and deleted subsequences by “-”.
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Replaced subsequences are shown as a deleted subsequence followed by an added
         
     | 
| 
      
 6 
     | 
    
         
            +
            # subsequence.
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            # This format is used by {Difference::Hash}.
         
     | 
| 
      
 9 
     | 
    
         
            +
            class Lookout::Diff::Formats::Set
         
     | 
| 
      
 10 
     | 
    
         
            +
              # Formats OPERATIONS as they would be applied to an unordered set.
         
     | 
| 
      
 11 
     | 
    
         
            +
              # @param [Operations] operations
         
     | 
| 
      
 12 
     | 
    
         
            +
              Value(:operations)
         
     | 
| 
      
 13 
     | 
    
         
            +
              include Enumerable
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 16 
     | 
    
         
            +
              #   Enumerates the formatted operations.
         
     | 
| 
      
 17 
     | 
    
         
            +
              #
         
     | 
| 
      
 18 
     | 
    
         
            +
              #   @yieldparam [String] string
         
     | 
| 
      
 19 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 20 
     | 
    
         
            +
              #   @return [Enumerator<String>] Enumerator over the formatted operations
         
     | 
| 
      
 21 
     | 
    
         
            +
              def each
         
     | 
| 
      
 22 
     | 
    
         
            +
                return enum_for(__method__) unless block_given?
         
     | 
| 
      
 23 
     | 
    
         
            +
                operations.each do |op|
         
     | 
| 
      
 24 
     | 
    
         
            +
                  operation = ToS.new(op)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  yield operation.to_s unless operation.empty?
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
                self
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              # @return The concatenation of the formatted operations
         
     | 
| 
      
 31 
     | 
    
         
            +
              def to_s; to_a.join("\n") end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              private
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              class ToS
         
     | 
| 
      
 36 
     | 
    
         
            +
                def initialize(operation) @lines = operation.apply(self) end
         
     | 
| 
      
 37 
     | 
    
         
            +
                def empty?; @lines.nil? end
         
     | 
| 
      
 38 
     | 
    
         
            +
                def delete(operation) mark('-', operation.old) end
         
     | 
| 
      
 39 
     | 
    
         
            +
                def copy(operation) end
         
     | 
| 
      
 40 
     | 
    
         
            +
                def insert(operation) mark('+', operation.new) end
         
     | 
| 
      
 41 
     | 
    
         
            +
                def replace(operation) delete(operation) + insert(operation) end
         
     | 
| 
      
 42 
     | 
    
         
            +
                def to_s; @lines.join("\n") end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                private
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                def mark(mark, slice) slice.map{ |item| [mark, item].join('') } end
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Formats {Group}s in unified format.  This format shows {Groups} of related
         
     | 
| 
      
 4 
     | 
    
         
            +
            # operations, providing a script of changes to be made that is both human and
         
     | 
| 
      
 5 
     | 
    
         
            +
            # computer readable.  For more information, see
         
     | 
| 
      
 6 
     | 
    
         
            +
            # {http://en.wikipedia.org/wiki/Diff#Unified_format}.
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            # This format is used by {Difference::String} for multi-line Strings.
         
     | 
| 
      
 9 
     | 
    
         
            +
            class Lookout::Diff::Formats::Unified
         
     | 
| 
      
 10 
     | 
    
         
            +
              # Formats GROUPS in unified format.
         
     | 
| 
      
 11 
     | 
    
         
            +
              # @param [Groups] groups
         
     | 
| 
      
 12 
     | 
    
         
            +
              Value(:groups)
         
     | 
| 
      
 13 
     | 
    
         
            +
              include Enumerable
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 16 
     | 
    
         
            +
              #   Enumerates the formatted groups.
         
     | 
| 
      
 17 
     | 
    
         
            +
              #
         
     | 
| 
      
 18 
     | 
    
         
            +
              #   @yieldparam [String] string
         
     | 
| 
      
 19 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 20 
     | 
    
         
            +
              #   @return [Enumerator<String>] An Enumerator over the formatted groups
         
     | 
| 
      
 21 
     | 
    
         
            +
              def each
         
     | 
| 
      
 22 
     | 
    
         
            +
                return enum_for(__method__) unless block_given?
         
     | 
| 
      
 23 
     | 
    
         
            +
                groups.each do |group|
         
     | 
| 
      
 24 
     | 
    
         
            +
                  next if group.parity?
         
     | 
| 
      
 25 
     | 
    
         
            +
                  yield ToS.new(group).to_s
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
                self
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              # @return The concatenation of the formatted groups
         
     | 
| 
      
 31 
     | 
    
         
            +
              def to_s; to_a.join("\n") end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              private
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              class ToS
         
     | 
| 
      
 36 
     | 
    
         
            +
                def initialize(group) @group = group end
         
     | 
| 
      
 37 
     | 
    
         
            +
                def delete(operation) mark('-', operation.old) end
         
     | 
| 
      
 38 
     | 
    
         
            +
                def copy(operation) mark(' ', operation.old) end
         
     | 
| 
      
 39 
     | 
    
         
            +
                def insert(operation) mark('+', operation.new) end
         
     | 
| 
      
 40 
     | 
    
         
            +
                def replace(operation) delete(operation).concat(insert(operation)) end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                def to_s
         
     | 
| 
      
 43 
     | 
    
         
            +
                  lines = ['@@ -%d,%d +%d,%d @@' %
         
     | 
| 
      
 44 
     | 
    
         
            +
                           [@group.old.begin + 1, @group.old.size,
         
     | 
| 
      
 45 
     | 
    
         
            +
                            @group.new.begin + 1, @group.new.size]]
         
     | 
| 
      
 46 
     | 
    
         
            +
                  @group.each do |operation|
         
     | 
| 
      
 47 
     | 
    
         
            +
                    lines.concat operation.apply(self)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
                  lines.join("\n")
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                private
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                def mark(mark, slice) slice.map{ |item| [mark, item].join('') } end
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,57 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Ordered sequence of related {Operation}s; type enumerated by {Groups}.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Lookout::Diff::Group
         
     | 
| 
      
 5 
     | 
    
         
            +
              # Initializes the group with an initial sequence of OPERATIONS.
         
     | 
| 
      
 6 
     | 
    
         
            +
              # @param [Operation, …] operations
         
     | 
| 
      
 7 
     | 
    
         
            +
              Value(:'*operations')
         
     | 
| 
      
 8 
     | 
    
         
            +
              include Enumerable
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              # @return True if the receiver doesn’t contain any operations
         
     | 
| 
      
 11 
     | 
    
         
            +
              def empty?; operations.empty? end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              # Adds OPERATION to the receiver.
         
     | 
| 
      
 14 
     | 
    
         
            +
              #
         
     | 
| 
      
 15 
     | 
    
         
            +
              # @param [Operation] operation
         
     | 
| 
      
 16 
     | 
    
         
            +
              def <<(operation) operations << operation; self end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              # {Operation#<< Folds} the last operation, leaving CONTEXT elements of
         
     | 
| 
      
 19 
     | 
    
         
            +
              # context.
         
     | 
| 
      
 20 
     | 
    
         
            +
              #
         
     | 
| 
      
 21 
     | 
    
         
            +
              # @param [Integer] context
         
     | 
| 
      
 22 
     | 
    
         
            +
              # @return [self]
         
     | 
| 
      
 23 
     | 
    
         
            +
              def fold(context) operations[-1] = operations[-1] << context; self end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              # @return True if the receiver contains one operation and that operation
         
     | 
| 
      
 26 
     | 
    
         
            +
              #   represents {Operation#parity? parity}
         
     | 
| 
      
 27 
     | 
    
         
            +
              def parity?
         
     | 
| 
      
 28 
     | 
    
         
            +
                operations.size == 1 and operations.first.parity?
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 32 
     | 
    
         
            +
              #   Enumerates the operations.
         
     | 
| 
      
 33 
     | 
    
         
            +
              #
         
     | 
| 
      
 34 
     | 
    
         
            +
              #   @yieldparam [Operation] operation
         
     | 
| 
      
 35 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 36 
     | 
    
         
            +
              #   @return [Enumerator<Operation>] An Enumerator over the operations
         
     | 
| 
      
 37 
     | 
    
         
            +
              def each
         
     | 
| 
      
 38 
     | 
    
         
            +
                return enum_for(__method__) unless block_given?
         
     | 
| 
      
 39 
     | 
    
         
            +
                operations.each do |operation| yield operation end
         
     | 
| 
      
 40 
     | 
    
         
            +
                self
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              # @return [Slice] The slice of the old sequence between the first operation’s
         
     | 
| 
      
 44 
     | 
    
         
            +
              #   beginning and the last operation’s end
         
     | 
| 
      
 45 
     | 
    
         
            +
              def old; slice(:old) end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              # @return [Slice] The slice of the new sequence between the first operation’s
         
     | 
| 
      
 48 
     | 
    
         
            +
              #   beginning and the last operation’s end
         
     | 
| 
      
 49 
     | 
    
         
            +
              def new; slice(:new) end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              private
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              def slice(target)
         
     | 
| 
      
 54 
     | 
    
         
            +
                # TODO: Should be #end_after(operations.last.send(target))
         
     | 
| 
      
 55 
     | 
    
         
            +
                operations.first.send(target).end_at(operations.last.send(target).end)
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Sequence of {Operations} bundled together into {Group}s that can then be used
         
     | 
| 
      
 4 
     | 
    
         
            +
            # to show the subsequences that differ, folding away the subsequences that are
         
     | 
| 
      
 5 
     | 
    
         
            +
            # the same, only keeping some context around the folding points.
         
     | 
| 
      
 6 
     | 
    
         
            +
            class Lookout::Diff::Groups
         
     | 
| 
      
 7 
     | 
    
         
            +
              # Initializes the sequence with the OPERATIONS to group and the number of
         
     | 
| 
      
 8 
     | 
    
         
            +
              # elements to leave as CONTEXT.
         
     | 
| 
      
 9 
     | 
    
         
            +
              #
         
     | 
| 
      
 10 
     | 
    
         
            +
              # @param [Operations] operations
         
     | 
| 
      
 11 
     | 
    
         
            +
              # @param [Integer] context
         
     | 
| 
      
 12 
     | 
    
         
            +
              Value(:operations, [:context, 3])
         
     | 
| 
      
 13 
     | 
    
         
            +
              include Enumerable
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 16 
     | 
    
         
            +
              #   Enumerates the groups of operations.
         
     | 
| 
      
 17 
     | 
    
         
            +
              #
         
     | 
| 
      
 18 
     | 
    
         
            +
              #   @yieldparam [Group] group
         
     | 
| 
      
 19 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 20 
     | 
    
         
            +
              #   @return [Enumerator<Group>] An Enumerator over the groups of operations
         
     | 
| 
      
 21 
     | 
    
         
            +
              def each
         
     | 
| 
      
 22 
     | 
    
         
            +
                return enum_for(__method__) unless block_given?
         
     | 
| 
      
 23 
     | 
    
         
            +
                saved = nil
         
     | 
| 
      
 24 
     | 
    
         
            +
                group = Lookout::Diff::Group.new
         
     | 
| 
      
 25 
     | 
    
         
            +
                operations.each do |operation|
         
     | 
| 
      
 26 
     | 
    
         
            +
                  if saved
         
     | 
| 
      
 27 
     | 
    
         
            +
                    yield saved
         
     | 
| 
      
 28 
     | 
    
         
            +
                    saved = nil
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                  if group.empty?
         
     | 
| 
      
 31 
     | 
    
         
            +
                    operation = operation >> context
         
     | 
| 
      
 32 
     | 
    
         
            +
                    group << operation
         
     | 
| 
      
 33 
     | 
    
         
            +
                  elsif operation.foldable? context
         
     | 
| 
      
 34 
     | 
    
         
            +
                    saved = group << (operation << context)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    group = Lookout::Diff::Group.new(operation >> context)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  else
         
     | 
| 
      
 37 
     | 
    
         
            +
                    group << operation
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
                if saved
         
     | 
| 
      
 41 
     | 
    
         
            +
                  yield saved
         
     | 
| 
      
 42 
     | 
    
         
            +
                elsif not group.empty?
         
     | 
| 
      
 43 
     | 
    
         
            +
                  yield group.fold(context)
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
                self
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Matching pair of {Slice}s of the sequences being “diffed”.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Lookout::Diff::Match
         
     | 
| 
      
 5 
     | 
    
         
            +
              # Initializes a match between OLD and NEW.
         
     | 
| 
      
 6 
     | 
    
         
            +
              # @param [Slice] old The slice of the old sequence
         
     | 
| 
      
 7 
     | 
    
         
            +
              # @param [Slice] new The slice of the new sequence
         
     | 
| 
      
 8 
     | 
    
         
            +
              Value(:old, :new, :comparable => true)
         
     | 
| 
      
 9 
     | 
    
         
            +
              public :old, :new
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              # @return True if the matching sequences are empty
         
     | 
| 
      
 12 
     | 
    
         
            +
              def empty?; old.empty? end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              # @return The number of matching elements
         
     | 
| 
      
 15 
     | 
    
         
            +
              def size; old.size end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              # @return A new match {Slice#+ encompassing} the slices of the
         
     | 
| 
      
 18 
     | 
    
         
            +
              #   receiver and OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
              # @note Logically, the receiver should {#touch?} OTHER, but this isn’t
         
     | 
| 
      
 20 
     | 
    
         
            +
              #   enforced.
         
     | 
| 
      
 21 
     | 
    
         
            +
              def +(other) self.class.new(old + other.old, new + other.new) end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              # @return True if {#old} and {#new} {Slice#touch? #touch?} those of OTHER
         
     | 
| 
      
 24 
     | 
    
         
            +
              def touch?(other) old.touch? other.old and new.touch? other.new end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              # @param [Range] old
         
     | 
| 
      
 27 
     | 
    
         
            +
              # @param [Range] new
         
     | 
| 
      
 28 
     | 
    
         
            +
              # @return [Match] A new match with {#old} and {#new} {Slice#at #at} OLD
         
     | 
| 
      
 29 
     | 
    
         
            +
              #   and NEW
         
     | 
| 
      
 30 
     | 
    
         
            +
              def at(old, new) self.class.new(self.old.at(old), self.new.at(new)) end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Base class for operations describing the changes to perform to get from the
         
     | 
| 
      
 4 
     | 
    
         
            +
            # old version of a sequence to the new in a “diff”.
         
     | 
| 
      
 5 
     | 
    
         
            +
            class Lookout::Diff::Operation
         
     | 
| 
      
 6 
     | 
    
         
            +
              # Initializes the operation with the slices of the OLD and NEW sequences.
         
     | 
| 
      
 7 
     | 
    
         
            +
              # @param [Slice] old The slice of the old sequence
         
     | 
| 
      
 8 
     | 
    
         
            +
              # @param [Slice] new The slice of the new sequence
         
     | 
| 
      
 9 
     | 
    
         
            +
              Value(:old, :new)
         
     | 
| 
      
 10 
     | 
    
         
            +
              public :old, :new
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              # @param [Integer] context
         
     | 
| 
      
 13 
     | 
    
         
            +
              # @return True if the operation is uninteresting to the actual “diff” and can
         
     | 
| 
      
 14 
     | 
    
         
            +
              #   be meaningfully folded, leaving CONTEXT elements
         
     | 
| 
      
 15 
     | 
    
         
            +
              # @see Operations::Copy#foldable?
         
     | 
| 
      
 16 
     | 
    
         
            +
              def foldable?(context) false end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              # Folds from the beginning of the receiver, leaving CONTEXT elements.
         
     | 
| 
      
 19 
     | 
    
         
            +
              # @param [Integer] context
         
     | 
| 
      
 20 
     | 
    
         
            +
              # @note Logically, the receiver should be {#foldable?} inside CONTEXT, but
         
     | 
| 
      
 21 
     | 
    
         
            +
              #   this isn’t enforced.
         
     | 
| 
      
 22 
     | 
    
         
            +
              def >>(context) self end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              # Folds from the end of the receiver, leaving CONTEXT elements.
         
     | 
| 
      
 25 
     | 
    
         
            +
              # @param [Integer] context
         
     | 
| 
      
 26 
     | 
    
         
            +
              # @note Logically, the receiver should be {#foldable?} inside CONTEXT, but
         
     | 
| 
      
 27 
     | 
    
         
            +
              #   this isn’t enforced.
         
     | 
| 
      
 28 
     | 
    
         
            +
              def <<(context) self end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              # @return True if the receiver represents parity
         
     | 
| 
      
 31 
     | 
    
         
            +
              # @see Operations::Copy#parity?
         
     | 
| 
      
 32 
     | 
    
         
            +
              def parity?; false end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              # Implements a double dispatch for enumerating operations, where OBJECT is
         
     | 
| 
      
 35 
     | 
    
         
            +
              # sent the last part of the receiver’s class’ name with the receiver as the
         
     | 
| 
      
 36 
     | 
    
         
            +
              # lone argument.
         
     | 
| 
      
 37 
     | 
    
         
            +
              # @return The result of OBJECT#name(self)
         
     | 
| 
      
 38 
     | 
    
         
            +
              def apply(object)
         
     | 
| 
      
 39 
     | 
    
         
            +
                object.send(@apply ||= self.class.name.split('::').last.downcase.to_sym, self)
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Sequence of {Operation}s based on a sequence of {Match}es.  Each match is
         
     | 
| 
      
 4 
     | 
    
         
            +
            # turned into a {Copy}, {Delete}, {Insert}, or {Replace} operation based on its
         
     | 
| 
      
 5 
     | 
    
         
            +
            # relation to other matches in the sequence of matches.  Empty copy operations
         
     | 
| 
      
 6 
     | 
    
         
            +
            # will never be a part of this sequence.
         
     | 
| 
      
 7 
     | 
    
         
            +
            class Lookout::Diff::Operations
         
     | 
| 
      
 8 
     | 
    
         
            +
              # Initializes a sequence of operations based on MATCHES.
         
     | 
| 
      
 9 
     | 
    
         
            +
              # @param [Enumerable<Match>] matches
         
     | 
| 
      
 10 
     | 
    
         
            +
              Value(:matches)
         
     | 
| 
      
 11 
     | 
    
         
            +
              include Enumerable
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 14 
     | 
    
         
            +
              #   Enumerates the operations.
         
     | 
| 
      
 15 
     | 
    
         
            +
              #
         
     | 
| 
      
 16 
     | 
    
         
            +
              #   @yieldparam [Operation] operation
         
     | 
| 
      
 17 
     | 
    
         
            +
              # @overload
         
     | 
| 
      
 18 
     | 
    
         
            +
              #   @return [Enumerator<Operation>] An Enumerator over the operations
         
     | 
| 
      
 19 
     | 
    
         
            +
              def each
         
     | 
| 
      
 20 
     | 
    
         
            +
                return enum_for(__method__) unless block_given?
         
     | 
| 
      
 21 
     | 
    
         
            +
                old = new = 0
         
     | 
| 
      
 22 
     | 
    
         
            +
                matches.each do |match|
         
     | 
| 
      
 23 
     | 
    
         
            +
                  type = if    old < match.old.begin and new < match.new.begin then Replace
         
     | 
| 
      
 24 
     | 
    
         
            +
                         elsif old < match.old.begin                           then Delete
         
     | 
| 
      
 25 
     | 
    
         
            +
                         elsif new < match.new.begin                           then Insert
         
     | 
| 
      
 26 
     | 
    
         
            +
                         else                                                       Copy
         
     | 
| 
      
 27 
     | 
    
         
            +
                         end
         
     | 
| 
      
 28 
     | 
    
         
            +
                  yield type.new(match.old.at(old...match.old.begin),
         
     | 
| 
      
 29 
     | 
    
         
            +
                                 match.new.at(new...match.new.begin)) unless type == Copy
         
     | 
| 
      
 30 
     | 
    
         
            +
                  yield Copy.new(match.old, match.new) unless match.empty?
         
     | 
| 
      
 31 
     | 
    
         
            +
                  old, new = match.old.end + 1, match.new.end + 1
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
                self
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Slice that should be copied from the old sequence.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Lookout::Diff::Operations::Copy < Lookout::Diff::Operation
         
     | 
| 
      
 5 
     | 
    
         
            +
              # @param [Integer] context
         
     | 
| 
      
 6 
     | 
    
         
            +
              # @return True if the slice of the old sequence is larger than CONTEXT * 2
         
     | 
| 
      
 7 
     | 
    
         
            +
              #   ({#old}{Slice#size #size} > CONTEXT * 2) so that it may be folded to
         
     | 
| 
      
 8 
     | 
    
         
            +
              #   CONTEXT at both ends ({#>>}, {#<<})
         
     | 
| 
      
 9 
     | 
    
         
            +
              def foldable?(context) old.size > context * 2 end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              # (see Operation#>>)
         
     | 
| 
      
 12 
     | 
    
         
            +
              def >>(context)
         
     | 
| 
      
 13 
     | 
    
         
            +
                self.class.new(old.begin_at([old.begin, old.end - context + 1].max),
         
     | 
| 
      
 14 
     | 
    
         
            +
                               new.begin_at([new.begin, new.end - context + 1].max))
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              # (see Operation#<<)
         
     | 
| 
      
 18 
     | 
    
         
            +
              def <<(context)
         
     | 
| 
      
 19 
     | 
    
         
            +
                self.class.new(old.end_at([old.end, old.begin + context - 1].min),
         
     | 
| 
      
 20 
     | 
    
         
            +
                               new.end_at([new.end, new.begin + context - 1].min))
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              # @return True if {#old} `#==` {#new}
         
     | 
| 
      
 24 
     | 
    
         
            +
              def parity?; old == new end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     |