Module: RPaste::NoPaste

Defined in:
lib/rpaste/nopaste/paste.rb,
lib/rpaste/nopaste/recent.rb,
lib/rpaste/nopaste/nopaste.rb,
lib/rpaste/nopaste/metadata.rb,
lib/rpaste/nopaste/result_set.rb,
lib/rpaste/pastebin/result_set.rb

Defined Under Namespace

Classes: Metadata, Paste, Recent, ResultSet

Class Method Summary collapse

Class Method Details

.paste(name, opts = {}) ⇒ Object

Retrieves the NoPaste Paste object associated with the specified name. See Paste.paste.


20
21
22
# File 'lib/rpaste/nopaste/nopaste.rb', line 20

def NoPaste.paste(name,opts={})
  Paste.paste(name,opts)
end

.post(opts = {}, &block) ⇒ Object

Submits a new paste to NoPaste. If a block is given, then it will be passed the Paste object before it is submitted to NoPaste.

NoPaste.post(:author => 'briefcase man') do |paste|
  paste.description = 'todays key'
  paste.text = 'is brought to you by the letter S, for symmetric'
end

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rpaste/nopaste/nopaste.rb', line 33

def NoPaste.post(opts={},&block)
  author = opts[:author]
  syntax = opts[:syntax]
  description = opts[:description]
  text = opts[:text]

  paste = Paste.new(nil,author,nil,syntax,description,text,&block)

  agent = RPaste.http_agent(opts)
  page = agent.get('http://rafb.net/paste/index.html')
  form = page.forms.first

  form.lang = paste.syntax if paste.syntax
  form.nick = paste.author if paste.author
  form.desc = paste.description if paste.description

  if opts[:convert_tabs]
    form.cvt_tabs = opts[:convert_tabs]
  end

  form.text = paste.text
  page = agent.submit(form)

  paste.name = page.search('//tr[3]/td/small').inner_text.gsub(/^URL: .*\//,'').gsub(/\.html$/,'')
  return paste
end

.recent(opts = {}, &block) ⇒ Object

Returns the list of all recent pastes on NoPaste. See Recent.get.


12
13
14
# File 'lib/rpaste/nopaste/nopaste.rb', line 12

def NoPaste.recent(opts={},&block)
  Recent.get(opts,&block)
end