Created
June 1, 2014 07:26
-
-
Save cobyism/d1e86f2f2b8fa7d3f20a to your computer and use it in GitHub Desktop.
Example GIF compiler script for Toasts.
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
#! /usr/bin/env ruby | |
require 'octokit' | |
require 'awesome_print' | |
require 'open-uri' | |
client = Octokit::Client.new(:login => ENV['GHUSER'], :oauth_token => ENV['GHTOKEN']) | |
repo = 'example/repo' | |
Dir.mkdir('build') if !File.exists?('build') | |
def build_issue(client, repo, number) | |
comments = client.issue_comments(repo, number) | |
num = 0 | |
comments.each do |comment| | |
if m = comment.body.match(/\!\[(.*?)\]\((.*?)\)/) | |
Dir.mkdir("build/#{number}") if !File.exists?("build/#{number}") | |
uri = m[2] | |
puts " getting #{uri}" | |
open(uri) do |f| | |
num += 1 | |
ext = 'png' | |
ext = 'jpg' if f.content_type == 'image/jpeg' | |
file = "#{num}.#{ext}" | |
s = File.open("build/#{number}/#{file}", "w+") | |
s.write(f.read) | |
s.close | |
end | |
end | |
end | |
Dir.chdir("build/#{number}") do | |
puts " building gif" | |
`gifme -o toast.gif *` | |
end | |
file = "build/#{number}/toast.gif" | |
if File.exists?(file) | |
return file | |
else | |
return false | |
end | |
end | |
toasts = client.list_issues(repo) | |
toasts.each do |issue| | |
puts "Building ##{issue.number}: '#{issue.title}'" | |
build_issue(client, repo, issue.number) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment