diff --git a/.Rprofile b/.Rprofile
new file mode 100644
index 0000000..4db5af4
--- /dev/null
+++ b/.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))
+}
diff --git a/NAMESPACE b/NAMESPACE
index 7a455b6..f996022 100644
--- a/NAMESPACE
+++ b/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)
diff --git a/R/main.R b/R/main.R
index 3e9f11a..78f5eb2 100644
--- a/R/main.R
+++ b/R/main.R
@@ -2,12 +2,32 @@
#'
#' @param x binary or XML property list
#' @export
+#' @examples
+#' xml <- '
+#'
+#'
+#'
+#' Label
+#' com.example.app
+#' Program
+#' /Users/Me/Scripts/cleanup.sh
+#' RunAtLoad
+#'
+#'
+#' '
+#'
+#' 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 <- '
+#'
+#'
+#'
+#' Label
+#' com.example.app
+#' Program
+#' /Users/Me/Scripts/cleanup.sh
+#' RunAtLoad
+#'
+#'
+#' '
+#'
+#' 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
}
\ No newline at end of file
diff --git a/README.Rmd b/README.Rmd
index 6b18dd2..8c5bf14 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -41,6 +41,82 @@ packageVersion("plist")
```
+Plaintext XML property list in a string:
+
+```{r xml-plist}
+xml <- '
+
+
+
+Label
+com.example.app
+Program
+/Users/Me/Scripts/cleanup.sh
+RunAtLoad
+
+
+'
+
+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}
diff --git a/README.md b/README.md
index 47e5e10..f2ab632 100644
--- a/README.md
+++ b/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 <- '
+
+
+
+Label
+com.example.app
+Program
+/Users/Me/Scripts/cleanup.sh
+RunAtLoad
+
+
+'
+
+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] "\n\n\n\n\tLabel\n\tcom.example.app\n\tProgram\n\t/Users/Me/Scripts/cleanup.sh\n\tRunAtLoad\n\t\n\n\n"
+## attr(,"class")
+## [1] "property_list" "character"
+
+plist_to_xml(raw_plist)
+## [1] "\n\n\n\n\tLabel\n\tcom.example.app\n\tProgram\n\t/Users/Me/Scripts/cleanup.sh\n\tRunAtLoad\n\t\n\n\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
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..c6c1438
--- /dev/null
+++ b/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
diff --git a/inst/sample/plist.bin b/inst/sample/plist.bin
new file mode 100644
index 0000000..2dd8b6c
Binary files /dev/null and b/inst/sample/plist.bin differ
diff --git a/inst/sample/plist.txt b/inst/sample/plist.txt
new file mode 100644
index 0000000..26c828d
--- /dev/null
+++ b/inst/sample/plist.txt
@@ -0,0 +1,12 @@
+
+
+
+
+ Label
+ com.example.app
+ Program
+ /Users/Me/Scripts/cleanup.sh
+ RunAtLoad
+
+
+
diff --git a/inst/tinytest/test_plist.R b/inst/tinytest/test_plist.R
index aa3f72e..8df1627 100644
--- a/inst/tinytest/test_plist.R
+++ b/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 <- '
+
+
+
+Label
+com.example.app
+Program
+/Users/Me/Scripts/cleanup.sh
+RunAtLoad
+
+
+'
+
+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)
diff --git a/man/plist_to_list.Rd b/man/plist_to_list.Rd
index 305a221..2cefa9f 100644
--- a/man/plist_to_list.Rd
+++ b/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 <- '
+
+
+
+Label
+com.example.app
+Program
+/Users/Me/Scripts/cleanup.sh
+RunAtLoad
+
+
+'
+
+plist_to_list(xml)
+}
diff --git a/man/plist_to_xml.Rd b/man/plist_to_xml.Rd
index 2b14481..e24eea9 100644
--- a/man/plist_to_xml.Rd
+++ b/man/plist_to_xml.Rd
@@ -12,3 +12,19 @@ plist_to_xml(x)
\description{
Convert a property list to raw (unparsed) XML
}
+\examples{
+xml <- '
+
+
+
+Label
+com.example.app
+Program
+/Users/Me/Scripts/cleanup.sh
+RunAtLoad
+
+
+'
+
+plist_to_xml(xml)
+}
diff --git a/man/read_plist.Rd b/man/read_plist.Rd
new file mode 100644
index 0000000..08614e8
--- /dev/null
+++ b/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"))
+}