All pastes #332780 Raw Edit

Unnamed

public text v1 · immutable
#332780 ·published 2007-01-30 08:09 UTC
rendered paste body
#!/usr/bin/ruby

require 'rubygems'
require 'net/http'
require 'hpricot'

class PasteBin
    attr_reader :file
    attr_reader :code
    def initialize(file)
        @file = file
        @code = nil
    end

    def getCode
        @code = File.read(@file)
    end

    def sendCode
        data = {"content" => @code, "description" => nil, "type" => '1', "expiry" => nil,
        "name" => nil, "s" => 'Submit+Post' }
        @response = Net::HTTP.post_form(URI.parse("http://pastebin.ca/new.php"), data)
    end

    def getLink
        puts @response
    end
end

paste = PasteBin.new(ARGV[0])
paste.getCode
paste.sendCode
paste.getLink