gistr: Work with 'GitHub' 'Gists'

GitHubのgistにあるファイルの管理

> library(gistr)

Attaching package: 'gistr'
The following objects are masked from 'package:stats':

    embed, update
The following object is masked from 'package:git2r':

    commits

バージョン: 0.3.6


関数名 概略
add_files Add files to a gist object
browse Open a gist on GitHub
commits List gist commits
create_gists Create gists
delete Delete a gist
embed Get embed script for a gist
fork Fork a gist
forks List forks on a gist
gist Get a gist
gist_auth Authorize with GitHub.
gist_create Create a gist
gist_create_git Create a gist via git instead of the GitHub Gists HTTP API
gist_create_obj Create a gist from an R object
gist_map Opens a full screen map after uploading a geojson file
gist_save Save gist files to disk
gistr-package R client for GitHub gists
gists List gists
rate_limit Get rate limit information
run Run a .Rmd file
star Star a gist
tabl Make a table from gist or commit class or a list of either
update Update/modify a gist

gist / as.gist

Arguments

  • id
  • ...
  • x
> gist("5f1a1011ea368e1c833e")
<gist>5f1a1011ea368e1c833e
  URL: https://gist.github.com/5f1a1011ea368e1c833e
  Description: String initialization notes
  Public: TRUE
  Created/Edited: 2016-01-08T20:19:30Z / 2016-01-08T20:19:31Z
  Files: FromCString.swift, NSString.swift, UnicodeScalar.swift
  Truncated?: FALSE, FALSE, FALSE

gist_auth

GitHubへの認証

> gist_auth()

gist_create

gistの作成

Arguments

  • files
  • description
  • public
  • browse
  • code...
  • filename
  • knit
  • knitopts, renderopts
  • include_source
  • imgur_inject
  • rmarkdown
  • ...
