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

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Thu Oct 20 19:54:59 UTC 2011


Revision: 3983
          http://rkward.svn.sourceforge.net/rkward/?rev=3983&view=rev
Author:   m-eik
Date:     2011-10-20 19:54:58 +0000 (Thu, 20 Oct 2011)
Log Message:
-----------
rkwarddev: improved menu support, dependencies are now included in the DESCRIPTION

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.about.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
    trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
    trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-20 17:04:50 UTC (rev 3982)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-20 19:54:58 UTC (rev 3983)
@@ -4,7 +4,10 @@
   - added "about" option to rk.XML.plugin() to overrule pluginmap defaults
   - added rk.plugin.component(), i.e. modularized the component generation, to allow for more than one
     component in rk.plugin.skeleton(), wich subsequently gained the new option "components"
+  - improved dependency support, rk.plugin.skeleton() writes dependencies from <about> to DESCRIPTION now
   - fixed dependency definition in rk.XML.about()
+  - fixed "verion" typo in rk.XML.about()
+  - the dot "." is now also allowed in file names
 
 ## 0.04-0 (2011-10-19)
   - for accurcy and consistency with the docs, the "properties" option changed to "modifiers" in rk.JS.vars()

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2011-10-20 17:04:50 UTC (rev 3982)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2011-10-20 19:54:58 UTC (rev 3983)
@@ -295,6 +295,63 @@
 } ## end function XML2person()
 
 
