| |   |
| 72 | 72 | end |
| 73 | 73 | end |
| 74 | 74 | |
| 75 | #diff = Diff::Display::Unified.new(load_diff("simple")) |
| 76 | #diff.render(Diff::Renderer::Base.new) |
| 75 | 77 | def render_inline_diff(udiff, src_sha, dst_sha) |
| 76 | | callback = Gitorious::Diff::InlineTableCallback.new |
| 78 | differ = Diff::Display::Unified.new(udiff) |
| 77 | 79 | out = %Q{<table class="codediff inline">\n} |
| 78 | 80 | out << "<thead>\n" |
| 79 | 81 | out << "<tr>" |
| … | … | |
| 83 | 83 | out << %Q{<td class="line-numbers">#{dst_sha}</td>} |
| 84 | 84 | out << "<td> </td></tr>\n" |
| 85 | 85 | out << "</thead>\n" |
| 86 | | out << Diff::Display::Unified::HTMLRenderer.run(udiff, callback) |
| 86 | out << differ.render(Gitorious::Diff::InlineTableCallback.new) |
| 87 | 87 | out << "</table>" |
| 88 | 88 | out |
| 89 | 89 | end |
| 90 | 90 | |
| 91 | 91 | def render_sidebyside_diff(udiff, src_sha, dst_sha) |
| 92 | | callback = Gitorious::Diff::SidebysideTableCallback.new |
| 92 | differ = Diff::Display::Unified.new(udiff) |
| 93 | 93 | out = %Q{<table class="codediff sidebyside">\n} |
| 94 | 94 | out << %Q{<colgroup class="left"><col class="lines"/><col class="code"/></colgroup>} |
| 95 | 95 | out << %Q{<colgroup class="right"><col class="lines"/><col class="code"/></colgroup>} |
| 96 | 96 | out << %Q{<thead><th colspan="2">#{src_sha}</th>} |
| 97 | 97 | out << %Q{<th colspan="2">#{dst_sha}</th></thead>} |
| 98 | | out << Diff::Display::Unified::HTMLRenderer.run(udiff, callback) |
| 98 | out << differ.render(Gitorious::Diff::SidebysideTableCallback.new) |
| 99 | 99 | out << "</table>" |
| 100 | 100 | out |
| 101 | 101 | end |
| toggle raw diff |
--- a/app/helpers/browse_helper.rb
+++ b/app/helpers/browse_helper.rb
@@ -72,8 +72,10 @@ module BrowseHelper
end
end
+ #diff = Diff::Display::Unified.new(load_diff("simple"))
+ #diff.render(Diff::Renderer::Base.new)
def render_inline_diff(udiff, src_sha, dst_sha)
- callback = Gitorious::Diff::InlineTableCallback.new
+ differ = Diff::Display::Unified.new(udiff)
out = %Q{<table class="codediff inline">\n}
out << "<thead>\n"
out << "<tr>"
@@ -81,19 +83,19 @@ module BrowseHelper
out << %Q{<td class="line-numbers">#{dst_sha}</td>}
out << "<td> </td></tr>\n"
out << "</thead>\n"
- out << Diff::Display::Unified::HTMLRenderer.run(udiff, callback)
+ out << differ.render(Gitorious::Diff::InlineTableCallback.new)
out << "</table>"
out
end
def render_sidebyside_diff(udiff, src_sha, dst_sha)
- callback = Gitorious::Diff::SidebysideTableCallback.new
+ differ = Diff::Display::Unified.new(udiff)
out = %Q{<table class="codediff sidebyside">\n}
out << %Q{<colgroup class="left"><col class="lines"/><col class="code"/></colgroup>}
out << %Q{<colgroup class="right"><col class="lines"/><col class="code"/></colgroup>}
out << %Q{<thead><th colspan="2">#{src_sha}</th>}
out << %Q{<th colspan="2">#{dst_sha}</th></thead>}
- out << Diff::Display::Unified::HTMLRenderer.run(udiff, callback)
+ out << differ.render(Gitorious::Diff::SidebysideTableCallback.new)
out << "</table>"
out
end |
| |   |
| 1 | 1 | module Gitorious |
| 2 | 2 | module Diff |
| 3 | | class InlineTableCallback |
| 4 | | |
| 5 | | # Before blocks |
| 6 | | def before_addblock(block) |
| 7 | | end |
| 8 | | |
| 9 | | def before_remblock(block) |
| 10 | | end |
| 11 | | |
| 12 | | def before_modblock(block) |
| 13 | | end |
| 14 | | |
| 15 | | def before_unmodblock(block) |
| 16 | | end |
| 17 | | |
| 18 | | def before_sepblock(block) |
| 19 | | end |
| 20 | | |
| 21 | | # After blocks |
| 22 | | def after_addblock(block) |
| 23 | | end |
| 24 | | |
| 25 | | def after_remblock(block) |
| 26 | | end |
| 27 | | |
| 28 | | def after_modblock(block) |
| 29 | | end |
| 30 | | |
| 31 | | def after_unmodblock(block) |
| 32 | | end |
| 33 | | |
| 34 | | def after_sepblock(block) |
| 35 | | end |
| 36 | | |
| 37 | | # Before lines |
| 38 | | def before_addline(line) |
| 3 | class InlineTableCallback < BaseCallback |
| 4 | def addline(line) |
| 39 | 5 | %Q{<tr class="changes">} + |
| 40 | 6 | %Q{<td class="line-numbers"> </td>} + |
| 41 | 7 | %Q{<td class="line-numbers">#{line.number}</td>} + |
| 42 | | %Q{<td class="code ins"><ins>} |
| 8 | %Q{<td class="code ins"><ins>#{escape(line)}</ins></td></tr>} |
| 43 | 9 | end |
| 44 | 10 | |
| 45 | | def before_remline(line) |
| 11 | def remline(line) |
| 46 | 12 | %Q{<tr class="changes">} + |
| 47 | 13 | %Q{<td class="line-numbers">#{line.number}</td>} + |
| 48 | 14 | %Q{<td class="line-numbers"> </td>} + |
| 49 | | %Q{<td class="code del"><del>} |
| 15 | %Q{<td class="code del"><del>#{escape(line)}</del></td></tr>} |
| 50 | 16 | end |
| 51 | 17 | |
| 52 | | def before_modline(line) |
| 18 | def modline(line) |
| 53 | 19 | %Q{<tr class="changes">} + |
| 54 | 20 | %Q{<td class="line-numbers"> </td>} + |
| 55 | 21 | %Q{<td class="line-numbers">#{line.number}</td>} + |
| 56 | | %Q{<td class="code unchanged mod">} |
| 22 | %Q{<td class="code unchanged mod">#{escape(line)}</td></tr>} |
| 57 | 23 | end |
| 58 | 24 | |
| 59 | | def before_unmodline(line) |
| 25 | def unmodline(line) |
| 60 | 26 | %Q{<tr class="changes">} + |
| 61 | 27 | %Q{<td class="line-numbers"> </td>} + |
| 62 | 28 | %Q{<td class="line-numbers">#{line.number}</td>} + |
| 63 | | %Q{<td class="code unchanged unmod">} |
| 29 | %Q{<td class="code unchanged unmod">#{escape(line)}</td></tr>} |
| 64 | 30 | end |
| 65 | 31 | |
| 66 | | def before_sepline(line) |
| 32 | def sepline(line) |
| 67 | 33 | %Q{<tr class="changes">} + |
| 68 | | %Q{<td class="line-numbers line-num-cut">...</td>} + |
| 69 | | %Q{<td class="line-numbers line-num-cut">...</td>} + |
| 70 | | %Q{<td class="code cut-line">} |
| 71 | | end |
| 72 | | |
| 73 | | # After lines |
| 74 | | def after_addline(line) |
| 75 | | "</ins></td></tr>" |
| 76 | | end |
| 77 | | |
| 78 | | def after_remline(line) |
| 79 | | "</del></td></tr>" |
| 80 | | end |
| 81 | | |
| 82 | | def after_modline(line) |
| 83 | | "</td></tr>" |
| 84 | | end |
| 85 | | |
| 86 | | def after_unmodline(line) |
| 87 | | "</td></tr>" |
| 88 | | end |
| 89 | | |
| 90 | | def after_sepline(line) |
| 91 | | "</td></tr>" |
| 92 | | end |
| 93 | | |
| 94 | | def new_line |
| 34 | %Q{<td class="line-numbers line-num-cut">…</td>} + |
| 35 | %Q{<td class="line-numbers line-num-cut">…</td>} + |
| 36 | %Q{<td class="code cut-line"></td></tr>} |
| 95 | 37 | end |
| 96 | 38 | end |
| 97 | 39 | end |
| toggle raw diff |
--- a/lib/gitorious/diff/inline_table_callback.rb
+++ b/lib/gitorious/diff/inline_table_callback.rb
@@ -1,97 +1,39 @@
module Gitorious
module Diff
- class InlineTableCallback
-
- # Before blocks
- def before_addblock(block)
- end
-
- def before_remblock(block)
- end
-
- def before_modblock(block)
- end
-
- def before_unmodblock(block)
- end
-
- def before_sepblock(block)
- end
-
- # After blocks
- def after_addblock(block)
- end
-
- def after_remblock(block)
- end
-
- def after_modblock(block)
- end
-
- def after_unmodblock(block)
- end
-
- def after_sepblock(block)
- end
-
- # Before lines
- def before_addline(line)
+ class InlineTableCallback < BaseCallback
+ def addline(line)
%Q{<tr class="changes">} +
%Q{<td class="line-numbers"> </td>} +
%Q{<td class="line-numbers">#{line.number}</td>} +
- %Q{<td class="code ins"><ins>}
+ %Q{<td class="code ins"><ins>#{escape(line)}</ins></td></tr>}
end
- def before_remline(line)
+ def remline(line)
%Q{<tr class="changes">} +
%Q{<td class="line-numbers">#{line.number}</td>} +
%Q{<td class="line-numbers"> </td>} +
- %Q{<td class="code del"><del>}
+ %Q{<td class="code del"><del>#{escape(line)}</del></td></tr>}
end
- def before_modline(line)
+ def modline(line)
%Q{<tr class="changes">} +
%Q{<td class="line-numbers"> </td>} +
%Q{<td class="line-numbers">#{line.number}</td>} +
- %Q{<td class="code unchanged mod">}
+ %Q{<td class="code unchanged mod">#{escape(line)}</td></tr>}
end
- def before_unmodline(line)
+ def unmodline(line)
%Q{<tr class="changes">} +
%Q{<td class="line-numbers"> </td>} +
%Q{<td class="line-numbers">#{line.number}</td>} +
- %Q{<td class="code unchanged unmod">}
+ %Q{<td class="code unchanged unmod">#{escape(line)}</td></tr>}
end
- def before_sepline(line)
+ def sepline(line)
%Q{<tr class="changes">} +
- %Q{<td class="line-numbers line-num-cut">...</td>} +
- %Q{<td class="line-numbers line-num-cut">...</td>} +
- %Q{<td class="code cut-line">}
- end
-
- # After lines
- def after_addline(line)
- "</ins></td></tr>"
- end
-
- def after_remline(line)
- "</del></td></tr>"
- end
-
- def after_modline(line)
- "</td></tr>"
- end
-
- def after_unmodline(line)
- "</td></tr>"
- end
-
- def after_sepline(line)
- "</td></tr>"
- end
-
- def new_line
+ %Q{<td class="line-numbers line-num-cut">…</td>} +
+ %Q{<td class="line-numbers line-num-cut">…</td>} +
+ %Q{<td class="code cut-line"></td></tr>}
end
end
end |
| |   |
| 1 | 1 | module Gitorious |
| 2 | 2 | module Diff |
| 3 | | class SidebysideTableCallback |
| 3 | class SidebysideTableCallback < BaseCallback |
| 4 | 4 | |
| 5 | 5 | # Before blocks |
| 6 | 6 | def before_addblock(block) |
| … | … | |
| 45 | 45 | end |
| 46 | 46 | |
| 47 | 47 | # Before lines |
| 48 | | def before_addline(line) |
| 48 | def addline(line) |
| 49 | 49 | # adds go on the right |
| 50 | 50 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 51 | 51 | %Q{<td class="code ins"></td>} + |
| 52 | 52 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 53 | | %Q{<td class="code ins"><ins>} |
| 53 | %Q{<td class="code ins"><ins>#{escape(line)}</ins></td></tr>} |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | | def before_remline(line) |
| 56 | def remline(line) |
| 57 | 57 | # rems go on the left (hide the right side) |
| 58 | 58 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 59 | 59 | %Q{<td class="code del"><del>#{CGI.escapeHTML(line)}</del></td>} + |
| 60 | 60 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 61 | | %Q{<td class="code del hidden"><del>} |
| 61 | %Q{<td class="code del hidden"><del>#{escape(line)}</del></td></tr>} |
| 62 | 62 | end |
| 63 | 63 | |
| 64 | | def before_modline(line) |
| 64 | def modline(line) |
| 65 | 65 | # TODO: figure how we best display these |
| 66 | 66 | # %Q{<th class="line-numbers">#{line.number}</th>} + |
| 67 | 67 | # %Q{<td class="code changed mod">#{CGI.escapeHTML(line)}</td>} + |
| 68 | 68 | # %Q{<th class="line-numbers">#{line.number}</th>} + |
| 69 | | # %Q{<td class="code changed mod">} |
| 69 | # %Q{<td class="code changed mod">#{escape(line)}</td></tr>} |
| 70 | 70 | end |
| 71 | 71 | |
| 72 | | def before_unmodline(line) |
| 72 | def unmodline(line) |
| 73 | 73 | # unmods goes on both sides |
| 74 | 74 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 75 | | %Q{<td class="code unchanged unmod">#{CGI.escapeHTML(line)}</td>} + |
| 75 | %Q{<td class="code unchanged unmod">#{escape(line)}</td>} + |
| 76 | 76 | %Q{<th class="line-numbers">#{line.number}</th>} + |
| 77 | | %Q{<td class="code unchanged unmod">} |
| 77 | %Q{<td class="code unchanged unmod">#{escape(line)}</td></tr>} |
| 78 | 78 | end |
| 79 | 79 | |
| 80 | | def before_sepline(line) |
| 81 | | %Q{<th class="line-numbers line-num-cut">...</th>} + |
| 82 | | %Q{<td class="code cut-line">...</td>} + |
| 83 | | %Q{<th class="line-numbers line-num-cut">...</th>} + |
| 84 | | %Q{<td class="code cut-line">} |
| 85 | | end |
| 86 | | |
| 87 | | # After lines |
| 88 | | def after_addline(line) |
| 89 | | "</ins></td></tr>" |
| 90 | | end |
| 91 | | |
| 92 | | def after_remline(line) |
| 93 | | "</del></td></tr>" |
| 94 | | end |
| 95 | | |
| 96 | | def after_modline(line) |
| 97 | | "</td></tr>" |
| 98 | | end |
| 99 | | |
| 100 | | def after_unmodline(line) |
| 101 | | "</td></tr>" |
| 102 | | end |
| 103 | | |
| 104 | | def after_sepline(line) |
| 105 | | "</td></tr>" |
| 106 | | end |
| 107 | | |
| 108 | | def new_line |
| 80 | def sepline(line) |
| 81 | %Q{<th class="line-numbers line-num-cut">…</th>} + |
| 82 | %Q{<td class="code cut-line"></td>} + |
| 83 | %Q{<th class="line-numbers line-num-cut">…</th>} + |
| 84 | %Q{<td class="code cut-line"></td></tr>} |
| 109 | 85 | end |
| 110 | 86 | end |
| 111 | 87 | end |
| toggle raw diff |
--- a/lib/gitorious/diff/sidebyside_table_callback.rb
+++ b/lib/gitorious/diff/sidebyside_table_callback.rb
@@ -1,6 +1,6 @@
module Gitorious
module Diff
- class SidebysideTableCallback
+ class SidebysideTableCallback < BaseCallback
# Before blocks
def before_addblock(block)
@@ -45,67 +45,43 @@ module Gitorious
end
# Before lines
- def before_addline(line)
+ def addline(line)
# adds go on the right
%Q{<th class="line-numbers">#{line.number}</th>} +
%Q{<td class="code ins"></td>} +
%Q{<th class="line-numbers">#{line.number}</th>} +
- %Q{<td class="code ins"><ins>}
+ %Q{<td class="code ins"><ins>#{escape(line)}</ins></td></tr>}
end
- def before_remline(line)
+ def remline(line)
# rems go on the left (hide the right side)
%Q{<th class="line-numbers">#{line.number}</th>} +
%Q{<td class="code del"><del>#{CGI.escapeHTML(line)}</del></td>} +
%Q{<th class="line-numbers">#{line.number}</th>} +
- %Q{<td class="code del hidden"><del>}
+ %Q{<td class="code del hidden"><del>#{escape(line)}</del></td></tr>}
end
- def before_modline(line)
+ def modline(line)
# TODO: figure how we best display these
# %Q{<th class="line-numbers">#{line.number}</th>} +
# %Q{<td class="code changed mod">#{CGI.escapeHTML(line)}</td>} +
# %Q{<th class="line-numbers">#{line.number}</th>} +
- # %Q{<td class="code changed mod">}
+ # %Q{<td class="code changed mod">#{escape(line)}</td></tr>}
end
- def before_unmodline(line)
+ def unmodline(line)
# unmods goes on both sides
%Q{<th class="line-numbers">#{line.number}</th>} +
- %Q{<td class="code unchanged unmod">#{CGI.escapeHTML(line)}</td>} +
+ %Q{<td class="code unchanged unmod">#{escape(line)}</td>} +
%Q{<th class="line-numbers">#{line.number}</th>} +
- %Q{<td class="code unchanged unmod">}
+ %Q{<td class="code unchanged unmod">#{escape(line)}</td></tr>}
end
- def before_sepline(line)
- %Q{<th class="line-numbers line-num-cut">...</th>} +
- %Q{<td class="code cut-line">...</td>} +
- %Q{<th class="line-numbers line-num-cut">...</th>} +
- %Q{<td class="code cut-line">}
- end
-
- # After lines
- def after_addline(line)
- "</ins></td></tr>"
- end
-
- def after_remline(line)
- "</del></td></tr>"
- end
-
- def after_modline(line)
- "</td></tr>"
- end
-
- def after_unmodline(line)
- "</td></tr>"
- end
-
- def after_sepline(line)
- "</td></tr>"
- end
-
- def new_line
+ def sepline(line)
+ %Q{<th class="line-numbers line-num-cut">…</th>} +
+ %Q{<td class="code cut-line"></td>} +
+ %Q{<th class="line-numbers line-num-cut">…</th>} +
+ %Q{<td class="code cut-line"></td></tr>}
end
end
end |
| |   |
| 0 | | Copyright (c) 2003 Marcel Molina Jr. |
| 1 | | |
| 2 | | Permission is hereby granted, free of charge, to any person obtaining |
| 3 | | a copy of this software and associated documentation files (the |
| 4 | | "Software"), to deal in the Software without restriction, including |
| 5 | | without limitation the rights to use, copy, modify, merge, publish, |
| 6 | | distribute, sublicense, and/or sell copies of the Software, and to |
| 7 | | permit persons to whom the Software is furnished to do so, subject to |
| 8 | | the following conditions: |
| 9 | | |
| 10 | | The above copyright notice and this permission notice shall be |
| 11 | | included in all copies or substantial portions of the Software. |
| 12 | | |
| 13 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 14 | | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 15 | | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 16 | | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 17 | | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 18 | | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 19 | | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| toggle raw diff |
--- a/vendor/diff-display/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2003 Marcel Molina Jr.
-
-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. |
| |   |
| 1 | Copyright (c) 2008 Johan Sørensen |
| 2 | Copyright (c) 2003 Marcel Molina Jr. |
| 3 | |
| 4 | Permission is hereby granted, free of charge, to any person obtaining |
| 5 | a copy of this software and associated documentation files (the |
| 6 | "Software"), to deal in the Software without restriction, including |
| 7 | without limitation the rights to use, copy, modify, merge, publish, |
| 8 | distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | permit persons to whom the Software is furnished to do so, subject to |
| 10 | the following conditions: |
| 11 | |
| 12 | The above copyright notice and this permission notice shall be |
| 13 | included in all copies or substantial portions of the Software. |
| 14 | |
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| toggle raw diff |
--- /dev/null
+++ b/vendor/diff-display/License.txt
@@ -0,0 +1,21 @@
+Copyright (c) 2008 Johan Sørensen
+Copyright (c) 2003 Marcel Molina Jr.
+
+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.
\ No newline at end of file |
| |   |
| 1 | require 'diff/display/version' |
| 2 | |
| 3 | AUTHOR = ['Johan Sørensen', 'Marcel Molina Jr.'] # can also be an array of Authors |
| 4 | EMAIL = "johan@johansorensen.com" |
| 5 | DESCRIPTION = "Displays a unified diffs in various (user-definable) ways" |
| 6 | GEM_NAME = 'diff-display' # what ppl will type to install your gem |
| 7 | RUBYFORGE_PROJECT = 'diff-display' # The unix name for your project |
| 8 | HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org" |
| 9 | DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}" |
| 10 | |
| 11 | @config_file = "~/.rubyforge/user-config.yml" |
| 12 | @config = nil |
| 13 | RUBYFORGE_USERNAME = "unknown" |
| 14 | def rubyforge_username |
| 15 | unless @config |
| 16 | begin |
| 17 | @config = YAML.load(File.read(File.expand_path(@config_file))) |
| 18 | rescue |
| 19 | puts <<-EOS |
| 20 | ERROR: No rubyforge config file found: #{@config_file} |
| 21 | Run 'rubyforge setup' to prepare your env for access to Rubyforge |
| 22 | - See http://newgem.rubyforge.org/rubyforge.html for more details |
| 23 | EOS |
| 24 | exit |
| 25 | end |
| 26 | end |
| 27 | RUBYFORGE_USERNAME.replace @config["username"] |
| 28 | end |
| 29 | |
| 30 | |
| 31 | REV = nil |
| 32 | # UNCOMMENT IF REQUIRED: |
| 33 | # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil |
| 34 | VERS = Diff::Display::VERSION::STRING + (REV ? ".#{REV}" : "") |
| 35 | RDOC_OPTS = ['--quiet', '--title', 'diff-display documentation', |
| 36 | "--opname", "index.html", |
| 37 | "--line-numbers", |
| 38 | "--main", "README", |
| 39 | "--inline-source"] |
| 40 | |
| 41 | class Hoe |
| 42 | def extra_deps |
| 43 | @extra_deps.reject! { |x| Array(x).first == 'hoe' } |
| 44 | @extra_deps |
| 45 | end |
| 46 | end |
| 47 | |
| 48 | # Generate all the Rake tasks |
| 49 | # Run 'rake -T' to see list of generated tasks (from gem root directory) |
| 50 | hoe = Hoe.new(GEM_NAME, VERS) do |p| |
| 51 | p.author = AUTHOR |
| 52 | p.description = DESCRIPTION |
| 53 | p.email = EMAIL |
| 54 | p.summary = DESCRIPTION |
| 55 | p.url = HOMEPATH |
| 56 | p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT |
| 57 | p.test_globs = ["test/**/test_*.rb"] |
| 58 | p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean. |
| 59 | |
| 60 | # == Optional |
| 61 | p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n") |
| 62 | #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ] |
| 63 | |
| 64 | #p.spec_extras = {} # A hash of extra values to set in the gemspec. |
| 65 | |
| 66 | end |
| 67 | |
| 68 | CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n") |
| 69 | PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}" |
| 70 | hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc') |
| 71 | hoe.rsync_args = '-av --delete --ignore-errors' |
| toggle raw diff |
--- /dev/null
+++ b/vendor/diff-display/config/hoe.rb
@@ -0,0 +1,71 @@
+require 'diff/display/version'
+
+AUTHOR = ['Johan Sørensen', 'Marcel Molina Jr.'] # can also be an array of Authors
+EMAIL = "johan@johansorensen.com"
+DESCRIPTION = "Displays a unified diffs in various (user-definable) ways"
+GEM_NAME = 'diff-display' # what ppl will type to install your gem
+RUBYFORGE_PROJECT = 'diff-display' # The unix name for your project
+HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
+DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
+
+@config_file = "~/.rubyforge/user-config.yml"
+@config = nil
+RUBYFORGE_USERNAME = "unknown"
+def rubyforge_username
+ unless @config
+ begin
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
+ rescue
+ puts <<-EOS
+ERROR: No rubyforge config file found: #{@config_file}
+Run 'rubyforge setup' to prepare your env for access to Rubyforge
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
+ EOS
+ exit
+ end
+ end
+ RUBYFORGE_USERNAME.replace @config["username"]
+end
+
+
+REV = nil
+# UNCOMMENT IF REQUIRED:
+# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
+VERS = Diff::Display::VERSION::STRING + (REV ? ".#{REV}" : "")
+RDOC_OPTS = ['--quiet', '--title', 'diff-display documentation',
+ "--opname", "index.html",
+ "--line-numbers",
+ "--main", "README",
+ "--inline-source"]
+
+class Hoe
+ def extra_deps
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
+ @extra_deps
+ end
+end
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+hoe = Hoe.new(GEM_NAME, VERS) do |p|
+ p.author = AUTHOR
+ p.description = DESCRIPTION
+ p.email = EMAIL
+ p.summary = DESCRIPTION
+ p.url = HOMEPATH
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
+ p.test_globs = ["test/**/test_*.rb"]
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
+
+ # == Optional
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
+
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
+
+end
+
+CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
+PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
+hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
+hoe.rsync_args = '-av --delete --ignore-errors'
\ No newline at end of file |
| |   |
| 1 | module Diff |
| 2 | module Display |
| 3 | class Data < Array |
| 4 | def initialize |
| 5 | super |
| 6 | end |
| 7 | |
| 8 | def to_diff |
| 9 | diff = "" |
| 10 | each do |block| |
| 11 | block.each do |line| |
| 12 | case line |
| 13 | when HeaderLine |
| 14 | diff << "#{line}\n" |
| 15 | when UnModLine |
| 16 | diff << " #{line}\n" |
| 17 | when SepLine |
| 18 | diff << "\n" |
| 19 | when AddLine |
| 20 | diff << "+#{line}\n" |
| 21 | when RemLine |
| 22 | diff << "-#{line}\n" |
| 23 | end |
| 24 | end |
| 25 | end |
| 26 | diff.chomp |
| 27 | end |
| 28 | end |
| 29 | |
| 30 | # Every line from the passed in diff gets transformed into an instance of |
| 31 | # one of line Line class's subclasses. One subclass exists for each line |
| 32 | # type in a diff. As such there is an AddLine class for added lines, a RemLine |
| 33 | # class for removed lines, an UnModLine class for lines which remain unchanged and |
| 34 | # a SepLine class which represents all the lines that aren't part of the diff. |
| 35 | class Line < String |
| 36 | class << self |
| 37 | def add(line, line_number) |
| 38 | AddLine.new(line, line_number) |
| 39 | end |
| 40 | |
| 41 | def rem(line, line_number) |
| 42 | RemLine.new(line, line_number) |
| 43 | end |
| 44 | |
| 45 | def unmod(line, line_number) |
| 46 | UnModLine.new(line, line_number) |
| 47 | end |
| 48 | |
| 49 | def header(line) |
| 50 | HeaderLine.new(line) |
| 51 | end |