-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Octokit to fetch Gist content when passed a GItHub token #28
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6c2d000
use octokit to fetch gists when token present
benbalter 15b2ee9
before(:each)
benbalter 6401936
working tests
benbalter 2d1b64e
dont look for truncation
benbalter 63a6ef7
document
benbalter 87b93ed
allways be backwards compatibling
benbalter b6eac05
Merge branch 'master' into api
benbalter 60bca91
missing end
benbalter 91b8363
whitespace
benbalter 32857aa
whitespace
benbalter d9c695f
cache client
benbalter 9153e43
balance whitespace
benbalter af85461
cache on the class, not the instance
benbalter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
{ | ||
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d", | ||
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks", | ||
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits", | ||
"id": "aa5a315d61ae9438b18d", | ||
"description": "description of gist", | ||
"public": true, | ||
"owner": { | ||
"login": "octocat", | ||
"id": 1, | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"user": null, | ||
"files": { | ||
"ring.erl": { | ||
"size": 932, | ||
"raw_url": "https://gist.githubusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl", | ||
"type": "text/plain", | ||
"language": "Erlang", | ||
"truncated": false, | ||
"content": "contents of gist" | ||
}, | ||
"hello-world.rb": { | ||
"size": 932, | ||
"raw_url": "https://gist.githubusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl", | ||
"type": "text/plain", | ||
"language": "Ruby", | ||
"truncated": false, | ||
"content": "puts 'hello world'" | ||
} | ||
}, | ||
"comments": 0, | ||
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/", | ||
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d", | ||
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git", | ||
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git", | ||
"created_at": "2010-04-14T02:15:15Z", | ||
"updated_at": "2011-06-20T11:34:15Z", | ||
"forks": [ | ||
{ | ||
"user": { | ||
"login": "octocat", | ||
"id": 1, | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"url": "https://api.github.com/gists/dee9c42e4998ce2ea439", | ||
"id": "dee9c42e4998ce2ea439", | ||
"created_at": "2011-04-14T16:00:49Z", | ||
"updated_at": "2011-04-14T16:00:49Z" | ||
} | ||
], | ||
"history": [ | ||
{ | ||
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d/57a7f021a713b1c5a6a199b54cc514735d2d462f", | ||
"version": "57a7f021a713b1c5a6a199b54cc514735d2d462f", | ||
"user": { | ||
"login": "octocat", | ||
"id": 1, | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"change_status": { | ||
"deletions": 0, | ||
"additions": 180, | ||
"total": 180 | ||
}, | ||
"committed_at": "2010-04-14T02:15:15Z" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d", | ||
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks", | ||
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits", | ||
"id": "aa5a315d61ae9438b18d", | ||
"description": "description of gist", | ||
"public": true, | ||
"owner": { | ||
"login": "octocat", | ||
"id": 1, | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"user": null, | ||
"files": { | ||
"ring.erl": { | ||
"size": 932, | ||
"raw_url": "https://gist.githubusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl", | ||
"type": "text/plain", | ||
"language": "Erlang", | ||
"truncated": false, | ||
"content": "contents of gist" | ||
} | ||
}, | ||
"comments": 0, | ||
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/", | ||
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d", | ||
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git", | ||
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git", | ||
"created_at": "2010-04-14T02:15:15Z", | ||
"updated_at": "2011-06-20T11:34:15Z", | ||
"forks": [ | ||
{ | ||
"user": { | ||
"login": "octocat", | ||
"id": 1, | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"url": "https://api.github.com/gists/dee9c42e4998ce2ea439", | ||
"id": "dee9c42e4998ce2ea439", | ||
"created_at": "2011-04-14T16:00:49Z", | ||
"updated_at": "2011-04-14T16:00:49Z" | ||
} | ||
], | ||
"history": [ | ||
{ | ||
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d/57a7f021a713b1c5a6a199b54cc514735d2d462f", | ||
"version": "57a7f021a713b1c5a6a199b54cc514735d2d462f", | ||
"user": { | ||
"login": "octocat", | ||
"id": 1, | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"change_status": { | ||
"deletions": 0, | ||
"additions": 180, | ||
"total": 180 | ||
}, | ||
"committed_at": "2010-04-14T02:15:15Z" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, I'm awfully silly. Really sorry, Ben, I misspoke. When I asked about caching, my reasoning was that for each
{% gist %}
, a newGistTag
instance is created and thus requires its own client. The Client won't change between variousgist
calls, so storing it so it's on the class rather than instance (or similar, store it anywhere you feel is appropriate) gives us a little speed boost and relieves some pressure on the garbage collector.Does that make sense? Sorry I didn't communicate all that. Still figuring out the right balance between being concise (saves time) and communicating 100% of what I was thinking.
So this code would become:
and would be accessed via
GistTag.client
(i.e. at the class level).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes total sense. Didn't think through that. Does it need to be
@@client
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, in the case of
@client
, it's an Instance variable on the Singleton.@@client
is a class variable onGistTag
,@client
is an instance variable on the Singleton instance ofGistTag
. It's equivalent to:Ruby is hella weird but there are fun nuances like this that keep things interesting. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. 📚. Implemented via af85461.