Sha256: 46b7a33a72b29932b130b235c954ac1e9179821fa39cc9667822d0c1a7ba8f65

Contents?: true

Size: 1.2 KB

Versions: 96

Compression:

Stored size: 1.2 KB

Contents

#! /usr/env/bin ruby
#--
# Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
#   adapted from:
#     Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
#     Smalltalk by Mario I. Wolczko <mario@wolczko.com>
#   implements McIlroy-Hunt diff algorithm
#
# This program is free software. It may be redistributed and/or modified under
# the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
# Ruby licence.
# 
# $Id$
#++
# Contains Diff::LCS::Block for bin/ldiff.

  # A block is an operation removing, adding, or changing a group of items.
  # Basically, this is just a list of changes, where each change adds or
  # deletes a single item. Used by bin/ldiff.
class Diff::LCS::Block
  attr_reader :changes, :insert, :remove

  def initialize(chunk)
    @changes = []
    @insert = []
    @remove = []

    chunk.each do |item|
      @changes << item
      @remove << item if item.deleting?
      @insert << item if item.adding?
    end
  end

  def diff_size
    @insert.size - @remove.size
  end

  def op
    case [@remove.empty?, @insert.empty?]
    when [false, false]
      '!'
    when [false, true]
      '-'
    when [true, false]
      '+'
    else # [true, true]
      '^'
    end
  end
end

Version data entries

96 entries across 89 versions & 16 rubygems

Version Path
classiccms-0.3.6 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
classiccms-0.3.5 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
classiccms-0.3.4 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
classiccms-0.3.3 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
classiccms-0.3.2 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
classiccms-0.3.1 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
classiccms-0.3.0 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
rails-uploader-0.0.1 vendor/bundle/ruby/1.9.1/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
ftl-0.2.0 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
classiccms-0.2.4.pre vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
horseman-0.0.5 vendor/ruby/1.9.1/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb
classicCMS-0.2.3 vendor/bundle/gems/diff-lcs-1.1.3/lib/diff/lcs/block.rb