diffed 0.0.9 → 0.0.10
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.
- data/lib/diffed.rb +2 -1
- data/lib/diffed/version.rb +1 -1
- data/lib/formatters/diff_html.rb +64 -0
- data/lib/models/file.rb +1 -1
- data/lib/models/line.rb +7 -7
- data/lib/models/section.rb +7 -4
- data/lib/parsers/unified.rb +10 -8
- data/spec/diffed_spec.rb +25 -5
- data/testdata/diff1.classed.html +8 -2
- data/testdata/diff1.styled.html +281 -51
- data/testdata/diff2.classed.html +16 -0
- data/testdata/diff2.diff +14 -0
- data/testdata/diff2.styled.html +72 -0
- data/testdata/git-show.styled.html +727 -147
- data/testdata/p4-describe.styled.html +727 -147
- metadata +17 -8
- data/lib/formatters/html.rb +0 -52
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diffed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-08-01 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: escape_utils
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156407380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156407380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156405120 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156405120
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156402280 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156402280
|
47
47
|
description: ! 'This is a library for creating HTML from a unified diff string, built
|
48
48
|
specifically for the diff section output by "perforce describe -du" or "git show
|
49
49
|
[commit SHA]", but with an eye towards solving a more general problem. It supports
|
@@ -65,7 +65,7 @@ files:
|
|
65
65
|
- diffed.gemspec
|
66
66
|
- lib/diffed.rb
|
67
67
|
- lib/diffed/version.rb
|
68
|
-
- lib/formatters/
|
68
|
+
- lib/formatters/diff_html.rb
|
69
69
|
- lib/models/file.rb
|
70
70
|
- lib/models/line.rb
|
71
71
|
- lib/models/section.rb
|
@@ -75,6 +75,9 @@ files:
|
|
75
75
|
- testdata/diff1.classed.html
|
76
76
|
- testdata/diff1.diff
|
77
77
|
- testdata/diff1.styled.html
|
78
|
+
- testdata/diff2.classed.html
|
79
|
+
- testdata/diff2.diff
|
80
|
+
- testdata/diff2.styled.html
|
78
81
|
- testdata/git-show.output
|
79
82
|
- testdata/git-show.styled.html
|
80
83
|
- testdata/p4-describe.output
|
@@ -91,12 +94,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
94
|
- - ! '>='
|
92
95
|
- !ruby/object:Gem::Version
|
93
96
|
version: '0'
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
hash: 3517251613537232967
|
94
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
101
|
none: false
|
96
102
|
requirements:
|
97
103
|
- - ! '>='
|
98
104
|
- !ruby/object:Gem::Version
|
99
105
|
version: '0'
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
hash: 3517251613537232967
|
100
109
|
requirements: []
|
101
110
|
rubyforge_project:
|
102
111
|
rubygems_version: 1.8.5
|
data/lib/formatters/html.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
module Diffed
|
2
|
-
module Html
|
3
|
-
def as_html_table(use_inline_styles=true)
|
4
|
-
html = make_table_tag(use_inline_styles)
|
5
|
-
|
6
|
-
sections.each do |section|
|
7
|
-
html << section.as_html_rows(use_inline_styles)
|
8
|
-
end
|
9
|
-
|
10
|
-
html << "</table>"
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
def format_styled_row(bg_color, text_color, row)
|
15
|
-
row_style = bg_color.nil? ? "" : %Q{ style="background-color: #{bg_color}"}
|
16
|
-
text_color = text_color
|
17
|
-
|
18
|
-
%Q{<tr#{row_style}><td style="border-left: 1px solid \#CCC">#{row.left}</td><td style="border-left: 1px solid \#CCC">#{row.right}</td><td style="border-left: 1px solid \#CCC; border-right: 1px solid \#CCC; color: #{text_color}"><pre>#{row.text}</pre></td></tr>\n}
|
19
|
-
end
|
20
|
-
|
21
|
-
def format_classed_row(css_class, row)
|
22
|
-
%Q{<tr class="#{css_class}"><td>#{row.left}</td><td>#{row.left}</td><td><pre>#{row.text}</pre></td></tr>\n}
|
23
|
-
end
|
24
|
-
|
25
|
-
def make_table_tag(inline_styles)
|
26
|
-
if inline_styles
|
27
|
-
table_attributes = %Q{cellpadding="5" style="border-collapse: collapse; border: 1px solid \#CCC; font-family: Consolas, courier, monospace; font-size: 13px; color: #888"}
|
28
|
-
else
|
29
|
-
table_attributes = %Q{class="coloured-diff"}
|
30
|
-
end
|
31
|
-
|
32
|
-
%Q{<table #{table_attributes}>\n}
|
33
|
-
end
|
34
|
-
|
35
|
-
class OutputRow
|
36
|
-
attr_reader :left, :right
|
37
|
-
|
38
|
-
def initialize(params = {})
|
39
|
-
if params[:code_line].nil?
|
40
|
-
@left, @right, @text = params[:left], params[:right], params[:text]
|
41
|
-
else
|
42
|
-
line = params[:code_line]
|
43
|
-
@left, @right, @text = line.left_line_num, line.right_line_num, line.text
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def text
|
48
|
-
EscapeUtils.escape_html(@text, false)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|