Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r33 - trunk: . src/org/argouml/ruby www

argouml-ruby
Discussion topic

Back to topic list

svn commit: r33 - trunk: . src/org/argouml/ruby www

Author linus
Full name Linus Tolke
Date 2010-01-12 11:19:56 PST
Message Author: linus
Date: 2010-01-12 11:19:55-0800
New Revision: 33

Modified:
   trunk/build.properties (props changed)
   trunk/build.xml (contents, props changed)
   trunk/build2.bat (props changed)
   trunk/build2.sh (contents, props changed)
   trunk/plugin.properties (props changed)
   trunk/plugin.xml (props changed)
   trunk/src/org/argoum​l/ruby/RubyGenerator​.java (contents, props changed)
   trunk/src/org/argoum​l/ruby/RubyModule.ja​va (contents, props changed)
   trunk/www/index.html (props changed)
   trunk/www/project_tools.html (props changed)

Log:
Fixed properties.

Modified: trunk/build.xml
Url: http://argouml-ruby.​tigris.org/source/br​owse/argouml-ruby/tr​unk/build.xml?view=d​iff&pathrev=33​&r1=32&r2=33
====================​====================​====================​==================
--- trunk/build.xml (original)
+++ trunk/build.xml 2010-01-12 11:19:55-0800
@@ -1,140 +1,140 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$
-// Copyright (c) 2006 The Regents of the University of California. All
-// Rights Reserved. Permission to use, copy, modify, and distribute this
-// software and its documentation without fee, and without a written
-// agreement is hereby granted, provided that the above copyright notice
-// and this paragraph appear in all copies. This software program and
-// documentation are copyrighted by The Regents of the University of
-// California. The software program and documentation are supplied "AS
-// IS", without any accompanying services from The Regents. The Regents
-// does not warrant that the operation of the program will be
-// uninterrupted or error-free. The end-user understands that the program
-// was developed for research purposes and is advised not to rely
-// exclusively on the program for any reason. IN NO EVENT SHALL THE
-// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
-// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
-// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
-// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
-// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
-// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-This is the build file for building the Ruby plugin for ArgoUML.
-
-For this file to work you need to have argouml either checked out alongside
-this directory and built using the package target or downloaded a release
-and unpacked in a directory argouml/build alongside this one. Like this:
-
-argouml-ruby/build.xml <- This file.
-argouml/src/argouml​-build/build/argouml​-model.jar
-argouml/src/argouml​-build/build/log4j.j​ar
-etc.
- -->
-
-<project basedir="." default="compile" name="ArgoUML Ruby module">
- <!-- ====================​====================​====================​======= -->
- <!-- Initialization target -->
- <!-- ====================​====================​====================​======= -->
- <target name="init">
- <property name="build.dir" value="build"/>
- <property name="build.classes" value="build/classes"/>
-
- <property name="debug" value="yes"/>
- <property name="deprecation" value="yes"/>
- <property name="optimize" value="yes"/>
-
- <property name="argo.root.dir" value="../argouml"/>
- <property name="argo.build.dir" value="${argo.root.​dir}/src/argouml-bui​ld/build"/>
-
- <property name="result.jar" value="argouml-ruby.jar"/>
-
- <path id="compile.classpath">
- <pathelement location="${argo.bu​ild.dir}/log4j.jar"/​>
- <pathelement location="${argo.bu​ild.dir}/argouml-mod​el.jar"/>
- <pathelement location="${argo.bu​ild.dir}/argouml.jar​"/>
- <pathelement location="${argo.bu​ild.dir}/ocl-argo.ja​r"/>
- </path>
-
- <path id="run.classpath">
- <fileset dir="${argo.build.dir}" includes="*.jar"/>
- </path>
- </target>
-
- <!-- ====================​====================​====================​======= -->
- <!-- Run from classes -->
- <!-- ====================​====================​====================​======= -->
- <target name="run" depends="install"
- description="Run with this module.">
- <java classname="org.argou​ml.application.Main"​
- fork="yes"
- taskname="argouml"
- jvmargs="-Xmx500M">
- <sysproperty key="log4j.configuration"
- value="org/argouml/r​esource/error_consol​e.lcf"/>
- <classpath>
- <pathelement location="${build.d​ir}/${result.jar}"/​>
- <path refid="run.classpath"/>
- </classpath>
- </java>
- </target>
-
- <!-- ====================​====================​====================​======= -->
- <!-- Compiles the source directory -->
- <!-- ====================​====================​====================​======= -->
- <target name="compile"
- depends="init"
- description="Compile the sources.">
- <!-- create directories -->
- <mkdir dir="${build.dir}"/>
- <mkdir dir="${build.classes}"/>
-
- <javac srcdir="src"
- destdir="${build.classes}"
- includes="org/argoum​l/**/*.java"
- debug="${debug}"
- deprecation="${deprecation}"
- optimize="${optimize}"
- >
- <classpath>
- <path refid="compile.classpath"/>
- </classpath>
- </javac>
- <copy file="src/manifest.mf" todir="${build.classes}"/>
- </target>
-
- <!-- ====================​====================​====================​======= -->
- <!-- Creates the jar file -->
- <!-- ====================​====================​====================​======= -->
- <target name="jar" depends="compile"
- description="Build the ${result.jar} file.">
- <jar basedir="${build.classes}"
- includes="org/argouml/**"
- jarfile="${build.di​r}/${result.jar}"
- manifest="${build.c​lasses}/manifest.mf"​/>
- </target>
-
- <!-- ====================​====================​====================​======= -->
- <!-- Install the jar file -->
- <!-- ====================​====================​====================​======= -->
- <target name="install" depends="jar"
- description="Copy the ${result.jar} file to the ArgoUML directory.">
- <copy todir="${argo.build​.dir}/ext">
- <fileset dir="${build.dir}" includes="${result.jar}"/>
- </copy>
- </target>
-
- <!-- ====================​====================​====================​======= -->
- <!-- Clean targets -->
- <!-- ====================​====================​====================​======= -->
- <target name="clean" depends="init"
- description="Clean out all built files.">
- <delete dir="${build.dir}" quiet="true"/>
- <delete quiet="true">
- <fileset dir="${build.dir}" includes="${result.jar}"/>
- </delete>
- </target>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$
+// Copyright (c) 2006 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+This is the build file for building the Ruby plugin for ArgoUML.
+
+For this file to work you need to have argouml either checked out alongside
+this directory and built using the package target or downloaded a release
+and unpacked in a directory argouml/build alongside this one. Like this:
+
+argouml-ruby/build.xml <- This file.
+argouml/src/argouml​-build/build/argouml​-model.jar
+argouml/src/argouml​-build/build/log4j.j​ar
+etc.
+ -->
+
+<project basedir="." default="compile" name="ArgoUML Ruby module">
+ <!-- ====================​====================​====================​======= -->
+ <!-- Initialization target -->
+ <!-- ====================​====================​====================​======= -->
+ <target name="init">
+ <property name="build.dir" value="build"/>
+ <property name="build.classes" value="build/classes"/>
+
+ <property name="debug" value="yes"/>
+ <property name="deprecation" value="yes"/>
+ <property name="optimize" value="yes"/>
+
+ <property name="argo.root.dir" value="../argouml"/>
+ <property name="argo.build.dir" value="${argo.root.​dir}/src/argouml-bui​ld/build"/>
+
+ <property name="result.jar" value="argouml-ruby.jar"/>
+
+ <path id="compile.classpath">
+ <pathelement location="${argo.bu​ild.dir}/log4j.jar"/​>
+ <pathelement location="${argo.bu​ild.dir}/argouml-mod​el.jar"/>
+ <pathelement location="${argo.bu​ild.dir}/argouml.jar​"/>
+ <pathelement location="${argo.bu​ild.dir}/ocl-argo.ja​r"/>
+ </path>
+
+ <path id="run.classpath">
+ <fileset dir="${argo.build.dir}" includes="*.jar"/>
+ </path>
+ </target>
+
+ <!-- ====================​====================​====================​======= -->
+ <!-- Run from classes -->
+ <!-- ====================​====================​====================​======= -->
+ <target name="run" depends="install"
+ description="Run with this module.">
+ <java classname="org.argou​ml.application.Main"​
+ fork="yes"
+ taskname="argouml"
+ jvmargs="-Xmx500M">
+ <sysproperty key="log4j.configuration"
+ value="org/argouml/r​esource/error_consol​e.lcf"/>
+ <classpath>
+ <pathelement location="${build.d​ir}/${result.jar}"/​>
+ <path refid="run.classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <!-- ====================​====================​====================​======= -->
+ <!-- Compiles the source directory -->
+ <!-- ====================​====================​====================​======= -->
+ <target name="compile"
+ depends="init"
+ description="Compile the sources.">
+ <!-- create directories -->
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.classes}"/>
+
+ <javac srcdir="src"
+ destdir="${build.classes}"
+ includes="org/argoum​l/**/*.java"
+ debug="${debug}"
+ deprecation="${deprecation}"
+ optimize="${optimize}"
+ >
+ <classpath>
+ <path refid="compile.classpath"/>
+ </classpath>
+ </javac>
+ <copy file="src/manifest.mf" todir="${build.classes}"/>
+ </target>
+
+ <!-- ====================​====================​====================​======= -->
+ <!-- Creates the jar file -->
+ <!-- ====================​====================​====================​======= -->
+ <target name="jar" depends="compile"
+ description="Build the ${result.jar} file.">
+ <jar basedir="${build.classes}"
+ includes="org/argouml/**"
+ jarfile="${build.di​r}/${result.jar}"
+ manifest="${build.c​lasses}/manifest.mf"​/>
+ </target>
+
+ <!-- ====================​====================​====================​======= -->
+ <!-- Install the jar file -->
+ <!-- ====================​====================​====================​======= -->
+ <target name="install" depends="jar"
+ description="Copy the ${result.jar} file to the ArgoUML directory.">
+ <copy todir="${argo.build​.dir}/ext">
+ <fileset dir="${build.dir}" includes="${result.jar}"/>
+ </copy>
+ </target>
+
+ <!-- ====================​====================​====================​======= -->
+ <!-- Clean targets -->
+ <!-- ====================​====================​====================​======= -->
+ <target name="clean" depends="init"
+ description="Clean out all built files.">
+ <delete dir="${build.dir}" quiet="true"/>
+ <delete quiet="true">
+ <fileset dir="${build.dir}" includes="${result.jar}"/>
+ </delete>
+ </target>
+</project>

