Module: AtCoderFriends::Scraping::Session

Included in:
Agent
Defined in:
lib/at_coder_friends/scraping/session.rb

Overview

session management for scraping

Constant Summary collapse

SESSION_STORE_FMT =
File.join(
  Dir.home, '.at_coder_friends', '%<user>s_session.yml'
)

Instance Method Summary collapse

Instance Method Details

#load_sessionObject



11
12
13
# File 'lib/at_coder_friends/scraping/session.rb', line 11

def load_session
  agent.cookie_jar.load(session_store) if File.exist?(session_store)
end

#save_sessionObject



15
16
17
18
19
# File 'lib/at_coder_friends/scraping/session.rb', line 15

def save_session
  dir = File.dirname(session_store)
  FileUtils.mkdir_p(dir)
  agent.cookie_jar.save_as(session_store)
end

#session_storeObject



21
22
23
# File 'lib/at_coder_friends/scraping/session.rb', line 21

def session_store
  @session_store ||= format(SESSION_STORE_FMT, user: ctx.config['user'])
end