Created
November 13, 2016 07:51
-
-
Save ongaeshi/a169ba85d04350e7dbf7d5b359f884c2 to your computer and use it in GitHub Desktop.
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
# https://developer.github.com/v3/gists/#create-a-gist | |
TOKEN = "XXXXXX" | |
def new_gist(filename, content) | |
json = { | |
# description: "Created by RubyPico at #{Time.now}", | |
public: true, | |
files: { | |
filename => { | |
content: content | |
}, | |
} | |
} | |
Browser.post( | |
"https://api.github.com/gists", | |
header: { "Authorization" => "token #{TOKEN}" }, | |
json: json | |
) | |
end | |
puts "Specify path" | |
path = prompt | |
File.open(path) do |f| | |
r = new_gist( | |
File.basename(path), | |
f.read | |
) | |
r = JSON.parse(r) | |
if r["html_url"] | |
puts r["html_url"] | |
else | |
puts r | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment