Browse Source

intial commit

master
boB Rudis 7 years ago
commit
db127762fe
No known key found for this signature in database GPG Key ID: 2A514A4997464560
  1. 10
      .Rbuildignore
  2. 1
      .codecov.yml
  3. 8
      .gitignore
  4. 31
      .travis.yml
  5. 21
      DESCRIPTION
  6. 6
      NAMESPACE
  7. 2
      NEWS.md
  8. 11
      R/freepst-package.R
  9. 22
      R/logging.r
  10. 61
      R/read-pst.r
  11. 5
      R/zzz.r
  12. 46
      README.Rmd
  13. 87
      README.md
  14. 21
      freepst.Rproj
  15. BIN
      inst/extdata/dist-list.pst
  16. BIN
      inst/extdata/example-2013.ost
  17. BIN
      inst/extdata/passworded.pst
  18. BIN
      inst/java/java-libpst-0.9.5-SNAPSHOT.jar
  19. 13
      man/freepst.Rd
  20. 21
      man/read_pst.Rd
  21. 2
      tests/test-all.R
  22. 6
      tests/testthat/test-freepst.R

10
.Rbuildignore

@ -0,0 +1,10 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^README\.*Rmd$
^README\.*html$
^NOTES\.*Rmd$
^NOTES\.*html$
^\.codecov\.yml$
^README_files$
^doc$

1
.codecov.yml

@ -0,0 +1 @@
comment: false

8
.gitignore

