Module: UtilityBelt::Pastie
- Included in:
- Object
- Defined in:
- lib/utility_belt/pastie.rb
Instance Method Summary collapse
- #pastie(stuff_to_paste = nil) ⇒ Object (also: #pst)
Instance Method Details
#pastie(stuff_to_paste = nil) ⇒ Object Also known as: pst
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/utility_belt/pastie.rb', line 8 def pastie(stuff_to_paste = nil) stuff_to_paste ||= Clipboard.read if Clipboard.available? # return nil unless stuff_to_paste pastie_url = Net::HTTP.post_form(URI.parse("http://pastie.caboo.se/pastes/create"), {"paste_parser" => "ruby", "paste[authorization]" => "burger", "paste[body]" => stuff_to_paste}).body.match(/href="([^\"]+)"/)[1] Clipboard.write(pastie_url) if Clipboard.available? WebBrowser.open(pastie_url) return pastie_url end |