[rkward-cvs] SF.net SVN: rkward-code:[4564] trunk/rkward/packages/rkwarddev

m-eik at users.sf.net m-eik at users.sf.net
Mon Feb 25 21:36:53 UTC 2013


Revision: 4564
          http://sourceforge.net/p/rkward/code/4564
Author:   m-eik
Date:     2013-02-25 21:36:50 +0000 (Mon, 25 Feb 2013)
Log Message:
-----------
rkwarddev: new function join() and (pseudo-)class rk.JS.echo.

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/DESCRIPTION
    trunk/rkward/packages/rkwarddev/NAMESPACE
    trunk/rkward/packages/rkwarddev/R/echo.R
    trunk/rkward/packages/rkwarddev/R/id.R
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/R/rk.JS.array.R
    trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R
    trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
    trunk/rkward/packages/rkwarddev/R/show-methods.R
    trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R
    trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
    trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
    trunk/rkward/packages/rkwarddev/man/rk.JS.array.Rd
    trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd

Added Paths:
-----------
    trunk/rkward/packages/rkwarddev/R/join.R
    trunk/rkward/packages/rkwarddev/man/join.Rd

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2013-02-25 21:36:50 UTC (rev 4564)
@@ -1,6 +1,6 @@
 ChangeLog for package rkwarddev
 
-changes in version 0.06-2 (2013-02-22)
+changes in version 0.06-2 (2013-02-25)
 changed:
   - the structure of <about> nodes will change in RKWard 0.6.1,
     <dependencies> will become a direct child of <document> or <component>, which explains
@@ -27,10 +27,13 @@
   - new function rk.XML.matrix()
   - new function rk.XML.dependencies()
   - new function rk.XML.dependency_check()
+  - new function join() to simplify ".join()" for JavaScript arrays
   - added options "dependencies", "namespace" and "priority" to
     rk.XML.pluginmap()
   - added option "dependencies" to rk.XML.component()
   - added "map" to rk.XML.require()
+  - the new class rk.JS.echo allows having objects in an echo() statement
+    without quoting it
 fixed:
   - added some missing parameter in the docs for rk.paste.JS.graph()
 

Modified: trunk/rkward/packages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/packages/rkwarddev/DESCRIPTION	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/DESCRIPTION	2013-02-25 21:36:50 UTC (rev 4564)
@@ -15,12 +15,13 @@
 Authors at R: c(person(given="Meik", family="Michalke",
     email="meik.michalke at hhu.de", role=c("aut", "cre")))
 Version: 0.06-2
-Date: 2013-02-22
+Date: 2013-02-25
 Collate:
     'echo.R'
     'id.R'
     'rk.JS.ite-class.R'
     'ite.R'
+    'join.R'
     'qp.R'
     'rk.build.plugin.R'
     'rk.comment.R'

Modified: trunk/rkward/packages/rkwarddev/NAMESPACE
===================================================================
--- trunk/rkward/packages/rkwarddev/NAMESPACE	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/NAMESPACE	2013-02-25 21:36:50 UTC (rev 4564)
@@ -1,6 +1,7 @@
 export(echo)
 export(id)
 export(ite)
+export(join)
 export(qp)
 export(rk.JS.array)
 export(rk.JS.doc)

Modified: trunk/rkward/packages/rkwarddev/R/echo.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/echo.R	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/R/echo.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -25,3 +25,14 @@
 	result <- paste("echo(", ID.content, ");", newline, sep="")
 	return(result)
 }
+
+## internal class rk.JS.echo
+# this is a quick fix to be able to add values into echo() without quotes
+setClass("rk.JS.echo",
+	representation=representation(
+		value="character"
+	),
+	prototype(
+		value=character()
+	)
+)

Modified: trunk/rkward/packages/rkwarddev/R/id.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/id.R	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/R/id.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -62,6 +62,9 @@
 					warning(paste("Object contained more than one ID, only the first one was used: ", node.id, sep=""), call.=FALSE)
 				} else {}
 				return(node.id)