Modified: trunk/build2.sh
Url: http://argouml-ruby.​tigris.org/source/br​owse/argouml-ruby/tr​unk/build2.sh?view=d​iff&pathrev=33​&r1=32&r2=33
====================​====================​====================​==================
--- trunk/build2.sh (original)
+++ trunk/build2.sh 2010-01-12 11:19:55-0800
@@ -1,29 +1,29 @@
-#! /bin/sh
-# $Id: build2.sh 56 2006-03-08 16:34:13Z tfmorris $
-#
-
-# +-------------------​--------------------​--------------------​--------------+
-# | Verify and Set Required Environment Variables |
-# +-------------------​--------------------​--------------------​--------------+
-if [ "$JAVA_HOME" = "" ] ; then
- echo "*******************​********************​********************​****"
- echo " ERROR: JAVA_HOME environment variable not found."
- echo ""
- echo " Please set JAVA_HOME to the Java JDK installation directory."
- echo "*******************​********************​********************​****"
- exit 1
-fi
-
-#
-# build.sh always calls the version of ant distributed with ArgoUML
-#
-ANT_HOME=../argouml​-core-tools/apache-a​nt-1.7.0
-
-echo ANT_HOME is: $ANT_HOME
-echo
-echo Starting Ant...
-echo
-
-$ANT_HOME/bin/ant -Doverride.build.pro​perties=../argouml/e​clipse-ant-build.pro​perties -Dargo.root.dir=`pwd`/.. $*
-
-#exit
+#! /bin/sh
+# $Id: build2.sh 56 2006-03-08 16:34:13Z tfmorris $
+#
+
+# +-------------------​--------------------​--------------------​--------------+
+# | Verify and Set Required Environment Variables |
+# +-------------------​--------------------​--------------------​--------------+
+if [ "$JAVA_HOME" = "" ] ; then
+ echo "*******************​********************​********************​****"
+ echo " ERROR: JAVA_HOME environment variable not found."
+ echo ""
+ echo " Please set JAVA_HOME to the Java JDK installation directory."
+ echo "*******************​********************​********************​****"
+ exit 1
+fi
+
+#
+# build.sh always calls the version of ant distributed with ArgoUML
+#
+ANT_HOME=../argouml​-core-tools/apache-a​nt-1.7.0
+
+echo ANT_HOME is: $ANT_HOME
+echo
+echo Starting Ant...
+echo
+
+$ANT_HOME/bin/ant -Doverride.build.pro​perties=../argouml/e​clipse-ant-build.pro​perties -Dargo.root.dir=`pwd`/.. $*
+
+#exit

Modified: trunk/src/org/argoum​l/ruby/RubyGenerator​.java
Url: http://argouml-ruby.​tigris.org/source/br​owse/argouml-ruby/tr​unk/src/org/argouml/​ruby/RubyGenerator.j​ava?view=diff&pa​threv=33&r1=32​&r2=33
====================​====================​====================​==================
--- trunk/src/org/argoum​l/ruby/RubyGenerator​.java (original)
+++ trunk/src/org/argoum​l/ruby/RubyGenerator​.java 2010-01-12 11:19:55-0800
@@ -1,286 +1,286 @@
-// $Id$
-// Copyright (c) 2006-2008 The Regents of the University of California. All
-// Rights Reserved. Permission to use, copy, modify, and distribute this
-// software and its documentation without fee, and without a written
-// agreement is hereby granted, provided that the above copyright notice
-// and this paragraph appear in all copies. This software program and
-// documentation are copyrighted by The Regents of the University of
-// California. The software program and documentation are supplied "AS
-// IS", without any accompanying services from The Regents. The Regents
-// does not warrant that the operation of the program will be
-// uninterrupted or error-free. The end-user understands that the program
-// was developed for research purposes and is advised not to rely
-// exclusively on the program for any reason. IN NO EVENT SHALL THE
-// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
-// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
-// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
-// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
-// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
-// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-package org.argouml.ruby;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.argouml.model.Model;
-import org.argouml.uml.gene​rator.CodeGenerator;​
-import org.argouml.uml.gene​rator.SourceUnit;
-
-/**
- * Generate Ruby code.
- *
- * @author Jacek Bojarski
- *
- */
-public class RubyGenerator implements CodeGenerator {
- /**
- * TODO: Where should we put the files?
- */
- private String whereToGenerate = "/tmp/generatedRuby";
- private String ext = ".rb";
-
- /**
- * Do the actual generation for an object.
- *
- * @param o
- * The object.
- * @return a SourceUnit.
- */
- private SourceUnit generateForObject(Object o) {
- if (Model.getFacade().isAClass(o))
- return generateClass(o);
-
- return null;
- }
-
- /**
- * Generate Code for class.
- *
- * @param o The object.
- * @return a SourceUnit.
- */
- private SourceUnit generateClass(Object o) {
- // TODO:use string buffer!?
- String className = capitalize(Model.get​Facade().getName(o))​;
- String src = "class " + className;
-
- // generalization:
- String baseClass = generateGeneralizati​on(Model.getFacade()​
- .getGeneralizations(o));
- if (!baseClass.equals("")) {
- src += " < " + capitalize(baseClass);
- }
- src += "\n";
-
- src += getAttributes(o);
- src += getOperations(o);
- src += "\nend";
- return new SourceUnit(
- capitalize(Model.get​Facade().getName(o))​ + ext,
- whereToGenerate, src);
-
- }
-
- /**
- * Generate code for generalizations of class.
- *
- * @param generalizations The list of generalizations.
- * @return code fo generalization.
- */
- private String generateGeneralizati​on(Collection generalizations) {
- if (generalizations == null) {
- return "";
- }
- String baseClass = "";
- Iterator iter = generalizations.iterator();
- while (iter.hasNext()) {
- Object generalization = iter.next();
- Object generalizableElement = Model.getFacade().getGeneral(
- generalization);
- if (generalizableElement != null) {
- baseClass = generateClassifierNa​me(generalizableElem​ent);
- break;
- }
- }
- return baseClass;
- }
-
- public String generateClassifierName(Object cls) {
- if (cls == null) {
- return "";
- }
- return Model.getFacade().getName(cls);
- }
-
- private String getAttributes(Object o) {
- String attrsSrc = "";
- Collection attrs = Model.getFacade().ge​tAttributes(o);
- // get classifier attributes
- for (Iterator i = attrs.iterator(); i.hasNext();) {
- Object attr = i.next();
- String varType = "@";
- String defaultValue = "";
- String attrName = Model.getFacade().ge​tName(attr);
- // is static?
- if (Model.getFacade().i​sStatic(attr)) {
- varType += "@";
- defaultValue = "=nil";
- }
- // Get initial value of attribut
- Object init = (Model.getFacade().g​etInitialValue(attr)​);
- if (init != null) {
- defaultValue = "="
- + ((String) (Model.getFacade().g​etBody(init))).trim(​);
- // need more elegant solution ;)
- }
- attrsSrc += varType + attrName + defaultValue + "\n";
- }
- attrsSrc += "\n";
- return attrsSrc;
- }
-
- private String getOperations(Object o) {
- String opersSrc = "";
- String protectedList = "";
- String privateList = "";
- Collection opers = Model.getFacade().ge​tOperations(o);
- for (Iterator i = opers.iterator(); i.hasNext();) {
- Object oper = i.next();
- String operName = Model.getFacade().ge​tName(oper);
- opersSrc += "def " + operName;
- // get params
- String params = getOperationsParams(oper);
- if (!params.equals("")) {
- opersSrc += "(" + params + ")";
- }
- opersSrc += "\nend\n";
- // get visibility of operation
- if (Model.getFacade().i​sProtected(oper)) {
- protectedList += ":" + operName + ",";
- }
- else if (Model.getFacade().i​sPrivate(oper)) {
- privateList += ":" + operName + ",";
- }
- }
- // write visibility of all operations
- if (!protectedList.equals("")) {
- opersSrc += "protected "
- + protectedList.substring(0, protectedList.length() - 1)
- + "\n";
- }
- if (!privateList.equals("")) {
- opersSrc += "private "
- + privateList.substring(0, privateList.length() - 1) + "\n";
- }
- return opersSrc;
- }
-
-
- private String getOperationsParams(Object o) {
- String paramsSrc = "";
- Collection params = Model.getFacade().ge​tParameters(o);
- // get operation params
- for (Iterator i = params.iterator(); i.hasNext();) {
- Object param = i.next();
- String defaultValue = "";
- String paramName = Model.getFacade().ge​tName(param);
- // skip return
- if (paramName.equals("return")) {
- continue;
- }
- // Get default value of param
- Object init = (Model.getFacade().g​etDefaultValue(param​));
- if (init != null) {
- defaultValue = "="
- + ((String) (Model.getFacade().g​etBody(init))).trim(​);
- }
- paramsSrc += paramName + defaultValue + ",";
- }
- if (!paramsSrc.equals("")) {
- paramsSrc = paramsSrc.substring(0, paramsSrc.length() - 1);
- }
- return paramsSrc;
- }
-
- private String capitalize(String str) {
- if (str.length() > 1) {
- return str.substring(0, 1).toUpperCase() + str.substring(1);
- } else {
- return str.toUpperCase();
- }
- }
-
- /*
- * @see org.argouml.uml.gene​rator.CodeGenerator#​generate(java.util.C​ollection,
- * boolean)
- */
- public Collection generate(Collection elements, boolean deps) {
- Collection res = new ArrayList();
-
- for (Iterator i = elements.iterator(); i.hasNext();) {
- Object o = i.next();
- SourceUnit su = generateForObject(o);
- if (su != null) {
- res.add(su);
- }
- }
- return res;
- }
-
- /*
- * @see org.argouml.uml.gene​rator.CodeGenerator#​generateFiles(java.u​til.Collection,
- * java.lang.String, boolean)
- */
- public Collection generateFiles(Collection elements, String path,
- boolean deps) {
- Collection res = new ArrayList();
-
- for (Iterator i = elements.iterator(); i.hasNext();) {
- Object o = i.next();
- SourceUnit su = generateForObject(o);
- if (su != null) {
- su.setBasePath(path);
- File file = new File(su.getFullName());
- try {
- OutputStream os = new FileOutputStream(file);
- OutputStreamWriter osw = new OutputStreamWriter(os);
- osw.write(su.getContent());
- osw.close();
- } catch (IOException e) {
- // TODO: The file could not be created.
- }
- res.add(file.getName());
- }
- }
- return res;
- }
-
- /*
- * @see org.argouml.uml.gene​rator.CodeGenerator#​generateFileList(jav​a.util.Collection,
- * boolean)
- */
- public Collection generateFileList(Collection elements, boolean deps) {
- Collection res = new ArrayList();
-
- for (Iterator i = elements.iterator(); i.hasNext();) {
- Object o = i.next();
- SourceUnit su = generateForObject(o);
- System.out.println(s​u.getFullName());
- File file = new File(su.getFullName());
- res.add(file.getName());
- }
- return res;
- }
-
+// $Id$
+// Copyright (c) 2006-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.ruby;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.argouml.model.Model;
+import org.argouml.uml.gene​rator.CodeGenerator;​
+import org.argouml.uml.gene​rator.SourceUnit;
+
+/**
+ * Generate Ruby code.
+ *
+ * @author Jacek Bojarski
+ *
+ */
+public class RubyGenerator implements CodeGenerator {
+ /**
+ * TODO: Where should we put the files?
+ */
+ private String whereToGenerate = "/tmp/generatedRuby";
+ private String ext = ".rb";
+
+ /**
+ * Do the actual generation for an object.
+ *
+ * @param o
+ * The object.
+ * @return a SourceUnit.
+ */
+ private SourceUnit generateForObject(Object o) {
+ if (Model.getFacade().isAClass(o))
+ return generateClass(o);
+
+ return null;
+ }
+
+ /**
+ * Generate Code for class.
+ *
+ * @param o The object.
+ * @return a SourceUnit.
+ */
+ private SourceUnit generateClass(Object o) {
+ // TODO:use string buffer!?
+ String className = capitalize(Model.get​Facade().getName(o))​;
+ String src = "class " + className;
+
+ // generalization:
+ String baseClass = generateGeneralizati​on(Model.getFacade()​
+ .getGeneralizations(o));
+ if (!baseClass.equals("")) {
+ src += " < " + capitalize(baseClass);
+ }
+ src += "\n";
+
+ src += getAttributes(o);
+ src += getOperations(o);
+ src += "\nend";
+ return new SourceUnit(
+ capitalize(Model.get​Facade().getName(o))​ + ext,
+ whereToGenerate, src);
+
+ }
+
+ /**
+ * Generate code for generalizations of class.
+ *
+ * @param generalizations The list of generalizations.
+ * @return code fo generalization.
+ */
+ private String generateGeneralizati​on(Collection generalizations) {
+ if (generalizations == null) {
+ return "";
+ }
+ String baseClass = "";
+ Iterator iter = generalizations.iterator();
+ while (iter.hasNext()) {
+ Object generalization = iter.next();
+ Object generalizableElement = Model.getFacade().getGeneral(
+ generalization);
+ if (generalizableElement != null) {
+ baseClass = generateClassifierNa​me(generalizableElem​ent);
+ break;
+ }
+ }
+ return baseClass;
+ }
+
+ public String generateClassifierName(Object cls) {
+ if (cls == null) {
+ return "";
+ }
+ return Model.getFacade().getName(cls);
+ }
+
+ private String getAttributes(Object o) {
+ String attrsSrc = "";
+ Collection attrs = Model.getFacade().ge​tAttributes(o);
+ // get classifier attributes
+ for (Iterator i = attrs.iterator(); i.hasNext();) {
+ Object attr = i.next();
+ String varType = "@";
+ String defaultValue = "";
+ String attrName = Model.getFacade().ge​tName(attr);
+ // is static?
+ if (Model.getFacade().i​sStatic(attr)) {
+ varType += "@";
+ defaultValue = "=nil";
+ }
+ // Get initial value of attribut
+ Object init = (Model.getFacade().g​etInitialValue(attr)​);
+ if (init != null) {
+ defaultValue = "="
+ + ((String) (Model.getFacade().g​etBody(init))).trim(​);
+ // need more elegant solution ;)
+ }
+ attrsSrc += varType + attrName + defaultValue + "\n";
+ }
+ attrsSrc += "\n";
+ return attrsSrc;
+ }
+
+ private String getOperations(Object o) {
+ String opersSrc = "";
+ String protectedList = "";
+ String privateList = "";
+ Collection opers = Model.getFacade().ge​tOperations(o);
+ for (Iterator i = opers.iterator(); i.hasNext();) {
+ Object oper = i.next();
+ String operName = Model.getFacade().ge​tName(oper);
+ opersSrc += "def " + operName;
+ // get params
+ String params = getOperationsParams(oper);
+ if (!params.equals("")) {
+ opersSrc += "(" + params + ")";
+ }
+ opersSrc += "\nend\n";
+ // get visibility of operation
+ if (Model.getFacade().i​sProtected(oper)) {
+ protectedList += ":" + operName + ",";
+ }
+ else if (Model.getFacade().i​sPrivate(oper)) {
+ privateList += ":" + operName + ",";
+ }
+ }
+ // write visibility of all operations
+ if (!protectedList.equals("")) {
+ opersSrc += "protected "
+ + protectedList.substring(0, protectedList.length() - 1)
+ + "\n";
+ }
+ if (!privateList.equals("")) {
+ opersSrc += "private "
+ + privateList.substring(0, privateList.length() - 1) + "\n";
+ }
+ return opersSrc;
+ }
+
+
+ private String getOperationsParams(Object o) {
+ String paramsSrc = "";
+ Collection params = Model.getFacade().ge​tParameters(o);
+ // get operation params
+ for (Iterator i = params.iterator(); i.hasNext();) {
+ Object param = i.next();
+ String defaultValue = "";
+ String paramName = Model.getFacade().ge​tName(param);
+ // skip return
+ if (paramName.equals("return")) {
+ continue;
+ }
+ // Get default value of param
+ Object init = (Model.getFacade().g​etDefaultValue(param​));
+ if (init != null) {
+ defaultValue = "="
+ + ((String) (Model.getFacade().g​etBody(init))).trim(​);
+ }
+ paramsSrc += paramName + defaultValue + ",";
+ }
+ if (!paramsSrc.equals("")) {
+ paramsSrc = paramsSrc.substring(0, paramsSrc.length() - 1);
+ }
+ return paramsSrc;
+ }
+
+ private String capitalize(String str) {
+ if (str.length() > 1) {
+ return str.substring(0, 1).toUpperCase() + str.substring(1);
+ } else {
+ return str.toUpperCase();
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.gene​rator.CodeGenerator#​generate(java.util.C​ollection,
+ * boolean)
+ */
+ public Collection generate(Collection elements, boolean deps) {
+ Collection res = new ArrayList();
+
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object o = i.next();
+ SourceUnit su = generateForObject(o);
+ if (su != null) {
+ res.add(su);
+ }
+ }
+ return res;
+ }
+
+ /*
+ * @see org.argouml.uml.gene​rator.CodeGenerator#​generateFiles(java.u​til.Collection,
+ * java.lang.String, boolean)
+ */
+ public Collection generateFiles(Collection elements, String path,
+ boolean deps) {
+ Collection res = new ArrayList();
+
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object o = i.next();
+ SourceUnit su = generateForObject(o);
+ if (su != null) {
+ su.setBasePath(path);
+ File file = new File(su.getFullName());
+ try {
+ OutputStream os = new FileOutputStream(file);
+ OutputStreamWriter osw = new OutputStreamWriter(os);
+ osw.write(su.getContent());
+ osw.close();
+ } catch (IOException e) {
+ // TODO: The file could not be created.
+ }
+ res.add(file.getName());
+ }
+ }
+ return res;
+ }
+
+ /*
+ * @see org.argouml.uml.gene​rator.CodeGenerator#​generateFileList(jav​a.util.Collection,
+ * boolean)
+ */
+ public Collection generateFileList(Collection elements, boolean deps) {
+ Collection res = new ArrayList();
+
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object o = i.next();
+ SourceUnit su = generateForObject(o);
+ System.out.println(s​u.getFullName());
+ File file = new File(su.getFullName());
+ res.add(file.getName());
+ }
+ return res;
+ }
+
 }
