You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/guides/rendering-data-as-graphs.md
+72-58Lines changed: 72 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,21 @@ title: Rendering Data as Graphs | GitHub API
7
7
* TOC
8
8
{:toc}
9
9
10
-
In this guide, we're going to poll repositories that we own, and render the
11
-
information there with graphs, using the [d3.js][d3.js] library. We'll also
12
-
be using Octokit, a Ruby library designed to interact with the GitHub API.
10
+
In this guide, we're going to use the API to fetch information about repositories
11
+
that we own, and the programming languages that make them up. Then, we'll
12
+
visualize that information in a couple of different ways using the [D3.js][D3.js] library. To
13
+
interact with the GitHub API, we'll be using the excellent Ruby library, [Octokit][Octokit].
13
14
14
-
We're going to jump right in and assume you've already read the ["Basics of Authentication"][basics-of-authentication]
15
-
guide.
15
+
If you haven't already, you should read the ["Basics of Authentication"][basics-of-authentication]
16
+
guide before starting this example. You can find the complete source code for this project in the [platform-samples][platform samples] repository.
16
17
17
-
Note: you can download the complete source code for this project [from the platform-samples repo](https://github.com/github/platform-samples/tree/master/api/ruby/rendering-data-as-graphs).
18
+
Let's jump right in!
18
19
19
-
Go ahead and register an application through GitHub. Set the main URL and callback
20
-
URL to `http://localhost:4567/`. As before, we're going to be implementing a Rack middleware
21
-
using [sinatra-auth-github][sinatra auth github]:
20
+
## Setting up an OAuth application
21
+
22
+
First, [register a new application][new oauth application] on GitHub. Set the main and callback
23
+
URLs to `http://localhost:4567/`. As [before][basics-of-authentication], we're going to handle authentication for the API by
24
+
implementing a Rack middleware using [sinatra-auth-github][sinatra auth github]:
22
25
23
26
require 'sinatra/auth/github'
24
27
@@ -68,10 +71,11 @@ Set up a similar _config.ru_ file as in the previous example:
68
71
## Fetching repository information
69
72
70
73
This time, in order to talk to the GitHub API, we're going to use the [Octokit
71
-
Ruby library][Octokit]. This is supremly better than directly making a bunch of
72
-
REST calls. Plus, Octokit was developed by a GitHubber, so you know it'll work.
74
+
Ruby library][Octokit]. This is much easier than directly making a bunch of
75
+
REST calls. Plus, Octokit was developed by a GitHubber, and is actively maintained,
76
+
so you know it'll work.
73
77
74
-
Establishing an Octokit instance is extremly easy; just pass your login
78
+
Authentication with the API via Octokit is easy. Just pass your login
75
79
and token to the `Octokit::Client` constructor:
76
80
77
81
if !authenticated?
@@ -80,18 +84,19 @@ and token to the `Octokit::Client` constructor:
0 commit comments