Sha256: 2a84595798d9706fa1483ad9a8a100bcdd2b48346be0495af86f95708937f55d
Contents?: true
Size: 772 Bytes
Versions: 2
Compression:
Stored size: 772 Bytes
Contents
require 'net/http' class WrttnIn attr_reader :public_url, :content def self.create(content, markup = :markdown) post_data = { :content => content, :parser => markup } response = Net::HTTP.post_form(URI.parse('http://wrttn.in/create'), post_data) if response.kind_of?(Net::HTTPRedirection) response_body = Net::HTTP.get(URI.join('http://wrttn.in', response['Location'])) if id = response_body.match(/<a href="\/(.*)" class="lab" target="_blank">public url<\/a>/)[1] self.new(id, content) else raise "Couldn't parse the response" end else raise "Couldn't create a post" end end def initialize(id, content) @public_url = "http://wrttn.in/#{id}" @content = content end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
muzang-plugins-1.1.6 | lib/muzang-plugins/muzang-grep/wrttn_in.rb |
muzang-plugins-1.1.5 | lib/muzang-plugins/muzang-grep/wrttn_in.rb |