Last active
May 2, 2017 08:00
-
-
Save obelisk68/b2824cba8fb68cea1980bb3ce57fd2d8 to your computer and use it in GitHub Desktop.
Created by RubyPico at Tue May 02 16:59:50 2017
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
def main | |
fname = Popup.input("ファイル名を入力して下さい") | |
return unless fname | |
unless File.exist?(fname) and File.file?(fname) | |
puts "ファイルが存在しないか、ディレクトリです" | |
return | |
end | |
file_content = File.open(fname) {|io| io.read} | |
# https://developer.github.com/v3/gists/#create-a-gist | |
json = { | |
description: "Created by RubyPico at #{Time.now}", | |
public: true, | |
files: { | |
fname => {content: file_content} | |
} | |
} | |
puts "アップロード中..." | |
result = Browser.post( | |
"https://api.github.com/gists", | |
header: { "Authorization" => "token ***" }, | |
json: json | |
) | |
if result.length < 100 | |
puts result | |
else | |
puts fname + "を Gist にアップロードしました" | |
end | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment