inir

library("knitr")
hook_output <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(output = function(x, options) {
   lines <- options$output.lines
   if (is.null(lines)) {
     return(hook_output(x, options))  # pass to default hook
   }
   x <- unlist(strsplit(x, "\n"))
   more <- "..."
   if (length(lines)==1) {        # first n lines
     if (length(x) > lines) {
       # truncate the output, but add ....
       x <- c(head(x, lines), more)
     }
   } else {
     x <- c(if (abs(lines[1])>1) more else NULL, 
            x[lines], 
            if (length(x)>lines[abs(length(lines))]) more else NULL
           )
   }
   # paste these lines together
   x <- paste(c(x, ""), collapse = "\n")
   hook_output(x, options)
 })

knitr::opts_chunk$set(
  comment = "#>",
  collapse = TRUE,
  warning = FALSE,
  message = FALSE
)

Build Status codecov.io

inir is a .ini/.cfg file parser

About .ini/.cfg files: the INI file Wikipedia page

Installation

install.packages("devtools")
devtools::install_github("sckott/inir")
library("inir")

Parse a file

Get a file

gitfile <- system.file("examples", "gitconfig.ini", package = "inir")

instantiate new object with file path

(res <- ini(gitfile))

get file path

res$file

read file

res$read()

get section names

res$sections()

get contents of a single section

res$get("core")

Meta



sckott/inir documentation built on May 29, 2019, 4:01 p.m.