7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/utility_belt/pastie.rb', line 7
def pastie(stuff_to_paste = nil)
stuff_to_paste ||= Clipboard.read if Clipboard.available?
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?
case Platform::IMPL
when :macosx
Kernel.system("open #{pastie_url}")
when :mswin
Kernel.system("start #{pastie_url}")
when :linux
kernel.system("xdg-open #{pastie_url}")
end
return pastie_url
end
|