Class: Acclir::AtCoder::Connection
- Inherits:
-
Object
- Object
- Acclir::AtCoder::Connection
- Defined in:
- lib/acclir/at_coder/connection.rb
Overview
Communication with AtCoder
Constant Summary collapse
- ATCODER_ROOT_URL =
"https://atcoder.jp"
- COOKIE_JAR_FILE_PATH =
"/tmp/acclir_cookie.yml"
Class Method Summary collapse
Class Method Details
.connection ⇒ Object
11 12 13 14 15 16 |
# File 'lib/acclir/at_coder/connection.rb', line 11 def connection @connection ||= Faraday.new(url: ATCODER_ROOT_URL) do |faraday| faraday.use :cookie_jar, jar: faraday.response :raise_error end end |
.get(path, &block) ⇒ Object
18 19 20 |
# File 'lib/acclir/at_coder/connection.rb', line 18 def get(path, &block) connection.get(path, &block) end |
.post(path, save_cookie: false, &block) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/acclir/at_coder/connection.rb', line 22 def post(path, save_cookie: false, &block) FileUtils.rm(COOKIE_JAR_FILE_PATH) if connection.post(path, &block).tap do if end end |