Module: Lexdrill::Remote
- Defined in:
- lib/lexdrill/remote.rb
Overview
Global "which Google Sheet to export to via a service account" setting.
Stored as a plain spreadsheet id, parsed out of a normal Google Sheets
share URL. Set via drill remote <url> — the user shares that
spreadsheet with their service account's email directly in Google
Sheets, so no interactive Google sign-in is needed at export/import time.
See Lexdrill::OauthRemote for the separate, personal-login-based flow.
Constant Summary collapse
Class Method Summary collapse
Class Method Details
.configured? ⇒ Boolean
24 25 26 |
# File 'lib/lexdrill/remote.rb', line 24 def self.configured? File.exist?(PATH) end |
.extract_id(url) ⇒ Object
20 21 22 |
# File 'lib/lexdrill/remote.rb', line 20 def self.extract_id(url) url[URL_PATTERN, 1] end |
.set(url) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/lexdrill/remote.rb', line 13 def self.set(url) id = extract_id(url) raise ArgumentError, "no spreadsheet id found in #{url.inspect}" unless id File.write(PATH, id) end |
.spreadsheet_id ⇒ Object
28 29 30 |
# File 'lib/lexdrill/remote.rb', line 28 def self.spreadsheet_id File.read(PATH).strip if configured? end |