pretty_diff 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/pretty_diff/chunk.rb +5 -4
- data/lib/pretty_diff/diff.rb +8 -4
- data/lib/pretty_diff/html_generators/line_generator.rb +5 -3
- data/lib/pretty_diff/html_generators/line_numbers_generator.rb +1 -1
- data/lib/pretty_diff/line.rb +3 -2
- data/lib/pretty_diff/line_numbers.rb +3 -2
- data/pretty_diff.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/pretty_diff/chunk.rb
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
# Represent a single piece of a diff.
|
3
3
|
#
|
4
4
|
class PrettyDiff::Chunk #:nodoc:
|
5
|
-
attr_reader :meta_info, :input, :lines
|
5
|
+
attr_reader :diff, :meta_info, :input, :lines
|
6
6
|
|
7
|
-
def initialize(meta_info, input)
|
7
|
+
def initialize(diff, meta_info, input)
|
8
|
+
@diff = diff
|
8
9
|
@meta_info = meta_info
|
9
10
|
@input = input
|
10
11
|
end
|
@@ -22,7 +23,7 @@ class PrettyDiff::Chunk #:nodoc:
|
|
22
23
|
# IMPORTANT! Before calling this method it's essential to call "find_lines!" first,
|
23
24
|
# otherwise the array will be empty.
|
24
25
|
def line_numbers
|
25
|
-
@_line_numbers ||= PrettyDiff::LineNumbers.new(meta_info)
|
26
|
+
@_line_numbers ||= PrettyDiff::LineNumbers.new(diff, meta_info)
|
26
27
|
end
|
27
28
|
|
28
29
|
private
|
@@ -36,7 +37,7 @@ private
|
|
36
37
|
def find_lines!
|
37
38
|
returning(@lines = []) do
|
38
39
|
input.split(/\r?\n/).each do |line_str|
|
39
|
-
line = PrettyDiff::Line.new(line_str)
|
40
|
+
line = PrettyDiff::Line.new(diff, line_str)
|
40
41
|
next if line.ignore?
|
41
42
|
@lines << line
|
42
43
|
line_numbers.act_on_line(line)
|
data/lib/pretty_diff/diff.rb
CHANGED
@@ -14,11 +14,15 @@ require 'cgi'
|
|
14
14
|
class PrettyDiff::Diff
|
15
15
|
CHUNK_REGEXP = /@@ .+ @@\n/
|
16
16
|
|
17
|
-
attr_reader :input
|
17
|
+
attr_reader :input, :options
|
18
18
|
|
19
|
-
# Create new Diff object.
|
20
|
-
|
19
|
+
# Create new Diff object.
|
20
|
+
# Accept a String in unified diff format and options hash.
|
21
|
+
# Currrent options:
|
22
|
+
# * wrap_lines -- wrap each line in code block with <div> element.
|
23
|
+
def initialize(unified_diff, options={})
|
21
24
|
@input = escape_html(unified_diff)
|
25
|
+
@options = options
|
22
26
|
end
|
23
27
|
|
24
28
|
# Generate HTML presentation. Return a string.
|
@@ -45,7 +49,7 @@ private
|
|
45
49
|
split = text.split(CHUNK_REGEXP)
|
46
50
|
split.shift
|
47
51
|
split.each_with_index do |lines, idx|
|
48
|
-
chunks << PrettyDiff::Chunk.new(meta_info[idx], lines)
|
52
|
+
chunks << PrettyDiff::Chunk.new(self, meta_info[idx], lines)
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
data/lib/pretty_diff/line.rb
CHANGED
data/pretty_diff.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pretty_diff}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ilya Sabanin"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-03-03}
|
13
13
|
s.description = %q{PrettyDiff is a highly customizable library for creating fully featured HTML
|
14
14
|
listings out of unified diff format strings.
|
15
15
|
Include copy/paste-safe line numbers and built-in syntax highlighting.}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretty_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Sabanin
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-03 00:00:00 +07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|