@ -0,0 +1,8 @@
.DS_Store
.Rproj.user
.Rhistory
.RData
.Rproj
src/*.o
src/*.so
src/*.dll

31
.travis.yml

@ -0,0 +1,31 @@
language: r
warnings_are_errors: true
sudo: required
cache: packages
r:
- oldrel
- release
- devel
apt_packages:
- libv8-dev
- xclip
env:
global:
- CRAN: http://cran.rstudio.com
after_success:
- Rscript -e 'covr::codecov()'
notifications:
email:
- bob@rud.is
irc:
channels:
- "104.236.112.222#builds"
nick: travisci

21
DESCRIPTION

@ -0,0 +1,21 @@
Package: freepst
Type: Package
Title: Read OST/PST Files
Version: 0.1.0
Date: 2017-08-23
Author: Bob Rudis (bob@rud.is)
Maintainer: Bob Rudis <bob@rud.is>
Description: An 'rJava' wrapper around 'java-libpst' <https://github.com/rjohnsondev/java-libpst>.
URL: https://github.com/hrbrmstr/freepst
BugReports: https://github.com/hrbrmstr/freepst/issues
License: AGPL
SystemRequirements: Java
Suggests:
testthat,
covr
Depends:
R (>= 3.2.0),
rJava
RoxygenNote: 6.0.1
Imports:
dplyr

6
NAMESPACE

@ -0,0 +1,6 @@
# Generated by roxygen2: do not edit by hand
export(read_pst)
export(stop_logging)
import(rJava)
importFrom(dplyr,bind_rows)

2
NEWS.md

@ -0,0 +1,2 @@
0.1.0
* Initial release

11
R/freepst-package.R

@ -0,0 +1,11 @@
#' Read OST/PST Files
#'
#' An 'rJava' wrapper around 'java-libpst' <https://github.com/rjohnsondev/java-libpst>.
#'
#' @md
#' @name freepst
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @import rJava
#' @importFrom dplyr bind_rows
NULL

22
R/logging.r

@ -0,0 +1,22 @@
#' @title rJava logging
#' @description Toggle verbose rJava logging
#' @details This function turns off the somewhat verbose rJava logging, most of which is
#' uninformative. It is called automatically when tabulizer is attached via
#' \code{library()}, \code{require}, etc. To keep logging on, load the package
#' namespace using \code{requireNamespace("tabulizer")} and reference functions
#' in using fully qualified references (e.g., \code{tabulizer::extract_tables()}.
#' @note This resets a global Java setting and may affect logging of other rJava operations,
#' requiring a restart of R.
#' @return `NULL`, invisibly.
#' @author Thomas J. Leeper <thosjleeper@@gmail.com>
#' @noRd
#' @md
#' @examples
#' \dontrun{
#' stop_logging()
#' }
#' @export
stop_logging <- function() {
rJava::J("java.util.logging.LogManager")$getLogManager()$reset()
invisible(NULL)
}

61
R/read-pst.r

@ -0,0 +1,61 @@
#' Get all messages in an OST/PST
#'
#' @param path path to OST/PST
#' @return data frame
#' @export
#' @examples
#' read_pst(system.file("extdata/example-2013.ost", package="freepst"))
#' read_pst(system.file("extdata/dist-list.pst", package="freepst"))
read_pst <- function(path) {
path <- path.expand(path)
if (!file.exists(path)) stop(sprintf("'%s' not found.", path), call.=FALSE)
f <- new(J("com.pff.PSTFile"), path)
rf <- f$getRootFolder()
depth <- -1
msgs <- list()
process_folder <- function(folder) {
if (folder$hasSubfolders()) {
child_folders <- folder$getSubFolders()
lapply(as.list(child_folders), process_folder)
}
if (folder$getContentCount() > 0) {
repeat {
email <- folder$getNextChild()
if (is.jnull(email)) break
if (email$getMessageClass() == "IPM.Microsoft.ScheduleData.FreeBusy") next
tmp <- list(
sent_by = email$getSenderName(),
sent_by_addr = email$getSenderEmailAddress(),
received_by = email$getReceivedByName(),
received_by_addr = email$getReceivedByAddress(),
recipients = email$getRecipientsString(),
sent_time = email$getClientSubmitTime()$toString(),
delivery_time = email$getMessageDeliveryTime()$toString(),
importance = email$getImportance(),
priority = email$getPriority(),
attachment_count = email$getNumberOfAttachments(),
subject = email$getSubject(),
body = email$getBody(),
headers = email$getTransportMessageHeaders(),
tostr = email$toString()
)
msgs <<- c(msgs, list(tmp))
}
}
}
process_folder(rf)
return(dplyr::bind_rows(msgs))
}

5
R/zzz.r

@ -0,0 +1,5 @@
.onLoad <- function(libname, pkgname) {
rJava::.jpackage(pkgname, jars = "*", lib.loc = libname)
rJava::.jaddClassPath(dir(file.path(getwd(), "inst/java"), full.names = TRUE))
stop_logging()
}

46
README.Rmd

@ -0,0 +1,46 @@
---
output: rmarkdown::github_document
---
`freepst` : Read OST/PST Files
An 'rJava' wrapper around 'java-libpst' <https://github.com/rjohnsondev/java-libpst>.
The following functions are implemented:
- `read_pst`: Get all messages in an OST/PST
### Installation
```{r eval=FALSE}
devtools::install_github("hrbrmstr/freepst")
```
```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
options(width=120)
```
### Usage
```{r message=FALSE, warning=FALSE, error=FALSE}
library(freepst)
# current verison
packageVersion("freepst")
dplyr::glimpse(read_pst(system.file("extdata/example-2013.ost", package="freepst")))
dplyr::glimpse(read_pst(system.file("extdata/dist-list.pst", package="freepst")))
```
### Test Results
```{r message=FALSE, warning=FALSE, error=FALSE}
library(freepst)
library(testthat)
date()
test_dir("tests/")
```

87
README.md

@ -0,0 +1,87 @@
`freepst` : Read OST/PST Files
An 'rJava' wrapper around 'java-libpst' <https://github.com/rjohnsondev/java-libpst>.
The following functions are implemented:
- `read_pst`: Get all messages in an OST/PST
### Installation
``` r
devtools::install_github("hrbrmstr/freepst")
```
### Usage
``` r
library(freepst)
# current verison
packageVersion("freepst")
```
## [1] '0.1.0'
``` r
dplyr::glimpse(read_pst(system.file("extdata/example-2013.ost", package="freepst")))
```
## Observations: 3
## Variables: 14
## $ sent_by <chr> "Microsoft Outlook", "Microsoft Outlook", "Bernard Chung"
## $ sent_by_addr <chr> "arc.test1@apogeephysicians.com", "arc.test1@apogeephysicians.com", "bernard.chung@apogeep...
## $ received_by <chr> "Arc Test", "Arc Test", "Arc Test"
## $ received_by_addr <chr> "arc.test1@apogeephysicians.com", "arc.test1@apogeephysicians.com", "arc.test1@apogeephysi...
## $ recipients <chr> "No recipients table!", "No recipients table!", "No recipients table!"
## $ sent_time <chr> "Thu Jun 05 12:22:32 EDT 2014", "Wed Apr 09 15:54:39 EDT 2014", "Wed Apr 09 12:38:31 EDT 2...
## $ delivery_time <chr> "Thu Jun 05 12:22:32 EDT 2014", "Wed Apr 09 15:54:39 EDT 2014", "Wed Apr 09 12:38:32 EDT 2...
## $ importance <int> 1, 1, 1
## $ priority <int> 0, 0, 0
## $ attachment_count <int> 0, 0, 0
## $ subject <chr> "Microsoft Outlook Test Message", "Microsoft Outlook Test Message", "Test 2"
## $ body <chr> "", "", ""
## $ headers <chr> "Return-Path: <arc.test1@apogeephysicians.com>\r\nDelivered-To: arc.test1@apogeephysicians...
## $ tostr <chr> "PSTEmail: Microsoft Outlook Test Message\nImportance: 1\nMessage Class: IPM.Note\n\nRetur...
``` r
dplyr::glimpse(read_pst(system.file("extdata/dist-list.pst", package="freepst")))
```
## Observations: 3
## Variables: 14
## $ sent_by <chr> "Unknown", "Unknown", "Unknown"
## $ sent_by_addr <chr> "Unknown", "Unknown", "Unknown"
## $ received_by <chr> "", "", ""
## $ received_by_addr <chr> "", "", ""
## $ recipients <chr> "No recipients table!", "No recipients table!", "No recipients table!"
## $ sent_time <chr> "Mon Aug 01 20:27:12 EDT 2016", "Sun May 25 09:58:28 EDT 2014", "Sun May 25 09:58:59 EDT 2...
## $ delivery_time <chr> "Mon Aug 01 20:27:12 EDT 2016", "Sun May 25 09:58:28 EDT 2014", "Sun May 25 09:58:59 EDT 2...
## $ importance <int> 1, 1, 1
## $ priority <int> 0, 0, 0
## $ attachment_count <int> 2, 0, 0
## $ subject <chr> "Test appointment", "contact name 1", "test dist list"
## $ body <chr> "This is a complete test\r\n", "", ""
## $ headers <chr> "", "", ""
## $ tostr <chr> "PSTEmail: Test appointment\nImportance: 1\nMessage Class: IPM.Appointment\n\n\n\n\n{4096=...
### Test Results
``` r
library(freepst)
library(testthat)
date()
```
## [1] "Wed Aug 23 10:34:09 2017"
``` r
test_dir("tests/")
```
## testthat results ========================================================================================================
## OK: 0 SKIPPED: 0 FAILED: 0
##
## DONE ===================================================================================================================

21
freepst.Rproj

@ -0,0 +1,21 @@
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageBuildArgs: --resave-data
PackageRoxygenize: rd,collate,namespace

BIN
inst/extdata/dist-list.pst

Binary file not shown.

BIN
inst/extdata/example-2013.ost

Binary file not shown.

BIN
inst/extdata/passworded.pst

Binary file not shown.

BIN
inst/java/java-libpst-0.9.5-SNAPSHOT.jar

Binary file not shown.

13
man/freepst.Rd

@ -0,0 +1,13 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/freepst-package.R
\docType{package}
\name{freepst}
\alias{freepst}
\alias{freepst-package}
\title{Read OST/PST Files}
\description{
An 'rJava' wrapper around 'java-libpst' \url{https://github.com/rjohnsondev/java-libpst}.
}
\author{
Bob Rudis (bob@rud.is)
}

21
man/read_pst.Rd

@ -0,0 +1,21 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read-pst.r
\name{read_pst}
\alias{read_pst}
\title{Get all messages in an OST/PST}
\usage{
read_pst(path)
}
\arguments{
\item{path}{path to OST/PST}
}
\value{
data frame
}
\description{
Get all messages in an OST/PST
}
\examples{
read_pst(system.file("extdata/example-2013.ost", package="freepst"))
read_pst(system.file("extdata/dist-list.pst", package="freepst"))
}

2
tests/test-all.R

@ -0,0 +1,2 @@
library(testthat)
test_check("freepst")

6
tests/testthat/test-freepst.R

@ -0,0 +1,6 @@
context("basic functionality")
test_that("we can do something", {
#expect_that(some_function(), is_a("data.frame"))
})
Loading…
Cancel
Save