\ No newline at end of file

Modified: trunk/src/org/argoum​l/ruby/RubyModule.ja​va
Url: http://argouml-ruby.​tigris.org/source/br​owse/argouml-ruby/tr​unk/src/org/argouml/​ruby/RubyModule.java​?view=diff&pathr​ev=33&r1=32&​r2=33
====================​====================​====================​==================
--- trunk/src/org/argoum​l/ruby/RubyModule.ja​va (original)
+++ trunk/src/org/argoum​l/ruby/RubyModule.ja​va 2010-01-12 11:19:55-0800
@@ -1,79 +1,79 @@
-// $Id$
-// Copyright (c) 2006 The Regents of the University of California. All
-// Rights Reserved. Permission to use, copy, modify, and distribute this
-// software and its documentation without fee, and without a written
-// agreement is hereby granted, provided that the above copyright notice
-// and this paragraph appear in all copies. This software program and
-// documentation are copyrighted by The Regents of the University of
-// California. The software program and documentation are supplied "AS
-// IS", without any accompanying services from The Regents. The Regents
-// does not warrant that the operation of the program will be
-// uninterrupted or error-free. The end-user understands that the program
-// was developed for research purposes and is advised not to rely
-// exclusively on the program for any reason. IN NO EVENT SHALL THE
-// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
-// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
-// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
-// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
-// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
-// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-package org.argouml.ruby;
-
-import org.argouml.modulelo​ader.ModuleInterface​;
-import org.argouml.uml.gene​rator.GeneratorHelpe​r;
-import org.argouml.uml.gene​rator.GeneratorManag​er;
-import org.argouml.uml.gene​rator.Language;
-
-/**
- * Module enabler for Ruby.
- *
- * @author Jacek Bojarski
- */
-public class RubyModule implements ModuleInterface {
- private Language myLang = GeneratorHelper.make​Language("Ruby");
-
- /*
- * @see org.argouml.modulelo​ader.ModuleInterface​#enable()
- */
- public boolean enable() {
- GeneratorManager.get​Instance().addGenera​tor(myLang,
- new RubyGenerator());
- return true;
- }
-
- /*
- * @see org.argouml.modulelo​ader.ModuleInterface​#disable()
- */
- public boolean disable() {
- GeneratorManager.get​Instance().removeGen​erator(myLang);
- return true;
- }
-
- /*
- * @see org.argouml.modulelo​ader.ModuleInterface​#getName()
- */
- public String getName() {
- return "Ruby";
- }
-
- /*
- * @see org.argouml.modulelo​ader.ModuleInterface​#getInfo(int)
- */
- public String getInfo(int type) {
- switch (type) {
- case DESCRIPTION:
- return "This is the Ruby module.";
- case AUTHOR:
- return "Jacek Bojarski";
- case VERSION:
- return "0.0.1";
- }
- return null;
- }
-
-}
+// $Id$
+// Copyright (c) 2006 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.ruby;
+
+import org.argouml.modulelo​ader.ModuleInterface​;
+import org.argouml.uml.gene​rator.GeneratorHelpe​r;
+import org.argouml.uml.gene​rator.GeneratorManag​er;
+import org.argouml.uml.gene​rator.Language;
+
+/**
+ * Module enabler for Ruby.
+ *
+ * @author Jacek Bojarski
+ */
+public class RubyModule implements ModuleInterface {
+ private Language myLang = GeneratorHelper.make​Language("Ruby");
+
+ /*
+ * @see org.argouml.modulelo​ader.ModuleInterface​#enable()
+ */
+ public boolean enable() {
+ GeneratorManager.get​Instance().addGenera​tor(myLang,
+ new RubyGenerator());
+ return true;
+ }
+
+ /*
+ * @see org.argouml.modulelo​ader.ModuleInterface​#disable()
+ */
+ public boolean disable() {
+ GeneratorManager.get​Instance().removeGen​erator(myLang);
+ return true;
+ }
+
+ /*
+ * @see org.argouml.modulelo​ader.ModuleInterface​#getName()
+ */
+ public String getName() {
+ return "Ruby";
+ }
+
+ /*
+ * @see org.argouml.modulelo​ader.ModuleInterface​#getInfo(int)
+ */
+ public String getInfo(int type) {
+ switch (type) {
+ case DESCRIPTION:
+ return "This is the Ruby module.";
+ case AUTHOR:
+ return "Jacek Bojarski";
+ case VERSION:
+ return "0.0.1";
+ }
+ return null;
+ }
+
+}

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r33 - trunk: . src/org/argouml/ruby www linus Linus Tolke 2010-01-12 11:19:56 PST
Messages per page: