[rkward-cvs] SF.net SVN: rkward-code:[4545] trunk/rkward/packages/rkwarddev/R/rk.XML. dependency_check.R

m-eik at users.sf.net m-eik at users.sf.net
Wed Feb 20 19:15:31 UTC 2013


Revision: 4545
          http://sourceforge.net/p/rkward/code/4545
Author:   m-eik
Date:     2013-02-20 19:15:30 +0000 (Wed, 20 Feb 2013)
Log Message:
-----------
rkwarddev: removed duplicated code from rk.XML.dependency_check()...

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/R/rk.XML.dependency_check.R

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.dependency_check.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.dependency_check.R	2013-02-20 19:04:47 UTC (rev 4544)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.dependency_check.R	2013-02-20 19:15:30 UTC (rev 4545)
@@ -45,110 +45,15 @@
 #' )
 
 rk.XML.dependency_check <- function(id.name, dependencies=NULL, package=NULL, pluginmap=NULL, hints=FALSE){
-	## package
-	# - name
-	# - min="min_version",
-	# - max="max_version",
-	# - repository
-	# create example, if empty
-	if(is.null(package)){
-		if(isTRUE(hints)){
-			xml.package.example <- XMLNode("package",
-				attrs=list(
-					name="CHANGE_ME_OR_DELETE_ME",
-					"min_version"="CHANGE_ME_OR_DELETE_ME",
-					"max_version"="CHANGE_ME_OR_DELETE_ME",
-					repository="CHANGE_ME_OR_DELETE_ME"
-				))
-			xml.package <- list(XMLNode("!--", xml.package.example))
-		} else {
-			xml.package <- list()
-		}
-	} else {
-		xml.package <- sapply(package, function(this.package){
-				pck.options <- names(this.package)
-				pck.attributes <- list(name=this.package[["name"]])
-				for (this.option in c("min", "max","repository" )){
-					if(this.option %in% pck.options){
-						pck.attributes[[this.option]] <- this.package[[this.option]]
-					} else {}
-				}
-				result <- XMLNode("package", attrs=pck.attributes)
-				return(result)
-			})
-	}
+	# this is basically rk.XML.dependencies() with a different node name and additional ID
+	xml.dependency_check <- rk.XML.dependencies(
+		dependencies=dependencies,
+		package=package,
+		pluginmap=pluginmap,
+		hints=hints)
 
-	## pluginmap
-	# - name,
-	# - url
-	# create example, if empty
-	if(is.null(pluginmap)){
-		if(isTRUE(hints)){
-			xml.pluginmap.text <- XMLNode("", "If this plugin depends on other pluginmaps, edit this part to your needs:")
-			xml.pluginmap.example <- XMLNode("pluginmap",
-				attrs=list(
-					name="CHANGE_ME_OR_DELETE_ME",
-					url="CHANGE_ME_OR_DELETE_ME"
-				))
-			xml.pluginmap <- list(XMLNode("!--", xml.pluginmap.text, xml.pluginmap.example))
-		} else {
-			xml.pluginmap <- list()
-		}
-	} else {
-		xml.pluginmap <- sapply(pluginmap, function(this.pluginmap){
-				result <- XMLNode("pluginmap",
-					attrs=list(
-						name=this.pluginmap[["name"]],
-						url=this.pluginmap[["url"]]
-					))
-				return(result)
-			})
-	}
+	XMLName(xml.dependency_check) <- "dependency_check"
+	XMLAttrs(xml.dependency_check)[["id"]] <- id.name
 
-	## dependencies
-	# - rkward.min="rkward_min_version",
-	# - rkward.max="rkward_max_version",
-	# - R.min="R_min_version",
-	# - R.max="R_max_version"
-	# + package
-	# + pluginmap
-	for (pmap in xml.pluginmap){
-		xml.package[[length(xml.package)+1]] <- pmap
-	}
-	# comment out an example dependency listing if it has no entries
-	if(is.null(dependencies)){
-		if(isTRUE(hints)){
-			R.v <- R.Version()
-			xml.dependencies <- XMLNode("dependencies",
-				attrs=list(
-					"rkward_min_version"=.rk.app.version,
-					"rkward_max_version"="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=child.list(xml.package, empty=FALSE))
-		} else {
-			xml.dependencies <- XMLNode("dependencies", .children=child.list(xml.package, empty=FALSE))
-		}
-	} else {
-		dep.options <- names(dependencies)
-		dep.attributes <- list(id=id.name)
-		if("rkward.min" %in% dep.options){
-			dep.attributes[["rkward_min_version"]] <- dependencies[["rkward.min"]]
-		} else {}
-		if("rkward.max" %in% dep.options){
-			dep.attributes[["rkward_max_version"]] <- dependencies[["rkward.max"]]
-		} else {}
-		if("R.min" %in% dep.options){
-			dep.attributes[["R_min_version"]] <- dependencies[["R.min"]]
-		} else {}
-		if("R.max" %in% dep.options){
-			dep.attributes[["R_max_version"]] <- dependencies[["R.max"]]
-		} else {}
-		xml.dependency_check <- XMLNode("dependency_check",
-			attrs=dep.attributes,
-			.children=child.list(xml.package, empty=FALSE))
-	}
-
 	return(xml.dependency_check)
 }





More information about the rkward-tracker mailing list