| Module | Gist |
| In: |
lib/gist.rb
|
It just gists.
| VERSION | = | '5.0.0' | ||
| CLIPBOARD_COMMANDS | = | { 'pbcopy' => 'pbpaste', 'xclip' => 'xclip -o', 'xsel -i' => 'xsel -o', 'putclip' => 'getclip', } | A list of clipboard commands with copy and paste support. | |
| GITHUB_API_URL | = | URI("https://api.github.com/") | ||
| GIT_IO_URL | = | URI("https://git.io") | ||
| GITHUB_BASE_PATH | = | "" | ||
| GHE_BASE_PATH | = | "/api/v3" | ||
| URL_ENV_NAME | = | "GITHUB_URL" | ||
| USER_AGENT | = | "gist/#{VERSION} (Net::HTTP, #{RUBY_DESCRIPTION})" |
Get the command to use for the clipboard action.
@param [Symbol] action either :copy or :paste @return [String] the command to run @raise [Gist::ClipboardError] if no clipboard integration could be found
Copy a string to the clipboard.
@param [String] content @raise [Gist::Error] if no clipboard integration could be found
Upload a gist to gist.github.com
@param [String] content the code you‘d like to gist @param [Hash] options more detailed options, see
the documentation for {multi_gist}
Run an HTTP operation
@param [URI::HTTP] The URI to which to connect @param [Net::HTTPRequest] The request to make @return [Net::HTTPResponse]
Return HTTP connection
@param [URI::HTTP] The URI to which to connect @return [Net::HTTP]
List all gists(private also) for authenticated user otherwise list public gists for given username (optional argument)
@param [String] user @deprecated
Log the user into gist.
This method asks the user for a username and password, and tries to obtain and OAuth2 access token, which is then stored in ~/.gist
@raise [Gist::Error] if something went wrong @param [Hash] credentials login details @option credentials [String] :username @option credentials [String] :password @see developer.github.com/v3/oauth/
Upload a gist to gist.github.com
@param [Hash] files the code you‘d like to gist: filename => content @param [Hash] options more detailed options
@option options [String] :description the description @option options [Boolean] :public (false) is this gist public @option options [Boolean] :anonymous (false) is this gist anonymous @option options [String] :access_token (`File.read("~/.gist")`) The OAuth2 access token. @option options [String] :update the URL or id of a gist to update @option options [Boolean] :copy (false) Copy resulting URL to clipboard, if successful. @option options [Boolean] :open (false) Open the resulting URL in a browser. @option options [Boolean] :skip_empty (false) Skip gisting empty files. @option options [Symbol] :output (:all) The type of return value you‘d like:
:html_url gives a String containing the url to the gist in a browser :short_url gives a String contianing a git.io url that redirects to html_url :javascript gives a String containing a script tag suitable for embedding the gist :all gives a Hash containing the parsed json response from the server
@return [String, Hash] the return value as configured by options[:output] @raise [Gist::Error] if something went wrong
Called after an HTTP response to gist to perform post-processing.
@param [String] body the text body from the github api @param [Hash] options more detailed options, see
the documentation for {multi_gist}
Open a URL in a browser.
@param [String] url @raise [RuntimeError] if no browser integration could be found
This method was heavily inspired by defunkt‘s Gist#open, @see github.com/defunkt/gist/blob/bca9b29/lib/gist.rb#L157
Get a string from the clipboard.
@param [String] content @raise [Gist::Error] if no clipboard integration could be found
return prettified string result of response body for all gists
@params [Net::HTTPResponse] response @return [String] prettified result of listing all gists
Convert github url into raw file url
Unfortunately the url returns from github‘s api is legacy, we have to taking a HTTPRedirection before appending it with ’/raw’. Let‘s looking forward for github‘s api fix :)
@param [String] url @return [String] the raw file url
Convert long github urls into short git.io ones
@param [String] url @return [String] shortened url, or long url if shortening fails