Sha256: b4c81b1845d1f593fbaadd74352c8a02a1208ea6ba7451ff5f13e7846f863654

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

require 'net/http'

module Ring
class SQA

  class Paste
    def self.add string
      Paste.new.add string
    rescue
      'paste failed'
    end

    def add string, url=CFG.paste.url
      paste string, url
    end

    private

    def paste string, url
      uri  = URI.parse url
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true if uri.scheme == 'https'
      rslt = http.post uri.path, URI.encode_www_form([['content',string], ['ttl','604800']])
      uri.path = rslt.fetch('location')
      uri.to_s
    end
  end

end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ring-sqa-0.0.19 lib/ring/sqa/paste.rb
ring-sqa-0.0.18 lib/ring/sqa/paste.rb