Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactored and some bugs fixed

  • Loading branch information...
commit 2855c9d5669b5ed6c05abb5753a03254d86bf585 1 parent bfe82a1
@dcrec1 authored
View
1  .classpath
@@ -8,5 +8,6 @@
<classpathentry exported="true" kind="lib" path="lib/jruby-engine.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jruby.jar"/>
<classpathentry kind="lib" path="lib/junit-4.1.jar"/>
+ <classpathentry kind="lib" path="lib/log4j-1.2.12.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
BIN  bin/com/mouseoverstudio/haml4j/Haml4jHelper.class
Binary file not shown
View
BIN  bin/com/mouseoverstudio/haml4j/Haml4jServlet.class
Binary file not shown
View
4 bin/com/mouseoverstudio/haml4j/haml4j.rb
@@ -12,6 +12,6 @@ def haml_engine_for(file_name)
return cache[file_name]
end
-def render(file_name)
- return haml_engine_for(file_name).render
+def render()
+ return haml_engine_for($file).render
end
View
BIN  bin/com/mouseoverstudio/haml4j/test/Haml4HelperTest.class
Binary file not shown
View
BIN  bin/com/mouseoverstudio/haml4j/test/Haml4jScriptTest.class
Binary file not shown
View
BIN  bin/com/mouseoverstudio/haml4j/test/Haml4jServletTest.class
Binary file not shown
View
BIN  dist/haml4j.jar
Binary file not shown
View
BIN  lib/log4j-1.2.12.jar
Binary file not shown
View
BIN  src/com/mouseoverstudio/haml4j/Haml4jHelper.java
Binary file not shown
View
BIN  src/com/mouseoverstudio/haml4j/Haml4jServlet.java
Binary file not shown
View
4 src/com/mouseoverstudio/haml4j/haml4j.rb
@@ -12,6 +12,6 @@ def haml_engine_for(file_name)
return cache[file_name]
end
-def render(file_name)
- return haml_engine_for(file_name).render
+def render()
+ return haml_engine_for($file).render
end
View
BIN  test/com/mouseoverstudio/haml4j/test/Haml4HelperTest.java
Binary file not shown
View
22 test/com/mouseoverstudio/haml4j/test/Haml4jScriptTest.java
@@ -2,13 +2,11 @@
import static com.mouseoverstudio.haml4j.Haml4jHelper.haml4jRubyScript;
import static com.mouseoverstudio.haml4j.Haml4jHelper.jRubyEngine;
-
-import java.io.FileNotFoundException;
-import java.util.HashMap;
+import static com.mouseoverstudio.haml4j.Haml4jHelper.urlFrom;
+import static org.junit.Assert.fail;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
-import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
import org.junit.Test;
@@ -22,23 +20,15 @@ public void testCache() {
engine.eval(haml4jRubyScript());
String template = "resources/simple.yaml";
SimpleScriptContext context = new SimpleScriptContext();
- //context.setAttribute("cache", new HashMap<String, Object>(), ScriptContext.GLOBAL_SCOPE);
- String call = "render('" + fullPathOf(template) + "')";
+ context.setAttribute("file", urlFrom(template), ScriptContext.ENGINE_SCOPE);
+ String call = "render()";
engine.eval(call, context);
engine.eval(call, context);
engine.eval(call, context);
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ScriptException e) {
- // TODO Auto-generated catch block
+ } catch (Exception e) {
e.printStackTrace();
+ fail();
}
}
- public String fullPathOf(String template) {
- return getClass().getClassLoader().getResource(template).toString()
- .substring(5);
- }
-
}
View
3  test/com/mouseoverstudio/haml4j/test/Haml4jServletTest.java
@@ -15,6 +15,7 @@
import java.util.Date;
import java.util.List;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -35,7 +36,7 @@
private MockedPrintWriter writer;
@BeforeClass
- public static void init() {
+ public static void init() throws ServletException {
servlet = new Haml4jServlet("resources/");
servlet.init();
}
Please sign in to comment.
Something went wrong with that request. Please try again.