pretty_diff 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +41 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/lib/pretty_diff.rb +9 -0
- data/lib/pretty_diff/chunk.rb +43 -0
- data/lib/pretty_diff/diff.rb +58 -0
- data/lib/pretty_diff/html_generator.rb +86 -0
- data/lib/pretty_diff/line.rb +53 -0
- data/lib/pretty_diff/line_numbers.rb +79 -0
- data/lib/pretty_diff/support.rb +8 -0
- data/pretty_diff.gemspec +70 -0
- data/test/chunk_test.rb +36 -0
- data/test/data/first.diff +34 -0
- data/test/data/second.diff +308 -0
- data/test/diff_test.rb +29 -0
- data/test/helper.rb +15 -0
- data/test/html_generator_test.rb +39 -0
- data/test/line_test.rb +45 -0
- metadata +92 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Ilya Sabanin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
= Pretty Diff
|
2
|
+
|
3
|
+
A tiny library for generating pretty HTML listings for unified Diff format. Heavily used in Beanstalk (http://beanstalkapp.com) application.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install pretty_diff
|
8
|
+
|
9
|
+
== Example
|
10
|
+
|
11
|
+
A quick example will tell it all:
|
12
|
+
|
13
|
+
udiff = File.read("awesome.diff")
|
14
|
+
pretty = PrettyDiff::Diff.new(udiff)
|
15
|
+
pretty.to_html
|
16
|
+
|
17
|
+
Wrap it with HTML, add some styles and you will get something like this:
|
18
|
+
|
19
|
+
http://ilya.sabanin.ru/projects/pretty_diff_example.html
|
20
|
+
|
21
|
+
== Features
|
22
|
+
|
23
|
+
The library is really easy to read and change. All HTML is concentrated in a single place -- HtmlGenerator; so it's very easy to customize the output to suit your needs.
|
24
|
+
|
25
|
+
By default PrettyDiff will generate HTML that can be easily colored with the CSS that you can find in the example above.
|
26
|
+
|
27
|
+
PrettyDiff will generate 2 columns of line numbers, as it's usually done for diffs. These columns are copy & paste safe, means that line numbers won't be copied when you copy diff contents.
|
28
|
+
|
29
|
+
Tabs will be automatically converted to double spaces.
|
30
|
+
|
31
|
+
HTML tags will be automatically escaped from the input string.
|
32
|
+
|
33
|
+
== To Do
|
34
|
+
|
35
|
+
The test suit can be somewhat improved.
|
36
|
+
|
37
|
+
== History
|
38
|
+
|
39
|
+
The library was extracted from Beanstalk during the awesome Wildbit Open Source Fridays.
|
40
|
+
|
41
|
+
Copyright (c) 2010 Ilya Sabanin, Wildbit; see LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "pretty_diff"
|
8
|
+
gem.summary = "Library for converting unified diff format into HTML listings."
|
9
|
+
gem.description = "PrettyDiff is easily customizable library for creating full featured HTML
|
10
|
+
listings out of unified diff format. Include copy&paste-safe line numbers
|
11
|
+
and built-in syntax highlighting."
|
12
|
+
gem.email = "ilya.sabanin@gmail.com"
|
13
|
+
gem.homepage = "http://github.com/isabanin/pretty_diff"
|
14
|
+
gem.authors = ["Ilya Sabanin"]
|
15
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/*_test.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'rcov/rcovtask'
|
32
|
+
Rcov::RcovTask.new do |test|
|
33
|
+
test.libs << 'test'
|
34
|
+
test.pattern = 'test/**/test_*.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :test => :check_dependencies
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rake/rdoctask'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "pretty_diff #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
data/lib/pretty_diff.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Represent a single piece of a diff.
|
3
|
+
#
|
4
|
+
class PrettyDiff::Chunk #:nodoc:
|
5
|
+
attr_reader :meta_info, :input, :lines
|
6
|
+
|
7
|
+
def initialize(meta_info, input)
|
8
|
+
@meta_info = meta_info
|
9
|
+
@input = input
|
10
|
+
end
|
11
|
+
|
12
|
+
# Generate HTML presentation for a Chunk. Return a string.
|
13
|
+
def to_html
|
14
|
+
# We have to find lines before we can call line numbers methods.
|
15
|
+
find_lines!
|
16
|
+
PrettyDiff::HtmlGenerator.generate_chunk(line_numbers, lines)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# Return LineNumbers object that represents two columns of numbers
|
22
|
+
# that will be displayed on the left of the HTML presentation.
|
23
|
+
#
|
24
|
+
# IMPORTANT! Before calling this method it's essential to call "find_lines!" first,
|
25
|
+
# otherwise the array will be empty.
|
26
|
+
def line_numbers
|
27
|
+
@_line_numbers ||= PrettyDiff::LineNumbers.new(meta_info)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Parse the input searching for lines. Initialize Line object for every line.
|
31
|
+
# Return an array of Line objects.
|
32
|
+
def find_lines!
|
33
|
+
returning(@lines = []) do
|
34
|
+
input.split(/\r?\n/).each do |line_str|
|
35
|
+
line = PrettyDiff::Line.new(line_str)
|
36
|
+
next if line.ignore?
|
37
|
+
@lines << line
|
38
|
+
line_numbers.act_on_line(line)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
#
|
4
|
+
# Main class to interact with. In fact this is the only class you should interact with
|
5
|
+
# when using the library.
|
6
|
+
#
|
7
|
+
# === Usage example:
|
8
|
+
# pretty = PrettyDiff::Diff.new(udiff)
|
9
|
+
# pretty.to_html
|
10
|
+
#
|
11
|
+
# Keep in mind that Diff will automatically escape all HTML tags from the intput string
|
12
|
+
# so that it doesn't interfere with the output.
|
13
|
+
#
|
14
|
+
# === Behind The Scenes:
|
15
|
+
# The Diff class is parsing input string and searching for Chunks.
|
16
|
+
# It's then asking HtmlGenerator to generate HTML for those chunks.
|
17
|
+
#
|
18
|
+
class PrettyDiff::Diff
|
19
|
+
CHUNK_REGEXP = /@@ .+ @@\n/
|
20
|
+
|
21
|
+
attr_reader :input
|
22
|
+
|
23
|
+
# Create new Diff object. Accept a String in unified diff format.
|
24
|
+
# Will automatically escape HTML tags from it.
|
25
|
+
def initialize(unified_diff)
|
26
|
+
@input = escape_html(unified_diff)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Generate HTML presentation. Return a string.
|
30
|
+
def to_html
|
31
|
+
PrettyDiff::HtmlGenerator.generate_diff(chunks)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Return an array of Chunk objects that Diff found in the input.
|
37
|
+
def chunks
|
38
|
+
@_chunks ||= find_chunks(input)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Parse the input for diff chunks and initialize a Chunk object for each of them.
|
42
|
+
# Return an array of Chunks.
|
43
|
+
def find_chunks(text)
|
44
|
+
meta_info = text.scan(CHUNK_REGEXP)
|
45
|
+
returning(chunks = []) do
|
46
|
+
split = text.split(CHUNK_REGEXP)
|
47
|
+
split.shift
|
48
|
+
split.each_with_index do |lines, idx|
|
49
|
+
chunks << PrettyDiff::Chunk.new(meta_info[idx], lines)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def escape_html(input_text)
|
55
|
+
CGI.escapeHTML(input_text)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#
|
2
|
+
# This is where all HTML stuff is kept. The module is responsible for converting
|
3
|
+
# various PrettyDiff classes into HTML.
|
4
|
+
#
|
5
|
+
# By customizing this file you can suit the output precisely to your needs.
|
6
|
+
#
|
7
|
+
# By default all HTML is generated with a built-in support for coloring using a
|
8
|
+
# CSS file that's available here:
|
9
|
+
#
|
10
|
+
# http://ilya.sabanin.ru/projects/pretty_diff_example.html
|
11
|
+
#
|
12
|
+
module PrettyDiff::HtmlGenerator #:nodoc:
|
13
|
+
extend self
|
14
|
+
|
15
|
+
def intro
|
16
|
+
%Q[<table class="highlighttable">]
|
17
|
+
end
|
18
|
+
|
19
|
+
def chunk_start
|
20
|
+
%Q[<tr>]
|
21
|
+
end
|
22
|
+
|
23
|
+
def line_numbers_column(text)
|
24
|
+
%Q[<td class="linenos"><pre>
|
25
|
+
#{text}</pre></td>]
|
26
|
+
end
|
27
|
+
|
28
|
+
def code(text)
|
29
|
+
%Q[<td class="code"><div class="highlight"><pre>
|
30
|
+
#{text}</pre></div></td>]
|
31
|
+
end
|
32
|
+
|
33
|
+
def added_line(text)
|
34
|
+
%Q[<span class="gi">#{text}</span>]
|
35
|
+
end
|
36
|
+
|
37
|
+
def deleted_line(text)
|
38
|
+
%Q[<span class="gd">#{text}</span>]
|
39
|
+
end
|
40
|
+
|
41
|
+
def not_modified_line(text)
|
42
|
+
text
|
43
|
+
end
|
44
|
+
|
45
|
+
def chunk_end
|
46
|
+
%Q[</tr>]
|
47
|
+
end
|
48
|
+
|
49
|
+
def chunk_separator
|
50
|
+
%Q[<tr class="chunk_separator"><td colspan="3"></td></tr>]
|
51
|
+
end
|
52
|
+
|
53
|
+
def outro
|
54
|
+
%Q[</table>]
|
55
|
+
end
|
56
|
+
|
57
|
+
def generate_diff(chunks)
|
58
|
+
chunks_html = chunks.map{|c| c.to_html}.join(chunk_separator).to_s
|
59
|
+
intro + chunks_html + outro
|
60
|
+
end
|
61
|
+
|
62
|
+
def generate_chunk(numbers, lines)
|
63
|
+
lines_html = lines.map{|l| l.to_html }.join("\n")
|
64
|
+
chunk_start +
|
65
|
+
numbers.to_html +
|
66
|
+
code(lines_html) +
|
67
|
+
chunk_end
|
68
|
+
end
|
69
|
+
|
70
|
+
def generate_line_numbers(left, right)
|
71
|
+
line_numbers_column(left.join("\n")) +
|
72
|
+
line_numbers_column(right.join("\n"))
|
73
|
+
end
|
74
|
+
|
75
|
+
def generate_line(obj)
|
76
|
+
content = obj.rendered
|
77
|
+
if obj.added?
|
78
|
+
added_line(content)
|
79
|
+
elsif obj.deleted?
|
80
|
+
deleted_line(content)
|
81
|
+
else
|
82
|
+
not_modified_line(content)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# Represent a single line of the diff.
|
3
|
+
#
|
4
|
+
class PrettyDiff::Line #:nodoc:
|
5
|
+
attr_reader :input
|
6
|
+
|
7
|
+
def initialize(input)
|
8
|
+
@input = input
|
9
|
+
end
|
10
|
+
|
11
|
+
# Generate HTML presentation for a Line. Return a string.
|
12
|
+
def to_html
|
13
|
+
PrettyDiff::HtmlGenerator.generate_line(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Prepare Line contents for injection into HTML structure.
|
17
|
+
# Currently used for replacing Tab symbols with spaces.
|
18
|
+
# Return a string.
|
19
|
+
def rendered
|
20
|
+
input.gsub("\t", ' ')
|
21
|
+
end
|
22
|
+
|
23
|
+
# Unified Diff sometimes emit a special line at the end of the file
|
24
|
+
# that we should not display in the output.
|
25
|
+
# Return true or false.
|
26
|
+
def ignore?
|
27
|
+
input =~ /\/
|
28
|
+
end
|
29
|
+
|
30
|
+
# Return status of the Line. Can be :added, :deleted or :not_modified.
|
31
|
+
def status
|
32
|
+
case input
|
33
|
+
when /^\+/
|
34
|
+
:added
|
35
|
+
when /^\-/
|
36
|
+
:deleted
|
37
|
+
else
|
38
|
+
:not_modified
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def added?
|
43
|
+
status == :added
|
44
|
+
end
|
45
|
+
|
46
|
+
def deleted?
|
47
|
+
status == :deleted
|
48
|
+
end
|
49
|
+
|
50
|
+
def not_modified?
|
51
|
+
status == :not_modified
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#
|
2
|
+
# Represent 2 columns of numbers that will be displayed
|
3
|
+
# on the left of the HTML presentation.
|
4
|
+
#
|
5
|
+
class PrettyDiff::LineNumbers #:nodoc:
|
6
|
+
|
7
|
+
attr_reader :meta_info
|
8
|
+
|
9
|
+
def initialize(meta)
|
10
|
+
@meta_info = meta
|
11
|
+
end
|
12
|
+
|
13
|
+
# Increase either left column of numbers, right or both of them; depending on the Line status.
|
14
|
+
def act_on_line(line)
|
15
|
+
if line.added?
|
16
|
+
increase_right
|
17
|
+
elsif line.deleted?
|
18
|
+
increase_left
|
19
|
+
else
|
20
|
+
increase_both
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Generate HTML presentation for a both line numbers columns. Return a string.
|
25
|
+
def to_html
|
26
|
+
PrettyDiff::HtmlGenerator.generate_line_numbers(left_column, right_column)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
# Search for information about line numbers changes provided by unified diff format.
|
32
|
+
def scan_meta(target)
|
33
|
+
meta_info.scan(target).flatten.first
|
34
|
+
end
|
35
|
+
|
36
|
+
def left_column
|
37
|
+
@left_column ||= []
|
38
|
+
end
|
39
|
+
|
40
|
+
def right_column
|
41
|
+
@right_column ||= []
|
42
|
+
end
|
43
|
+
|
44
|
+
# Return starting number for the left column according to unified diff information.
|
45
|
+
def left_starts_at
|
46
|
+
scan_meta(/^@@ -(\d+),/).to_i
|
47
|
+
end
|
48
|
+
|
49
|
+
# Return starting number for the right column according to unified diff information.
|
50
|
+
def right_starts_at
|
51
|
+
scan_meta(/\+(\d+),\d+ @@$/).to_i
|
52
|
+
end
|
53
|
+
|
54
|
+
# Increase left column line number by one.
|
55
|
+
def increase_left
|
56
|
+
left_column << increase_or_start(:left)
|
57
|
+
right_column << nil
|
58
|
+
end
|
59
|
+
|
60
|
+
# Increase right column line number by one.
|
61
|
+
def increase_right
|
62
|
+
left_column << nil
|
63
|
+
right_column << increase_or_start(:right)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Increase both columns line numbers by one.
|
67
|
+
def increase_both
|
68
|
+
left_column << increase_or_start(:left)
|
69
|
+
right_column << increase_or_start(:right)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Either increasing existing line number by one or using the initial number provided by
|
73
|
+
# unified diff format.
|
74
|
+
def increase_or_start(which)
|
75
|
+
previous = send("#{which}_column").reverse.find{|e| !e.nil?}
|
76
|
+
if previous then previous + 1 else send("#{which}_starts_at") end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/pretty_diff.gemspec
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{pretty_diff}
|
8
|
+
s.version = "0.3.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ilya Sabanin"]
|
12
|
+
s.date = %q{2010-01-15}
|
13
|
+
s.description = %q{PrettyDiff is easily customizable library for creating full featured HTML
|
14
|
+
listings out of unified diff format. Include copy&paste-safe line numbers
|
15
|
+
and built-in syntax highlighting.}
|
16
|
+
s.email = %q{ilya.sabanin@gmail.com}
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/pretty_diff.rb",
|
29
|
+
"lib/pretty_diff/chunk.rb",
|
30
|
+
"lib/pretty_diff/diff.rb",
|
31
|
+
"lib/pretty_diff/html_generator.rb",
|
32
|
+
"lib/pretty_diff/line.rb",
|
33
|
+
"lib/pretty_diff/line_numbers.rb",
|
34
|
+
"lib/pretty_diff/support.rb",
|
35
|
+
"pretty_diff.gemspec",
|
36
|
+
"test/chunk_test.rb",
|
37
|
+
"test/data/first.diff",
|
38
|
+
"test/data/second.diff",
|
39
|
+
"test/diff_test.rb",
|
40
|
+
"test/helper.rb",
|
41
|
+
"test/html_generator_test.rb",
|
42
|
+
"test/line_test.rb"
|
43
|
+
]
|
44
|
+
s.homepage = %q{http://github.com/isabanin/pretty_diff}
|
45
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = %q{1.3.5}
|
48
|
+
s.summary = %q{Library for converting unified diff format into HTML listings.}
|
49
|
+
s.test_files = [
|
50
|
+
"test/chunk_test.rb",
|
51
|
+
"test/diff_test.rb",
|
52
|
+
"test/helper.rb",
|
53
|
+
"test/html_generator_test.rb",
|
54
|
+
"test/line_test.rb"
|
55
|
+
]
|
56
|
+
|
57
|
+
if s.respond_to? :specification_version then
|
58
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
|
+
s.specification_version = 3
|
60
|
+
|
61
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
62
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
data/test/chunk_test.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
# <link rel="stylesheet" href="../stylesheets/codecolorer.css" type="text/css" media="screen, projection" />
|
4
|
+
# <link rel="stylesheet" href="../stylesheets/modalbox.css" type="text/css" media="screen, projection" />
|
5
|
+
# <link rel="stylesheet" href="../stylesheets/print.css" type="text/css" media="print" />
|
6
|
+
#+ <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" />
|
7
|
+
#+ <link rel="apple-touch-icon" href="../images/apple-touch-icon.png"/>
|
8
|
+
# <script type="text/javascript" src="../javascripts/prototype.js" charset="utf-8"></script>
|
9
|
+
# <script type="text/javascript" src="../javascripts/scriptaculous.js" charset="utf-8"></script>
|
10
|
+
# <script type="text/javascript" src="../javascripts/application.js" charset="utf-8"></script>
|
11
|
+
|
12
|
+
class ChunkTest < Test::Unit::TestCase
|
13
|
+
context "Diff Chunk" do
|
14
|
+
setup do
|
15
|
+
@diff = PrettyDiff::Diff.new read_diff('second.diff')
|
16
|
+
@chunk = @diff.send(:chunks).first
|
17
|
+
@chunk.send(:find_lines!)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "generate HTML without errors" do
|
21
|
+
assert @chunk.to_html
|
22
|
+
end
|
23
|
+
|
24
|
+
should "find correct amount of left line numbers" do
|
25
|
+
assert @chunk.send(:line_numbers).send(:left_column).compact.size == 6
|
26
|
+
end
|
27
|
+
|
28
|
+
should "find correct amount of right line numbers" do
|
29
|
+
assert @chunk.send(:line_numbers).send(:right_column).compact.size == 8
|
30
|
+
end
|
31
|
+
|
32
|
+
should "find correct amount of lines" do
|
33
|
+
assert @chunk.lines.size == 8
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
--- Revision 1945
|
2
|
+
+++ Revision 1995
|
3
|
+
@@ -8,6 +8,10 @@
|
4
|
+
border: 0;
|
5
|
+
}
|
6
|
+
|
7
|
+
+.sep {
|
8
|
+
+ color: #AAA;
|
9
|
+
+}
|
10
|
+
+
|
11
|
+
/* Short statistic */
|
12
|
+
|
13
|
+
.short-stat dl {
|
14
|
+
@@ -59,12 +63,18 @@
|
15
|
+
color: #999;
|
16
|
+
}
|
17
|
+
|
18
|
+
- table.account-overview td .status {
|
19
|
+
+ table.account-overview td.label.top {
|
20
|
+
+ vertical-align: top;
|
21
|
+
+ }
|
22
|
+
+
|
23
|
+
+ table.account-overview td .status,
|
24
|
+
+ table.repos-table td .status {
|
25
|
+
padding-left: 1.75em;
|
26
|
+
background: url(../images/i_error_light.gif) 0 0 no-repeat;
|
27
|
+
}
|
28
|
+
|
29
|
+
- table.account-overview td .status.active {
|
30
|
+
+ table.account-overview td .status.active,
|
31
|
+
+ table.repos-table td .status.success {
|
32
|
+
padding-left: 1.75em;
|
33
|
+
background: url(../images/i-yes.gif) 0 0 no-repeat;
|
34
|
+
}
|
@@ -0,0 +1,308 @@
|
|
1
|
+
--- Revision 1053
|
2
|
+
+++ Revision 2195
|
3
|
+
@@ -11,6 +11,8 @@
|
4
|
+
<link rel="stylesheet" href="../stylesheets/codecolorer.css" type="text/css" media="screen, projection" />
|
5
|
+
<link rel="stylesheet" href="../stylesheets/modalbox.css" type="text/css" media="screen, projection" />
|
6
|
+
<link rel="stylesheet" href="../stylesheets/print.css" type="text/css" media="print" />
|
7
|
+
+ <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" />
|
8
|
+
+ <link rel="apple-touch-icon" href="../images/apple-touch-icon.png"/>
|
9
|
+
<script type="text/javascript" src="../javascripts/prototype.js" charset="utf-8"></script>
|
10
|
+
<script type="text/javascript" src="../javascripts/scriptaculous.js" charset="utf-8"></script>
|
11
|
+
<script type="text/javascript" src="../javascripts/application.js" charset="utf-8"></script>
|
12
|
+
@@ -19,12 +21,10 @@
|
13
|
+
<body>
|
14
|
+
<div id="container">
|
15
|
+
<div id="header">
|
16
|
+
- <ul class="metanav">
|
17
|
+
- <li class="active"><a href="hq-dashboard.html" title="Dashboard"><span>Dashboard</span></a></li>
|
18
|
+
- <li><a href="hq-profile.html" title="My Profile"><span>My Profile</span></a></li>
|
19
|
+
- <li><a href="help.html" title="Help"><span>Help</span></a></li>
|
20
|
+
- <li><a href="logout.html" title="Logout"><span>Logout</span></a></li>
|
21
|
+
- </ul>
|
22
|
+
+ <div class="metanav">
|
23
|
+
+ <p class="meta-global"><a href="hq-dashboard.html" title="Dashboard">Dashboard</a> • <a href="help-overview.html" title="Help">Help</a></p>
|
24
|
+
+ <p class="meta-personal"><em>Andrew Okonetschnikow</em> • <a href="hq-profile.html" title="My Profile">My Profile</a> • <a href="logout.html" title="Logout">Logout</a></p>
|
25
|
+
+ </div>
|
26
|
+
|
27
|
+
<h1>Wildbit</h1>
|
28
|
+
<ul class="mainnav">
|
29
|
+
@@ -49,175 +49,141 @@
|
30
|
+
|
31
|
+
<form action="search-results.html" method="get" class="search-form">
|
32
|
+
<fieldset>
|
33
|
+
- <legend><b>Search in all repositories</b></legend>
|
34
|
+
<div class="form-row">
|
35
|
+
- <input type="search" name="search" id="search" size="50" value="keyword" style="width: 90%" /> <input type="submit" value="Go!" style="width: 5% " />
|
36
|
+
+ <input type="search" name="search" id="search" size="50" value="keyword" />
|
37
|
+
+ <select>
|
38
|
+
+ <option>All repositories</option>
|
39
|
+
+ <option disabled="disabled"></option>
|
40
|
+
+ <option>Beanstalk</option>
|
41
|
+
+ <option>Newsberry</option>
|
42
|
+
+ <option>Wildbit Public</option>
|
43
|
+
+ </select>
|
44
|
+
+ <input type="submit" value="Search" />
|
45
|
+
</div>
|
46
|
+
</fieldset>
|
47
|
+
</form>
|
48
|
+
|
49
|
+
|
50
|
+
- <h2><b>In comments <span class="light">(9)</span></b></h2>
|
51
|
+
-
|
52
|
+
<div class="activity-timeline search-results">
|
53
|
+
+
|
54
|
+
<div class="rev-item">
|
55
|
+
<h3><a href="repo-activity-changeset.html" title="See revision changeset">765</a></h3>
|
56
|
+
- <p class="rev-repo label-red"><a href="repo-activity.html">Newsberry</a></p>
|
57
|
+
- <p class="rev-user">eugene, <span class="rev-date">10/21/07</span></p>
|
58
|
+
-
|
59
|
+
+ <p class="rev-repo label-red"><a href="adm-repo-activity.html">Newsberry</a></p>
|
60
|
+
+ <p class="rev-user"><img src="../images/users/default.gif" alt="Default" /></p>
|
61
|
+
<div class="rev-comment">
|
62
|
+
- <p>
|
63
|
+
- <a href="repo-activity-changeset.html" title="See revision changeset">BugzID: 762 (Green <span class="marked">arrow</span> in Vibe Meter helper)</a>
|
64
|
+
- </p>
|
65
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">BugzID: 762 (Green <span class="highlight">arrow</span> in Vibe Meter helper)</a></p>
|
66
|
+
+ <p class="rev-meta-info">by Eugene Fedorenko (eugene) <span class="time">Feb 06, 2009 15:30:00 GMT</span></p>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
<div class="rev-item">
|
71
|
+
<h3><a href="repo-activity-changeset.html" title="See revision changeset">1062</a></h3>
|
72
|
+
- <p class="rev-repo label-orange"><a href="repo-activity.html">Nuzizo</a></p>
|
73
|
+
- <p class="rev-user">andrew, <span class="rev-date">10/27/07</span></p>
|
74
|
+
-
|
75
|
+
+ <p class="rev-repo label-orange"><a href="adm-repo-activity.html">Nuzizo</a></p>
|
76
|
+
+ <p class="rev-user"><img src="../images/users/andrew.gif" width="32" height="32" alt="Andrew" /></p>
|
77
|
+
<div class="rev-comment">
|
78
|
+
- <p>
|
79
|
+
- <a href="repo-activity-changeset.html" title="See revision changeset">BugzID:689 Dashboard: removed stats box, added hint to profile meter; My <span class="marked">friends updates</span> redesigned; Added colors for profile filling small meters;</a>
|
80
|
+
- </p>
|
81
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">BugzID:689 Dashboard: removed stats box, added hint to <span class="highlight">profile meter</span>; My friends updates redesigned; Added colors for profile filling small meters;</a></p>
|
82
|
+
+ <p class="rev-meta-info">by Andrew Okonetchnikow (andrew) <span class="time">Feb 05, 2009 10:30:00 GMT</span></p>
|
83
|
+
</div>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<div class="rev-item">
|
87
|
+
- <h3><a href="repo-activity-changeset.html" title="See revision changeset">343</a></h3>
|
88
|
+
- <p class="rev-repo label-yellow"><a href="repo-activity.html">Project Alpha</a></p>
|
89
|
+
- <p class="rev-user">dmitry, <span class="rev-date">10/17/07</span></p>
|
90
|
+
-
|
91
|
+
+ <h3><a href="repo-activity-changeset.html" title="See revision changeset">3</a></h3>
|
92
|
+
+ <p class="rev-repo label-yellow"><a href="adm-repo-activity.html">Project Alpha</a></p>
|
93
|
+
+ <p class="rev-user"><img src="../images/users/dmitry.gif" alt="Dmitry" /></p>
|
94
|
+
<div class="rev-comment">
|
95
|
+
- <p>
|
96
|
+
- <a href="repo-activity-changeset.html" title="See revision changeset">Updated copy in minor areas. After speaking with <span class="marked">Darren</span>, there should be a second revision.</a>
|
97
|
+
- </p>
|
98
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">Updated copy in minor areas. After speaking with Darren, there should be a <span class="highlight">second revision</span>.</a></p>
|
99
|
+
+ <p class="rev-meta-info">by Dmitry Sabanin (dmitry) <span class="time">Jan 01, 2008 11:00:00 GMT</span></p>
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
<div class="rev-item">
|
104
|
+
- <h3><a href="repo-activity-changeset.html" title="See revision changeset">1060</a></h3>
|
105
|
+
- <p class="rev-repo label-red"><a href="repo-activity.html">Newsberry</a></p>
|
106
|
+
- <p class="rev-user">eugene, <span class="rev-date">09/13/07</span></p>
|
107
|
+
-
|
108
|
+
+ <h3><a href="repo-activity-changeset.html" title="See revision changeset">765</a></h3>
|
109
|
+
+ <p class="rev-repo label-red"><a href="adm-repo-activity.html">Newsberry</a></p>
|
110
|
+
+ <p class="rev-user"><img src="../images/users/default.gif" alt="Default" /></p>
|
111
|
+
<div class="rev-comment">
|
112
|
+
- <p>
|
113
|
+
- <a href="repo-activity-changeset.html" title="See revision changeset">BugzID: 762 (Green arrow in <span class="marked">Vibe Meter</span> helper)</a>
|
114
|
+
- </p>
|
115
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">BugzID: 762 (Green <span class="highlight">arrow</span> in Vibe Meter helper)</a></p>
|
116
|
+
+ <p class="rev-meta-info">by Eugene Fedorenko (eugene) <span class="time">Feb 06, 2009 15:30:00 GMT</span></p>
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div class="rev-item">
|
121
|
+
- <h3><a href="repo-activity-changeset.html" title="See revision changeset">1059</a></h3>
|
122
|
+
- <p class="rev-repo label-green"><a href="repo-activity.html">PodcastPeople</a></p>
|
123
|
+
- <p class="rev-user">andrew, <span class="rev-date">11/27/07</span></p>
|
124
|
+
-
|
125
|
+
+ <h3><a href="repo-activity-changeset.html" title="See revision changeset">1062</a></h3>
|
126
|
+
+ <p class="rev-repo label-orange"><a href="adm-repo-activity.html">Nuzizo</a></p>
|
127
|
+
+ <p class="rev-user"><img src="../images/users/andrew.gif" width="32" height="32" alt="Andrew" /></p>
|
128
|
+
<div class="rev-comment">
|
129
|
+
- <p>
|
130
|
+
- <a href="repo-activity-changeset.html" title="See revision changeset">BugzID: 762 (Green arrow in <span class="marked">Vibe Meter</span> helper)</a>
|
131
|
+
- </p>
|
132
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">BugzID:689 Dashboard: removed stats box, added hint to <span class="highlight">profile meter</span>; My friends updates redesigned; Added colors for profile filling small meters;</a></p>
|
133
|
+
+ <p class="rev-meta-info">by Andrew Okonetchnikow (andrew) <span class="time">Feb 05, 2009 10:30:00 GMT</span></p>
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
- <p class="more"><a href="#">See more results in comments…</a></p>
|
137
|
+
- </div>
|
138
|
+
|
139
|
+
-
|
140
|
+
- <h2><b>In files <span class="light">(7)</span></b></h2>
|
141
|
+
-
|
142
|
+
- <div class="activity-timeline search-results">
|
143
|
+
<div class="rev-item">
|
144
|
+
- <h3><a href="repo-activity-changeset.html" title="See revision changeset">765</a></h3>
|
145
|
+
- <p class="rev-repo label-red"><a href="repo-activity.html">Newsberry</a></p>
|
146
|
+
- <p class="rev-user">eugene, <span class="rev-date">10/21/07</span></p>
|
147
|
+
-
|
148
|
+
- <div class="file-desc">
|
149
|
+
- <h3 class="diff-title" id="diff01">trunk/application/app/controllers/logs_controller.rb</h3>
|
150
|
+
- <div class="codecolorer-container javascript">
|
151
|
+
- <div class="codecolorer">
|
152
|
+
- <ol start="21">
|
153
|
+
- <li class="li1"><div class="de1">getWidth: <span class="kw2">function</span><span class="br0">(</span><span class="marked">element</span><span class="br0">)</span> <span class="br0">{</span></div></li>
|
154
|
+
- <li class="li1"><div class="de1"> <span class="kw1">return</span> $<span class="br0">(</span>element<span class="br0">)</span>.<span class="me1">getDimensions</span><span class="br0">(</span><span class="br0">)</span>.<span class="me1">width</span>;</div></li>
|
155
|
+
- </ol>
|
156
|
+
- </div>
|
157
|
+
- </div>
|
158
|
+
+ <h3><a href="repo-activity-changeset.html" title="See revision changeset">3</a></h3>
|
159
|
+
+ <p class="rev-repo label-yellow"><a href="adm-repo-activity.html">Project Alpha</a></p>
|
160
|
+
+ <p class="rev-user"><img src="../images/users/dmitry.gif" alt="Dmitry" /></p>
|
161
|
+
+ <div class="rev-comment">
|
162
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">Updated copy in minor areas. After speaking with Darren, there should be a <span class="highlight">second revision</span>.</a></p>
|
163
|
+
+ <p class="rev-meta-info">by Dmitry Sabanin (dmitry) <span class="time">Jan 01, 2008 11:00:00 GMT</span></p>
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
<div class="rev-item">
|
168
|
+
- <h3><a href="repo-activity-changeset.html" title="See revision changeset">1062</a></h3>
|
169
|
+
- <p class="rev-repo label-orange"><a href="repo-activity.html">Nuzizo</a></p>
|
170
|
+
- <p class="rev-user">andrew, <span class="rev-date">10/27/07</span></p>
|
171
|
+
-
|
172
|
+
- <div class="file-desc">
|
173
|
+
- <h3 class="diff-title" id="diff01">trunk/application/app/controllers/logs_controller.rb</h3>
|
174
|
+
- <div class="codecolorer-container javascript">
|
175
|
+
- <div class="codecolorer">
|
176
|
+
- <ol start="623">
|
177
|
+
- <li class="li1"><div class="de1"> els.<span class="me1">display</span> = <span class="st0">'block'</span>;</div></li>
|
178
|
+
- <li class="li1"><div class="de1"> <span class="kw2">var</span> original<span class="marked">Width</span> = element.<span class="me1">clientWidth</span>;</div></li>
|
179
|
+
- </ol>
|
180
|
+
- </div>
|
181
|
+
- </div>
|
182
|
+
+ <h3><a href="repo-activity-changeset.html" title="See revision changeset">765</a></h3>
|
183
|
+
+ <p class="rev-repo label-red"><a href="adm-repo-activity.html">Newsberry</a></p>
|
184
|
+
+ <p class="rev-user"><img src="../images/users/default.gif" alt="Default" /></p>
|
185
|
+
+ <div class="rev-comment">
|
186
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">BugzID: 762 (Green <span class="highlight">arrow</span> in Vibe Meter helper)</a></p>
|
187
|
+
+ <p class="rev-meta-info">by Eugene Fedorenko (eugene) <span class="time">Feb 06, 2009 15:30:00 GMT</span></p>
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
|
191
|
+
<div class="rev-item">
|
192
|
+
- <h3><a href="repo-activity-changeset.html" title="See revision changeset">343</a></h3>
|
193
|
+
- <p class="rev-repo label-yellow"><a href="repo-activity.html">Project Alpha</a></p>
|
194
|
+
- <p class="rev-user">dmitry, <span class="rev-date">10/17/07</span></p>
|
195
|
+
-
|
196
|
+
- <div class="file-desc">
|
197
|
+
- <h3 class="diff-title" id="diff01">trunk/application/app/controllers/logs_controller.rb</h3>
|
198
|
+
- <div class="codecolorer-container javascript">
|
199
|
+
- <div class="codecolorer">
|
200
|
+
- <ol start="73">
|
201
|
+
- <li class="li1"><div class="de1"> <span class="kw1">if</span> <span class="br0">(</span>display != <span class="st0">'none'</span> && display != <span class="kw2">null</span><span class="br0">)</span> <span class="co1">// Safari bug</span></div></li>
|
202
|
+
- <li class="li1"><div class="de1"> <span class="kw1">return</span> <span class="br0">{</span>width: <span class="marked">element</span>.<span class="me1">offsetWidth</span>, height: element.<span class="me1">offsetHeight</span><span class="br0">}</span>;</div></li>
|
203
|
+
- </ol>
|
204
|
+
- </div>
|
205
|
+
- </div>
|
206
|
+
+ <h3><a href="repo-activity-changeset.html" title="See revision changeset">1062</a></h3>
|
207
|
+
+ <p class="rev-repo label-orange"><a href="adm-repo-activity.html">Nuzizo</a></p>
|
208
|
+
+ <p class="rev-user"><img src="../images/users/andrew.gif" width="32" height="32" alt="Andrew" /></p>
|
209
|
+
+ <div class="rev-comment">
|
210
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">BugzID:689 Dashboard: removed stats box, added hint to <span class="highlight">profile meter</span>; My friends updates redesigned; Added colors for profile filling small meters;</a></p>
|
211
|
+
+ <p class="rev-meta-info">by Andrew Okonetchnikow (andrew) <span class="time">Feb 05, 2009 10:30:00 GMT</span></p>
|
212
|
+
</div>
|
213
|
+
</div>
|
214
|
+
|
215
|
+
<div class="rev-item">
|
216
|
+
- <h3><a href="repo-activity-changeset.html" title="See revision changeset">1060</a></h3>
|
217
|
+
- <p class="rev-repo label-red"><a href="repo-activity.html">Newsberry</a></p>
|
218
|
+
- <p class="rev-user">eugene, <span class="rev-date">09/13/07</span></p>
|
219
|
+
-
|
220
|
+
- <div class="file-desc">
|
221
|
+
- <h3 class="diff-title" id="diff01">trunk/application/app/controllers/logs_controller.rb</h3>
|
222
|
+
- <div class="codecolorer-container javascript">
|
223
|
+
- <div class="codecolorer">
|
224
|
+
- <ol start="145">
|
225
|
+
- <li class="li1"><div class="de1"> els.<span class="me1"><span class="marked">visibility</span></span> = <span class="st0">'hidden'</span>;</div></li>
|
226
|
+
- <li class="li1"><div class="de1"> els.<span class="me1">position</span> = <span class="st0">'absolute'</span>;</div></li>
|
227
|
+
- </ol>
|
228
|
+
- </div>
|
229
|
+
- </div>
|
230
|
+
+ <h3><a href="repo-activity-changeset.html" title="See revision changeset">3</a></h3>
|
231
|
+
+ <p class="rev-repo label-yellow"><a href="adm-repo-activity.html">Project Alpha</a></p>
|
232
|
+
+ <p class="rev-user"><img src="../images/users/dmitry.gif" alt="Dmitry" /></p>
|
233
|
+
+ <div class="rev-comment">
|
234
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">Updated copy in minor areas. After speaking with Darren, there should be a <span class="highlight">second revision</span>.</a></p>
|
235
|
+
+ <p class="rev-meta-info">by Dmitry Sabanin (dmitry) <span class="time">Jan 01, 2008 11:00:00 GMT</span></p>
|
236
|
+
</div>
|
237
|
+
</div>
|
238
|
+
|
239
|
+
<div class="rev-item">
|
240
|
+
- <h3><a href="repo-activity-changeset.html" title="See revision changeset">1059</a></h3>
|
241
|
+
- <p class="rev-repo label-green"><a href="repo-activity.html">PodcastPeople</a></p>
|
242
|
+
- <p class="rev-user">andrew, <span class="rev-date">11/27/07</span></p>
|
243
|
+
-
|
244
|
+
- <div class="file-desc">
|
245
|
+
- <h3 class="diff-title" id="diff01">trunk/application/app/controllers/logs_controller.rb</h3>
|
246
|
+
- <div class="codecolorer-container javascript">
|
247
|
+
- <div class="codecolorer">
|
248
|
+
- <ol start="572">
|
249
|
+
- <li class="li1"><div class="de1"> els.<span class="me1">display</span> = <span class="st0">'block'</span>;</div></li>
|
250
|
+
- <li class="li1"><div class="de1"> <span class="kw2">var</span> original<span class="marked">Width</span> = element.<span class="me1">clientWidth</span>;</div></li>
|
251
|
+
- </ol>
|
252
|
+
- </div>
|
253
|
+
- </div>
|
254
|
+
+ <h3><a href="repo-activity-changeset.html" title="See revision changeset">765</a></h3>
|
255
|
+
+ <p class="rev-repo label-red"><a href="adm-repo-activity.html">Newsberry</a></p>
|
256
|
+
+ <p class="rev-user"><img src="../images/users/default.gif" alt="Default" /></p>
|
257
|
+
+ <div class="rev-comment">
|
258
|
+
+ <p><a href="repo-activity-changeset.html" title="See revision changeset">BugzID: 762 (Green <span class="highlight">arrow</span> in Vibe Meter helper)</a></p>
|
259
|
+
+ <p class="rev-meta-info">by Eugene Fedorenko (eugene) <span class="time">Feb 06, 2009 15:30:00 GMT</span></p>
|
260
|
+
</div>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
- <p class="more"><a href="#">See more results in files…</a></p>
|
264
|
+
+ </div>
|
265
|
+
|
266
|
+
+ <div class="paginator">
|
267
|
+
+ <p class="status">Showing <strong>1–20</strong> of 2532 commits</p>
|
268
|
+
+ <div class="pageList">
|
269
|
+
+ <span class="disabled">← Previous</span>
|
270
|
+
+ <span class="current">1</span>
|
271
|
+
+ <a class="page" href="/page2/">2</a>
|
272
|
+
+ <a class="page" href="/page3/">3</a>
|
273
|
+
+ <a class="page" href="/page4/">4</a>
|
274
|
+
+ <a class="page" href="/page5/">5</a>
|
275
|
+
+ <a class="page" href="/page6/">6</a>
|
276
|
+
+ <a class="page" href="/page7/">7</a>
|
277
|
+
+ <span class="break">...</span>
|
278
|
+
+ <a class="page" href="/page57/">57</a>
|
279
|
+
+ <a class="page end" href="/page58/">58</a>
|
280
|
+
+ <a class="link" href="#2">Next →</a>
|
281
|
+
+ </div>
|
282
|
+
</div>
|
283
|
+
|
284
|
+
</div>
|
285
|
+
@@ -225,10 +191,18 @@
|
286
|
+
</div>
|
287
|
+
|
288
|
+
<div id="footer">
|
289
|
+
- <a class="beanstalk-logo" href="../../public/" title="Beanstalk version control for team leads">Beanstalk version control for team leads</a>
|
290
|
+
- <p class="vcard">© 2007, <a href="http://www.wildbit.com/" class="fn org url">Wildbit LLC</a>. All rights reserved.</p>
|
291
|
+
- <p><a href="textpage-privacy.html">Privacy Policy</a> <span class="sep">•</span> <a href="textpage-terms.html">Terms of Use</a></p>
|
292
|
+
+ <div class="wildbit">
|
293
|
+
+ <a class="beanstalk-logo" href="../../public/" title="Beanstalk version control for team leads"> </a>
|
294
|
+
+ <p class="vcard">© 2007, <a href="http://www.wildbit.com/" class="fn org url">Wildbit LLC</a>. All rights reserved.</p>
|
295
|
+
+ <p><a href="textpage-privacy.html">Privacy Policy</a> <span class="sep">•</span> <a href="textpage-terms.html">Terms of Use</a></p>
|
296
|
+
+ </div>
|
297
|
+
+
|
298
|
+
+ <div class="engine-yard">
|
299
|
+
+ <a class="ey-logo" href="http://engineyard.com" title="Engine Yard: Fully-Managed Ruby & Rails Hosting and Deployment"> </a>
|
300
|
+
+ <p>Hosting provided by our</p>
|
301
|
+
+ <p>partners at <a href="http://engineyard.com" title="Engine Yard: Fully-Managed Ruby & Rails Hosting and Deployment">Engine Yard</a></p>
|
302
|
+
+ </div>
|
303
|
+
</div>
|
304
|
+
-
|
305
|
+
+</div>
|
306
|
+
</body>
|
307
|
+
</html>
|
308
|
+
|
data/test/diff_test.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
require 'cgi'
|
3
|
+
|
4
|
+
class DiffTest < Test::Unit::TestCase
|
5
|
+
context "Pretty Diff" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@small_diff = PrettyDiff::Diff.new read_diff('first.diff')
|
9
|
+
@big_diff = PrettyDiff::Diff.new read_diff('second.diff')
|
10
|
+
end
|
11
|
+
|
12
|
+
should "generate correct amount of chunks for each diff" do
|
13
|
+
assert_equal 2, @small_diff.send(:chunks).size
|
14
|
+
assert_equal 4, @big_diff.send(:chunks).size
|
15
|
+
end
|
16
|
+
|
17
|
+
should "generate HTML representation without errors" do
|
18
|
+
assert @small_diff.to_html
|
19
|
+
assert @big_diff.to_html
|
20
|
+
end
|
21
|
+
|
22
|
+
should "escape HTML from the input string" do
|
23
|
+
text = "<b>Funky HTML</b>"
|
24
|
+
diff = PrettyDiff::Diff.new(text)
|
25
|
+
assert_equal "<b>Funky HTML</b>", diff.input
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
require 'pretty_diff'
|
8
|
+
|
9
|
+
class Test::Unit::TestCase
|
10
|
+
|
11
|
+
def read_diff(name)
|
12
|
+
File.read(File.join(File.dirname(__FILE__), "data", name))
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class HtmlGeneratorTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Html Generator" do
|
6
|
+
|
7
|
+
context "for lines" do
|
8
|
+
should "generate correct HTML for added line" do
|
9
|
+
text = "+package chiro.methods.new.ones;"
|
10
|
+
expected_html = %Q[<span class="gi">#{text}</span>]
|
11
|
+
assert_equal expected_html, line_to_html(text)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "generate correct HTML for deleted line" do
|
15
|
+
text = '- browser.setTimeout("50000");'
|
16
|
+
expected_html = %Q[<span class="gd">- browser.setTimeout("50000");</span>]
|
17
|
+
assert_equal expected_html, line_to_html(text)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "generate correct HTML for not modified line" do
|
21
|
+
text = ' public static void close() {'
|
22
|
+
expected_html = " public static void close() {"
|
23
|
+
assert_equal expected_html, line_to_html(text)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def new_line(text)
|
32
|
+
PrettyDiff::Line.new(text)
|
33
|
+
end
|
34
|
+
|
35
|
+
def line_to_html(text)
|
36
|
+
new_line(text).to_html
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/test/line_test.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class LineTest < Test::Unit::TestCase
|
4
|
+
context "PrettyDiff's Line" do
|
5
|
+
|
6
|
+
should "indicate :added status correctly" do
|
7
|
+
added_line = new_diff("+package chiro.methods.new.ones;")
|
8
|
+
assert_equal :added, added_line.status
|
9
|
+
end
|
10
|
+
|
11
|
+
should "indicate :deleted status correctly" do
|
12
|
+
deleted_line = new_diff('-browser.setTimeout("50000");')
|
13
|
+
assert_equal :deleted, deleted_line.status
|
14
|
+
end
|
15
|
+
|
16
|
+
should "indicate :not_modified status correctly" do
|
17
|
+
not_modified_line = new_diff("class User < ActiveRecord::Base")
|
18
|
+
assert_equal :not_modified, not_modified_line.status
|
19
|
+
end
|
20
|
+
|
21
|
+
should "ignore trailing 'no newline' text" do
|
22
|
+
text = ''
|
23
|
+
line = new_diff(text)
|
24
|
+
assert line.ignore?
|
25
|
+
end
|
26
|
+
|
27
|
+
should "replace tabs with spaces" do
|
28
|
+
text = " hello eptut {1, 2, 3}"
|
29
|
+
expected_output = " hello eptut {1, 2, 3}"
|
30
|
+
line = new_diff(text)
|
31
|
+
assert_equal expected_output, line.rendered
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def new_diff(text)
|
39
|
+
PrettyDiff::Line.new(text)
|
40
|
+
end
|
41
|
+
|
42
|
+
def line_to_html(text)
|
43
|
+
new_diff(text).to_html
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pretty_diff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilya Sabanin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-15 00:00:00 +07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thoughtbot-shoulda
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: |-
|
26
|
+
PrettyDiff is easily customizable library for creating full featured HTML
|
27
|
+
listings out of unified diff format. Include copy&paste-safe line numbers
|
28
|
+
and built-in syntax highlighting.
|
29
|
+
email: ilya.sabanin@gmail.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files:
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
files:
|
38
|
+
- .document
|
39
|
+
- .gitignore
|
40
|
+
- LICENSE
|
41
|
+
- README.rdoc
|
42
|
+
- Rakefile
|
43
|
+
- VERSION
|
44
|
+
- lib/pretty_diff.rb
|
45
|
+
- lib/pretty_diff/chunk.rb
|
46
|
+
- lib/pretty_diff/diff.rb
|
47
|
+
- lib/pretty_diff/html_generator.rb
|
48
|
+
- lib/pretty_diff/line.rb
|
49
|
+
- lib/pretty_diff/line_numbers.rb
|
50
|
+
- lib/pretty_diff/support.rb
|
51
|
+
- pretty_diff.gemspec
|
52
|
+
- test/chunk_test.rb
|
53
|
+
- test/data/first.diff
|
54
|
+
- test/data/second.diff
|
55
|
+
- test/diff_test.rb
|
56
|
+
- test/helper.rb
|
57
|
+
- test/html_generator_test.rb
|
58
|
+
- test/line_test.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/isabanin/pretty_diff
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --charset=UTF-8
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.5
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Library for converting unified diff format into HTML listings.
|
87
|
+
test_files:
|
88
|
+
- test/chunk_test.rb
|
89
|
+
- test/diff_test.rb
|
90
|
+
- test/helper.rb
|
91
|
+
- test/html_generator_test.rb
|
92
|
+
- test/line_test.rb
|