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
Constant Summary collapse
- POST_URL =
The NoPaste post URL
'http://rafb.net/paste/index.html'
Class Method Summary collapse
-
.paste(name) ⇒ Object
Retrieves the NoPaste Paste object associated with the specified name.
-
.post(options = {}, &block) ⇒ Object
Submits a new paste to NoPaste with the specified options.
-
.recent(&block) ⇒ Object
Returns the list of all recent pastes on NoPaste.
Class Method Details
.paste(name) ⇒ Object
Retrieves the NoPaste Paste object associated with the specified name. See Paste.paste.
23 24 25 |
# File 'lib/rpaste/nopaste/nopaste.rb', line 23 def NoPaste.paste(name) Paste.paste(name) end |
.post(options = {}, &block) ⇒ Object
Submits a new paste to NoPaste with the specified options. If a block is given, then it will be passed the Paste object before it is submitted to NoPaste.
options may contain the following keys:
:author
-
The author of the paste.
:syntax
-
The syntax of the paste.
:description
-
The description for the paste.
:text
-
The text to paste.
:convert_tabs
-
Indicates that tabs will be converted to spaces.
NoPaste.post(:author => 'briefcase man') do |paste|
paste.description = 'todays key'
paste.text = 'is brought to you by the letter S, for symmetric'
end
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rpaste/nopaste/nopaste.rb', line 45 def NoPaste.post(={},&block) = [:author] syntax = [:syntax] description = [:description] text = [:text] paste = Paste.new(nil,,nil,syntax,description,text,&block) agent = RPaste.web_agent page = agent.get(POST_URL) form = page.forms.first form.lang = paste.syntax if paste.syntax form.nick = paste. if paste. form.desc = paste.description if paste.description if [:convert_tabs] form.cvt_tabs = [: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 |