diffed 0.0.4 → 0.0.5
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/diffed.gemspec +2 -1
- data/lib/diffed.rb +8 -3
- data/lib/diffed/version.rb +1 -1
- data/lib/parsers/unified.rb +10 -1
- data/spec/diffed_spec.rb +8 -2
- data/testdata/git-show.output +160 -0
- data/testdata/git-show.styled.html +143 -68
- data/testdata/p4-describe.output +169 -0
- data/testdata/p4-describe.styled.html +147 -0
- metadata +20 -16
- data/testdata/git-show.diff +0 -90
data/diffed.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["jundai@kurutta.net"]
|
11
11
|
gem.description = %q{This is a library for creating HTML from a unified diff string, built specifically for the diff section } +
|
12
12
|
%q{output by "perforce describe -du" or "git show [commit SHA]", but with an eye towards solving a more general problem. } +
|
13
|
-
%q{It supports two modes: with inline styles or with CSS classes(which you can style yourself). Either mode outputs an HTML table }
|
13
|
+
%q{It supports two modes: with inline styles or with CSS classes(which you can style yourself). Either mode outputs an HTML table } +
|
14
14
|
%q{that you may want to include in a Web page or an HTML e-mail.}
|
15
15
|
gem.summary = %q{This is a library for creating HTML from a unified diff string}
|
16
16
|
gem.homepage = "http://github.com/Jun-Dai/diffed"
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
21
|
gem.require_paths = ["lib"]
|
22
22
|
|
23
|
+
gem.add_dependency "escape_utils"
|
23
24
|
gem.add_development_dependency "rake"
|
24
25
|
gem.add_development_dependency "rspec"
|
25
26
|
end
|
data/lib/diffed.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'diffed/version'
|
2
|
+
require 'parsers/unified'
|
3
|
+
require 'escape_utils'
|
3
4
|
|
4
5
|
module Diffed
|
5
6
|
class Diff
|
@@ -78,7 +79,7 @@ module Diffed
|
|
78
79
|
end
|
79
80
|
|
80
81
|
class OutputRow
|
81
|
-
attr_reader :left, :right
|
82
|
+
attr_reader :left, :right
|
82
83
|
|
83
84
|
def initialize(params = {})
|
84
85
|
if params[:code_line].nil?
|
@@ -88,6 +89,10 @@ module Diffed
|
|
88
89
|
@left, @right, @text = line.left_line_num, line.right_line_num, line.text
|
89
90
|
end
|
90
91
|
end
|
92
|
+
|
93
|
+
def text
|
94
|
+
EscapeUtils.escape_html(@text, false)
|
95
|
+
end
|
91
96
|
end
|
92
97
|
end
|
93
98
|
end
|
data/lib/diffed/version.rb
CHANGED
data/lib/parsers/unified.rb
CHANGED
@@ -79,7 +79,16 @@ module Diffed
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def line(left_counter, right_counter)
|
82
|
-
Line.new(@type, @
|
82
|
+
Line.new(@type, @line_text, left_line_num(left_counter), right_line_num(right_counter))
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
def left_line_num(left_counter)
|
87
|
+
@type == :right ? "." : left_counter
|
88
|
+
end
|
89
|
+
|
90
|
+
def right_line_num(right_counter)
|
91
|
+
@type == :left ? "." : right_counter
|
83
92
|
end
|
84
93
|
end
|
85
94
|
|
data/spec/diffed_spec.rb
CHANGED
@@ -8,10 +8,16 @@ describe "Diffed::Diff.as_html_table" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "produces an html table representation of the diff portions of the output of 'git show', with CSS styles inline" do
|
11
|
-
diff = Diffed::Diff.new(File.read("testdata/git-show.
|
11
|
+
diff = Diffed::Diff.new(File.read("testdata/git-show.output"))
|
12
12
|
output = diff.as_html_table
|
13
13
|
output.strip == File.read("testdata/git-show.styled.html").strip
|
14
|
-
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "produces an html table representation of the diff portions of the output of 'p4 describe -du', with CSS styles inline" do
|
17
|
+
diff = Diffed::Diff.new(File.read("testdata/p4-describe.output"))
|
18
|
+
output = diff.as_html_table
|
19
|
+
output.strip == File.read("testdata/p4-describe.styled.html").strip
|
20
|
+
end
|
15
21
|
|
16
22
|
it "produces an html table representation of a diff, with CSS classes" do
|
17
23
|
diff = Diffed::Diff.new(File.read("testdata/diff1.diff"))
|
@@ -0,0 +1,160 @@
|
|
1
|
+
commit 2045449f6b2236386c6ba33602225827c5fc3e32
|
2
|
+
Author: Jun-Dai Bates-Kobashigawa <bako@taraval.net>
|
3
|
+
Date: Mon Jul 22 23:59:11 2013 +0100
|
4
|
+
|
5
|
+
Testing a git submission using two open source Java files.
|
6
|
+
This will give me a sample diff to use in my test scenario.
|
7
|
+
|
8
|
+
diff --git a/handlebars/src/main/java/com/github/jknack/handlebars/internal/BaseTemplate.java b/handlebars/src/main/java/com/github/jknack/handlebars/internal/BaseTemplate.java
|
9
|
+
index 851c582..a086ae0 100644
|
10
|
+
--- a/handlebars/src/main/java/com/github/jknack/handlebars/internal/BaseTemplate.java
|
11
|
+
+++ b/handlebars/src/main/java/com/github/jknack/handlebars/internal/BaseTemplate.java
|
12
|
+
@@ -23,7 +23,6 @@ import static org.apache.commons.lang3.Validate.isTrue;
|
13
|
+
import static org.apache.commons.lang3.Validate.notNull;
|
14
|
+
|
15
|
+
import java.io.IOException;
|
16
|
+
-import java.io.InputStream;
|
17
|
+
import java.io.Writer;
|
18
|
+
import java.lang.reflect.InvocationHandler;
|
19
|
+
import java.lang.reflect.Method;
|
20
|
+
@@ -75,7 +74,7 @@ abstract class BaseTemplate implements Template {
|
21
|
+
/**
|
22
|
+
* A Handlebars.js lock.
|
23
|
+
*/
|
24
|
+
- private static final Object JS_LOCK = new Object();
|
25
|
+
+ private final Object jsLock = new Object();
|
26
|
+
|
27
|
+
/**
|
28
|
+
* A pre-compiled JavaScript function.
|
29
|
+
@@ -85,12 +84,12 @@ abstract class BaseTemplate implements Template {
|
30
|
+
/**
|
31
|
+
* Handlerbars.js version.
|
32
|
+
*/
|
33
|
+
- private static final String HBS_FILE = "/handlebars-1.0.rc.3.js";
|
34
|
+
+ private static final String HBS_FILE = "/handlebars-1.0.0.js";
|
35
|
+
|
36
|
+
/**
|
37
|
+
* A shared scope with Handlebars.js objects.
|
38
|
+
*/
|
39
|
+
- private static ScriptableObject sharedScope;
|
40
|
+
+ private ScriptableObject sharedScope;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* {@inheritDoc}
|
44
|
+
@@ -287,7 +286,7 @@ abstract class BaseTemplate implements Template {
|
45
|
+
|
46
|
+
@Override
|
47
|
+
public String toJavaScript() throws IOException {
|
48
|
+
- synchronized (JS_LOCK) {
|
49
|
+
+ synchronized (jsLock) {
|
50
|
+
if (javaScript == null) {
|
51
|
+
org.mozilla.javascript.Context ctx = null;
|
52
|
+
try {
|
53
|
+
@@ -330,7 +329,7 @@ abstract class BaseTemplate implements Template {
|
54
|
+
* @param ctx A rhino context.
|
55
|
+
* @return A new scope where handlebars.js is present.
|
56
|
+
*/
|
57
|
+
- private static Scriptable newScope(final org.mozilla.javascript.Context ctx) {
|
58
|
+
+ private Scriptable newScope(final org.mozilla.javascript.Context ctx) {
|
59
|
+
Scriptable sharedScope = sharedScope(ctx);
|
60
|
+
Scriptable scope = ctx.newObject(sharedScope);
|
61
|
+
scope.setParentScope(null);
|
62
|
+
@@ -345,12 +344,10 @@ abstract class BaseTemplate implements Template {
|
63
|
+
* @param ctx A rhino context.
|
64
|
+
* @return A handlebars.js scope. Shared between executions.
|
65
|
+
*/
|
66
|
+
- private static Scriptable
|
67
|
+
- sharedScope(final org.mozilla.javascript.Context ctx) {
|
68
|
+
+ private Scriptable sharedScope(final org.mozilla.javascript.Context ctx) {
|
69
|
+
if (sharedScope == null) {
|
70
|
+
sharedScope = ctx.initStandardObjects();
|
71
|
+
- ctx.evaluateString(sharedScope, handlebarsScript(HBS_FILE), HBS_FILE, 1,
|
72
|
+
- null);
|
73
|
+
+ ctx.evaluateString(sharedScope, handlebarsScript(HBS_FILE), HBS_FILE, 1, null);
|
74
|
+
}
|
75
|
+
return sharedScope;
|
76
|
+
}
|
77
|
+
@@ -361,25 +358,11 @@ abstract class BaseTemplate implements Template {
|
78
|
+
* @param location The handlebars.js location.
|
79
|
+
* @return The resource content.
|
80
|
+
*/
|
81
|
+
- private static String handlebarsScript(final String location) {
|
82
|
+
- InputStream in = BaseTemplate.class.getResourceAsStream(location);
|
83
|
+
- notNull(in, "Handlebars.js script not found at " + location);
|
84
|
+
+ private String handlebarsScript(final String location) {
|
85
|
+
try {
|
86
|
+
- int ch = in.read();
|
87
|
+
- StringBuilder script = new StringBuilder();
|
88
|
+
- while (ch != -1) {
|
89
|
+
- script.append((char) ch);
|
90
|
+
- ch = in.read();
|
91
|
+
- }
|
92
|
+
- return script.toString();
|
93
|
+
+ return Files.read(location);
|
94
|
+
} catch (IOException ex) {
|
95
|
+
- throw new IllegalStateException("Unable to read file " + location);
|
96
|
+
- } finally {
|
97
|
+
- try {
|
98
|
+
- in.close();
|
99
|
+
- } catch (IOException ex) {
|
100
|
+
- throw new IllegalStateException("Unable to close file " + location);
|
101
|
+
- }
|
102
|
+
+ throw new IllegalArgumentException("Unable to read file: " + location, ex);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
diff --git a/handlebars/src/test/java/com/github/jknack/handlebars/ToStringTest.java b/handlebars/src/test/java/com/github/jknack/handlebars/ToStringTest.java
|
107
|
+
index 08c4465..3397c15 100644
|
108
|
+
--- a/handlebars/src/test/java/com/github/jknack/handlebars/ToStringTest.java
|
109
|
+
+++ b/handlebars/src/test/java/com/github/jknack/handlebars/ToStringTest.java
|
110
|
+
@@ -2,32 +2,32 @@ package com.github.jknack.handlebars;
|
111
|
+
|
112
|
+
import static org.junit.Assert.assertEquals;
|
113
|
+
|
114
|
+
-import org.junit.Test;
|
115
|
+
-
|
116
|
+
import java.io.IOException;
|
117
|
+
|
118
|
+
+import org.junit.Test;
|
119
|
+
+
|
120
|
+
public class ToStringTest {
|
121
|
+
|
122
|
+
- public static class UnsafeString {
|
123
|
+
- String underlying;
|
124
|
+
+ public static class UnsafeString {
|
125
|
+
+ String underlying;
|
126
|
+
|
127
|
+
- public UnsafeString(String underlying) {
|
128
|
+
- this.underlying = underlying;
|
129
|
+
- }
|
130
|
+
+ public UnsafeString(final String underlying) {
|
131
|
+
+ this.underlying = underlying;
|
132
|
+
+ }
|
133
|
+
|
134
|
+
- @Override
|
135
|
+
- public String toString() {
|
136
|
+
- return "<h1>" + underlying + "</h1>";
|
137
|
+
- }
|
138
|
+
+ @Override
|
139
|
+
+ public String toString() {
|
140
|
+
+ return "<h1>" + underlying + "</h1>";
|
141
|
+
}
|
142
|
+
+ }
|
143
|
+
|
144
|
+
- @Test
|
145
|
+
- public void unsafeString() throws IOException {
|
146
|
+
- Handlebars handlebars = new Handlebars();
|
147
|
+
- Template template = handlebars.compileInline("{{this}}");
|
148
|
+
+ @Test
|
149
|
+
+ public void unsafeString() throws IOException {
|
150
|
+
+ Handlebars handlebars = new Handlebars();
|
151
|
+
+ Template template = handlebars.compileInline("{{this}}");
|
152
|
+
|
153
|
+
- String result = template.apply(new UnsafeString("Hello"));
|
154
|
+
+ String result = template.apply(new UnsafeString("Hello"));
|
155
|
+
|
156
|
+
- assertEquals("<h1>Hello</h1>", result);
|
157
|
+
- }
|
158
|
+
+ assertEquals("<h1>Hello</h1>", result);
|
159
|
+
+ }
|
160
|
+
}
|
@@ -1,72 +1,147 @@
|
|
1
1
|
<table cellpadding="5" style="border-collapse: collapse; border: 1px solid #CCC; font-family: Consolas, courier, monospace; font-size: 13px; color: #888">
|
2
|
-
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -
|
3
|
-
<tr
|
4
|
-
<tr
|
5
|
-
<tr
|
6
|
-
<tr><td style="border-left: 1px solid #CCC">
|
7
|
-
<tr><td style="border-left: 1px solid #CCC">
|
8
|
-
<tr><td style="border-left: 1px solid #CCC">
|
9
|
-
<tr
|
10
|
-
<tr style="background-color: #
|
11
|
-
<tr><td style="border-left: 1px solid #CCC">
|
12
|
-
<tr><td style="border-left: 1px solid #CCC">
|
13
|
-
<tr><td style="border-left: 1px solid #CCC">
|
14
|
-
<tr style="background-color: #
|
15
|
-
<tr><td style="border-left: 1px solid #CCC"
|
2
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -23,7 +23,6 @@ import static org.apache.commons.lang3.Validate.isTrue;</pre></td></tr>
|
3
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import static org.apache.commons.lang3.Validate.notNull;</pre></td></tr>
|
4
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
5
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.io.IOException;</pre></td></tr>
|
6
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>-import java.io.InputStream;</pre></td></tr>
|
7
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.io.Writer;</pre></td></tr>
|
8
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.lang.reflect.InvocationHandler;</pre></td></tr>
|
9
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.lang.reflect.Method;</pre></td></tr>
|
10
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -75,7 +74,7 @@ abstract class BaseTemplate implements Template {</pre></td></tr>
|
11
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
12
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * A Handlebars.js lock.</pre></td></tr>
|
13
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
14
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static final Object JS_LOCK = new Object();</pre></td></tr>
|
15
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private final Object jsLock = new Object();</pre></td></tr>
|
16
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
17
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
18
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * A pre-compiled JavaScript function.</pre></td></tr>
|
19
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -85,12 +84,12 @@ abstract class BaseTemplate implements Template {</pre></td></tr>
|
20
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
21
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * Handlerbars.js version.</pre></td></tr>
|
22
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
23
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static final String HBS_FILE = "/handlebars-1.0.rc.3.js";</pre></td></tr>
|
24
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private static final String HBS_FILE = "/handlebars-1.0.0.js";</pre></td></tr>
|
16
25
|
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
17
|
-
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>
|
18
|
-
<tr
|
19
|
-
<tr
|
20
|
-
<tr style="background-color: #
|
21
|
-
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">
|
26
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
27
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * A shared scope with Handlebars.js objects.</pre></td></tr>
|
28
|
+
<tr><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
29
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static ScriptableObject sharedScope;</pre></td></tr>
|
30
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private ScriptableObject sharedScope;</pre></td></tr>
|
31
|
+
<tr><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
32
|
+
<tr><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
33
|
+
<tr><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * {@inheritDoc}</pre></td></tr>
|
34
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -287,7 +286,7 @@ abstract class BaseTemplate implements Template {</pre></td></tr>
|
35
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
36
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> @Override</pre></td></tr>
|
37
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> public String toJavaScript() throws IOException {</pre></td></tr>
|
38
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- synchronized (JS_LOCK) {</pre></td></tr>
|
39
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ synchronized (jsLock) {</pre></td></tr>
|
40
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> if (javaScript == null) {</pre></td></tr>
|
41
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> org.mozilla.javascript.Context ctx = null;</pre></td></tr>
|
42
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> try {</pre></td></tr>
|
43
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -330,7 +329,7 @@ abstract class BaseTemplate implements Template {</pre></td></tr>
|
44
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @param ctx A rhino context.</pre></td></tr>
|
45
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @return A new scope where handlebars.js is present.</pre></td></tr>
|
46
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
47
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static Scriptable newScope(final org.mozilla.javascript.Context ctx) {</pre></td></tr>
|
48
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private Scriptable newScope(final org.mozilla.javascript.Context ctx) {</pre></td></tr>
|
49
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> Scriptable sharedScope = sharedScope(ctx);</pre></td></tr>
|
50
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> Scriptable scope = ctx.newObject(sharedScope);</pre></td></tr>
|
51
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> scope.setParentScope(null);</pre></td></tr>
|
52
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -345,12 +344,10 @@ abstract class BaseTemplate implements Template {</pre></td></tr>
|
53
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @param ctx A rhino context.</pre></td></tr>
|
54
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @return A handlebars.js scope. Shared between executions.</pre></td></tr>
|
55
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
56
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static Scriptable</pre></td></tr>
|
57
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- sharedScope(final org.mozilla.javascript.Context ctx) {</pre></td></tr>
|
58
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private Scriptable sharedScope(final org.mozilla.javascript.Context ctx) {</pre></td></tr>
|
59
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> if (sharedScope == null) {</pre></td></tr>
|
60
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> sharedScope = ctx.initStandardObjects();</pre></td></tr>
|
61
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- ctx.evaluateString(sharedScope, handlebarsScript(HBS_FILE), HBS_FILE, 1,</pre></td></tr>
|
62
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- null);</pre></td></tr>
|
63
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ ctx.evaluateString(sharedScope, handlebarsScript(HBS_FILE), HBS_FILE, 1, null);</pre></td></tr>
|
64
|
+
<tr><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
65
|
+
<tr><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> return sharedScope;</pre></td></tr>
|
66
|
+
<tr><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
67
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -361,25 +358,11 @@ abstract class BaseTemplate implements Template {</pre></td></tr>
|
68
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @param location The handlebars.js location.</pre></td></tr>
|
69
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @return The resource content.</pre></td></tr>
|
70
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
71
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static String handlebarsScript(final String location) {</pre></td></tr>
|
72
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- InputStream in = BaseTemplate.class.getResourceAsStream(location);</pre></td></tr>
|
73
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- notNull(in, "Handlebars.js script not found at " + location);</pre></td></tr>
|
74
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private String handlebarsScript(final String location) {</pre></td></tr>
|
75
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> try {</pre></td></tr>
|
76
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- int ch = in.read();</pre></td></tr>
|
77
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- StringBuilder script = new StringBuilder();</pre></td></tr>
|
78
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- while (ch != -1) {</pre></td></tr>
|
79
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- script.append((char) ch);</pre></td></tr>
|
80
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- ch = in.read();</pre></td></tr>
|
81
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">13</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
82
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">14</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- return script.toString();</pre></td></tr>
|
83
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ return Files.read(location);</pre></td></tr>
|
84
|
+
<tr><td style="border-left: 1px solid #CCC">15</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> } catch (IOException ex) {</pre></td></tr>
|
85
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">16</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- throw new IllegalStateException("Unable to read file " + location);</pre></td></tr>
|
86
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">17</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- } finally {</pre></td></tr>
|
87
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">18</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- try {</pre></td></tr>
|
88
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">19</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- in.close();</pre></td></tr>
|
89
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">20</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- } catch (IOException ex) {</pre></td></tr>
|
90
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">21</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- throw new IllegalStateException("Unable to close file " + location);</pre></td></tr>
|
91
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">22</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
92
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ throw new IllegalArgumentException("Unable to read file: " + location, ex);</pre></td></tr>
|
93
|
+
<tr><td style="border-left: 1px solid #CCC">23</td><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
94
|
+
<tr><td style="border-left: 1px solid #CCC">24</td><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
95
|
+
<tr><td style="border-left: 1px solid #CCC">25</td><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
96
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -2,32 +2,32 @@ package com.github.jknack.handlebars;</pre></td></tr>
|
97
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
98
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import static org.junit.Assert.assertEquals;</pre></td></tr>
|
99
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
100
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>-import org.junit.Test;</pre></td></tr>
|
101
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>-</pre></td></tr>
|
102
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.io.IOException;</pre></td></tr>
|
103
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
104
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+import org.junit.Test;</pre></td></tr>
|
105
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+</pre></td></tr>
|
106
|
+
<tr><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> public class ToStringTest {</pre></td></tr>
|
22
107
|
<tr><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
23
|
-
<tr><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC"
|
24
|
-
<tr><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC"
|
25
|
-
<tr style="background-color: #
|
26
|
-
<tr style="background-color: #
|
27
|
-
<tr
|
28
|
-
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">
|
29
|
-
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">
|
30
|
-
<tr style="background-color: #
|
31
|
-
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">13</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+
|
32
|
-
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">14</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+
|
33
|
-
<tr><td style="border-left: 1px solid #CCC"
|
34
|
-
<tr><td style="border-left: 1px solid #CCC">
|
35
|
-
<tr><td style="border-left: 1px solid #CCC">
|
36
|
-
<tr style="background-color: #
|
37
|
-
<tr><td style="border-left: 1px solid #CCC">
|
38
|
-
<tr><td style="border-left: 1px solid #CCC">
|
39
|
-
<tr><td style="border-left: 1px solid #CCC"
|
40
|
-
<tr style="background-color: #
|
41
|
-
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">
|
42
|
-
<tr><td style="border-left: 1px solid #CCC">
|
43
|
-
<tr style="background-color: #
|
44
|
-
<tr
|
45
|
-
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">
|
46
|
-
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">
|
47
|
-
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">
|
48
|
-
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">
|
49
|
-
<tr style="background-color: #
|
50
|
-
<tr style="background-color: #
|
51
|
-
<tr style="background-color: #
|
52
|
-
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">
|
53
|
-
<tr
|
54
|
-
<tr><td style="border-left: 1px solid #CCC">
|
55
|
-
<tr><td style="border-left: 1px solid #CCC"
|
56
|
-
<tr
|
57
|
-
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">
|
58
|
-
<tr style="background-color: #
|
59
|
-
<tr><td style="border-left: 1px solid #CCC"
|
60
|
-
<tr><td style="border-left: 1px solid #CCC"
|
61
|
-
<tr
|
62
|
-
<tr><td style="border-left: 1px solid #CCC">62</td><td style="border-left: 1px solid #CCC">53</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> s.add_development_dependency(%q<shoulda>, [">= 0"])</pre></td></tr>
|
63
|
-
<tr><td style="border-left: 1px solid #CCC">63</td><td style="border-left: 1px solid #CCC">54</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> else</pre></td></tr>
|
64
|
-
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">55</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ s.add_dependency(%q<jeweler>, [">= 0"])</pre></td></tr>
|
65
|
-
<tr><td style="border-left: 1px solid #CCC">64</td><td style="border-left: 1px solid #CCC">56</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> s.add_dependency(%q<shoulda>, [">= 0"])</pre></td></tr>
|
66
|
-
<tr><td style="border-left: 1px solid #CCC">65</td><td style="border-left: 1px solid #CCC">57</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> end</pre></td></tr>
|
67
|
-
<tr><td style="border-left: 1px solid #CCC">66</td><td style="border-left: 1px solid #CCC">58</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> else</pre></td></tr>
|
68
|
-
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">59</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ s.add_dependency(%q<jeweler>, [">= 0"])</pre></td></tr>
|
69
|
-
<tr><td style="border-left: 1px solid #CCC">67</td><td style="border-left: 1px solid #CCC">60</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> s.add_dependency(%q<shoulda>, [">= 0"])</pre></td></tr>
|
70
|
-
<tr><td style="border-left: 1px solid #CCC">68</td><td style="border-left: 1px solid #CCC">61</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> end</pre></td></tr>
|
71
|
-
<tr><td style="border-left: 1px solid #CCC">69</td><td style="border-left: 1px solid #CCC">62</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> end</pre></td></tr>
|
108
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- public static class UnsafeString {</pre></td></tr>
|
109
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- String underlying;</pre></td></tr>
|
110
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ public static class UnsafeString {</pre></td></tr>
|
111
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ String underlying;</pre></td></tr>
|
112
|
+
<tr><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
113
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">13</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- public UnsafeString(String underlying) {</pre></td></tr>
|
114
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">14</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- this.underlying = underlying;</pre></td></tr>
|
115
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">15</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
116
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">13</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ public UnsafeString(final String underlying) {</pre></td></tr>
|
117
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">14</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ this.underlying = underlying;</pre></td></tr>
|
118
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">15</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ }</pre></td></tr>
|
119
|
+
<tr><td style="border-left: 1px solid #CCC">16</td><td style="border-left: 1px solid #CCC">16</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
120
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">17</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- @Override</pre></td></tr>
|
121
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">18</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- public String toString() {</pre></td></tr>
|
122
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">19</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- return "<h1>" + underlying + "</h1>";</pre></td></tr>
|
123
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">20</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
124
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">17</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ @Override</pre></td></tr>
|
125
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">18</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ public String toString() {</pre></td></tr>
|
126
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">19</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ return "<h1>" + underlying + "</h1>";</pre></td></tr>
|
127
|
+
<tr><td style="border-left: 1px solid #CCC">21</td><td style="border-left: 1px solid #CCC">20</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
128
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">21</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ }</pre></td></tr>
|
129
|
+
<tr><td style="border-left: 1px solid #CCC">22</td><td style="border-left: 1px solid #CCC">22</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
130
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">23</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- @Test</pre></td></tr>
|
131
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">24</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- public void unsafeString() throws IOException {</pre></td></tr>
|
132
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">25</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- Handlebars handlebars = new Handlebars();</pre></td></tr>
|
133
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">26</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- Template template = handlebars.compileInline("{{this}}");</pre></td></tr>
|
134
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">23</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ @Test</pre></td></tr>
|
135
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">24</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ public void unsafeString() throws IOException {</pre></td></tr>
|
136
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">25</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ Handlebars handlebars = new Handlebars();</pre></td></tr>
|
137
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">26</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ Template template = handlebars.compileInline("{{this}}");</pre></td></tr>
|
138
|
+
<tr><td style="border-left: 1px solid #CCC">27</td><td style="border-left: 1px solid #CCC">27</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
139
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">28</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- String result = template.apply(new UnsafeString("Hello"));</pre></td></tr>
|
140
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">28</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ String result = template.apply(new UnsafeString("Hello"));</pre></td></tr>
|
141
|
+
<tr><td style="border-left: 1px solid #CCC">29</td><td style="border-left: 1px solid #CCC">29</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
142
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">30</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- assertEquals("&lt;h1&gt;Hello&lt;/h1&gt;", result);</pre></td></tr>
|
143
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">31</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
144
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">30</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ assertEquals("&lt;h1&gt;Hello&lt;/h1&gt;", result);</pre></td></tr>
|
145
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">31</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ }</pre></td></tr>
|
146
|
+
<tr><td style="border-left: 1px solid #CCC">32</td><td style="border-left: 1px solid #CCC">32</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
72
147
|
</table>
|
@@ -0,0 +1,169 @@
|
|
1
|
+
Change 2 by jundai@Cortez on 2013/07/22 23:47:13
|
2
|
+
|
3
|
+
Testing a p4 submission using two open source Java files.
|
4
|
+
This will give me a sample diff to use in my test scenario.
|
5
|
+
|
6
|
+
Jobs fixed ...
|
7
|
+
|
8
|
+
test_p4_job on 2013/07/22 by jundai *closed*
|
9
|
+
|
10
|
+
This is a perforce job of some sort
|
11
|
+
that I have presumably closed with this submission.
|
12
|
+
|
13
|
+
Affected files ...
|
14
|
+
|
15
|
+
... //depot/handlebars/src/main/java/com/github/jknack/handlebars/internal/BaseTemplate.java#2 edit
|
16
|
+
... //depot/handlebars/src/test/java/com/github/jknack/handlebars/ToStringTest.java#2 edit
|
17
|
+
|
18
|
+
Differences ...
|
19
|
+
|
20
|
+
==== //depot/handlebars/src/main/java/com/github/jknack/handlebars/internal/BaseTemplate.java#2 (text) ====
|
21
|
+
|
22
|
+
@@ -23,7 +23,6 @@
|
23
|
+
import static org.apache.commons.lang3.Validate.notNull;
|
24
|
+
|
25
|
+
import java.io.IOException;
|
26
|
+
-import java.io.InputStream;
|
27
|
+
import java.io.Writer;
|
28
|
+
import java.lang.reflect.InvocationHandler;
|
29
|
+
import java.lang.reflect.Method;
|
30
|
+
@@ -75,7 +74,7 @@
|
31
|
+
/**
|
32
|
+
* A Handlebars.js lock.
|
33
|
+
*/
|
34
|
+
- private static final Object JS_LOCK = new Object();
|
35
|
+
+ private final Object jsLock = new Object();
|
36
|
+
|
37
|
+
/**
|
38
|
+
* A pre-compiled JavaScript function.
|
39
|
+
@@ -85,12 +84,12 @@
|
40
|
+
/**
|
41
|
+
* Handlerbars.js version.
|
42
|
+
*/
|
43
|
+
- private static final String HBS_FILE = "/handlebars-1.0.rc.3.js";
|
44
|
+
+ private static final String HBS_FILE = "/handlebars-1.0.0.js";
|
45
|
+
|
46
|
+
/**
|
47
|
+
* A shared scope with Handlebars.js objects.
|
48
|
+
*/
|
49
|
+
- private static ScriptableObject sharedScope;
|
50
|
+
+ private ScriptableObject sharedScope;
|
51
|
+
|
52
|
+
/**
|
53
|
+
* {@inheritDoc}
|
54
|
+
@@ -287,7 +286,7 @@
|
55
|
+
|
56
|
+
@Override
|
57
|
+
public String toJavaScript() throws IOException {
|
58
|
+
- synchronized (JS_LOCK) {
|
59
|
+
+ synchronized (jsLock) {
|
60
|
+
if (javaScript == null) {
|
61
|
+
org.mozilla.javascript.Context ctx = null;
|
62
|
+
try {
|
63
|
+
@@ -330,7 +329,7 @@
|
64
|
+
* @param ctx A rhino context.
|
65
|
+
* @return A new scope where handlebars.js is present.
|
66
|
+
*/
|
67
|
+
- private static Scriptable newScope(final org.mozilla.javascript.Context ctx) {
|
68
|
+
+ private Scriptable newScope(final org.mozilla.javascript.Context ctx) {
|
69
|
+
Scriptable sharedScope = sharedScope(ctx);
|
70
|
+
Scriptable scope = ctx.newObject(sharedScope);
|
71
|
+
scope.setParentScope(null);
|
72
|
+
@@ -345,12 +344,10 @@
|
73
|
+
* @param ctx A rhino context.
|
74
|
+
* @return A handlebars.js scope. Shared between executions.
|
75
|
+
*/
|
76
|
+
- private static Scriptable
|
77
|
+
- sharedScope(final org.mozilla.javascript.Context ctx) {
|
78
|
+
+ private Scriptable sharedScope(final org.mozilla.javascript.Context ctx) {
|
79
|
+
if (sharedScope == null) {
|
80
|
+
sharedScope = ctx.initStandardObjects();
|
81
|
+
- ctx.evaluateString(sharedScope, handlebarsScript(HBS_FILE), HBS_FILE, 1,
|
82
|
+
- null);
|
83
|
+
+ ctx.evaluateString(sharedScope, handlebarsScript(HBS_FILE), HBS_FILE, 1, null);
|
84
|
+
}
|
85
|
+
return sharedScope;
|
86
|
+
}
|
87
|
+
@@ -361,25 +358,11 @@
|
88
|
+
* @param location The handlebars.js location.
|
89
|
+
* @return The resource content.
|
90
|
+
*/
|
91
|
+
- private static String handlebarsScript(final String location) {
|
92
|
+
- InputStream in = BaseTemplate.class.getResourceAsStream(location);
|
93
|
+
- notNull(in, "Handlebars.js script not found at " + location);
|
94
|
+
+ private String handlebarsScript(final String location) {
|
95
|
+
try {
|
96
|
+
- int ch = in.read();
|
97
|
+
- StringBuilder script = new StringBuilder();
|
98
|
+
- while (ch != -1) {
|
99
|
+
- script.append((char) ch);
|
100
|
+
- ch = in.read();
|
101
|
+
- }
|
102
|
+
- return script.toString();
|
103
|
+
+ return Files.read(location);
|
104
|
+
} catch (IOException ex) {
|
105
|
+
- throw new IllegalStateException("Unable to read file " + location);
|
106
|
+
- } finally {
|
107
|
+
- try {
|
108
|
+
- in.close();
|
109
|
+
- } catch (IOException ex) {
|
110
|
+
- throw new IllegalStateException("Unable to close file " + location);
|
111
|
+
- }
|
112
|
+
+ throw new IllegalArgumentException("Unable to read file: " + location, ex);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
==== //depot/handlebars/src/test/java/com/github/jknack/handlebars/ToStringTest.java#2 (text) ====
|
118
|
+
|
119
|
+
@@ -2,32 +2,32 @@
|
120
|
+
|
121
|
+
import static org.junit.Assert.assertEquals;
|
122
|
+
|
123
|
+
+import java.io.IOException;
|
124
|
+
+
|
125
|
+
import org.junit.Test;
|
126
|
+
|
127
|
+
-import java.io.IOException;
|
128
|
+
-
|
129
|
+
public class ToStringTest {
|
130
|
+
|
131
|
+
- public static class UnsafeString {
|
132
|
+
- String underlying;
|
133
|
+
+ public static class UnsafeString {
|
134
|
+
+ String underlying;
|
135
|
+
|
136
|
+
- public UnsafeString(String underlying) {
|
137
|
+
- this.underlying = underlying;
|
138
|
+
- }
|
139
|
+
+ public UnsafeString(final String underlying) {
|
140
|
+
+ this.underlying = underlying;
|
141
|
+
+ }
|
142
|
+
|
143
|
+
- @Override
|
144
|
+
- public String toString() {
|
145
|
+
- return "<h1>" + underlying + "</h1>";
|
146
|
+
- }
|
147
|
+
+ @Override
|
148
|
+
+ public String toString() {
|
149
|
+
+ return "<h1>" + underlying + "</h1>";
|
150
|
+
}
|
151
|
+
+ }
|
152
|
+
|
153
|
+
- @Test
|
154
|
+
- public void unsafeString() throws IOException {
|
155
|
+
- Handlebars handlebars = new Handlebars();
|
156
|
+
- Template template = handlebars.compileInline("{{this}}");
|
157
|
+
+ @Test
|
158
|
+
+ public void unsafeString() throws IOException {
|
159
|
+
+ Handlebars handlebars = new Handlebars();
|
160
|
+
+ Template template = handlebars.compileInline("{{this}}");
|
161
|
+
|
162
|
+
- String result = template.apply(new UnsafeString("Hello"));
|
163
|
+
+ String result = template.apply(new UnsafeString("Hello"));
|
164
|
+
|
165
|
+
- assertEquals("<h1>Hello</h1>", result);
|
166
|
+
- }
|
167
|
+
+ assertEquals("<h1>Hello</h1>", result);
|
168
|
+
+ }
|
169
|
+
}
|
@@ -0,0 +1,147 @@
|
|
1
|
+
<table cellpadding="5" style="border-collapse: collapse; border: 1px solid #CCC; font-family: Consolas, courier, monospace; font-size: 13px; color: #888">
|
2
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -23,7 +23,6 @@</pre></td></tr>
|
3
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import static org.apache.commons.lang3.Validate.notNull;</pre></td></tr>
|
4
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
5
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.io.IOException;</pre></td></tr>
|
6
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>-import java.io.InputStream;</pre></td></tr>
|
7
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.io.Writer;</pre></td></tr>
|
8
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.lang.reflect.InvocationHandler;</pre></td></tr>
|
9
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import java.lang.reflect.Method;</pre></td></tr>
|
10
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -75,7 +74,7 @@</pre></td></tr>
|
11
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
12
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * A Handlebars.js lock.</pre></td></tr>
|
13
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
14
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static final Object JS_LOCK = new Object();</pre></td></tr>
|
15
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private final Object jsLock = new Object();</pre></td></tr>
|
16
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
17
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
18
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * A pre-compiled JavaScript function.</pre></td></tr>
|
19
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -85,12 +84,12 @@</pre></td></tr>
|
20
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
21
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * Handlerbars.js version.</pre></td></tr>
|
22
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
23
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static final String HBS_FILE = "/handlebars-1.0.rc.3.js";</pre></td></tr>
|
24
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private static final String HBS_FILE = "/handlebars-1.0.0.js";</pre></td></tr>
|
25
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
26
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
27
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * A shared scope with Handlebars.js objects.</pre></td></tr>
|
28
|
+
<tr><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
29
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static ScriptableObject sharedScope;</pre></td></tr>
|
30
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private ScriptableObject sharedScope;</pre></td></tr>
|
31
|
+
<tr><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
32
|
+
<tr><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> /**</pre></td></tr>
|
33
|
+
<tr><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * {@inheritDoc}</pre></td></tr>
|
34
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -287,7 +286,7 @@</pre></td></tr>
|
35
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
36
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> @Override</pre></td></tr>
|
37
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> public String toJavaScript() throws IOException {</pre></td></tr>
|
38
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- synchronized (JS_LOCK) {</pre></td></tr>
|
39
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ synchronized (jsLock) {</pre></td></tr>
|
40
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> if (javaScript == null) {</pre></td></tr>
|
41
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> org.mozilla.javascript.Context ctx = null;</pre></td></tr>
|
42
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> try {</pre></td></tr>
|
43
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -330,7 +329,7 @@</pre></td></tr>
|
44
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @param ctx A rhino context.</pre></td></tr>
|
45
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @return A new scope where handlebars.js is present.</pre></td></tr>
|
46
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
47
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static Scriptable newScope(final org.mozilla.javascript.Context ctx) {</pre></td></tr>
|
48
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private Scriptable newScope(final org.mozilla.javascript.Context ctx) {</pre></td></tr>
|
49
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> Scriptable sharedScope = sharedScope(ctx);</pre></td></tr>
|
50
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> Scriptable scope = ctx.newObject(sharedScope);</pre></td></tr>
|
51
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> scope.setParentScope(null);</pre></td></tr>
|
52
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -345,12 +344,10 @@</pre></td></tr>
|
53
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @param ctx A rhino context.</pre></td></tr>
|
54
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @return A handlebars.js scope. Shared between executions.</pre></td></tr>
|
55
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
56
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static Scriptable</pre></td></tr>
|
57
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- sharedScope(final org.mozilla.javascript.Context ctx) {</pre></td></tr>
|
58
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private Scriptable sharedScope(final org.mozilla.javascript.Context ctx) {</pre></td></tr>
|
59
|
+
<tr><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> if (sharedScope == null) {</pre></td></tr>
|
60
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> sharedScope = ctx.initStandardObjects();</pre></td></tr>
|
61
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- ctx.evaluateString(sharedScope, handlebarsScript(HBS_FILE), HBS_FILE, 1,</pre></td></tr>
|
62
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- null);</pre></td></tr>
|
63
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ ctx.evaluateString(sharedScope, handlebarsScript(HBS_FILE), HBS_FILE, 1, null);</pre></td></tr>
|
64
|
+
<tr><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
65
|
+
<tr><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> return sharedScope;</pre></td></tr>
|
66
|
+
<tr><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
67
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -361,25 +358,11 @@</pre></td></tr>
|
68
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @param location The handlebars.js location.</pre></td></tr>
|
69
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> * @return The resource content.</pre></td></tr>
|
70
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> */</pre></td></tr>
|
71
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- private static String handlebarsScript(final String location) {</pre></td></tr>
|
72
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- InputStream in = BaseTemplate.class.getResourceAsStream(location);</pre></td></tr>
|
73
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- notNull(in, "Handlebars.js script not found at " + location);</pre></td></tr>
|
74
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ private String handlebarsScript(final String location) {</pre></td></tr>
|
75
|
+
<tr><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> try {</pre></td></tr>
|
76
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- int ch = in.read();</pre></td></tr>
|
77
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- StringBuilder script = new StringBuilder();</pre></td></tr>
|
78
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- while (ch != -1) {</pre></td></tr>
|
79
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- script.append((char) ch);</pre></td></tr>
|
80
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- ch = in.read();</pre></td></tr>
|
81
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">13</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
82
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">14</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- return script.toString();</pre></td></tr>
|
83
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ return Files.read(location);</pre></td></tr>
|
84
|
+
<tr><td style="border-left: 1px solid #CCC">15</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> } catch (IOException ex) {</pre></td></tr>
|
85
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">16</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- throw new IllegalStateException("Unable to read file " + location);</pre></td></tr>
|
86
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">17</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- } finally {</pre></td></tr>
|
87
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">18</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- try {</pre></td></tr>
|
88
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">19</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- in.close();</pre></td></tr>
|
89
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">20</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- } catch (IOException ex) {</pre></td></tr>
|
90
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">21</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- throw new IllegalStateException("Unable to close file " + location);</pre></td></tr>
|
91
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">22</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
92
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ throw new IllegalArgumentException("Unable to read file: " + location, ex);</pre></td></tr>
|
93
|
+
<tr><td style="border-left: 1px solid #CCC">23</td><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
94
|
+
<tr><td style="border-left: 1px solid #CCC">24</td><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
95
|
+
<tr><td style="border-left: 1px solid #CCC">25</td><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
96
|
+
<tr style="background-color: #F0F0FF"><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC">...</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #888"><pre>@@ -2,32 +2,32 @@</pre></td></tr>
|
97
|
+
<tr><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC">1</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
98
|
+
<tr><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC">2</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import static org.junit.Assert.assertEquals;</pre></td></tr>
|
99
|
+
<tr><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC">3</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
100
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+import java.io.IOException;</pre></td></tr>
|
101
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+</pre></td></tr>
|
102
|
+
<tr><td style="border-left: 1px solid #CCC">4</td><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> import org.junit.Test;</pre></td></tr>
|
103
|
+
<tr><td style="border-left: 1px solid #CCC">5</td><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
104
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">6</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>-import java.io.IOException;</pre></td></tr>
|
105
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">7</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>-</pre></td></tr>
|
106
|
+
<tr><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC">8</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> public class ToStringTest {</pre></td></tr>
|
107
|
+
<tr><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC">9</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
108
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- public static class UnsafeString {</pre></td></tr>
|
109
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- String underlying;</pre></td></tr>
|
110
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">10</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ public static class UnsafeString {</pre></td></tr>
|
111
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">11</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ String underlying;</pre></td></tr>
|
112
|
+
<tr><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC">12</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
113
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">13</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- public UnsafeString(String underlying) {</pre></td></tr>
|
114
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">14</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- this.underlying = underlying;</pre></td></tr>
|
115
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">15</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
116
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">13</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ public UnsafeString(final String underlying) {</pre></td></tr>
|
117
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">14</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ this.underlying = underlying;</pre></td></tr>
|
118
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">15</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ }</pre></td></tr>
|
119
|
+
<tr><td style="border-left: 1px solid #CCC">16</td><td style="border-left: 1px solid #CCC">16</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
120
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">17</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- @Override</pre></td></tr>
|
121
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">18</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- public String toString() {</pre></td></tr>
|
122
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">19</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- return "<h1>" + underlying + "</h1>";</pre></td></tr>
|
123
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">20</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
124
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">17</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ @Override</pre></td></tr>
|
125
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">18</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ public String toString() {</pre></td></tr>
|
126
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">19</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ return "<h1>" + underlying + "</h1>";</pre></td></tr>
|
127
|
+
<tr><td style="border-left: 1px solid #CCC">21</td><td style="border-left: 1px solid #CCC">20</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
128
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">21</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ }</pre></td></tr>
|
129
|
+
<tr><td style="border-left: 1px solid #CCC">22</td><td style="border-left: 1px solid #CCC">22</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
130
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">23</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- @Test</pre></td></tr>
|
131
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">24</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- public void unsafeString() throws IOException {</pre></td></tr>
|
132
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">25</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- Handlebars handlebars = new Handlebars();</pre></td></tr>
|
133
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">26</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- Template template = handlebars.compileInline("{{this}}");</pre></td></tr>
|
134
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">23</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ @Test</pre></td></tr>
|
135
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">24</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ public void unsafeString() throws IOException {</pre></td></tr>
|
136
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">25</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ Handlebars handlebars = new Handlebars();</pre></td></tr>
|
137
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">26</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ Template template = handlebars.compileInline("{{this}}");</pre></td></tr>
|
138
|
+
<tr><td style="border-left: 1px solid #CCC">27</td><td style="border-left: 1px solid #CCC">27</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
139
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">28</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- String result = template.apply(new UnsafeString("Hello"));</pre></td></tr>
|
140
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">28</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ String result = template.apply(new UnsafeString("Hello"));</pre></td></tr>
|
141
|
+
<tr><td style="border-left: 1px solid #CCC">29</td><td style="border-left: 1px solid #CCC">29</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> </pre></td></tr>
|
142
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">30</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- assertEquals("&lt;h1&gt;Hello&lt;/h1&gt;", result);</pre></td></tr>
|
143
|
+
<tr style="background-color: #FDD"><td style="border-left: 1px solid #CCC">31</td><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>- }</pre></td></tr>
|
144
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">30</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ assertEquals("&lt;h1&gt;Hello&lt;/h1&gt;", result);</pre></td></tr>
|
145
|
+
<tr style="background-color: #DFD"><td style="border-left: 1px solid #CCC">.</td><td style="border-left: 1px solid #CCC">31</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre>+ }</pre></td></tr>
|
146
|
+
<tr><td style="border-left: 1px solid #CCC">32</td><td style="border-left: 1px solid #CCC">32</td><td style="border-left: 1px solid #CCC; border-right: 1px solid #CCC; color: #000"><pre> }</pre></td></tr>
|
147
|
+
</table>
|
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,27 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-22 00:00:00.
|
12
|
+
date: 2013-07-22 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
15
|
+
name: escape_utils
|
16
|
+
requirement: &2157409940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0'
|
22
|
-
type: :
|
22
|
+
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: *2157409940
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &2157409520 !ruby/object:Gem::Requirement
|
25
28
|
none: false
|
26
29
|
requirements:
|
27
30
|
- - ! '>='
|
28
31
|
- !ruby/object:Gem::Version
|
29
32
|
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2157409520
|
30
36
|
- !ruby/object:Gem::Dependency
|
31
37
|
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &2157409100 !ruby/object:Gem::Requirement
|
33
39
|
none: false
|
34
40
|
requirements:
|
35
41
|
- - ! '>='
|
@@ -37,17 +43,13 @@ dependencies:
|
|
37
43
|
version: '0'
|
38
44
|
type: :development
|
39
45
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
+
version_requirements: *2157409100
|
46
47
|
description: ! 'This is a library for creating HTML from a unified diff string, built
|
47
48
|
specifically for the diff section output by "perforce describe -du" or "git show
|
48
49
|
[commit SHA]", but with an eye towards solving a more general problem. It supports
|
49
50
|
two modes: with inline styles or with CSS classes(which you can style yourself). Either
|
50
|
-
mode outputs an HTML table
|
51
|
+
mode outputs an HTML table that you may want to include in a Web page or an HTML
|
52
|
+
e-mail.'
|
51
53
|
email:
|
52
54
|
- jundai@kurutta.net
|
53
55
|
executables: []
|
@@ -71,8 +73,10 @@ files:
|
|
71
73
|
- testdata/diff1.classed.html
|
72
74
|
- testdata/diff1.diff
|
73
75
|
- testdata/diff1.styled.html
|
74
|
-
- testdata/git-show.
|
76
|
+
- testdata/git-show.output
|
75
77
|
- testdata/git-show.styled.html
|
78
|
+
- testdata/p4-describe.output
|
79
|
+
- testdata/p4-describe.styled.html
|
76
80
|
homepage: http://github.com/Jun-Dai/diffed
|
77
81
|
licenses: []
|
78
82
|
post_install_message:
|
@@ -93,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
97
|
version: '0'
|
94
98
|
requirements: []
|
95
99
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.5
|
97
101
|
signing_key:
|
98
102
|
specification_version: 3
|
99
103
|
summary: This is a library for creating HTML from a unified diff string
|
data/testdata/git-show.diff
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
commit fc8d95f7e0b577a7a0d11d9f66bd5fd2b2596618
|
2
|
-
Author: Ilya Sabanin <ilya@sabanin.ru>
|
3
|
-
Date: Fri Apr 5 11:15:25 2013 -0400
|
4
|
-
|
5
|
-
Ruby 1.9 compat and version bump
|
6
|
-
|
7
|
-
diff --git a/VERSION b/VERSION
|
8
|
-
index f76f913..b3ec163 100644
|
9
|
-
--- a/VERSION
|
10
|
-
+++ b/VERSION
|
11
|
-
@@ -1 +1 @@
|
12
|
-
-0.9.2
|
13
|
-
|
14
|
-
+0.9.3
|
15
|
-
|
16
|
-
diff --git a/lib/pretty_diff/html_generators/diff_generator.rb b/lib/pretty_diff/html_generators/diff_generator.rb
|
17
|
-
index 2bec9dc..e073125 100644
|
18
|
-
--- a/lib/pretty_diff/html_generators/diff_generator.rb
|
19
|
-
+++ b/lib/pretty_diff/html_generators/diff_generator.rb
|
20
|
-
@@ -7,7 +7,7 @@ class PrettyDiff::DiffGenerator
|
21
|
-
end
|
22
|
-
|
23
|
-
def generate
|
24
|
-
- diff.chunks.map{|c| c.to_html}.to_s
|
25
|
-
+ diff.chunks.map{|c| c.to_html}.join('')
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
diff --git a/pretty_diff.gemspec b/pretty_diff.gemspec
|
30
|
-
index 8239303..5ee8bad 100644
|
31
|
-
--- a/pretty_diff.gemspec
|
32
|
-
+++ b/pretty_diff.gemspec
|
33
|
-
@@ -4,16 +4,14 @@
|
34
|
-
# -*- encoding: utf-8 -*-
|
35
|
-
|
36
|
-
Gem::Specification.new do |s|
|
37
|
-
- s.name = %q{pretty_diff}
|
38
|
-
- s.version = "0.9.2"
|
39
|
-
+ s.name = "pretty_diff"
|
40
|
-
+ s.version = "0.9.3"
|
41
|
-
|
42
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
43
|
-
s.authors = ["Ilya Sabanin"]
|
44
|
-
- s.date = %q{2012-05-04}
|
45
|
-
- s.description = %q{PrettyDiff is a highly customizable library for creating fully featured HTML
|
46
|
-
- listings out of unified diff format strings.
|
47
|
-
- Include copy/paste-safe line numbers and built-in syntax highlighting.}
|
48
|
-
- s.email = %q{ilya.sabanin@gmail.com}
|
49
|
-
+ s.date = "2013-04-05"
|
50
|
-
+ s.description = "PrettyDiff is a highly customizable library for creating fully featured HTML\n listings out of unified diff format strings.\n Include copy/paste-safe line numbers and built-in syntax highlighting."
|
51
|
-
+ s.email = "ilya.sabanin@gmail.com"
|
52
|
-
s.extra_rdoc_files = [
|
53
|
-
"LICENSE",
|
54
|
-
"README.rdoc"
|
55
|
-
@@ -42,28 +40,23 @@ Gem::Specification.new do |s|
|
56
|
-
"test/html_generator_test.rb",
|
57
|
-
"test/line_test.rb"
|
58
|
-
]
|
59
|
-
- s.homepage = %q{http://github.com/isabanin/pretty_diff}
|
60
|
-
+ s.homepage = "http://github.com/isabanin/pretty_diff"
|
61
|
-
s.require_paths = ["lib"]
|
62
|
-
- s.rubygems_version = %q{1.3.7}
|
63
|
-
- s.summary = %q{Library for converting unified diff format into HTML listings.}
|
64
|
-
- s.test_files = [
|
65
|
-
- "test/chunk_test.rb",
|
66
|
-
- "test/diff_test.rb",
|
67
|
-
- "test/helper.rb",
|
68
|
-
- "test/html_generator_test.rb",
|
69
|
-
- "test/line_test.rb"
|
70
|
-
- ]
|
71
|
-
+ s.rubygems_version = "2.0.3"
|
72
|
-
+ s.summary = "Library for converting unified diff format into HTML listings."
|
73
|
-
|
74
|
-
if s.respond_to? :specification_version then
|
75
|
-
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
76
|
-
- s.specification_version = 3
|
77
|
-
+ s.specification_version = 4
|
78
|
-
|
79
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
80
|
-
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
|
81
|
-
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
82
|
-
else
|
83
|
-
+ s.add_dependency(%q<jeweler>, [">= 0"])
|
84
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
85
|
-
end
|
86
|
-
else
|
87
|
-
+ s.add_dependency(%q<jeweler>, [">= 0"])
|
88
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
89
|
-
end
|
90
|
-
end
|