eval/eval.rb
# Public: Pastebins the result of a code evaluation.
#
# This is used when the output of an evaluation is too long for IRC. The
# full result is pastebinned.
#
# credentials - An optional Hash containing two keys, :username, and :password
#               which, if present, are used to authenticate with the pastebin,
#               to have the given account own the paste.
#
# Returns a String containing link to the paste, or an error message stating
#   why we couldn't get it.
Pastebins the result of a code evaluation.
This is used when the output of an evaluation is too long for IRC. The
full result is pastebinned.

An optional Hash containing two keys, :username, and :password
which, if present, are used to authenticate with the pastebin,
to have the given account own the paste.

Returns a String containing link to the paste, or an error message stating
why we couldn't get it.
Pastebins the result of a code evaluation . This is used when the output of an evaluation is too long for IRC . The full result is pastebinned . An optional Hash containing two keys : username and : password which if present are used to authenticate with the pastebin to have the given account own the paste . Returns a String containing link to the paste or an error message stating why we couldn ' t get it .
def pastebin(credentials = {})
    begin
      username = credentials[:username] || nil
      password = credentials[:password] || nil
      heap = Refheap::Paste.new(username, password)
      input = File.open("#{@home}/#{@script_filename}").read
      language = Linguist::FileBlob.new("#{@home}/#{@script_filename}").language.name
      paste = "Input (#{@script_filename}):\n#{input}\n\nOutput:\n#{@result}"
      paste = heap.create(paste, :language => language, :private => true)
      "Output truncated: #{paste['url']} (#{@result.lines.count} lines of total output)"
    rescue Exception => e
      "Couldn't connect to the pastebin server."
      puts e
    end
  end
def pastebin ( credentials = { } ) begin username = credentials [ :username ] || nil password = credentials [ :password ] || nil heap = Refheap :: Paste . new ( username , password ) input = File . open ( "#{@home}/#{@script_filename}" ) . read language = Linguist :: FileBlob . new ( "#{@home}/#{@script_filename}" ) . language . name paste = "Input (#{@script_filename}):\n#{input}\n\nOutput:\n#{@result}" paste = heap . create ( paste , :language => language , :private => true ) "Output truncated: #{paste['url']} (#{@result.lines.count} lines of total output)" rescue Exception => e "Couldn't connect to the pastebin server." puts e end end
Public: Pastebins the result of a code evaluation.
Public : Pastebins the result of a code evaluation .
credentials