Class: C11n::Importer::GoogleDrive

Inherits:
Object
  • Object
show all
Defined in:
lib/c11n/importer/google_drive.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ GoogleDrive

Returns a new instance of GoogleDrive.



7
8
9
# File 'lib/c11n/importer/google_drive.rb', line 7

def initialize(options = {})
  @driver = C11n::External::GoogleDriveDriver.new(options)
end

Instance Method Details

#categoriesObject



27
28
29
# File 'lib/c11n/importer/google_drive.rb', line 27

def categories
  {}
end

#importObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/c11n/importer/google_drive.rb', line 15

def import
  deserialized = {}

  table.to_hash.each do |locale, translations|
    deserialized[locale] = translations.inject({}) do |result, key_and_translation|
      result.merge key_and_translation.first => deserialize(key_and_translation.last, types[key_and_translation.first])
    end
  end

  deserialized
end

#tableObject



11
12
13
# File 'lib/c11n/importer/google_drive.rb', line 11

def table
  @table ||= C11n::Table.new(@driver.table)
end

#typesObject



31
32
33
# File 'lib/c11n/importer/google_drive.rb', line 31

def types
  table.types
end