diff --git a/Gemfile b/Gemfile index 4d6a181..41c87a9 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,7 @@ gem 'gettext', '~> 3.1', :require => false gem 'locale', '~> 2.1' gem 'whenever', :require => false gem 'eita-jrails', '~> 0.10.0', require: 'jrails' +gem 'diffy', '~> 3.0' # API dependencies gem 'grape', '~> 0.12' diff --git a/debian/control b/debian/control index 41f1f3b..de3dc19 100644 --- a/debian/control +++ b/debian/control @@ -12,6 +12,7 @@ Build-Depends: cucumber, ruby-capybara, ruby-cucumber-rails, ruby-database-cleaner, + ruby-diffy, ruby-gettext, ruby-mocha, ruby-rspec (>= 2.14), diff --git a/vendor/plugins/diffy/.rspec b/vendor/plugins/diffy/.rspec deleted file mode 100644 index 7eb1831..0000000 --- a/vendor/plugins/diffy/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---color ---profile diff --git a/vendor/plugins/diffy/.travis.yml b/vendor/plugins/diffy/.travis.yml deleted file mode 100644 index 16b4b06..0000000 --- a/vendor/plugins/diffy/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: ruby -rvm: - - 1.8.7 - - 1.9.2 - - 1.9.3 - - 2.0.0 - - 2.1.0 - - 2.1.1 - - rbx diff --git a/vendor/plugins/diffy/CHANGELOG b/vendor/plugins/diffy/CHANGELOG deleted file mode 100644 index df23243..0000000 --- a/vendor/plugins/diffy/CHANGELOG +++ /dev/null @@ -1,26 +0,0 @@ -allow_empty_diff is true by default - -== 2.1.0 == -Windows support - -== 2.0.10 == -Close tempfile after it's been written to to avoid too many open file handles - -== 2.0.9 == -Memoize calls to `which diff` which should result in a minor performance -improvement in high use environments. - -== 2.0.8 == -Handle non-UTF-8 byte sequences in Ruby 1.9. -Avoid non-deterministic deletion of temp files when GC runs - -== 2.0.7 == -Added :allow_empty_diff option - -== Oops, need to backfill changelog == - -== 1.0.1 == -* Compatibility with ruby 1.8.6 and 1.9 - -== 1.0.0 == -* HTML output and better documentation diff --git a/vendor/plugins/diffy/CONTRIBUTORS b/vendor/plugins/diffy/CONTRIBUTORS deleted file mode 100644 index 1816237..0000000 --- a/vendor/plugins/diffy/CONTRIBUTORS +++ /dev/null @@ -1,10 +0,0 @@ -* Sam Goldstein -* joelash -* chaffeqa -* Lincoln Ritter -* Bernhard Weichel -* Yuichi Tateno -* Nigel Thorne -* Richard Stiller -* printercu -* Bryan Ricker diff --git a/vendor/plugins/diffy/Gemfile b/vendor/plugins/diffy/Gemfile deleted file mode 100644 index bd605a9..0000000 --- a/vendor/plugins/diffy/Gemfile +++ /dev/null @@ -1,10 +0,0 @@ -source 'https://rubygems.org' - -platforms :rbx do - gem 'rubysl', '~> 2.0' -end - - -group :test, :development do - gemspec -end diff --git a/vendor/plugins/diffy/LICENSE b/vendor/plugins/diffy/LICENSE deleted file mode 100644 index 2696197..0000000 --- a/vendor/plugins/diffy/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010 Sam Goldstein - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/plugins/diffy/README.md b/vendor/plugins/diffy/README.md deleted file mode 100644 index 1a173d6..0000000 --- a/vendor/plugins/diffy/README.md +++ /dev/null @@ -1,260 +0,0 @@ -Diffy - Easy Diffing With Ruby [![Build Status](https://secure.travis-ci.org/samg/diffy.png)](http://travis-ci.org/samg/diffy) -============================ - -Need diffs in your ruby app? Diffy has you covered. It provides a convenient -way to generate a diff from two strings or files. Instead of reimplementing -the LCS diff algorithm Diffy uses battle tested Unix diff to generate diffs, -and focuses on providing a convenient interface, and getting out of your way. - -Supported Formats ------------------ - -It provides several built in format options which can be passed to -`Diffy::Diff#to_s`. - -* `:text` - Plain text output -* `:color` - ANSI colorized text suitable for use in a terminal -* `:html` - HTML output. Since version 2.0 this format does inline highlighting of the character changes between lines. -* `:html_simple` - HTML output without inline highlighting. This may be useful in situations where high performance is required or simpler output is desired. - -A default format can be set like so: - - Diffy::Diff.default_format = :html - -Installation ------------- - -###on Unix - - gem install diffy - -###on Windows: - -1. ensure that you have a working `which` and `diff` on your machine and on - your search path. - - There are two options: - - 1. install unxutils - - note that these tools contain diff 2.7 which has a different handling - of whitespace in the diff results. This makes Diffy spec tests - yielding one fail on Windows. - - 2. install these two individually from the gnuwin32 project - - - note that this delivers diff 2.8 which makes Diffy spec pass - even on Windows. - - -2. install the gem by - - gem install diffy - - -Getting Started ---------------- - -Here's an example of using Diffy to diff two strings - - $ irb - >> string1 = <<-TXT - >" Hello how are you - >" I'm fine - >" That's great - >" TXT - => "Hello how are you\nI'm fine\nThat's great\n" - >> string2 = <<-TXT - >" Hello how are you? - >" I'm fine - >" That's swell - >" TXT - => "Hello how are you?\nI'm fine\nThat's swell\n" - >> puts Diffy::Diff.new(string1, string2) - -Hello how are you - +Hello how are you? - I'm fine - -That's great - +That's swell - -HTML Output ---------------- - -Outputing the diff as html is easy too. Here's an example using the -`:html_simple` formatter. - - >> puts Diffy::Diff.new(string1, string2).to_s(:html_simple) -
-
    -
  • Hello how are you
  • -
  • Hello how are you?
  • -
  • I'm fine
  • -
  • That's great
  • -
  • That's swell
  • -