+			} else if(inherits(this.part, "rk.JS.echo")){
+				node.id <- slot(this.part, "value")
+				return(node.id)
 			} else {
 				if(isTRUE(quote)){
 					text.part <- deparse(this.part)

Added: trunk/rkward/packages/rkwarddev/R/join.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/join.R	                        (rev 0)
+++ trunk/rkward/packages/rkwarddev/R/join.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -0,0 +1,35 @@
+#' Generate JavaScript to join an array object
+#'
+#' This function pastes an object of class \code{rk.JS.arr} similar to \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}},
+#' but was specifically written for elements like \code{<optionset>} or \code{<matrix>}, whose values must be queried
+#' by \code{getList()} rather than \code{getValue()}. This means, the resulting variable is already an array an merely
+#' needs to be joined in as R code output (e.g., an \code{<optioncolumn>}).
+#'
+#' @param var Either a character string (the name of the variable to combine to a vector or list),
+#'		or an object of class \code{XiMpLe.node} (whose ID will be extracted and used). Also
+#'		accepts objects of class \code{rk.JS.arr}.
+#' @param by Character string by which the values ought to be joined.
+#' @return An object of class \code{rk.JS.echo}.
+#' @export
+#' @seealso \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}},
+#'		\code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
+#'		\code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
+#'		\code{\link[rkwarddev:echo]{echo}},
+#'		\code{\link[rkwarddev:id]{id}},
+#'		and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
+# @examples
+
+join <- function(var, by="\", \""){
+
+	if(inherits(var, "rk.JS.arr")){
+		arr.name  <- slot(object, "opt.name")
+	} else {
+		arr.name <- id(var)
+	}
+
+	JS.join <- new("rk.JS.echo",
+			value=paste(camelCode(arr.name), ".join(", qp(by) ,")", sep="")
+		)
+
+	return(JS.join)
+}

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -764,6 +764,7 @@
 } ## end function clean.name()
 
 
+
 ## function paste.JS.ite()
 paste.JS.ite <- function(object, level=1, indent.by="\t", recurse=FALSE, empty.e=FALSE){
 	stopifnot(inherits(object, "rk.JS.ite"))

Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.array.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.array.R	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.array.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -7,7 +7,7 @@
 #' @param option A character string, naming, e.g., an option of an R function which should be
 #'		constructed from several variables.
 #' @param variables A list with either character strings (the names of the variables to combine to a vector or list),
-#'		of objects of class \code{XiMpLe.node} with plugin XML nodes (whose ID will be extracted and used).
+#'		or objects of class \code{XiMpLe.node} with plugin XML nodes (whose ID will be extracted and used).
 #' @param funct Character string, name of the R function to be called to combine the options, e.g. "list" for \code{list()},
 #'		or "c" for \code{c()}.
 #' @param var.prefix A character string. sets a global string to be used as a prefix for the JS variable names.

Modified: trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -58,6 +58,8 @@
 		} else if(inherits(this.object, "rk.JS.var")){
 			result <- paste.JS.var(this.object, level=level, indent.by=indent.by, JS.prefix=var.prefix,
 				modifiers=modifiers, default=default, join=join, getter=getter)
+		} else if(inherits(this.object, "rk.JS.echo")){
+			result <- slot(this.object, "value")
 		} else if(is.XiMpLe.node(this.object)){
 			if(identical(XMLName(this.object), "!--")){
 				result <- paste(indent(level, by=indent.by),

Modified: trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -4,7 +4,7 @@
 #' Package: \tab rkwarddev\cr
 #' Type: \tab Package\cr
 #' Version: \tab 0.06-2\cr
-#' Date: \tab 2013-02-22\cr
+#' Date: \tab 2013-02-25\cr
 #' Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-18),rkward (>= 0.5.6)\cr
 #' Enhances: \tab rkward\cr
 #' Encoding: \tab UTF-8\cr

Modified: trunk/rkward/packages/rkwarddev/R/show-methods.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/show-methods.R	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/R/show-methods.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -9,6 +9,7 @@
 #' @include rk.JS.ite-class.R
 #' @include rk.JS.opt-class.R
 #' @include rk.JS.var-class.R
+#' @include echo.R
 #' @exportMethod show
 #' @rdname show-methods
 setGeneric("show")
@@ -17,6 +18,7 @@
 setMethod("show", signature(object="rk.JS.arr"), function(object){
 	cat(rk.paste.JS(object))
 })
+
 #' @rdname show-methods
 setMethod("show", signature(object="rk.JS.ite"), function(object){
 	cat(rk.paste.JS(object))
@@ -31,3 +33,8 @@
 setMethod("show", signature(object="rk.JS.var"), function(object){
 	cat(rk.paste.JS(object))
 })
+
+#' @rdname show-methods
+setMethod("show", signature(object="rk.JS.echo"), function(object){
+	cat(rk.paste.JS(object))
+})

Modified: trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R
===================================================================
--- trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R	2013-02-25 21:36:50 UTC (rev 4564)
@@ -86,10 +86,22 @@
 		dep.frame.R <- rk.XML.frame(
 				dep.rmin <- rk.XML.input("R min", size="small"),
 				dep.rmax <- rk.XML.input("R max", size="small"),
-				rk.XML.stretch(), label="Depends on R version")#,
-# 	rk.XML.row(dep.frame.packages <- rk.XML.frame(rk.XML.stretch(before=list(
-# 			rk.XML.text("Separate package names by space:"),
-# 			dep.pckg <- rk.XML.input("Packages"))), label="Depends on R packages"))
+				rk.XML.stretch(), label="Depends on R version")),
+	rk.XML.row(
+		dep.optionset.packages <- rk.XML.optionset(
+				content=rk.XML.frame(rk.XML.stretch(before=list(
+					dep.pckg.name <- rk.XML.input("Package")#,
+# 					dep.pckg.min <- rk.XML.input("min"),
+# 					dep.pckg.max <- rk.XML.input("max"),
+# 					dep.pckg.repo <- rk.XML.input("Repository")
+				)), label="Depends on R packages"),
+				optioncolumn=list(
+					dep.optioncol.pckg.name <- rk.XML.optioncolumn(connect=dep.pckg.name, modifier="text")#,
+# 					dep.optioncol.pckg.min <- rk.XML.optioncolumn(connect=dep.pckg.min, modifier="text"),
+# 					dep.optioncol.pckg.max <- rk.XML.optioncolumn(connect=dep.pckg.max, modifier="text"),
+# 					dep.optioncol.pckg.repo <- rk.XML.optioncolumn(connect=dep.pckg.repo, modifier="text")
+				)
+			)
 	), label="Define dependencies", checkable=TRUE, chk=FALSE)
 
 tab2.create <- rk.XML.col(crt.opts, dep.opts)
@@ -179,8 +191,15 @@
 		echo(js.opt.about.author),
 		echo(js.opt.about.about),
 	echo("\n)\n\n"),
-	ite(id(js.frm.dep.opts, " && ", js.opt.about.dep),
-		echo("plugin.dependencies <- rk.XML.dependencies(", js.opt.about.dep, "\n)\n\n")),
+	ite(id(js.frm.dep.opts, " && (", js.opt.about.dep, " || ", dep.optioncol.pckg.name, ")"),
+		rk.paste.JS(
+			echo("plugin.dependencies <- rk.XML.dependencies("),
+			ite(id(js.opt.about.dep), echo(js.opt.about.dep)),
+			ite(id(js.opt.about.dep, " && ", dep.optioncol.pckg.name), echo(",")),
+			ite(id(dep.optioncol.pckg.name),
+				echo("\n\tpackage=list(\n\t\tc(name=\"", join(dep.optioncol.pckg.name, by="\"),\n\t\tc(name=\""), "\")\n\t)")),
+			echo("\n)\n\n"),
+		level=3)),
 	echo("plugin.dir <- rk.plugin.skeleton(\n\tabout=about.plugin,"),
 		ite(id(js.frm.dep.opts, " && ", js.opt.about.dep), echo("\n\tdependencies=plugin.dependencies,")),
 		echo(js.opt.skeleton),
@@ -192,7 +211,7 @@
 rk.plugin.skeleton(
 	about=about.info,
 	path=output.dir,
-	guess.getter=FALSE,
+	guess.getter=TRUE,
 	xml=list(
 		dialog=sklt.tabbook,
 		logic=logic.section),

Modified: trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/NEWS.Rd	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/inst/NEWS.Rd	2013-02-25 21:36:50 UTC (rev 4564)
@@ -1,7 +1,7 @@
 \name{NEWS}
 \title{News for Package 'rkwarddev'}
 \encoding{UTF-8}
-\section{Changes in rkwarddev version 0.06-2 (2013-02-22)}{
+\section{Changes in rkwarddev version 0.06-2 (2013-02-25)}{
   \subsection{changed}{
     \itemize{
       \item the structure of <about> nodes will change in RKWard 0.6.1,
@@ -32,6 +32,7 @@
       \item new function \code{rk.XML.matrix()}
       \item new function \code{rk.XML.dependencies()}
       \item new function \code{rk.XML.dependency_check()}
+      \item new function \code{join()} to simplify "\code{.join()}" for JavaScript arrays
       \item added options \code{"dependencies"}, \code{"namespace"} and \code{"priority"} to
         \code{rk.XML.pluginmap()}
       \item added option \code{"dependencies"} to \code{rk.XML.component()}

Modified: trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
===================================================================
(Binary files differ)

Added: trunk/rkward/packages/rkwarddev/man/join.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/join.Rd	                        (rev 0)
+++ trunk/rkward/packages/rkwarddev/man/join.Rd	2013-02-25 21:36:50 UTC (rev 4564)
@@ -0,0 +1,39 @@
+\name{join}
+\alias{join}
+\title{Generate JavaScript to join an array object}
+\usage{
+  join(var, by = "\", \"")
+}
+\arguments{
+  \item{var}{Either a character string (the name of the
+  variable to combine to a vector or list), or an object of
+  class \code{XiMpLe.node} (whose ID will be extracted and
+  used). Also accepts objects of class \code{rk.JS.arr}.}
+
+  \item{by}{Character string by which the values ought to
+  be joined.}
+}
+\value{
+  An object of class \code{rk.JS.echo}.
+}
+\description{
+  This function pastes an object of class \code{rk.JS.arr}
+  similar to
+  \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}}, but was
+  specifically written for elements like \code{<optionset>}
+  or \code{<matrix>}, whose values must be queried by
+  \code{getList()} rather than \code{getValue()}. This
+  means, the resulting variable is already an array an
+  merely needs to be joined in as R code output (e.g., an
+  \code{<optioncolumn>}).
+}
+\seealso{
+  \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}},
+  \code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
+  \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
+  \code{\link[rkwarddev:echo]{echo}},
+  \code{\link[rkwarddev:id]{id}}, and the
+  \href{help:rkwardplugins}{Introduction to Writing Plugins
+  for RKWard}
+}
+

Modified: trunk/rkward/packages/rkwarddev/man/rk.JS.array.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.JS.array.Rd	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/man/rk.JS.array.Rd	2013-02-25 21:36:50 UTC (rev 4564)
@@ -12,7 +12,7 @@
 
   \item{variables}{A list with either character strings
   (the names of the variables to combine to a vector or
-  list), of objects of class \code{XiMpLe.node} with plugin
+  list), or objects of class \code{XiMpLe.node} with plugin
   XML nodes (whose ID will be extracted and used).}
 
   \item{funct}{Character string, name of the R function to

Modified: trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2013-02-24 20:59:27 UTC (rev 4563)
+++ trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2013-02-25 21:36:50 UTC (rev 4564)
@@ -9,7 +9,7 @@
 \details{
   \tabular{ll}{ Package: \tab rkwarddev\cr Type: \tab
   Package\cr Version: \tab 0.06-2\cr Date: \tab
-  2013-02-22\cr Depends: \tab R (>= 2.9.0),methods,XiMpLe
+  2013-02-25\cr Depends: \tab R (>= 2.9.0),methods,XiMpLe
   (>= 0.03-18),rkward (>= 0.5.6)\cr Enhances: \tab
   rkward\cr Encoding: \tab UTF-8\cr License: \tab GPL (>=
   3)\cr LazyLoad: \tab yes\cr URL: \tab





More information about the rkward-tracker mailing list