forked from cran-task-views/WebTechnologies
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildxml.R
30 lines (29 loc) · 1.27 KB
/
buildxml.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
if(!require("stringr")) install.packages("stringr", repos="http://cran.rstudio.com")
template <- readLines("WebTechnologies.ctv")
pattern <- "pkg>[[:alnum:]]+[[:alnum:].]*[[:alnum:]]+"
out <- paste0(template, collapse = " ")
pkgs <- stringr::str_extract_all(out, pattern)[[1]]
pkgs <- unique(gsub("^pkg>", "", pkgs))
priority <- c('curl','httr','jsonlite','RSelenium','shiny','xml2')
pkgs <- pkgs[ !pkgs %in% priority] # remove priority packages
pkgs <- lapply(as.list(sort(pkgs)), function(x) list(package=x))
output <-
c(paste0('<CRANTaskView>
<name>WebTechnologies</name>
<topic>Web Technologies and Services</topic>
<maintainer email="[email protected]">Thomas Leeper, Scott Chamberlain, Patrick Mair, Karthik Ram, Christopher Gandrud</maintainer>
<version>',Sys.Date(),'</version>'),
' <info>',
paste0(" ",template),
' </info>',
' <packagelist>',
# list priority packages explicitly
paste0(' <pkg priority="core">', priority, '</pkg>', collapse = "\n"),
# add all other packages from `pkgs`
paste0(' <pkg>', unlist(unname(pkgs)), '</pkg>', collapse = "\n"),
' </packagelist>',
' <links>',
' <a href="https://github.com/ropensci/opendata">Open Data TaskView</a>',
' </links>',
'</CRANTaskView>')
writeLines(output, "WebTechnologies.ctv")