Skip to content

Instantly share code, notes, and snippets.

@obelisk68
Last active May 2, 2017 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obelisk68/b2824cba8fb68cea1980bb3ce57fd2d8 to your computer and use it in GitHub Desktop.
Save obelisk68/b2824cba8fb68cea1980bb3ce57fd2d8 to your computer and use it in GitHub Desktop.
Created by RubyPico at Tue May 02 16:59:50 2017
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