diff options
| author | BrewTestBot | 2015-08-03 13:09:07 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2015-08-03 13:22:35 +0100 |
| commit | 13d544e11e92ba8ea3788723432046f8dfe4adf9 (patch) | |
| tree | e6da18436d9ce956e6fbe80e3185c67cf3b58808 /Library/Homebrew/cmd/gist-logs.rb | |
| parent | 3b68215be793774fafd9ce124a2065f5968f50e5 (diff) | |
| download | brew-13d544e11e92ba8ea3788723432046f8dfe4adf9.tar.bz2 | |
Core files style updates.
Closes Homebrew/homebrew#42354.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew/cmd/gist-logs.rb')
| -rw-r--r-- | Library/Homebrew/cmd/gist-logs.rb | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb index ffd02ab52..db89f8e2e 100644 --- a/Library/Homebrew/cmd/gist-logs.rb +++ b/Library/Homebrew/cmd/gist-logs.rb @@ -1,11 +1,11 @@ -require 'formula' -require 'cmd/config' -require 'net/http' -require 'net/https' -require 'stringio' +require "formula" +require "cmd/config" +require "net/http" +require "net/https" +require "stringio" module Homebrew - def gistify_logs f + def gistify_logs(f) files = load_logs(f.logs) s = StringIO.new @@ -23,12 +23,12 @@ module Homebrew url = create_gist(files) - if ARGV.include?('--new-issue') || ARGV.switch?('n') + if ARGV.include?("--new-issue") || ARGV.switch?("n") auth = :AUTH_TOKEN unless HOMEBREW_GITHUB_API_TOKEN - puts 'You can create a personal access token: https://github.com/settings/tokens' - puts 'and then set HOMEBREW_GITHUB_API_TOKEN as authentication method.' + puts "You can create a personal access token: https://github.com/settings/tokens" + puts "and then set HOMEBREW_GITHUB_API_TOKEN as authentication method." puts auth = :AUTH_BASIC @@ -40,19 +40,19 @@ module Homebrew puts url if url end - #Hack for ruby < 1.9.3 + # Hack for ruby < 1.9.3 def noecho_gets - system 'stty -echo' + system "stty -echo" result = $stdin.gets - system 'stty echo' + system "stty echo" puts result end - def login request - print 'GitHub User: ' + def login(request) + print "GitHub User: " user = $stdin.gets.chomp - print 'Password: ' + print "Password: " password = noecho_gets.chomp puts request.basic_auth(user, password) @@ -64,23 +64,23 @@ module Homebrew contents = file.size? ? file.read : "empty log" logs[file.basename.to_s] = { :content => contents } end if dir.exist? - raise 'No logs.' if logs.empty? + raise "No logs." if logs.empty? logs end - def create_gist files - post("/gists", { "public" => true, "files" => files })["html_url"] + def create_gist(files) + post("/gists", "public" => true, "files" => files)["html_url"] end - def new_issue repo, title, body, auth + def new_issue(repo, title, body, auth) post("/repos/#{repo}/issues", { "title" => title, "body" => body }, auth)["html_url"] end def http @http ||= begin - uri = URI.parse('https://api.github.com') - p = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : nil - if p.class == URI::HTTP or p.class == URI::HTTPS + uri = URI.parse("https://api.github.com") + p = ENV["http_proxy"] ? URI.parse(ENV["http_proxy"]) : nil + if p.class == URI::HTTP || p.class == URI::HTTPS @http = Net::HTTP.new(uri.host, uri.port, p.host, p.port, p.user, p.password) else @http = Net::HTTP.new(uri.host, uri.port) @@ -94,10 +94,10 @@ module Homebrew headers = { "User-Agent" => HOMEBREW_USER_AGENT, "Accept" => "application/vnd.github.v3+json", - "Content-Type" => "application/json", + "Content-Type" => "application/json" } - if auth == :AUTH_TOKEN || (auth == nil && HOMEBREW_GITHUB_API_TOKEN) + if auth == :AUTH_TOKEN || (auth.nil? && HOMEBREW_GITHUB_API_TOKEN) headers["Authorization"] = "token #{HOMEBREW_GITHUB_API_TOKEN}" end |