> gist_create(code = {'
+ x <- letters
+ numbers <- runif(8)
+ numbers
+ '},
+ knit = TRUE,
+ public = FALSE)

gists

gistに投稿されたものの情報を取得する

Arguments

  • what... 対象を指定する。public, minepublic, mineallあるいはstarred
  • since
  • page
  • per_page... 取得件数
  • ...
> gists(what = "minepublic", per_page = 2)
[[1]]
<gist>e73bc26c209284944598
  URL: https://gist.github.com/e73bc26c209284944598
  Description: 
  Public: TRUE
  Created/Edited: 2016-01-23T08:44:01Z / 2016-01-23T08:44:02Z
  Files: pkg_infrastructure.R
  Truncated?: FALSE

[[2]]
<gist>b9cf68217c596369721a
  URL: https://gist.github.com/b9cf68217c596369721a
  Description: Add file to .gitignore
  Public: TRUE
  Created/Edited: 2016-01-13T04:08:50Z / 2016-01-14T01:45:56Z
  Files: add_ignore.R
  Truncated?: FALSE
> gists(waht = "starred", per_page = 2)
[[1]]
<gist>86bb1823d4cef7f0a4b9
  URL: https://gist.github.com/86bb1823d4cef7f0a4b9
  Description: Untitled
  Public: TRUE
  Created/Edited: 2016-01-29T17:51:52Z / 2016-01-29T17:51:52Z
  Files: dabblet.css, dabblet.html, dabblet.js, settings.json
  Truncated?: FALSE, FALSE, FALSE, FALSE

[[2]]
<gist>59c17ce7a1ade6cfc3c6
  URL: https://gist.github.com/59c17ce7a1ade6cfc3c6
  Description: Build Rsync for Android with Android NDK
  Public: TRUE
  Created/Edited: 2016-01-29T17:51:49Z / 2016-01-29T17:51:49Z
  Files: Application.mk
  Truncated?: FALSE

tabl

> gist("5f1a1011ea368e1c833e") %>% tabl() %>% {
+   str(.) %>% print()
+   class(.)
+ }
List of 3
 $ data   :Classes 'tbl_df', 'tbl' and 'data.frame':    3 obs. of  38 variables:
  ..$ id                       : chr [1:3] "5f1a1011ea368e1c833e" "5f1a1011ea368e1c833e" "5f1a1011ea368e1c833e"
  ..$ url                      : chr [1:3] "https://api.github.com/gists/5f1a1011ea368e1c833e" "https://api.github.com/gists/5f1a1011ea368e1c833e" "https://api.github.com/gists/5f1a1011ea368e1c833e"
  ..$ forks_url                : chr [1:3] "https://api.github.com/gists/5f1a1011ea368e1c833e/forks" "https://api.github.com/gists/5f1a1011ea368e1c833e/forks" "https://api.github.com/gists/5f1a1011ea368e1c833e/forks"
  ..$ commits_url              : chr [1:3] "https://api.github.com/gists/5f1a1011ea368e1c833e/commits" "https://api.github.com/gists/5f1a1011ea368e1c833e/commits" "https://api.github.com/gists/5f1a1011ea368e1c833e/commits"
  ..$ git_pull_url             : chr [1:3] "https://gist.github.com/5f1a1011ea368e1c833e.git" "https://gist.github.com/5f1a1011ea368e1c833e.git" "https://gist.github.com/5f1a1011ea368e1c833e.git"
  ..$ git_push_url             : chr [1:3] "https://gist.github.com/5f1a1011ea368e1c833e.git" "https://gist.github.com/5f1a1011ea368e1c833e.git" "https://gist.github.com/5f1a1011ea368e1c833e.git"
  ..$ html_url                 : chr [1:3] "https://gist.github.com/5f1a1011ea368e1c833e" "https://gist.github.com/5f1a1011ea368e1c833e" "https://gist.github.com/5f1a1011ea368e1c833e"
  ..$ public                   : chr [1:3] "TRUE" "TRUE" "TRUE"
  ..$ created_at               : chr [1:3] "2016-01-08T20:19:30Z" "2016-01-08T20:19:30Z" "2016-01-08T20:19:30Z"
  ..$ updated_at               : chr [1:3] "2016-01-08T20:19:31Z" "2016-01-08T20:19:31Z" "2016-01-08T20:19:31Z"
  ..$ description              : chr [1:3] "String initialization notes" "String initialization notes" "String initialization notes"
  ..$ comments                 : chr [1:3] "0" "0" "0"
  ..$ user                     : chr [1:3] NA NA NA
  ..$ comments_url             : chr [1:3] "https://api.github.com/gists/5f1a1011ea368e1c833e/comments" "https://api.github.com/gists/5f1a1011ea368e1c833e/comments" "https://api.github.com/gists/5f1a1011ea368e1c833e/comments"
  ..$ files_filename           : chr [1:3] "FromCString.swift" "NSString.swift" "UnicodeScalar.swift"
  ..$ files_type               : chr [1:3] "text/plain" "text/plain" "text/plain"
  ..$ files_language           : chr [1:3] "Swift" "Swift" "Swift"
  ..$ files_raw_url            : chr [1:3] "https://gist.githubusercontent.com/zwaldowski/5f1a1011ea368e1c833e/raw/6ee7728251a69753c9080a0b414b5050cdca6c08/FromCString.swi"| __truncated__ "https://gist.githubusercontent.com/zwaldowski/5f1a1011ea368e1c833e/raw/ec9e01a662df3490926e13bd43a68ca6b1999df3/NSString.swift" "https://gist.githubusercontent.com/zwaldowski/5f1a1011ea368e1c833e/raw/8ed98a461d34b2c20a64879b0fad1727eebc073f/UnicodeScalar.s"| __truncated__
  ..$ files_size               : chr [1:3] "196" "411" "740"
  ..$ files_truncated          : chr [1:3] "FALSE" "FALSE" "FALSE"
  ..$ files_content            : chr [1:3] "// The gold standard, at least at present\nlet utf8Buffer: UnsafeBufferPointer<CChar> = ...\nvar arrayVersion = Array(utf8Buffe"| __truncated__ "let utf8Buffer: UnsafeBufferPointer<UInt8> = ...\n\n// Crossing the NSString bridge performs slower than you'd like\nlet nsStri"| __truncated__ "let utf8Buffer: UnsafeBufferPointer<UInt8> = ...\nlet codePointCount = ... // assume this comes from UTF16.measure(_:input:repa"| __truncated__
  ..$ owner_login              : chr [1:3] "zwaldowski" "zwaldowski" "zwaldowski"
  ..$ owner_id                 : chr [1:3] "170812" "170812" "170812"
  ..$ owner_avatar_url         : chr [1:3] "https://avatars.githubusercontent.com/u/170812?v=3" "https://avatars.githubusercontent.com/u/170812?v=3" "https://avatars.githubusercontent.com/u/170812?v=3"
  ..$ owner_gravatar_id        : chr [1:3] "" "" ""
  ..$ owner_url                : chr [1:3] "https://api.github.com/users/zwaldowski" "https://api.github.com/users/zwaldowski" "https://api.github.com/users/zwaldowski"
  ..$ owner_html_url           : chr [1:3] "https://github.com/zwaldowski" "https://github.com/zwaldowski" "https://github.com/zwaldowski"
  ..$ owner_followers_url      : chr [1:3] "https://api.github.com/users/zwaldowski/followers" "https://api.github.com/users/zwaldowski/followers" "https://api.github.com/users/zwaldowski/followers"
  ..$ owner_following_url      : chr [1:3] "https://api.github.com/users/zwaldowski/following{/other_user}" "https://api.github.com/users/zwaldowski/following{/other_user}" "https://api.github.com/users/zwaldowski/following{/other_user}"
  ..$ owner_gists_url          : chr [1:3] "https://api.github.com/users/zwaldowski/gists{/gist_id}" "https://api.github.com/users/zwaldowski/gists{/gist_id}" "https://api.github.com/users/zwaldowski/gists{/gist_id}"
  ..$ owner_starred_url        : chr [1:3] "https://api.github.com/users/zwaldowski/starred{/owner}{/repo}" "https://api.github.com/users/zwaldowski/starred{/owner}{/repo}" "https://api.github.com/users/zwaldowski/starred{/owner}{/repo}"
  ..$ owner_subscriptions_url  : chr [1:3] "https://api.github.com/users/zwaldowski/subscriptions" "https://api.github.com/users/zwaldowski/subscriptions" "https://api.github.com/users/zwaldowski/subscriptions"
  ..$ owner_organizations_url  : chr [1:3] "https://api.github.com/users/zwaldowski/orgs" "https://api.github.com/users/zwaldowski/orgs" "https://api.github.com/users/zwaldowski/orgs"
  ..$ owner_repos_url          : chr [1:3] "https://api.github.com/users/zwaldowski/repos" "https://api.github.com/users/zwaldowski/repos" "https://api.github.com/users/zwaldowski/repos"
  ..$ owner_events_url         : chr [1:3] "https://api.github.com/users/zwaldowski/events{/privacy}" "https://api.github.com/users/zwaldowski/events{/privacy}" "https://api.github.com/users/zwaldowski/events{/privacy}"
  ..$ owner_received_events_url: chr [1:3] "https://api.github.com/users/zwaldowski/received_events" "https://api.github.com/users/zwaldowski/received_events" "https://api.github.com/users/zwaldowski/received_events"
  ..$ owner_type               : chr [1:3] "User" "User" "User"
  ..$ owner_site_admin         : chr [1:3] "FALSE" "FALSE" "FALSE"
 $ forks  : NULL
 $ history:Classes 'tbl_df', 'tbl' and 'data.frame':    1 obs. of  23 variables:
  ..$ history_user.login              : chr "zwaldowski"
  ..$ history_user.id                 : int 170812
  ..$ history_user.avatar_url         : chr "https://avatars.githubusercontent.com/u/170812?v=3"
  ..$ history_user.gravatar_id        : chr ""
  ..$ history_user.url                : chr "https://api.github.com/users/zwaldowski"
  ..$ history_user.html_url           : chr "https://github.com/zwaldowski"
  ..$ history_user.followers_url      : chr "https://api.github.com/users/zwaldowski/followers"
  ..$ history_user.following_url      : chr "https://api.github.com/users/zwaldowski/following{/other_user}"
  ..$ history_user.gists_url          : chr "https://api.github.com/users/zwaldowski/gists{/gist_id}"
  ..$ history_user.starred_url        : chr "https://api.github.com/users/zwaldowski/starred{/owner}{/repo}"
  ..$ history_user.subscriptions_url  : chr "https://api.github.com/users/zwaldowski/subscriptions"
  ..$ history_user.organizations_url  : chr "https://api.github.com/users/zwaldowski/orgs"
  ..$ history_user.repos_url          : chr "https://api.github.com/users/zwaldowski/repos"
  ..$ history_user.events_url         : chr "https://api.github.com/users/zwaldowski/events{/privacy}"
  ..$ history_user.received_events_url: chr "https://api.github.com/users/zwaldowski/received_events"
  ..$ history_user.type               : chr "User"
  ..$ history_user.site_admin         : logi FALSE
  ..$ history_version                 : chr "3373b24383a4ba812d1bc3425ce3565d4c8161df"
  ..$ history_committed_at            : chr "2016-01-08T20:19:30Z"
  ..$ history_change_status.total     : int 25
  ..$ history_change_status.additions : int 25
  ..$ history_change_status.deletions : int 0
  ..$ history_url                     : chr "https://api.github.com/gists/5f1a1011ea368e1c833e/3373b24383a4ba812d1bc3425ce3565d4c8161df"
NULL
[1] "list"

rate_limit

> rate_limit()
Rate limit: 5000
Remaining:  4986
Resets in:  26s