Class: Pixab::LocalizationSmartcatMerge

Inherits:
Object
  • Object
show all
Defined in:
lib/LocalizationSmartcatMerge.rb

Instance Method Summary collapse

Instance Method Details

#run(commands = nil) ⇒ Object



9
10
11
12
13
14
15
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
43
# File 'lib/LocalizationSmartcatMerge.rb', line 9

def run(commands=nil)
  download_params = []
  import_params = ["--delete-file-after-import"]
  commands.each_index do |index|
    command = commands[index]

    unless command.start_with?("--")
      next
    end

    if command == "--ab"
      download_params += ["--output", "{LANGUAGE}.json", "--tags", "ab"]
      import_params.push("--ab")
      next
    end

    if command == "--abtest"
      download_params += ["--output", "{LANGUAGE}.json", "--tags", "merge_test"]
      import_params.push("--abtest")
      next
    end

    if command.start_with?("--to-")
      import_params.push(command.sub("--to-", "--"))
      import_params.push(commands[index + 1])
    else
      download_params.push(command)
      download_params.push(commands[index + 1])
    end

  end

  LocalizationSmartcat.new.run(download_params)
  LocalizationSmartcatImport.new.run(import_params)
end