Module: TransyncConfig

Defined in:
lib/transync/transync_config.rb

Constant Summary collapse

WORKSHEET_COLUMNS =

Result of WORKSHEET_COLUMNS should be something like this depends on LANGUAGES set in settings yaml file WORKSHEET_COLUMNS = { key: 1, en: 2, de: 3 }

{ key: 1 }
START_ROW =
2

Class Method Summary collapse

Class Method Details

.init_spreadsheetObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/transync/transync_config.rb', line 16

def self.init_spreadsheet
  # Authorizes with OAuth and gets an access token.
  client             = Google::APIClient.new(
    application_name: 'Transync',
    application_version: Transync::VERSION
  )
  auth               = client.authorization
  auth.client_id     = CONFIG['GDOC']['client_id'] # "YOUR CLIENT ID"
  auth.client_secret = CONFIG['GDOC']['client_secret'] # "YOUR CLIENT SECRET"
  auth.scope = [
      'https://www.googleapis.com/auth/drive',
      'https://spreadsheets.google.com/feeds/'
  ]
  auth.redirect_uri = 'urn:ietf:wg:oauth:2.0:oob'
  print("1. Open this page:\n%s\n\n" % auth.authorization_uri)
  print('2. Enter the authorization code shown in the page: ')
  auth.code = $stdin.gets.chomp
  auth.fetch_access_token!
  access_token = auth.access_token

  # session     = GoogleDrive.login_with_oauth(CONFIG['GDOC']['email'], CONFIG['GDOC']['password'])
  session     = GoogleDrive.(access_token)
  spreadsheet = session.spreadsheet_by_key(CONFIG['GDOC']['key'])
  worksheets  = spreadsheet.worksheets

  return spreadsheet, worksheets
end

.re_initObject

used for init command after we create new tabs



61
62
63
# File 'lib/transync/transync_config.rb', line 61

def self.re_init
  @spreadsheet, @worksheets = TransyncConfig.init_spreadsheet
end

.spreadsheetObject



69
70
71
# File 'lib/transync/transync_config.rb', line 69

def self.spreadsheet
  @spreadsheet
end

.worksheetsObject



65
66
67
# File 'lib/transync/transync_config.rb', line 65

def self.worksheets
  @worksheets
end