Thanks.
- Asiri
On Thu, Jul 23, 2009 at 5:49 PM, asiri <platform-notifications(a)xwiki.org>wrote;wrote:
Author: asiri
Date: 2009-07-23 14:19:58 +0200 (Thu, 23 Jul 2009)
New Revision: 22042
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/pom.xml
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/rendering/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/rendering/internal/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/rendering/internal/macro/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/rendering/internal/macro/ruby/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/rendering/internal/macro/ruby/RubyMacro.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/resources/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/resources/META-INF/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/resources/META-INF/components.txt
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/xwiki/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/xwiki/rendering/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/xwiki/rendering/macro/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/xwiki/rendering/macro/ruby/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/xwiki/rendering/macro/ruby/RenderingTests.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby1.test
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby2.test
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby3.test
Modified:
platform/core/trunk/xwiki-core/pom.xml
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml
Log:
XWIKI-2849: Create ruby macro for rendering 2.0
* Implemented.
Modified: platform/core/trunk/xwiki-core/pom.xml
===================================================================
--- platform/core/trunk/xwiki-core/pom.xml 2009-07-22 23:34:44 UTC
(rev 22041)
+++ platform/core/trunk/xwiki-core/pom.xml 2009-07-23 12:19:58 UTC
(rev 22042)
@@ -700,6 +700,13 @@
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-core-rendering-macro-wikibridge</artifactId>
<version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.xwiki.platform</groupId>
+ <artifactId>xwiki-core-rendering-macro-ruby</artifactId>
+ <version>${pom.version}</version>
+ <!-- Only needed at runtime since it's a component implementation
-->
+ <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml
===================================================================
--- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml
2009-07-22 23:34:44 UTC (rev 22041)
+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml
2009-07-23 12:19:58 UTC (rev 22042)
@@ -127,6 +127,7 @@
<module>xwiki-rendering-macro-chart</module>
<module>xwiki-rendering-macro-footnotes</module>
<module>xwiki-rendering-macro-wikibridge</module>
+ <module>xwiki-rendering-macro-ruby</module>
</modules>
</project>
Property changes on:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.classpath
.project
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/pom.xml
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/pom.xml
(rev 0)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/pom.xml
2009-07-23 12:19:58 UTC (rev 22042)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *
+-->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd
">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.xwiki.platform</groupId>
+ <artifactId>xwiki-core-rendering-macros-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>xwiki-core-rendering-macro-ruby</artifactId>
+ <name>XWiki Platform - Core - Rendering - Macro - Ruby</name>
+ <description>XWiki Platform - Core - Rendering - Macro -
Ruby</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.xwiki.platform</groupId>
+ <artifactId>xwiki-core-rendering-macro-script</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jruby</groupId>
+ <artifactId>jruby</artifactId>
+ <version>1.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.script</groupId>
+ <artifactId>jruby-engine</artifactId>
+ <version>1.3.0-xwiki</version>
+ </dependency>
+ <!-- Testing dependencies -->
+ <dependency>
+ <groupId>org.xwiki.platform</groupId>
+ <artifactId>xwiki-core-rendering-macro-script</artifactId>
+ <version>${pom.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/RenderingTests.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <!-- Apply the Checkstyle configurations defined in the top level
pom.xml file -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/rendering/internal/macro/ruby/RubyMacro.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/rendering/internal/macro/ruby/RubyMacro.java
(rev 0)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/java/org/xwiki/rendering/internal/macro/ruby/RubyMacro.java
2009-07-23 12:19:58 UTC (rev 22042)
@@ -0,0 +1,66 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.macro.ruby;
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.rendering.macro.descriptor.DefaultContentDescriptor;
+import org.xwiki.rendering.macro.script.AbstractJRSR223ScriptMacro;
+import org.xwiki.rendering.macro.script.JSR223ScriptMacroParameters;
+
+/**
+ * A macro for executing ruby scripts.
+ *
+ * @version $Id:$
+ * @since 2.0M2
+ */
+@Component("ruby")
+public class RubyMacro extends
AbstractJRSR223ScriptMacro<JSR223ScriptMacroParameters>
+{
+ /**
+ * The description of the macro.
+ */
+ private static final String DESCRIPTION = "Execute a ruby script.";
+
+ /**
+ * The description of the macro content.
+ */
+ private static final String CONTENT_DESCRIPTION = "The ruby script to
execute";
+
+ /**
+ * Create and initialize the descriptor of the macro.
+ */
+ public RubyMacro()
+ {
+ super(DESCRIPTION, new
DefaultContentDescriptor(CONTENT_DESCRIPTION));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object eval(String content, ScriptEngine engine,
ScriptContext scriptContext) throws ScriptException
+ {
+ return super.eval(content, engine, scriptContext);
+ }
+}
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/resources/META-INF/components.txt
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/resources/META-INF/components.txt
(rev 0)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/main/resources/META-INF/components.txt
2009-07-23 12:19:58 UTC (rev 22042)
@@ -0,0 +1 @@
+org.xwiki.rendering.internal.macro.ruby.RubyMacro
\ No newline at end of file
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/xwiki/rendering/macro/ruby/RenderingTests.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/xwiki/rendering/macro/ruby/RenderingTests.java
(rev 0)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/java/org/xwiki/rendering/macro/ruby/RenderingTests.java
2009-07-23 12:19:58 UTC (rev 22042)
@@ -0,0 +1,86 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.xwiki.rendering.macro.ruby;
+
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.xwiki.bridge.DocumentAccessBridge;
+import org.xwiki.component.descriptor.DefaultComponentDescriptor;
+import org.xwiki.component.embed.EmbeddableComponentManager;
+import org.xwiki.component.manager.ComponentManager;
+import org.xwiki.rendering.scaffolding.RenderingTestSuite;
+import org.xwiki.test.ComponentManagerTestSetup;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+/**
+ * Rendering tests for ruby macro.
+ *
+ * @version $Id:$
+ * @since 2.0M2
+ */
+public class RenderingTests extends TestCase
+{
+ /**
+ * Creates a rendering test suit for testing ruby macro.
+ *
+ * @return rendering test suit for testing ruby macro.
+ * @throws Exception if an error occurs while setting up the test
suite.
+ */
+ public static Test suite() throws Exception
+ {
+ RenderingTestSuite suite = new RenderingTestSuite("Test Ruby
Macro");
+
+ suite.addTestsFromResource("macroruby1", true);
+ suite.addTestsFromResource("macroruby2", true);
+ suite.addTestsFromResource("macroruby3", true);
+
+ ComponentManagerTestSetup testSetup = new
ComponentManagerTestSetup(suite);
+ setUpMocks(testSetup.getComponentManager());
+
+ return testSetup;
+ }
+
+ /**
+ * Sets up mock component descriptors.
+ *
+ * @param componentManager the {@link ComponentManager} component.
+ */
+ public static void setUpMocks(EmbeddableComponentManager
componentManager)
+ {
+ Mockery context = new Mockery();
+
+ // Document Access Bridge Mock setup
+ final DocumentAccessBridge mockDocumentAccessBridge =
context.mock(DocumentAccessBridge.class);
+ context.checking(new Expectations()
+ {
+ {
+ allowing(mockDocumentAccessBridge).hasProgrammingRights();
+ will(returnValue(true));
+ }
+ });
+
+ DefaultComponentDescriptor<DocumentAccessBridge> descriptorDAB =
+ new DefaultComponentDescriptor<DocumentAccessBridge>();
+ descriptorDAB.setRole(DocumentAccessBridge.class);
+ componentManager.registerComponent(descriptorDAB,
mockDocumentAccessBridge);
+ }
+}
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby1.test
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby1.test
(rev 0)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby1.test
2009-07-23 12:19:58 UTC (rev 22042)
@@ -0,0 +1,14 @@
+.#-----------------------------------------------------
+.input|xwiki/2.0
+.#-----------------------------------------------------
+{{ruby}}
+puts "Hello World!!!"
+{{/ruby}}
+
+== Hello {{ruby}}puts "World!!!"{{/ruby}}==
+.#-----------------------------------------------------
+.expect|xhtml/1.0
+.#-----------------------------------------------------
+<!--startmacro:ruby|-||-|
+puts "Hello World!!!"
+--><p>Hello World!!!</p><!--stopmacro--><h2
id="HHello"><span>Hello
<!--startmacro:ruby|-||-|puts
"World!!!"-->World!!!<!--stopmacro--></span></h2>
\ No newline at end of file
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby2.test
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby2.test
(rev 0)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby2.test
2009-07-23 12:19:58 UTC (rev 22042)
@@ -0,0 +1,16 @@
+.#-----------------------------------------------------
+.input|xwiki/2.0
+.# Verify ruby macro does not fail with null content
+.#-----------------------------------------------------
+{{ruby/}}{{ruby}}{{/ruby}}
+.#-----------------------------------------------------
+.expect|event/1.0
+.#-----------------------------------------------------
+beginDocument
+beginParagraph
+beginMacroMarkerInline [ruby] []
+endMacroMarkerInline [ruby] []
+beginMacroMarkerInline [ruby] [] []
+endMacroMarkerInline [ruby] [] []
+endParagraph
+endDocument
\ No newline at end of file
Added:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby3.test
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby3.test
(rev 0)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-ruby/src/test/resources/macroruby3.test
2009-07-23 12:19:58 UTC (rev 22042)
@@ -0,0 +1,28 @@
+.#-----------------------------------------------------
+.input|xwiki/2.0
+.#-----------------------------------------------------
+{{ruby}}
+require 'java'
+include_class 'java.util.TreeSet'
+set = TreeSet.new
+set.add "foo"
+set.add "Bar"
+set.add "baz"
+set.each do |v|
+ puts "value: #{v}"
+end
+{{/ruby}}
+.#-----------------------------------------------------
+.expect|xhtml/1.0
+.#-----------------------------------------------------
+<!--startmacro:ruby|-||-|
+require 'java'
+include_class 'java.util.TreeSet'
+set = TreeSet.new
+set.add "foo"
+set.add "Bar"
+set.add "baz"
+set.each do |v|
+ puts "value: #{v}"
+end
+--><p>value: Bar<br/>value: baz<br/>value:
foo</p><!--stopmacro-->
\ No newline at end of file
_______________________________________________
notifications mailing list
notifications(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications
_______________________________________________
devs mailing list
devs(a)xwiki.org