Module: RPaste::PasteBin
- Defined in:
- lib/rpaste/pastebin/recent.rb,
lib/rpaste/pastebin/metadata.rb,
lib/rpaste/pastebin/pastebin.rb
Defined Under Namespace
Class Method Summary collapse
-
.post(opts = {}, &block) ⇒ Object
Submits a new paste to PasteBin.
-
.recent(opts = {}, &block) ⇒ Object
Returns the list of all recent pastes on PasteBin.
Class Method Details
.post(opts = {}, &block) ⇒ Object
Submits a new paste to PasteBin. If a block is given, then it will be passed the Paste object before it is submitted to PasteBin.
PasteBin.post(:author => 'xyz') do |paste|
paste.description = 'test'
paste.text = %{
<?xml version="1.0" ?>
<test>
<x>1</x>
<y>0</y>
</test>
}
end
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rpaste/pastebin/pastebin.rb', line 31 def PasteBin.post(opts={},&block) paste = Paste.new(opts,&block) agent = RPaste.http_agent(opts) page = agent.get('http://pastebin.com/pastebin.php') form = page.forms.first form.format = paste.syntax if paste.syntax form.code2 = paste.text form.poster = paste. if paste. case paste.retained when :day then form.expire = 'd' when :month form.expire = 'm' when :forever form.expire = 'f' end agent.submit(form) return true end |