Module: VkMusic::Utility::Authorizer

Defined in:
lib/vk_music/utility/authorizer.rb

Overview

Creates authorized client based of cookies file or ENV variables

Class Method Summary collapse

Class Method Details

.call(login, password, cookie_path) ⇒ Mechanize

Returns logged in Mechanize client.

Parameters:

  • cookie_path (string)

Returns:

  • (Mechanize)

    logged in Mechanize client



10
11
12
13
14
15
16
17
18
19
# File 'lib/vk_music/utility/authorizer.rb', line 10

def call(, password, cookie_path)
  agent = Mechanize.new
  if File.exist?(cookie_path)
    load_cookie_jar(agent.cookie_jar, cookie_path)
  else
    (agent, , password)
  end
  agent.cookie_jar.save(cookie_path, session: true)
  agent
end