Class: Pastie

Inherits:
Object
  • Object
show all
Defined in:
lib/pastie.rb

Overview

:nodoc: all

Constant Summary collapse

PASTE_URL =
ENV['SAKE_PASTIE_URL'] || ENV['PASTIE_URL'] || 'http://pastie.caboo.se/pastes/create'

Class Method Summary collapse

Class Method Details

.paste(text) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pastie.rb', line 6

def self.paste(text)
  text_file = Tempfile.open('w+')
  text_file << text
  text_file.flush

  cmd = "  curl \#{PASTE_URL} \\\n  -s -L -o /dev/null -w \"%{url_effective}\" \\\n  -H \"Expect:\" \\\n  -F \"paste[parser]=ruby\" \\\n  -F \"paste[restricted]=0\" \\\n  -F \"paste[authorization]=burger\" \\\n  -F \"paste[body]=<\#{text_file.path}\" \\\n  -F \"key=\" \\\n  -F \"x=27\" \\\n  -F \"y=27\"\n  EOS\n  \n  out = %x{\n    \#{cmd}\n  }\n\n  text_file.close(true)\n  out\nend\n"