You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
4.0 KiB

8 years ago
8 years ago
`wand` : Retrieve 'Magic' Attributes from Files and Directories
8 years ago
The `libmagic` library must be installed and available to use this. The package should also be pretty straightforward to get working on Windows. Assistance to do that is welcome.
8 years ago
The following functions are implemented:
8 years ago
- `incant` : returns the "magic" metadata of the files in the input vector (as a data frame)
- `magic_wand_file` : provides a full path to the package-provided `magic` file
8 years ago
### Installation
``` r
8 years ago
devtools::install_github("hrbrmstr/wand")
8 years ago
```
### Usage
``` r
8 years ago
library(wand)
library(magrittr)
library(dplyr)
8 years ago
system.file("img", package="wand") %>%
list.files(full.names=TRUE) %>%
incant() %>%
glimpse()
```
## Observations: 10
## Variables: 5
8 years ago
## $ file <chr> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/wand/img/example_dir", "/Librar...
## $ mime_type <chr> "inode/directory", "text/x-c", "text/html", "text/plain", "text/rtf", "image/jpeg", "applicatio...
## $ encoding <chr> "binary", "us-ascii", "us-ascii", "us-ascii", "us-ascii", "binary", "binary", "binary", "us-asc...
## $ extensions <chr> NA, "???", "???", "???", "???", "jpeg/jpg/jpe/jfif", "???", "???", "???", "???"
## $ description <chr> "directory", "C source, ASCII text", "HTML document, ASCII text, with CRLF line terminators", "...
8 years ago
``` r
system.file("img", package="wand") %>%
list.files(full.names=TRUE) %>%
incant(magic_wand_file()) %>%
select(description) %>%
unlist(use.names=FALSE)
```
## [1] "directory"
## [2] "C source, ASCII text"
## [3] "HTML document, ASCII text, with CRLF line terminators"
## [4] "ASCII text, with no line terminators"
## [5] "Rich Text Format data, version 1, ANSI"
## [6] "JPEG image data, JFIF standard 1.01, aspect ratio, density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=2, orientation=upper-left], baseline, precision 8, 800x700, frames 3"
## [7] "PDF document, version 1.3"
## [8] "PNG image data, 800 x 700, 8-bit/color RGBA, non-interlaced"
## [9] "ASCII text, with very long lines, with CRLF line terminators"
## [10] "TIFF image data, big-endian"
``` r
8 years ago
# current verison
8 years ago
packageVersion("wand")
8 years ago
```
## [1] '0.1.0'
### Test Results
``` r
8 years ago
library(wand)
8 years ago
library(testthat)
8 years ago
date()
```
8 years ago
## [1] "Fri Aug 12 23:58:20 2016"
8 years ago
``` r
test_dir("tests/")
```
## testthat results ========================================================================================================
8 years ago
## OK: 1 SKIPPED: 0 FAILED: 0
8 years ago
##
## DONE ===================================================================================================================