Browse Source

tests; readme; examples; travis; appveyor; codecov

master
boB Rudis 5 years ago
parent
commit
f212b6c3d2
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 31
      .Rprofile
  2. 1
      NAMESPACE
  3. 65
      R/main.R
  4. 76
      README.Rmd
  5. 138
      README.md
  6. 45
      appveyor.yml
  7. BIN
      inst/sample/plist.bin
  8. 12
      inst/sample/plist.txt
  9. 65
      inst/tinytest/test_plist.R
  10. 16
      man/plist_to_list.Rd
  11. 16
      man/plist_to_xml.Rd
  12. 18
      man/read_plist.Rd

31
.Rprofile

@ -0,0 +1,31 @@
.First <- function() {
options(
repos = c(CRAN="http://bigd/cran/"),
# repos = c(CRAN = "https://cloud.r-project.org"),
# repos = c(CRAN="https://cran.rstudio.com/"),
deparse.max.lines = 200,
HTTPUserAgent = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*",
menu.graphics = FALSE,
sergeant.bigint.warnonce = FALSE,
athena.driver = "odbc",
java.parameters = c(getOption("java.parameters", default = NULL), "-Xrs"),
tidyverse.quiet=TRUE,
devtools.name = "Bob Rudis",
devtools.desc.author = 'c(person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre")))',
devtools.desc.license = "MIT + file LICENSE"
)
}
if (interactive()) {
options(java.parameters = "-Xmx4g")
suppressPackageStartupMessages({
library(usethis)
library(devtools)
# library(bit64)
})
# methods::setAs("integer", "integer64", function(from) bit64::as.integer64(from))
# methods::setAs("double", "integer64", function(from) bit64::as.integer64(from))
# methods::setAs("numeric", "integer64", function(from) bit64::as.integer64(from))
}

1
NAMESPACE

@ -2,6 +2,7 @@
export(plist_to_list)
export(plist_to_xml)
export(read_plist)
importFrom(Rcpp,sourceCpp)
importFrom(XML,readKeyValueDB)
useDynLib(plist, .registration = TRUE)

65
R/main.R

