Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
first version up
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Feb 5, 2015
0 parents commit 46a6d51
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
@@ -0,0 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
README.Rmd
.travis.yml
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.Rproj.user
.Rhistory
.RData
15 changes: 15 additions & 0 deletions DESCRIPTION
@@ -0,0 +1,15 @@
Package: etseed
Title: etcd R client
Description: etcd R client
Version: 0.0.1.99
Date: 2015-02-05
License: MIT + file LICENSE
URL: https://github.com/sckott/etseed
BugReports: https://github.com/sckott/etseed/issues
Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"),
email = "myrmecocystus@gmail.com"))
License: MIT + file LICENSE
LazyData: true
Imports:
httr,
jsonlite
6 changes: 6 additions & 0 deletions NAMESPACE
@@ -0,0 +1,6 @@
# Generated by roxygen2 (4.1.0): do not edit by hand

export(key)
export(keys)
import(httr)
import(jsonlite)
9 changes: 9 additions & 0 deletions R/etseed-package.R
@@ -0,0 +1,9 @@
#' Ping urls to time requests
#'
#' @name etseed-package
#' @aliases etseed
#' @docType package
#' @title etcd R client
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com}
#' @keywords package
NULL
27 changes: 27 additions & 0 deletions R/keys.R
@@ -0,0 +1,27 @@
#' List a key or all keys
#'
#' @import httr jsonlite
#' @name keys
#'
#' @param key (character) A key name. Optional.
#' @param ... Further args passed on to \code{\link[httr]{GET}}
#'
#' @examples \dontrun{
#' # List all keys
#' keys()
#'
#' # A single key
#' key("mykey")
#' }

#' @export
#' @rdname keys
keys <- function(...) {
etseed_GET(sprintf("%s%s/", etcdbase(), "keys"), ...)
}

#' @export
#' @rdname keys
key <- function(key, ...) {
etseed_GET(sprintf("%s%s/%s/", etcdbase(), "keys", key), ...)
}
8 changes: 8 additions & 0 deletions R/zzz.R
@@ -0,0 +1,8 @@
etseed_GET <- function(url, ...){
res <- GET(url, ...)
stop_for_status(res)
tt <- content(res, "text")
jsonlite::fromJSON(tt, FALSE)
}

etcdbase <- function() "http://127.0.0.1:4001/v2/"
55 changes: 55 additions & 0 deletions README.Rmd
@@ -0,0 +1,55 @@
etseed
========

```{r echo=FALSE}
knitr::opts_chunk$set(
warning = FALSE,
message = FALSE,
collapse = TRUE,
comment = "#>"
)
```

__etcd R client__

## Installation

Install `etseed`

```{r eval=FALSE}
install.packages("devtools")
devtools::install_github("sckott/etseed")
```

```{r}
library("etseed")
```

## Start etcd

at the command line on OSX

```sh
brew install etcd
etcd
```

done.

## Get version

```{r}
version()
```

## List keys

```{r}
keys()
```

## List a key

```{r}
key("mykey")
```
92 changes: 92 additions & 0 deletions README.md
@@ -0,0 +1,92 @@
etseed
========



__etcd R client__

## Installation

Install `etseed`


```r
install.packages("devtools")
devtools::install_github("sckott/etseed")
```


```r
library("etseed")
```

## Start etcd

at the command line on OSX

```sh
brew install etcd
etcd
```

done.

## Get version


```r
version()
#> Error in eval(expr, envir, enclos): could not find function "version"
```

## List keys


```r
keys()
#> $action
#> [1] "get"
#>
#> $node
#> $node$key
#> [1] "/"
#>
#> $node$dir
#> [1] TRUE
#>
#> $node$nodes
#> $node$nodes[[1]]
#> $node$nodes[[1]]$key
#> [1] "/mykey"
#>
#> $node$nodes[[1]]$value
#> [1] "this is awesome"
#>
#> $node$nodes[[1]]$modifiedIndex
#> [1] 3
#>
#> $node$nodes[[1]]$createdIndex
#> [1] 3
```

## List a key


```r
key("mykey")
#> $action
#> [1] "get"
#>
#> $node
#> $node$key
#> [1] "/mykey"
#>
#> $node$value
#> [1] "this is awesome"
#>
#> $node$modifiedIndex
#> [1] 3
#>
#> $node$createdIndex
#> [1] 3
```
21 changes: 21 additions & 0 deletions etseed.Rproj
@@ -0,0 +1,21 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: knitr
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
15 changes: 15 additions & 0 deletions man/etseed-package.Rd
@@ -0,0 +1,15 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Please edit documentation in R/etseed-package.R
\docType{package}
\name{etseed-package}
\alias{etseed}
\alias{etseed-package}
\title{etcd R client}
\description{
Ping urls to time requests
}
\author{
Scott Chamberlain \email{myrmecocystus@gmail.com}
}
\keyword{package}

29 changes: 29 additions & 0 deletions man/keys.Rd
@@ -0,0 +1,29 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Please edit documentation in R/keys.R
\name{keys}
\alias{key}
\alias{keys}
\title{List a key or all keys}
\usage{
keys(...)

key(key, ...)
}
\arguments{
\item{...}{Further args passed on to \code{\link[httr]{GET}}}

\item{key}{(character) A key name. Optional.}
}
\description{
List a key or all keys
}
\examples{
\dontrun{
# List all keys
keys()

# A single key
key("mykey")
}
}

0 comments on commit 46a6d51

Please sign in to comment.