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.



5
6
7
8
# File 'lib/transync/sync/init.rb', line 5

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

Instance Method Details

#runObject



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

def run
  @config['FILES'].each do |file|
    worksheet = TransyncConfig.worksheets.detect{ |s| s.title == file }
    if worksheet.nil?
      worksheet = TransyncConfig.spreadsheet.add_worksheet(file)
      puts "\u{2713} adding '#{file}' worksheet to spreadsheet with first row (key and languages)".colorize(:green)
    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.re_init
  sync = TranslationSync.new(@path, 'x2g')
  sync.run('x2g')
end