-
- -The `:html` formatter will give you inline highlighting a la github. - - >> puts Diffy::Diff.new("foo\n", "Foo\n").to_s(:html) -
-
    -
  • foo
  • -
  • Foo
  • -
-
- -There's some pretty nice css provided in `Diffy::CSS`. - - >> puts Diffy::CSS - .diff{overflow:auto;} - .diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;} - .diff del, .diff ins{display:block;text-decoration:none;} - .diff li{padding:0; display:table-row;margin: 0;height:1em;} - .diff li.ins{background:#dfd; color:#080} - .diff li.del{background:#fee; color:#b00} - .diff li:hover{background:#ffc} - /* try 'whitespace:pre;' if you don't want lines to wrap */ - .diff del, .diff ins, .diff span{white-space:pre-wrap;font-family:courier;} - .diff del strong{font-weight:normal;background:#fcc;} - .diff ins strong{font-weight:normal;background:#9f9;} - .diff li.diff-comment { display: none; } - .diff li.diff-block-info { background: none repeat scroll 0 0 gray; } - -Other Diff Options ------------------- - -### Diffing files instead of strings - -You can diff files instead of strings by using the `:source` option. - - >> puts Diffy::Diff.new('/tmp/foo', '/tmp/bar', :source => 'files') - -### Full Diff Output - -By default Diffy removes the superfluous diff output. This is because its -default is to show the complete diff'ed file (`diff -U 10000` is the default). - -Diffy does support full output, just use the `:include_diff_info => true` -option when initializing: - - >> Diffy::Diff.new("foo\nbar\n", "foo\nbar\nbaz\n", :include_diff_info => true).to_s(:text) - =>--- /Users/chaffeqa/Projects/stiwiki/tmp/diffy20111116-82153-ie27ex 2011-11-16 20:16:41.000000000 -0500 - +++ /Users/chaffeqa/Projects/stiwiki/tmp/diffy20111116-82153-wzrhw5 2011-11-16 20:16:41.000000000 -0500 - @@ -1,2 +1,3 @@ - foo - bar - +baz - -And even deals a bit with the formatting! - -### Empty Diff Behavior - -By default Diffy will return empty string if there are no -differences in inputs. In previous versions the full text of its first input -was returned in this case. To restore this behaviour simply use the -`:allow_empty_diff => false` option when initializing. - -### Plus and Minus symbols in HTML output - -By default Diffy doesn't include the `+`, `-`, and ` ` at the beginning of line for -HTML output. - -You can use the `:include_plus_and_minus_in_html` option to include those -symbols in the output. - - >> puts Diffy::Diff.new(string1, string2, :include_plus_and_minus_in_html => true).to_s(:html_simple) -
-
    -
  • -Hello how are you
  • -
  • +Hello how are you?
  • -
  • I'm fine
  • -
  • -That's great
  • -
  • +That's swell
  • -
-
- -### Number of lines of context around changes - -You can use the `:context` option to override the number of lines of context -that are shown around each change (this defaults to 10000 to show the full -file). - - >> puts Diffy::Diff.new("foo\nfoo\nBAR\nbang\nbaz", "foo\nfoo\nbar\nbang\nbaz", :context => 1) - foo - -BAR - +bar - bang - - -### Overriding the command line options passed to diff. - -You can use the `:diff` option to override the command line options that are -passed to unix diff. They default to `-U 10000`. This option will noop if -combined with the `:context` option. - - >> puts Diffy::Diff.new(" foo\nbar\n", "foo\nbar\n", :diff => "-w") - foo - bar - -Default Diff Options --------------------- - -You can set the default options for new `Diffy::Diff`s using the -`Diffy::Diff.default_options` and `Diffy::Diff.default_options=` methods. -Options passed to `Diffy::Diff.new` will be merged into the default options. - - >> Diffy::Diff.default_options - => {:diff=>"-U 10000", :source=>"strings", :include_diff_info=>false, :include_plus_and_minus_in_html=>false} - >> Diffy::Diff.default_options.merge!(:source => 'files') - => {:diff=>"-U 10000", :source=>"files", :include_diff_info=>false, :include_plus_and_minus_in_html=>false} - - -Custom Formats --------------- - -Diffy tries to make generating your own custom formatted output easy. -`Diffy::Diff` provides an enumerable interface which lets you iterate over -lines in the diff. - - >> Diffy::Diff.new("foo\nbar\n", "foo\nbar\nbaz\n").each do |line| - >* case line - >> when /^\+/ then puts "line #{line.chomp} added" - >> when /^-/ then puts "line #{line.chomp} removed" - >> end - >> end - line +baz added - => [" foo\n", " bar\n", "+baz\n"] - -You can also use `Diffy::Diff#each_chunk` to iterate each grouping of additions, -deletions, and unchanged in a diff. - - >> Diffy::Diff.new("foo\nbar\nbang\nbaz\n", "foo\nbar\nbing\nbong\n").each_chunk.to_a - => [" foo\n bar\n", "-bang\n-baz\n", "+bing\n+bong\n"] - -Use `#map`, `#inject`, or any of Enumerable's methods. Go crazy. - - -Ruby Version Compatibility -------------------------- - -Support for Ruby 1.8.6 was dropped beginning at version 2.0 in order to support -the chainable enumerators available in 1.8.7 and 1.9. - -If you want to use Diffy and Ruby 1.8.6 then: - - $ gem install diffy -v1.1.0 - -Testing ------------- - -Diffy includes a full set of rspec tests. When contributing please include -tests for your changes. - -[![Build Status](https://secure.travis-ci.org/samg/diffy.png)](http://travis-ci.org/samg/diffy) - ---------------------------------------------------------------------- - -Report bugs or request features at http://github.com/samg/diffy/issues - diff --git a/vendor/plugins/diffy/Rakefile b/vendor/plugins/diffy/Rakefile deleted file mode 100644 index 80ea28c..0000000 --- a/vendor/plugins/diffy/Rakefile +++ /dev/null @@ -1,8 +0,0 @@ -require 'rspec/core/rake_task' - -task :default => :spec - -desc "Run all specs in spec directory" -RSpec::Core::RakeTask.new(:spec) do |t| - t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default. -end diff --git a/vendor/plugins/diffy/diffy.gemspec b/vendor/plugins/diffy/diffy.gemspec deleted file mode 100644 index 3ea63d9..0000000 --- a/vendor/plugins/diffy/diffy.gemspec +++ /dev/null @@ -1,23 +0,0 @@ -# coding: utf-8 -lib = File.expand_path('../lib', __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'diffy/version' - -Gem::Specification.new do |spec| - spec.name = "diffy" - spec.version = Diffy::VERSION - spec.authors = ["Sam Goldstein"] - spec.email = ["sgrock@gmail.org"] - spec.description = "Convenient diffing in ruby" - spec.summary = "A convenient way to diff string in ruby" - spec.homepage = "http://github.com/samg/diffy" - spec.license = "MIT" - - spec.files = `git ls-files`.split($/) - spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } - spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = ["lib"] - - spec.add_development_dependency "rake" - spec.add_development_dependency "rspec", '~> 2.0' -end diff --git a/vendor/plugins/diffy/lib/diffy.rb b/vendor/plugins/diffy/lib/diffy.rb deleted file mode 100644 index 0a922fc..0000000 --- a/vendor/plugins/diffy/lib/diffy.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'tempfile' -require 'erb' -require 'rbconfig' - -module Diffy - WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) -end -require 'open3' unless Diffy::WINDOWS -require File.join(File.dirname(__FILE__), 'diffy', 'format') -require File.join(File.dirname(__FILE__), 'diffy', 'html_formatter') -require File.join(File.dirname(__FILE__), 'diffy', 'diff') -require File.join(File.dirname(__FILE__), 'diffy', 'css') diff --git a/vendor/plugins/diffy/lib/diffy/css.rb b/vendor/plugins/diffy/lib/diffy/css.rb deleted file mode 100644 index 1c56d9f..0000000 --- a/vendor/plugins/diffy/lib/diffy/css.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Diffy - CSS = <<-STYLE -.diff{overflow:auto;} -.diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;} -.diff del, .diff ins{display:block;text-decoration:none;} -.diff li{padding:0; display:table-row;margin: 0;height:1em;} -.diff li.ins{background:#dfd; color:#080} -.diff li.del{background:#fee; color:#b00} -.diff li:hover{background:#ffc} -/* try 'whitespace:pre;' if you don't want lines to wrap */ -.diff del, .diff ins, .diff span{white-space:pre-wrap;font-family:courier;} -.diff del strong{font-weight:normal;background:#fcc;} -.diff ins strong{font-weight:normal;background:#9f9;} -.diff li.diff-comment { display: none; } -.diff li.diff-block-info { background: none repeat scroll 0 0 gray; } - STYLE -end diff --git a/vendor/plugins/diffy/lib/diffy/diff.rb b/vendor/plugins/diffy/lib/diffy/diff.rb deleted file mode 100644 index efbcf5b..0000000 --- a/vendor/plugins/diffy/lib/diffy/diff.rb +++ /dev/null @@ -1,161 +0,0 @@ -module Diffy - class Diff - class << self - attr_writer :default_format - def default_format - @default_format || :text - end - - attr_writer :default_options - # default options passed to new Diff objects - def default_options - @default_options ||= { - :diff => '-U 10000', - :source => 'strings', - :include_diff_info => false, - :include_plus_and_minus_in_html => false, - :context => nil, - :allow_empty_diff => true, - } - end - - end - include Enumerable - attr_reader :string1, :string2, :options, :diff - - # supported options - # +:diff+:: A cli options string passed to diff - # +:source+:: Either _strings_ or _files_. Determines whether string1 - # and string2 should be interpreted as strings or file paths. - # +:include_diff_info+:: Include diff header info - # +:include_plus_and_minus_in_html+:: Show the +, -, ' ' at the - # beginning of lines in html output. - def initialize(string1, string2, options = {}) - @options = self.class.default_options.merge(options) - if ! ['strings', 'files'].include?(@options[:source]) - raise ArgumentError, "Invalid :source option #{@options[:source].inspect}. Supported options are 'strings' and 'files'." - end - @string1, @string2 = string1, string2 - end - - def diff - @diff ||= begin - paths = case options[:source] - when 'strings' - [tempfile(string1), tempfile(string2)] - when 'files' - [string1, string2] - end - - if WINDOWS - # don't use open3 on windows - cmd = "\"#{diff_bin}\" #{diff_options.join(' ')} #{paths.map{|s| "\"#{s}\""}.join(' ')}" - diff = `#{cmd}` - else - diff = Open3.popen3(diff_bin, *(diff_options + paths)) { |i, o, e| o.read } - end - diff.force_encoding('ASCII-8BIT') if diff.respond_to?(:valid_encoding?) && !diff.valid_encoding? - if diff =~ /\A\s*\Z/ && !options[:allow_empty_diff] - diff = case options[:source] - when 'strings' then string1 - when 'files' then File.read(string1) - end.gsub(/^/, " ") - end - diff - end - ensure - # unlink the tempfiles explicitly now that the diff is generated - Array(@tempfiles).each do |t| - begin - # check that the path is not nil and file still exists. - # REE seems to be very agressive with when it magically removes - # tempfiles - t.unlink if t.path && File.exist?(t.path) - rescue => e - warn "#{e.class}: #{e}" - warn e.backtrace.join("\n") - end - end - end - - def each - lines = case @options[:include_diff_info] - when false then diff.split("\n").reject{|x| x =~ /^(---|\+\+\+|@@|\\\\)/ }.map {|line| line + "\n" } - when true then diff.split("\n").map {|line| line + "\n" } - end - if block_given? - lines.each{|line| yield line} - else - lines.to_enum - end - end - - def each_chunk - old_state = nil - chunks = inject([]) do |cc, line| - state = line.each_char.first - if state == old_state - cc.last << line - else - cc.push line.dup - end - old_state = state - cc - end - - if block_given? - chunks.each{|chunk| yield chunk } - else - chunks.to_enum - end - end - - def tempfile(string) - t = Tempfile.new('diffy') - # ensure tempfiles aren't unlinked when GC runs by maintaining a - # reference to them. - @tempfiles ||=[] - @tempfiles.push(t) - t.print(string) - t.flush - t.close - t.path - end - - def to_s(format = nil) - format ||= self.class.default_format - formats = Format.instance_methods(false).map{|x| x.to_s} - if formats.include? format.to_s - enum = self - enum.extend Format - enum.send format - else - raise ArgumentError, - "Format #{format.inspect} not found in #{formats.inspect}" - end - end - private - - @@bin = nil - def diff_bin - return @@bin if @@bin - - @@bin ||= "" - if WINDOWS - @@bin = `which diff.exe`.chomp if @@bin.empty? - end - @@bin = `which diff`.chomp if @@bin.empty? - - if @@bin.empty? - raise "Can't find a diff executable in PATH #{ENV['PATH']}" - end - @@bin - end - - # options pass to diff program - def diff_options - Array(options[:context] ? "-U #{options[:context]}" : options[:diff]) - end - - end -end diff --git a/vendor/plugins/diffy/lib/diffy/format.rb b/vendor/plugins/diffy/lib/diffy/format.rb deleted file mode 100644 index eea97b0..0000000 --- a/vendor/plugins/diffy/lib/diffy/format.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Diffy - module Format - # ANSI color output suitable for terminal output - def color - map do |line| - case line - when /^(---|\+\+\+|\\\\)/ - "\033[90m#{line.chomp}\033[0m" - when /^\+/ - "\033[32m#{line.chomp}\033[0m" - when /^-/ - "\033[31m#{line.chomp}\033[0m" - when /^@@/ - "\033[36m#{line.chomp}\033[0m" - else - line.chomp - end - end.join("\n") + "\n" - end - - # Basic text output - def text - to_a.join - end - - # Basic html output which does not attempt to highlight the changes - # between lines, and is more performant. - def html_simple - HtmlFormatter.new(self, options).to_s - end - - # Html output which does inline highlighting of changes between two lines. - def html - HtmlFormatter.new(self, options.merge(:highlight_words => true)).to_s - end - end -end diff --git a/vendor/plugins/diffy/lib/diffy/html_formatter.rb b/vendor/plugins/diffy/lib/diffy/html_formatter.rb deleted file mode 100644 index 1ecdeeb..0000000 --- a/vendor/plugins/diffy/lib/diffy/html_formatter.rb +++ /dev/null @@ -1,133 +0,0 @@ -module Diffy - class HtmlFormatter - def initialize(diff, options = {}) - @diff = diff - @options = options - end - - def to_s - if @options[:highlight_words] - wrap_lines(highlighted_words) - else - wrap_lines(@diff.map{|line| wrap_line(ERB::Util.h(line))}) - end - end - - private - def wrap_line(line) - cleaned = clean_line(line) - case line - when /^(---|\+\+\+|\\\\)/ - '
  • ' + line.chomp + '
  • ' - when /^\+/ - '
  • ' + cleaned + '
  • ' - when /^-/ - '
  • ' + cleaned + '
  • ' - when /^ / - '
  • ' + cleaned + '
  • ' - when /^@@/ - '
  • ' + line.chomp + '
  • ' - end - end - - # remove +/- or wrap in html - def clean_line(line) - if @options[:include_plus_and_minus_in_html] - line.sub(/^(.)/, '\1') - else - line.sub(/^./, '') - end.chomp - end - - def wrap_lines(lines) - if lines.empty? - %'
    ' - else - %'
    \n
      \n#{lines.join("\n")}\n
    \n
    \n' - end - end - - def highlighted_words - chunks = @diff.each_chunk. - reject{|c| c == '\ No newline at end of file'"\n"} - - processed = [] - lines = chunks.each_with_index.map do |chunk1, index| - next if processed.include? index - processed << index - chunk1 = chunk1 - chunk2 = chunks[index + 1] - if not chunk2 - next ERB::Util.h(chunk1) - end - - dir1 = chunk1.each_char.first - dir2 = chunk2.each_char.first - case [dir1, dir2] - when ['-', '+'] - if chunk1.each_char.take(3).join("") =~ /^(---|\+\+\+|\\\\)/ and - chunk2.each_char.take(3).join("") =~ /^(---|\+\+\+|\\\\)/ - ERB::Util.h(chunk1) - else - line_diff = Diffy::Diff.new( - split_characters(chunk1), - split_characters(chunk2) - ) - hi1 = reconstruct_characters(line_diff, '-') - hi2 = reconstruct_characters(line_diff, '+') - processed << (index + 1) - [hi1, hi2] - end - else - ERB::Util.h(chunk1) - end - end.flatten - lines.map{|line| line.each_line.map(&:chomp).to_a if line }.flatten.compact. - map{|line|wrap_line(line) }.compact - end - - def split_characters(chunk) - chunk.gsub(/^./, '').each_line.map do |line| - chars = line.sub(/([\r\n]$)/, '').split('') - # add escaped newlines - chars += [($1 || "\n").gsub("\r", '\r').gsub("\n", '\n')] - chars.map{|chr| ERB::Util.h(chr) } - end.flatten.join("\n") + "\n" - end - - def reconstruct_characters(line_diff, type) - enum = line_diff.each_chunk - enum.each_with_index.map do |l, i| - re = /(^|\\n)#{Regexp.escape(type)}/ - case l - when re - highlight(l) - when /^ / - if i > 1 and enum.to_a[i+1] and l.each_line.to_a.size < 4 - highlight(l) - else - l.gsub(/^./, '').gsub("\n", ''). - gsub('\r', "\r").gsub('\n', "\n") - end - end - end.join('').split("\n").map do |l| - type + l.gsub('' , '') - end - end - - def highlight(lines) - "" + - lines. - # strip diff tokens (e.g. +,-,etc.) - gsub(/(^|\\n)./, ''). - # mark line boundaries from higher level line diff - # html is all escaped so using brackets should make this safe. - gsub('\n', ''). - # join characters back by stripping out newlines - gsub("\n", ''). - # close and reopen strong tags. we don't want inline elements - # spanning block elements which get added later. - gsub('',"\n") + "" - end - end -end diff --git a/vendor/plugins/diffy/lib/diffy/version.rb b/vendor/plugins/diffy/lib/diffy/version.rb deleted file mode 100644 index 630ea8c..0000000 --- a/vendor/plugins/diffy/lib/diffy/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Diffy - VERSION = '3.0.3' -end diff --git a/vendor/plugins/diffy/spec/demo_app.rb b/vendor/plugins/diffy/spec/demo_app.rb deleted file mode 100644 index 1db939a..0000000 --- a/vendor/plugins/diffy/spec/demo_app.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'rubygems' -require 'sinatra' -require 'json' -require File.dirname(__FILE__) + '/../lib/diffy' - -blk = proc do - Diffy::Diff.default_options.merge! JSON.parse(params[:options]) rescue {} - haml "- d = Diffy::Diff.new(params[:one].to_s, params[:two].to_s)\n%div= d.to_s(:html)\n%pre= d.to_s" -end -post '/', &blk -get '/', &blk -__END__ - -@@ layout -%html - %head - :css - .diff{overflow:auto;} - .diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;} - .diff del, .diff ins{display:block;text-decoration:none;} - .diff li{padding:0; display:table-row;margin: 0;height:1em;} - .diff li.ins{background:#dfd; color:#080} - .diff li.del{background:#fee; color:#b00} - .diff li:hover{background:#ffc} - .diff del, .diff ins, .diff span{white-space:pre-wrap;font-family:courier;} - .diff del strong{font-weight:normal;background:#fcc;} - .diff ins strong{font-weight:normal;background:#9f9;} - .diff li.diff-comment { display: none; } - .diff li.diff-block-info { background: none repeat scroll 0 0 gray; } - %body - = yield - %form{:action => '', :method => 'post'} - %label JSON diff options - %textarea{:name => 'options', :style => 'width:100%;height:250px;'}= params[:options] - %label One - %textarea{:name => 'one', :style => 'width:100%;height:250px;'}= params[:one] - %br/ - %label Two - %textarea{:name => 'two', :style => 'width:100%;height:250px;'}= params[:two] - %br/ - %input{:type => 'submit'} - %br/ - -@@ index -%div.title Hello world!!!!! - diff --git a/vendor/plugins/diffy/spec/diffy_spec.rb b/vendor/plugins/diffy/spec/diffy_spec.rb deleted file mode 100644 index bcc23b3..0000000 --- a/vendor/plugins/diffy/spec/diffy_spec.rb +++ /dev/null @@ -1,576 +0,0 @@ -require 'rspec' -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'diffy')) - -describe Diffy::Diff do - - describe "diffing two files" do - def tempfile(string, fn = 'diffy-spec') - t = Tempfile.new(fn) - # ensure tempfiles aren't unlinked when GC runs by maintaining a - # reference to them. - @tempfiles ||=[] - @tempfiles.push(t) - t.print(string) - t.flush - t.close - t.path - end - - it "should accept file paths as arguments" do - string1 = "foo\nbar\nbang\n" - string2 = "foo\nbang\n" - path1, path2 = tempfile(string1), tempfile(string2) - Diffy::Diff.new(path1, path2, :source => 'files').to_s.should == <<-DIFF - foo --bar - bang - DIFF - end - - it "should accept file paths with spaces as arguments" do - string1 = "foo\nbar\nbang\n" - string2 = "foo\nbang\n" - path1, path2 = tempfile(string1, 'path with spaces'), tempfile(string2, 'path with spaces') - Diffy::Diff.new(path1, path2, :source => 'files').to_s.should == <<-DIFF - foo --bar - bang - DIFF - end - - it "should accept file paths with spaces as arguments on windows" do - begin - - orig_verbose, $VERBOSE = $VERBOSE, nil #silence redefine constant warnings - orig_windows, Diffy::WINDOWS = Diffy::WINDOWS, true - string1 = "foo\nbar\nbang\n" - string2 = "foo\nbang\n" - path1, path2 = tempfile(string1, 'path with spaces'), tempfile(string2, 'path with spaces') - Diffy::Diff.new(path1, path2, :source => 'files').to_s.should == <<-DIFF - foo --bar - bang - DIFF - ensure - Diffy::WINDOWS, $VERBOSE = orig_windows, orig_verbose - end - - end - - describe "with no line different" do - before do - string1 = "foo\nbar\nbang\n" - string2 = "foo\nbar\nbang\n" - @path1, @path2 = tempfile(string1), tempfile(string2) - end - - it "should show everything" do - Diffy::Diff.new(@path1, @path2, :source => 'files', :allow_empty_diff => false). - to_s.should == <<-DIFF - foo - bar - bang - DIFF - end - - it "should not show everything if the :allow_empty_diff option is set" do - Diffy::Diff.new(@path1, @path2, :source => 'files', :allow_empty_diff => true).to_s.should == '' - end - end - describe "with lines that start with backslashes" do - before do - string1 = "foo\n\\\\bag\nbang\n" - string2 = "foo\n\\\\bar\nbang\n" - @path1, @path2 = tempfile(string1), tempfile(string2) - end - - it "should not leave lines out" do - Diffy::Diff.new(@path1, @path2, :source => 'files').to_s.should == <<-DIFF - foo --\\\\bag -+\\\\bar - bang - DIFF - end - end - - describe "with non valid UTF bytes" do - before do - string1 = "Foo ICS95095010000000000083320000BS01030000004100+\xFF00000000000000000\n" - string2 = "Bar ICS95095010000000000083320000BS01030000004100+\xFF00000000000000000\n" - @path1, @path2 = tempfile(string1), tempfile(string2) - end - it "should not raise invalid encoding issues" do - desired = <<-DIFF --Foo ICS95095010000000000083320000BS01030000004100+\xFF00000000000000000 -+Bar ICS95095010000000000083320000BS01030000004100+\xFF00000000000000000 - DIFF - desired.force_encoding("ASCII-8BIT") if desired.respond_to?(:force_encoding) - Diffy::Diff.new(@path1, @path2, :source => 'files').to_s.should == desired - end - end - - end - - describe "handling temp files" do - it "should unlink tempfiles after generating the diff" do - before_tmpfiles = Dir.entries(Dir.tmpdir) - d = ::Diffy::Diff.new("a", "b").to_s - after_tmpfiles = Dir.entries(Dir.tmpdir) - before_tmpfiles.should =~ after_tmpfiles - end - - it "should still be able to generate multiple diffs" do - d = ::Diffy::Diff.new("a", "b") - d.to_s.should be_a String - d.to_s(:html).should be_a String - end - end - - describe "options[:context]" do - it "should limit context lines to 1" do - diff = Diffy::Diff.new("foo\nfoo\nBAR\nbang\nbaz", "foo\nfoo\nbar\nbang\nbaz", :context => 1) - diff.to_s.should == <<-DIFF - foo --BAR -+bar - bang - DIFF - end - end - - describe "options[:include_plus_and_minus_in_html]" do - it "defaults to false" do - @diffy = Diffy::Diff.new(" foo\nbar\n", "foo\nbar\n") - @diffy.options[:include_plus_and_minus_in_html].should == false - end - - it "can be set to true" do - @diffy = Diffy::Diff.new(" foo\nbar\n", "foo\nbar\n", :include_plus_and_minus_in_html=> true ) - @diffy.options[:include_plus_and_minus_in_html].should == true - end - - describe "formats" do - it "includes symbols in html_simple" do - output = Diffy::Diff.new("foo\nbar\nbang\n", "foo\nbang\n", :include_plus_and_minus_in_html => true ). - to_s(:html_simple) - output.should == <<-HTML -
    -
      -
    • foo
    • -
    • -bar
    • -
    • bang
    • -
    -
    - HTML - end - - it "includes symbols in html" do - output = Diffy::Diff.new("foo\nbar\nbang\n", "foo\naba\nbang\n", :include_plus_and_minus_in_html => true ). - to_s(:html) - output.should == <<-HTML -
    -
      -
    • foo
    • -
    • -bar
    • -
    • +aba
    • -
    • bang
    • -
    -
    - HTML - end - - end - - end - - describe "options[:include_diff_info]" do - it "defaults to false" do - @diffy = Diffy::Diff.new(" foo\nbar\n", "foo\nbar\n") - @diffy.options[:include_diff_info].should == false - end - - it "can be set to true" do - @diffy = Diffy::Diff.new(" foo\nbar\n", "foo\nbar\n", :include_diff_info => true ) - @diffy.options[:include_diff_info].should == true - end - - it "includes all diff output" do - output = Diffy::Diff.new("foo\nbar\nbang\n", "foo\nbang\n", :include_diff_info => true ).to_s - output.to_s.should match( /@@/) - output.should match( /---/) - output.should match( /\+\+\+/) - end - - describe "formats" do - it "works for :color" do - output = Diffy::Diff.new("foo\nbar\nbang\n", "foo\nbang\n", :include_diff_info => true ).to_s(:color) - output.should match( /\e\[0m\n\e\[36m\@\@/ ) - output.to_s.should match( /\e\[90m---/) - output.to_s.should match( /\e\[0m\n\e\[90m\+\+\+/) - end - - it "works for :html_simple" do - output = Diffy::Diff.new("foo\nbar\nbang\n", "foo\nbang\n", :include_diff_info => true ).to_s(:html_simple) - output.split("\n").should include( "
  • @@ -1,3 +1,2 @@
  • " ) - output.should include( "
  • ---") - output.should include( "
  • +++") - end - end - end - - describe "options[:diff]" do - it "should accept an option to diff" do - @diff = Diffy::Diff.new(" foo\nbar\n", "foo\nbar\n", :diff => "-w", :allow_empty_diff => false) - @diff.to_s.should == <<-DIFF - foo - bar - DIFF - end - - it "should accept multiple arguments to diff" do - @diff = Diffy::Diff.new(" foo\nbar\n", "foo\nbaz\n", :diff => ["-w", "-U 3"]) - @diff.to_s.should == <<-DIFF - foo --bar -+baz - DIFF - end - end - - describe "#to_s" do - describe "with no line different" do - before do - @string1 = "foo\nbar\nbang\n" - @string2 = "foo\nbar\nbang\n" - end - - it "should show everything" do - Diffy::Diff.new(@string1, @string2, :allow_empty_diff => false).to_s.should == <<-DIFF - foo - bar - bang - DIFF - end - end - describe "with one line different" do - before do - @string1 = "foo\nbar\nbang\n" - @string2 = "foo\nbang\n" - end - - it "should show one line removed" do - Diffy::Diff.new(@string1, @string2).to_s.should == <<-DIFF - foo --bar - bang - DIFF - end - - it "to_s should accept a format key" do - Diffy::Diff.new(@string1, @string2).to_s(:color). - should == " foo\n\e[31m-bar\e[0m\n bang\n" - end - - it "should accept a default format option" do - old_format = Diffy::Diff.default_format - Diffy::Diff.default_format = :color - Diffy::Diff.new(@string1, @string2).to_s. - should == " foo\n\e[31m-bar\e[0m\n bang\n" - Diffy::Diff.default_format = old_format - end - - it "should accept a default options" do - old_options = Diffy::Diff.default_options - Diffy::Diff.default_options = old_options.merge(:include_diff_info => true) - Diffy::Diff.new(@string1, @string2).to_s. - should include('@@ -1,3 +1,2 @@') - Diffy::Diff.default_options = old_options - end - - it "should show one line added" do - Diffy::Diff.new(@string2, @string1).to_s. - should == <<-DIFF - foo -+bar - bang - DIFF - end - end - - describe "with one line changed" do - before do - @string1 = "foo\nbar\nbang\n" - @string2 = "foo\nbong\nbang\n" - end - it "should show one line added and one removed" do - Diffy::Diff.new(@string1, @string2).to_s.should == <<-DIFF - foo --bar -+bong - bang - DIFF - end - end - - describe "with totally different strings" do - before do - @string1 = "foo\nbar\nbang\n" - @string2 = "one\ntwo\nthree\n" - end - it "should show one line added and one removed" do - Diffy::Diff.new(@string1, @string2).to_s.should == <<-DIFF --foo --bar --bang -+one -+two -+three - DIFF - end - end - - describe "with a somewhat complicated diff" do - before do - @string1 = "foo\nbar\nbang\nwoot\n" - @string2 = "one\ntwo\nthree\nbar\nbang\nbaz\n" - @diff = Diffy::Diff.new(@string1, @string2) - end - it "should show one line added and one removed" do - @diff.to_s.should == <<-DIFF --foo -+one -+two -+three - bar - bang --woot -+baz - DIFF - end - - it "should make an awesome simple html diff" do - @diff.to_s(:html_simple).should == <<-HTML -
    -
      -
    • foo
    • -
    • one
    • -
    • two
    • -
    • three
    • -
    • bar
    • -
    • bang
    • -
    • woot
    • -
    • baz
    • -
    -
    - HTML - end - - it "should accept overrides to diff's options" do - @diff = Diffy::Diff.new(@string1, @string2, :diff => "--rcs") - @diff.to_s.should == <<-DIFF -d1 1 -a1 3 -one -two -three -d4 1 -a4 1 -baz - DIFF - end - end - - describe "html" do - it "should not allow html injection on the last line" do - @string1 = "hahaha\ntime flies like an arrow\nfoo bar\nbang baz\n", "").to_s(:html) - diff.should include('<script>') - diff.should_not include('