Class: Hackershout::Provider::Reddit

Inherits:
Base
  • Object
show all
Defined in:
lib/hackershout/provider/reddit.rb

Constant Summary collapse

URL =
{
  :login => 'http://www.reddit.com/r/ruby/',
  :submit => 'http://www.reddit.com/r/ruby/submit',
}

Instance Attribute Summary

Attributes inherited from Base

#agent

Instance Method Summary collapse

Methods inherited from Base

#initialize, #publish

Methods included from Output

#blank, #print

Constructor Details

This class inherits a constructor from Hackershout::Provider::Base

Instance Method Details

#postObject

Not logging in! :(



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hackershout/provider/reddit.rb', line 11

def post
  raise NotImplementedError
  page = agent.get(URL[:login])
   = page.forms_with(:action => 'http://www.reddit.com/r/ruby/post/login').first
  .user = @login
  .passwd = @password
  page = .submit
  puts page.links_with(:text => 'logout').inspect
  page = page.links_with(:text => 'Submit a link').first.click
  puts page.inspect

rescue Mechanize::ResponseCodeError=>e
  puts "#{@name} is unavailable for now. Please try in a few minutes. The server gave the following reason:"
  puts e.inspect
end