+## function XML2dependencies()
+# extracts the package dependencies info from XML "about" nodes
+XML2dependencies <- function(node){
+	if(inherits(node, "XiMpLe.node")){
+		# check if this is *really* a about section, otherwise die of boredom
+		if(!identical(node at name, "about")){
+			stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
+		} else {}
+	} else {
+		stop(simpleError("'about' must be a XiMpLe.node, see ?rk.XML.about()!"))
+	}
+	check.deps <- sapply(node at children, function(this.child){identical(this.child at name, "dependencies")})
+	if(any(check.deps)){
+		got.deps <- node at children[[which(check.deps)]]
+		deps.packages <- list()
+		# first see if RKWard and R versions are given
+		deps.RkR <- got.deps at attributes
+		deps.RkR.options  <- names(deps.RkR)
+		R.min <- ifelse("R_min_version" %in% deps.RkR.options, paste(">= ", deps.RkR[["R_min_version"]], sep=""), "")
+		R.max <- ifelse("R_max_version" %in% deps.RkR.options, paste("< ", deps.RkR[["R_max_version"]], sep=""), "")
+		R.version.indices <- sum(!identical(R.min, ""), !identical(R.max, ""))
+		if(R.version.indices > 0){
+			deps.packages[[length(deps.packages) + 1]] <- paste("R (", R.min, ifelse(R.version.indices > 1, ", ", ""), R.max, ")", sep="")
+		} else {}
+		Rk.min <- ifelse("rkward_min_version" %in% deps.RkR.options, paste(">= ", deps.RkR[["rkward_min_version"]], sep=""), "")
+		Rk.max <- ifelse("rkward_max_version" %in% deps.RkR.options, paste("< ", deps.RkR[["rkward_max_version"]], sep=""), "")
+		Rk.version.indices <- sum(!identical(Rk.min, ""), !identical(Rk.max, ""))
+		if(Rk.version.indices > 0){
+			deps.packages[[length(deps.packages) + 1]] <- paste("rkward (", Rk.min, ifelse(Rk.version.indices > 1, ", ", ""), Rk.max, ")", sep="")
+		} else {}
+		check.deps.pckg <- sapply(got.deps at children, function(this.child){identical(this.child at name, "package")})
+		if(any(check.deps.pckg)){
+			deps.packages[[length(deps.packages) + 1]] <- paste(sapply(which(check.deps.pckg), function(this.pckg){
+					this.pckg.dep <- got.deps at children[[this.pckg]]@attributes
+					pckg.options <- names(this.pckg.dep)
+					pckg.name <- this.pckg.dep[["name"]]
+					pckg.min <- ifelse("min" %in% pckg.options, paste(">= ", this.pckg.dep[["min"]], sep=""), "")
+					pckg.max <- ifelse("max" %in% pckg.options, paste("< ", this.pckg.dep[["max"]], sep=""), "")
+					version.indices <- sum(!identical(pckg.min, ""), !identical(pckg.max, ""))
+					if(version.indices > 0){
+						pckg.version <- paste(" (", pckg.min, ifelse(version.indices > 1, ", ", ""), pckg.max, ")", sep="")
+					} else {
+						pckg.version <- NULL
+					}
+					return(paste(pckg.name, pckg.version, sep=""))
+				}), collapse=", ")
+			results <- paste(unlist(deps.packages), collapse=", ")
+		} else {
+			results <- ""
+		}
+	} else {
+		results <- ""
+	}
+	return(results)
+} ## end function XML2dependencies()
+
+
 ## function get.by.role()
 # filters a vector with person objects by roles
 get.by.role <- function(persons, role="aut"){
@@ -424,7 +481,7 @@
 ## function clean.name()
 clean.name <- function(name, message=TRUE){
 	name.orig <- name
-	name <- gsub("[[:space:]]*[^[:alnum:]_]*", "", name)
+	name <- gsub("[[:space:]]*[^[:alnum:]_.]*", "", name)
 	if(!identical(name.orig, name)){
 		if(isTRUE(message)){
 			message(paste("For filenames ", sQuote(name.orig), " was renamed to ", sQuote(name), ".", sep=""))

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.about.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.about.R	2011-10-20 17:04:50 UTC (rev 3982)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.about.R	2011-10-20 19:54:58 UTC (rev 3983)
@@ -180,8 +180,8 @@
 	## dependencies
 	# - rkward.min="rkward_min_version",
 	# - rkward.max="rkward_max_version",
-	# - R.min="R_min_verion",
-	# - R.max="R_max_verion"
+	# - R.min="R_min_version",
+	# - R.max="R_max_version"
 	# + package
 	# + pluginmap
 	for (pmap in xml.pluginmap){
@@ -200,8 +200,8 @@
 					attributes=list(
 						"rkward_min_version"=.rk.app.version,
 						"rkward_max_version"="CHANGE_ME_OR_DELETE_ME",
-						"R_min_verion"=paste(R.v$major, R.v$minor, sep="."),
-						"R_max_verion"="CHANGE_ME_OR_DELETE_ME"
+						"R_min_version"=paste(R.v$major, R.v$minor, sep="."),
+						"R_max_version"="CHANGE_ME_OR_DELETE_ME"
 					),
 					children=xml.package,
 					value=""
@@ -216,10 +216,10 @@
 			dep.attributes[["rkward_max_version"]] <- dependencies[["rkward.max"]]
 		} else {}
 		if("R.min" %in% dep.options){
-			dep.attributes[["R_min_verion"]] <- dependencies[["R.min"]]
+			dep.attributes[["R_min_version"]] <- dependencies[["R.min"]]
 		} else {}
 		if("R.max" %in% dep.options){
-			dep.attributes[["R_max_verion"]] <- dependencies[["R.max"]]
+			dep.attributes[["R_max_version"]] <- dependencies[["R.max"]]
 		} else {}
 		xml.dependencies <- new("XiMpLe.node",
 					name="dependencies",

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2011-10-20 17:04:50 UTC (rev 3982)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2011-10-20 19:54:58 UTC (rev 3983)
@@ -130,6 +130,7 @@
 				} else {
 					xml.basename <- name.orig
 				}
+				names(this.comp) <- NULL
 				components.XML.list[[length(components.XML.list) + 1]] <- rk.XML.component(
 					label=xml.basename,
 					file=this.comp,

Modified: trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R	2011-10-20 17:04:50 UTC (rev 3982)
+++ trunk/rkward/packages/rkwarddev/R/rk.plugin.skeleton.R	2011-10-20 19:54:58 UTC (rev 3983)
@@ -182,11 +182,15 @@
 
 	## create the main component
 	got.pm.options <- names(pluginmap)
+	# check for name of main component. if it's set, use it
+	if(!"name" %in% got.pm.options){
+		pluginmap[["name"]] <- name.orig
+	} else {}
 	if(!"hierarchy" %in% got.pm.options) {
 		pluginmap[["hierarchy"]] <- eval(formals(rk.XML.pluginmap)[["hierarchy"]])
 	} else {}
 	main.component <- rk.plugin.component(
-		name=name.orig,
+		name=pluginmap[["name"]],
 		xml=xml,
 		js=js,
 		rkh=rkh,
@@ -261,7 +265,10 @@
 			} else {}
 			# get components and hierarchy info from the components list
 			all.components <- sapply(components, function(this.comp){
-					paste("plugins/", clean.name(this.comp at name), ".xml", sep="")
+					named.compo <- paste("plugins/", clean.name(this.comp at name), ".xml", sep="")
+					# we'll name the component, to nicen the menu entry
+					names(named.compo) <- this.comp at name
+					return(named.compo)
 				})
 			all.hierarchies <- lapply(components, function(this.comp){
 					this.comp at hierarchy
@@ -308,7 +315,6 @@
 				include=c("given", "family", "email"), braces=list(email=c("<", ">")))
 
 ## TODO: check and add the commented values here:
-## especially dependencies must be created from 'about'
 			desc <- data.frame(
 				Package=name,
 				Type="Package",
@@ -318,7 +324,7 @@
 				Author=all.authors,
 				AuthorsR=XML2person(about.node, eval=FALSE),
 				Maintainer=all.maintainers,
-#				Depends="R (>= 2.9.0)",
+				Depends=XML2dependencies(about.node),
 				Enhances="rkward",
 				Description=about.node at attributes[["shortinfo"]],
 				License=about.node at attributes[["license"]],

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

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rkward-tracker mailing list