@ -2,12 +2,32 @@
#'
#' @param x binary or XML property list
#' @export
#' @examples
#' xml <- '<?xml version="1.0" encoding="UTF-8"?>
#' <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
#' <plist version="1.0">
#' <dict>
#' <key>Label</key>
#' <string>com.example.app</string>
#' <key>Program</key>
#' <string>/Users/Me/Scripts/cleanup.sh</string>
#' <key>RunAtLoad</key>
#' <true/>
#' </dict>
#' </plist>'
#'
#' plist_to_list(xml)
plist_to_list <- function(x) {
if (is.character(x)) x <- charToRaw(x)
stopifnot(is.raw(x))
tmp <- int_get_plist(x)
XML::readKeyValueDB(tmp)
tmp <- XML::readKeyValueDB(tmp)
class(tmp) <- c("property_list", "list")
tmp
}
@ -15,10 +35,51 @@ plist_to_list <- function(x) {
#'
#' @param x binary or XML property list
#' @export
#' @examples
#' xml <- '<?xml version="1.0" encoding="UTF-8"?>
#' <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
#' <plist version="1.0">
#' <dict>
#' <key>Label</key>
#' <string>com.example.app</string>
#' <key>Program</key>
#' <string>/Users/Me/Scripts/cleanup.sh</string>
#' <key>RunAtLoad</key>
#' <true/>
#' </dict>
#' </plist>'
#'
#' plist_to_xml(xml)
plist_to_xml <- function(x) {
if (is.character(x)) x <- charToRaw(x)
stopifnot(is.raw(x))
tmp <- int_get_plist(x)
class(tmp) <- c("property_list", "character")
tmp
}
#' Read a binary or XML property list from a file/connection
#'
#' @param x a file or connection (will be [path.expand()]ed)
#' @export
#' @examples
#' read_plist(system.file("sample/plist.txt", package = "plist"))
#' read_plist(system.file("sample/plist.bin", package = "plist"))
read_plist <- function(x) {
x <- path.expand(x[1])
stopifnot(file.exists(x))
tmp <- readBin(x, what = "raw", n = file.size(x))
tmp <- int_get_plist(tmp)
tmp <- XML::readKeyValueDB(tmp)
class(tmp) <- c("property_list", "list")
int_get_plist(x)
tmp
}

76
README.Rmd

@ -41,6 +41,82 @@ packageVersion("plist")
```
Plaintext XML property list in a string:
```{r xml-plist}
xml <- '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.app</string>
<key>Program</key>
<string>/Users/Me/Scripts/cleanup.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>'
plist_to_list(xml)
```
Same content but binary property list:
```{r raw-plist}
as.raw(c(0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x20,
0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x22, 0x55,
0x54, 0x46, 0x2d, 0x38, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x21, 0x44,
0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, 0x6c, 0x69, 0x73,
0x74, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d,
0x2f, 0x2f, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x2f, 0x2f, 0x44, 0x54,
0x44, 0x20, 0x50, 0x4c, 0x49, 0x53, 0x54, 0x20, 0x31, 0x2e, 0x30,
0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70,
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x61, 0x70, 0x70, 0x6c,
0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x54, 0x44, 0x73, 0x2f,
0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x4c, 0x69, 0x73,
0x74, 0x2d, 0x31, 0x2e, 0x30, 0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e,
0x0a, 0x3c, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x3e,
0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09,
0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x3c,
0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x78,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x3c, 0x2f,
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c,
0x6b, 0x65, 0x79, 0x3e, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d,
0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x2f, 0x55, 0x73, 0x65, 0x72,
0x73, 0x2f, 0x4d, 0x65, 0x2f, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74,
0x73, 0x2f, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x75, 0x70, 0x2e, 0x73,
0x68, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a,
0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x52, 0x75, 0x6e, 0x41,
0x74, 0x4c, 0x6f, 0x61, 0x64, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e,
0x0a, 0x09, 0x09, 0x3c, 0x74, 0x72, 0x75, 0x65, 0x2f, 0x3e, 0x0a,
0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x3c, 0x2f,
0x70, 0x6c, 0x69, 0x73, 0x74, 0x3e, 0x0a)) -> raw_plist
plist_to_list(raw_plist)
```
Raw, unparsed XML vs a list:
```{r uparsed-xml}
plist_to_xml(xml)
plist_to_xml(raw_plist)
```
From files:
```{r from-files}
# plaintext XML
read_plist(system.file("sample/plist.txt", package = "plist"))
# binary
read_plist(system.file("sample/plist.bin", package = "plist"))
```
## plist Metrics
```{r cloc, echo=FALSE}

138
README.md

@ -7,7 +7,9 @@ by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keyb
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/plist.svg?branch=master)](https://travis-ci.org/hrbrmstr/plist)
Status](https://travis-ci.org/hrbrmstr/plist.svg?branch=master)](https://travis-ci.org/hrbrmstr/plist)
[![Windows build
status](https://ci.appveyor.com/api/projects/status/github/hrbrmstr/plist?svg=true)](https://ci.appveyor.com/project/hrbrmstr/plist)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
@ -35,6 +37,8 @@ The following functions are implemented:
- `plist_to_list`: Convert a property list (binary or XML) to an R
list
- `plist_to_xml`: Convert a property list to raw (unparsed) XML
- `read_plist`: Read a binary or XML property list from a
file/connection
## Installation
@ -63,13 +67,139 @@ packageVersion("plist")
## [1] '0.1.0'
```
Plaintext XML property list in a string:
``` r
xml <- '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.app</string>
<key>Program</key>
<string>/Users/Me/Scripts/cleanup.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>'
plist_to_list(xml)
## $Label
## [1] "com.example.app"
##
## $Program
## [1] "/Users/Me/Scripts/cleanup.sh"
##
## $RunAtLoad
## [1] TRUE
##
## attr(,"class")
## [1] "property_list" "list"
```
Same content but binary property list:
``` r
as.raw(c(0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x20,
0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x22, 0x55,
0x54, 0x46, 0x2d, 0x38, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x21, 0x44,
0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, 0x6c, 0x69, 0x73,
0x74, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d,
0x2f, 0x2f, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x2f, 0x2f, 0x44, 0x54,
0x44, 0x20, 0x50, 0x4c, 0x49, 0x53, 0x54, 0x20, 0x31, 0x2e, 0x30,
0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70,
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x61, 0x70, 0x70, 0x6c,
0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x54, 0x44, 0x73, 0x2f,
0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x4c, 0x69, 0x73,
0x74, 0x2d, 0x31, 0x2e, 0x30, 0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e,
0x0a, 0x3c, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x3e,
0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09,
0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x3c,
0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x78,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x3c, 0x2f,
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c,
0x6b, 0x65, 0x79, 0x3e, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d,
0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x2f, 0x55, 0x73, 0x65, 0x72,
0x73, 0x2f, 0x4d, 0x65, 0x2f, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74,
0x73, 0x2f, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x75, 0x70, 0x2e, 0x73,
0x68, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a,
0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x52, 0x75, 0x6e, 0x41,
0x74, 0x4c, 0x6f, 0x61, 0x64, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e,
0x0a, 0x09, 0x09, 0x3c, 0x74, 0x72, 0x75, 0x65, 0x2f, 0x3e, 0x0a,
0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x3c, 0x2f,
0x70, 0x6c, 0x69, 0x73, 0x74, 0x3e, 0x0a)) -> raw_plist
plist_to_list(raw_plist)
## $Label
## [1] "com.example.app"
##
## $Program
## [1] "/Users/Me/Scripts/cleanup.sh"
##
## $RunAtLoad
## [1] TRUE
##
## attr(,"class")
## [1] "property_list" "list"
```
Raw, unparsed XML vs a list:
``` r
plist_to_xml(xml)
## [1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>Label</key>\n\t<string>com.example.app</string>\n\t<key>Program</key>\n\t<string>/Users/Me/Scripts/cleanup.sh</string>\n\t<key>RunAtLoad</key>\n\t<true/>\n</dict>\n</plist>\n"
## attr(,"class")
## [1] "property_list" "character"
plist_to_xml(raw_plist)
## [1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>Label</key>\n\t<string>com.example.app</string>\n\t<key>Program</key>\n\t<string>/Users/Me/Scripts/cleanup.sh</string>\n\t<key>RunAtLoad</key>\n\t<true/>\n</dict>\n</plist>\n"
## attr(,"class")
## [1] "property_list" "character"
```
From files:
``` r
# plaintext XML
read_plist(system.file("sample/plist.txt", package = "plist"))
## $Label
## [1] "com.example.app"
##
## $Program
## [1] "/Users/Me/Scripts/cleanup.sh"
##
## $RunAtLoad
## [1] TRUE
##
## attr(,"class")
## [1] "property_list" "list"
# binary
read_plist(system.file("sample/plist.bin", package = "plist"))
## $Label
## [1] "com.example.app"
##
## $Program
## [1] "/Users/Me/Scripts/cleanup.sh"
##
## $RunAtLoad
## [1] TRUE
##
## attr(,"class")
## [1] "property_list" "list"
```
## plist Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
| C++ | 2 | 0.29 | 37 | 0.61 | 16 | 0.37 | 4 | 0.07 |
| R | 4 | 0.57 | 16 | 0.26 | 11 | 0.26 | 28 | 0.46 |
| Rmd | 1 | 0.14 | 8 | 0.13 | 16 | 0.37 | 29 | 0.48 |
| Rmd | 1 | 0.14 | 58 | 0.46 | 28 | 0.44 | 43 | 0.38 |
| C++ | 2 | 0.29 | 37 | 0.29 | 16 | 0.25 | 4 | 0.04 |
| R | 4 | 0.57 | 31 | 0.25 | 20 | 0.31 | 65 | 0.58 |
## Code of Conduct

45
appveyor.yml

@ -0,0 +1,45 @@
# DO NOT CHANGE the "init" and "install" sections below
# Download script file from GitHub
init:
ps: |
$ErrorActionPreference = "Stop"
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
Import-Module '..\appveyor-tool.ps1'
install:
ps: Bootstrap
cache:
- C:\RLibrary
# Adapt as necessary starting from here
build_script:
- travis-tool.sh install_deps
test_script:
- travis-tool.sh run_tests
on_failure:
- 7z a failure.zip *.Rcheck\*
- appveyor PushArtifact failure.zip
artifacts:
- path: '*.Rcheck\**\*.log'
name: Logs
- path: '*.Rcheck\**\*.out'
name: Logs
- path: '*.Rcheck\**\*.fail'
name: Logs
- path: '*.Rcheck\**\*.Rout'
name: Logs
- path: '\*_*.tar.gz'
name: Bits
- path: '\*_*.zip'
name: Bits

BIN
inst/sample/plist.bin

Binary file not shown.

12
inst/sample/plist.txt

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.app</string>
<key>Program</key>
<string>/Users/Me/Scripts/cleanup.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

65
inst/tinytest/test_plist.R

@ -1,4 +1,65 @@
as.raw(c(0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x20,
0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x22, 0x55,
0x54, 0x46, 0x2d, 0x38, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x21, 0x44,
0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, 0x6c, 0x69, 0x73,
0x74, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d,
0x2f, 0x2f, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x2f, 0x2f, 0x44, 0x54,
0x44, 0x20, 0x50, 0x4c, 0x49, 0x53, 0x54, 0x20, 0x31, 0x2e, 0x30,
0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70,
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x61, 0x70, 0x70, 0x6c,
0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x54, 0x44, 0x73, 0x2f,
0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x4c, 0x69, 0x73,
0x74, 0x2d, 0x31, 0x2e, 0x30, 0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e,
0x0a, 0x3c, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x3e,
0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09,
0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x3c,
0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x78,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x3c, 0x2f,
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c,
0x6b, 0x65, 0x79, 0x3e, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d,
0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x2f, 0x55, 0x73, 0x65, 0x72,
0x73, 0x2f, 0x4d, 0x65, 0x2f, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74,
0x73, 0x2f, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x75, 0x70, 0x2e, 0x73,
0x68, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a,
0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x52, 0x75, 0x6e, 0x41,
0x74, 0x4c, 0x6f, 0x61, 0x64, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e,
0x0a, 0x09, 0x09, 0x3c, 0x74, 0x72, 0x75, 0x65, 0x2f, 0x3e, 0x0a,
0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x3c, 0x2f,
0x70, 0x6c, 0x69, 0x73, 0x74, 0x3e, 0x0a)) -> raw_plist
res <- plist_to_list(raw_plist)
expect_true("Label" %in% names(res))
xml <- '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.app</string>
<key>Program</key>
<string>/Users/Me/Scripts/cleanup.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>'
res <- plist_to_list(xml)
expect_true("Label" %in% names(res))
expect_true(nchar(plist_to_xml(xml)) == 338)
expect_true(nchar(plist_to_xml(raw_plist)) == 338)
res <- read_plist(system.file("sample/plist.txt", package = "plist"))
expect_true("Label" %in% names(res))
res <- read_plist(system.file("sample/plist.bin", package = "plist"))
expect_true("Label" %in% names(res))
# Placeholder with simple test
expect_equal(1 + 1, 2)

16
man/plist_to_list.Rd

@ -12,3 +12,19 @@ plist_to_list(x)
\description{
Convert a property list (binary or XML) to an R list
}
\examples{
xml <- '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.app</string>
<key>Program</key>
<string>/Users/Me/Scripts/cleanup.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>'
plist_to_list(xml)
}

16
man/plist_to_xml.Rd

@ -12,3 +12,19 @@ plist_to_xml(x)
\description{
Convert a property list to raw (unparsed) XML
}
\examples{
xml <- '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.app</string>
<key>Program</key>
<string>/Users/Me/Scripts/cleanup.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>'
plist_to_xml(xml)
}

18
man/read_plist.Rd

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/main.R
\name{read_plist}
\alias{read_plist}
\title{Read a binary or XML property list from a file/connection}
\usage{
read_plist(x)
}
\arguments{
\item{x}{a file or connection (will be \code{\link[=path.expand]{path.expand()}}ed)}
}
\description{
Read a binary or XML property list from a file/connection
}
\examples{
read_plist(system.file("sample/plist.txt", package = "plist"))
read_plist(system.file("sample/plist.bin", package = "plist"))
}
Loading…
Cancel
Save