[rkward] packages/rkwarddev: improved rk.XML.dependencies() and rk.XML.about()

m.eik michalke meik.michalke at uni-duesseldorf.de
Sun Oct 11 13:03:27 UTC 2015


Git commit d5064705c868e8b8df199e6c93f31761f910ec42 by m.eik michalke.
Committed on 11/10/2015 at 12:54.
Pushed by meikm into branch 'master'.

improved rk.XML.dependencies() and rk.XML.about()

  - both functions didn't know min/max version numbers for pluginmap dependencies yet

M  +27   -5    packages/rkwarddev/R/rk.XML.about.R
M  +33   -9    packages/rkwarddev/R/rk.XML.dependencies.R
M  +6    -4    packages/rkwarddev/man/rk.XML.dependencies.Rd

http://commits.kde.org/rkward/d5064705c868e8b8df199e6c93f31761f910ec42

diff --git a/packages/rkwarddev/R/rk.XML.about.R b/packages/rkwarddev/R/rk.XML.about.R
index 66f337a..6f0f41f 100644
--- a/packages/rkwarddev/R/rk.XML.about.R
+++ b/packages/rkwarddev/R/rk.XML.about.R
@@ -135,6 +135,11 @@ rk.XML.about <- function(name, author, about=list(desc="SHORT_DESCRIPTION", vers
       warning("<package> inside <about> is deprecated, use rk.XML.dependencies() instead!")
       xml.package <- sapply(package, function(this.package){
           pck.options <- names(this.package)
+          if(!"name" %in% pc.options){
+            stop(simpleError(
+              paste0("Missing but mandatory information to define package dependencies:\n  \"name\"")
+            ))
+          } else {}
           pck.attributes <- list(name=this.package[["name"]])
           for (this.option in c("min", "max","repository" )){
             if(this.option %in% pck.options){
@@ -158,13 +163,30 @@ rk.XML.about <- function(name, author, about=list(desc="SHORT_DESCRIPTION", vers
     } else {
       warning("<pluginmap> inside <about> is deprecated, use rk.XML.dependencies() instead!")
       xml.pluginmap <- sapply(pluginmap, function(this.pluginmap){
-          result <- XMLNode("pluginmap",
-            attrs=list(
-              name=this.pluginmap[["name"]],
-              url=this.pluginmap[["url"]]
+          plm.options <- names(this.pluginmap)
+          # check for missing attributes
+          mandatory.options <- c("name", "url")
+          missing.options <- !mandatory.options %in% plm.options
+          if(any(missing.options)){
+            stop(simpleError(
+              paste0("Missing but mandatory information to define pluginmap dependencies:\n  \"",
+                paste0(mandatory.options[missing.options], collapse="\", \""), "\""
+              )
             ))
+          } else {}
+          plm.attributes <- list(
+            name=this.pluginmap[["name"]],
+            url=this.pluginmap[["url"]]
+          )
+          if("min" %in% plm.options){
+            plm.attributes[["min_version"]] <- this.pluginmap[["min"]]
+          } else {}
+          if("rkward.max" %in% plm.options){
+            plm.attributes[["max_version"]] <- this.pluginmap[["max"]]
+          } else {}
+          result <- XMLNode("pluginmap", attrs=plm.attributes)
           return(result)
-        })
+      })
     }
 
   ###################
diff --git a/packages/rkwarddev/R/rk.XML.dependencies.R b/packages/rkwarddev/R/rk.XML.dependencies.R
index 73130bd..a93e001 100644
--- a/packages/rkwarddev/R/rk.XML.dependencies.R
+++ b/packages/rkwarddev/R/rk.XML.dependencies.R
@@ -30,15 +30,17 @@
 #'    }
 #' @param package A list of named character vectors, each with these elements:
 #'    \describe{
-#'      \item{name}{Name of a package this plugin depends on (optional)}
+#'      \item{name}{Name of a package this plugin depends on (required)}
 #'      \item{min}{Minimum version of the package (optional)}
 #'      \item{max}{Maximum version of the package (optional)}
-#'      \item{repository}{Repository to download the package (optional)}
+#'      \item{repository}{Repository to download the package (optional, recommended)}
 #'    }
 #' @param pluginmap A named list with these elements:
 #'    \describe{
-#'      \item{name}{Identifier of a pluginmap this plugin depends on (optional)}
-#'      \item{url}{URL to get the pluginmap (optional)}
+#'      \item{name}{Identifier of a pluginmap this plugin depends on (required)}
+#'      \item{min}{Minimum version of the pluginmap (optional)}
+#'      \item{max}{Maximum version of the pluginmap (optional)}
+#'      \item{url}{URL to get the pluginmap (required)}
 #'    }
 #' @param hints Logical, if \code{TRUE}, \code{NULL} values will be replaced with example text.
 #' @export
@@ -83,6 +85,11 @@ rk.XML.dependencies <- function(dependencies=NULL, package=NULL, pluginmap=NULL,
   } else {
     xml.package <- sapply(package, function(this.package){
         pck.options <- names(this.package)
+        if(!"name" %in% pck.options){
+          stop(simpleError(
+            paste0("Missing but mandatory information to define package dependencies:\n  \"name\"")
+          ))
+        } else {}
         pck.attributes <- list(name=this.package[["name"]])
         for (this.option in c("min", "max","repository" )){
           if(this.option %in% pck.options){
@@ -112,13 +119,30 @@ rk.XML.dependencies <- function(dependencies=NULL, package=NULL, pluginmap=NULL,
     }
   } else {
     xml.pluginmap <- sapply(pluginmap, function(this.pluginmap){
-        result <- XMLNode("pluginmap",
-          attrs=list(
-            name=this.pluginmap[["name"]],
-            url=this.pluginmap[["url"]]
+        plm.options <- names(this.pluginmap)
+        # check for missing attributes
+        mandatory.options <- c("name", "url")
+        missing.options <- !mandatory.options %in% plm.options
+        if(any(missing.options)){
+          stop(simpleError(
+            paste0("Missing but mandatory information to define pluginmap dependencies:\n  \"",
+              paste0(mandatory.options[missing.options], collapse="\", \""), "\""
+            )
           ))
+        } else {}
+        plm.attributes <- list(
+          name=this.pluginmap[["name"]],
+          url=this.pluginmap[["url"]]
+        )
+        if("min" %in% plm.options){
+          plm.attributes[["min_version"]] <- this.pluginmap[["min"]]
+        } else {}
+        if("rkward.max" %in% plm.options){
+          plm.attributes[["max_version"]] <- this.pluginmap[["max"]]
+        } else {}
+        result <- XMLNode("pluginmap", attrs=plm.attributes)
         return(result)
-      })
+    })
   }
 
   ## dependencies
diff --git a/packages/rkwarddev/man/rk.XML.dependencies.Rd b/packages/rkwarddev/man/rk.XML.dependencies.Rd
index 11f2937..66227f7 100644
--- a/packages/rkwarddev/man/rk.XML.dependencies.Rd
+++ b/packages/rkwarddev/man/rk.XML.dependencies.Rd
@@ -18,16 +18,18 @@ rk.XML.dependencies(dependencies = NULL, package = NULL, pluginmap = NULL,
 
 \item{package}{A list of named character vectors, each with these elements:
 \describe{
-  \item{name}{Name of a package this plugin depends on (optional)}
+  \item{name}{Name of a package this plugin depends on (required)}
   \item{min}{Minimum version of the package (optional)}
   \item{max}{Maximum version of the package (optional)}
-  \item{repository}{Repository to download the package (optional)}
+  \item{repository}{Repository to download the package (optional, recommended)}
 }}
 
 \item{pluginmap}{A named list with these elements:
 \describe{
-  \item{name}{Identifier of a pluginmap this plugin depends on (optional)}
-  \item{url}{URL to get the pluginmap (optional)}
+  \item{name}{Identifier of a pluginmap this plugin depends on (required)}
+  \item{min}{Minimum version of the pluginmap (optional)}
+  \item{max}{Maximum version of the pluginmap (optional)}
+  \item{url}{URL to get the pluginmap (required)}
 }}
 
 \item{hints}{Logical, if \code{TRUE},



More information about the rkward-tracker mailing list