Class: Rlsgem

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

Class Method Summary collapse

Class Method Details

.cut(url) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/rlsgem.rb', line 5

def self.cut(url)
  if !url
    return "Usage: Rlsgem.cut('http://some.long.web/site')"
  else
    postData = Net::HTTP.post_form(URI.parse('http://rls.io/u'), {'url'=>"#{url}"})
    body = JSON.parse(postData.body)
    return body["url"]
  end
end

.paste_file(title, file) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/rlsgem.rb', line 15

def self.paste_file(title, file)
  if !title || !file
    return "Usage: Rlsgem.paste_file('Awesome File', '/home/john/christmasgifts.rb')"
  else
    pasteData = File.read(file)
    postData = Net::HTTP.post_form(URI.parse('http://rls.io/p'), {'title'=>"#{title}",'content'=>"#{pasteData}"})
    body = postData.body.gsub(/^...................................|...............................$/,'')
    return body
  end
end