class Onebox::Engine::GithubGistOnebox
Constants
- MAX_FILES
Public Instance Methods
url()
click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 15 def url "https://api.github.com/gists/#{match[:sha]}" end
Private Instance Methods
data()
click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 21 def data @data ||= { title: 'gist.github.com', link: link, gist_files: gist_files.take(MAX_FILES), truncated_files?: truncated_files? } end
gist_api()
click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 42 def gist_api @raw ||= raw.clone rescue OpenURI::HTTPError # The Gist API rate limit of 60 requests per hour was reached. nil end
gist_files()
click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 34 def gist_files return [] unless gist_api @gist_files ||= gist_api["files"].values.map do |file_json| GistFile.new(file_json) end end
match()
click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 49 def match @match ||= @url.match(%r{gist\.github\.com/([^/]+/)?(?<sha>[0-9a-f]+)}) end
truncated_files?()
click to toggle source
# File lib/onebox/engine/github_gist_onebox.rb, line 30 def truncated_files? gist_files.size > MAX_FILES end