Class: Pixab::SmartcatBatch

Inherits:
Object
  • Object
show all
Defined in:
lib/localization/smartcat/SmartcatBatch.rb

Instance Method Summary collapse

Instance Method Details

#is_skipped_collection(collection) ⇒ Object

判断合集后缀为-debug, -ongoing, -bug时。忽略此合集拉取



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/localization/smartcat/SmartcatBatch.rb', line 32

def is_skipped_collection(collection)
  if collection.nil?
    return true
  end

  if collection.end_with?('-debug', '-ongoing', '-bug')
    return true
  end

  return false
end

#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
# File 'lib/localization/smartcat/SmartcatBatch.rb', line 9

def run(commands = nil)
  collections = Pixab::SmartcatCollections.collections
  if collections.nil?
    puts "Collections为空".red
    return
  end

  smartcat = Pixab::LocalizationSmartcat.new
  new_commands = commands.nil? ? [] : commands
  collections.each_with_index do |collection, index|
    if is_skipped_collection(collection)
      next
    end

    new_commands.push('--collections', collection)
    if index > 0
      new_commands.push('--mode', 'a')
    end
    smartcat.run(new_commands)
  end
end