Class: Init

Inherits:
Object
  • Object
show all
Defined in:
lib/transync/sync/init.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Init

Returns a new instance of Init.



3
4
5
6
# File 'lib/transync/sync/init.rb', line 3

def initialize(path)
  @path   = path
  @config = TransyncConfig::CONFIG
end

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/transync/sync/init.rb', line 8

def run
  @config['FILES'].each do |file|
    worksheet = TransyncConfig::WORKSHEETS.detect{ |s| s.title == file }
    if worksheet.nil?
      worksheet = TransyncConfig::SPREADSHEET.add_worksheet(file)
      p "Adding #{file} worksheet to spreadsheet with first row (key and languages)"
    end

    worksheet[1, 1] = 'Key'
    @config['LANGUAGES'].each_with_index do |language, index|
      worksheet[1, index + 2] = language.upcase
    end
    worksheet.save
  end

  # re-init spreadsheet after new worksheets were created
  TransyncConfig.init_spreadsheet
  sync = TranslationSync.new(@path, 'x2g')
  sync.run('x2g')
end