Sha256: 8f51dd0a0eb9e2bec7640abcd3add54d8aa0ea3cc346b21b104ebd7f80db4b54

Contents?: true

Size: 488 Bytes

Versions: 4

Compression:

Stored size: 488 Bytes

Contents

module Niconico
  class Fabric
    attr_reader :agent

    def initialize(agent=nil)
      @agent = agent || Mechanize.new
      @agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
    end

    def sign_in(email, password)
      @agent.post(
        "https://secure.nicovideo.jp/secure/login?site=niconico",
        "mail" => email,
        "password" => password
      )
      return self
    end

    def signed_in?
      @agent.cookies.any? {|c| c.name == 'user_session'}
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nv-1.2.2 lib/nv/niconico/fabric.rb
nv-1.2.1 lib/nv/niconico/fabric.rb
nv-1.0.1 lib/nv/niconico/fabric.rb
nv-1.0.0 lib/nv/niconico/fabric.rb