Sha256: 630b81925873cf94c8889bdfe021d60ab52afba639c6fa4901f83060a645f096

Contents?: true

Size: 619 Bytes

Versions: 1

Compression:

Stored size: 619 Bytes

Contents

require 'google_drive'
require 'config'

module I18n
  module Migrations
    class GoogleSpreadsheet
      attr_reader :sheet

      def initialize(locale)
        @session = GoogleDrive::Session.from_service_account_key(Config.google_service_account_key_path)

        url = Config.google_spreadsheets[locale] || raise("Can't find google spreadsheet for #{locale}")
        @spreadsheet = @session.spreadsheet_by_url(url)
        @sheet = sheet_for("Sheet1")
      end

      def sheet_for(name)
        @spreadsheet.worksheet_by_title(name) || raise("couldn't find worksheet for #{name}")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i18n-migrations-0.1.1 lib/i18n/migrations/google_spreadsheet.rb