Sha256: 4e721108938acee630b996a937ab0c15f685dc397163642edac6ffb0cdf8a0f6

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Ubiquitously
  module Queness
    class Account < Ubiquitously::Service::Account
      def login
        page = agent.get("http://www.queness.com/")
        form = page.form_with(:action => "http://www.queness.com/login.php")
        form["login[username]"] = username
        form["login[password]"] = password
        form.checkboxes.first.check
        page = form.submit

        authorize!(page.parser.css(".error").text !~ /Incorrect/i)
      end
    end
    
    class Post < Ubiquitously::Service::Post
      def create
        page = agent.get("http://www.queness.com/post")
        form = page.forms.detect { |form| !form.form_node.css(".postform").first.nil? }
        
        form["form[title]"] = token[:title]
        form["form[description]"] = token[:description]
        form["form[url]"] = token[:url]
        # 1-4 tags
        form.checkboxes_with(:name => "tags[]").each do |box|
          case box.value.to_s
          when "1", "12", "11", "3"
            box.check
          end
        end
        
        page = form.submit
        
        true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ubiquitously-0.1.0 lib/ubiquitously/services/queness.rb