web_translate_it 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/history.md +5 -0
 - data/lib/web_translate_it/command_line.rb +10 -13
 - data/lib/web_translate_it/configuration.rb +2 -4
 - data/lib/web_translate_it/connection.rb +19 -30
 - data/lib/web_translate_it/project.rb +6 -5
 - data/lib/web_translate_it/string.rb +7 -7
 - data/lib/web_translate_it/term.rb +7 -7
 - data/lib/web_translate_it/term_translation.rb +2 -2
 - data/lib/web_translate_it/translation.rb +1 -1
 - data/lib/web_translate_it/translation_file.rb +11 -11
 - data/lib/web_translate_it/util/array_util.rb +1 -1
 - data/lib/web_translate_it/util.rb +4 -4
 - data/lib/web_translate_it.rb +2 -0
 - data/readme.md +7 -7
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 48cb64ddfb593274e4eefbca5fde69d8ee35a1fc3c7d1776ef0fc094a64d7db5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 684e5a256509281d8d2913c4c14aa5d6c9757ef0cce6c9edb00f8d5f84bb90df
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: cb75b3f71b20995afb60038a39ce148d92d9b2abd15074a076e9abe14a04d4f0d171e89d75ce864272fa4d6d1ddce62ac5359dcdbf492bc9b10f8931247665ca
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 28cbdd2751c994a285d71d3eee33141b2d0011a79e469375fc28d05da45d775a9e8d31e8b7de3b60b84043e18a0e603b4bfd493cc49e73da54774f1d8cc5a4bd
         
     | 
    
        data/history.md
    CHANGED
    
    | 
         @@ -1,3 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## Version 2.6.1 / 2022-03-09
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * Display error message for `before_pull`, `after_pull`, `before_push`, `after_push` hooks.
         
     | 
| 
      
 4 
     | 
    
         
            +
            * Remove `silence_errors` option in configuration file. If SSL isn’t properly configured, it needs to be fixed by updating your cert chain.
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       1 
6 
     | 
    
         
             
            ## Version 2.6.0 / 2022-03-08
         
     | 
| 
       2 
7 
     | 
    
         | 
| 
       3 
8 
     | 
    
         
             
            * Code cleaning using Rubocop.
         
     | 
| 
         @@ -51,7 +51,7 @@ module WebTranslateIt 
     | 
|
| 
       51 
51 
     | 
    
         
             
                  end
         
     | 
| 
       52 
52 
     | 
    
         
             
                  files = found_files if parameters.any?
         
     | 
| 
       53 
53 
     | 
    
         
             
                  files = files.uniq.sort { |a, b| a.file_path <=> b.file_path }
         
     | 
| 
       54 
     | 
    
         
            -
                  if files. 
     | 
| 
      
 54 
     | 
    
         
            +
                  if files.empty?
         
     | 
| 
       55 
55 
     | 
    
         
             
                    puts 'No files to pull.'
         
     | 
| 
       56 
56 
     | 
    
         
             
                  else
         
     | 
| 
       57 
57 
     | 
    
         
             
                    # Now actually pulling files
         
     | 
| 
         @@ -82,10 +82,10 @@ module WebTranslateIt 
     | 
|
| 
       82 
82 
     | 
    
         
             
                  return unless configuration.before_pull
         
     | 
| 
       83 
83 
     | 
    
         | 
| 
       84 
84 
     | 
    
         
             
                  output = `#{configuration.before_pull}`
         
     | 
| 
       85 
     | 
    
         
            -
                  if  
     | 
| 
      
 85 
     | 
    
         
            +
                  if $CHILD_STATUS.success?
         
     | 
| 
       86 
86 
     | 
    
         
             
                    puts output
         
     | 
| 
       87 
87 
     | 
    
         
             
                  else
         
     | 
| 
       88 
     | 
    
         
            -
                    abort  
     | 
| 
      
 88 
     | 
    
         
            +
                    abort "Error: before_pull command exited with: #{output}"
         
     | 
| 
       89 
89 
     | 
    
         
             
                  end
         
     | 
| 
       90 
90 
     | 
    
         
             
                end
         
     | 
| 
       91 
91 
     | 
    
         | 
| 
         @@ -93,10 +93,10 @@ module WebTranslateIt 
     | 
|
| 
       93 
93 
     | 
    
         
             
                  return unless configuration.after_pull
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
                  output = `#{configuration.after_pull}`
         
     | 
| 
       96 
     | 
    
         
            -
                  if  
     | 
| 
      
 96 
     | 
    
         
            +
                  if $CHILD_STATUS.success?
         
     | 
| 
       97 
97 
     | 
    
         
             
                    puts output
         
     | 
| 
       98 
98 
     | 
    
         
             
                  else
         
     | 
| 
       99 
     | 
    
         
            -
                    abort  
     | 
| 
      
 99 
     | 
    
         
            +
                    abort "Error: after_pull command exited with: #{output}"
         
     | 
| 
       100 
100 
     | 
    
         
             
                  end
         
     | 
| 
       101 
101 
     | 
    
         
             
                end
         
     | 
| 
       102 
102 
     | 
    
         | 
| 
         @@ -111,7 +111,7 @@ module WebTranslateIt 
     | 
|
| 
       111 
111 
     | 
    
         
             
                              else
         
     | 
| 
       112 
112 
     | 
    
         
             
                                configuration.files.find_all { |file| file.locale == locale }.sort { |a, b| a.file_path <=> b.file_path }
         
     | 
| 
       113 
113 
     | 
    
         
             
                              end
         
     | 
| 
       114 
     | 
    
         
            -
                      if files. 
     | 
| 
      
 114 
     | 
    
         
            +
                      if files.empty?
         
     | 
| 
       115 
115 
     | 
    
         
             
                        puts "Couldn't find any local files registered on WebTranslateIt to push."
         
     | 
| 
       116 
116 
     | 
    
         
             
                      else
         
     | 
| 
       117 
117 
     | 
    
         
             
                        files.each do |file|
         
     | 
| 
         @@ -129,10 +129,10 @@ module WebTranslateIt 
     | 
|
| 
       129 
129 
     | 
    
         
             
                  return unless configuration.before_push
         
     | 
| 
       130 
130 
     | 
    
         | 
| 
       131 
131 
     | 
    
         
             
                  output = `#{configuration.before_push}`
         
     | 
| 
       132 
     | 
    
         
            -
                  if  
     | 
| 
      
 132 
     | 
    
         
            +
                  if $CHILD_STATUS.success?
         
     | 
| 
       133 
133 
     | 
    
         
             
                    puts output
         
     | 
| 
       134 
134 
     | 
    
         
             
                  else
         
     | 
| 
       135 
     | 
    
         
            -
                    abort  
     | 
| 
      
 135 
     | 
    
         
            +
                    abort "Error: before_push command exited with: #{output}"
         
     | 
| 
       136 
136 
     | 
    
         
             
                  end
         
     | 
| 
       137 
137 
     | 
    
         
             
                end
         
     | 
| 
       138 
138 
     | 
    
         | 
| 
         @@ -140,10 +140,10 @@ module WebTranslateIt 
     | 
|
| 
       140 
140 
     | 
    
         
             
                  return unless configuration.after_push
         
     | 
| 
       141 
141 
     | 
    
         | 
| 
       142 
142 
     | 
    
         
             
                  output = `#{configuration.after_push}`
         
     | 
| 
       143 
     | 
    
         
            -
                  if  
     | 
| 
      
 143 
     | 
    
         
            +
                  if $CHILD_STATUS.success?
         
     | 
| 
       144 
144 
     | 
    
         
             
                    puts output
         
     | 
| 
       145 
145 
     | 
    
         
             
                  else
         
     | 
| 
       146 
     | 
    
         
            -
                    abort  
     | 
| 
      
 146 
     | 
    
         
            +
                    abort "Error: after_push command exited with: #{output}"
         
     | 
| 
       147 
147 
     | 
    
         
             
                  end
         
     | 
| 
       148 
148 
     | 
    
         
             
                end
         
     | 
| 
       149 
149 
     | 
    
         | 
| 
         @@ -435,9 +435,6 @@ module WebTranslateIt 
     | 
|
| 
       435 
435 
     | 
    
         
             
                    # before_push: "echo 'some unix command'"   # Command executed before pushing files
         
     | 
| 
       436 
436 
     | 
    
         
             
                    # after_push:  "touch tmp/restart.txt"      # Command executed after pushing files
         
     | 
| 
       437 
437 
     | 
    
         | 
| 
       438 
     | 
    
         
            -
                    # Silence SSL errors
         
     | 
| 
       439 
     | 
    
         
            -
                    # silence_errors: true
         
     | 
| 
       440 
     | 
    
         
            -
             
     | 
| 
       441 
438 
     | 
    
         
             
                  FILE
         
     | 
| 
       442 
439 
     | 
    
         
             
                end
         
     | 
| 
       443 
440 
     | 
    
         | 
| 
         @@ -32,7 +32,6 @@ module WebTranslateIt 
     | 
|
| 
       32 
32 
     | 
    
         
             
                    set_locales_needed(configuration)
         
     | 
| 
       33 
33 
     | 
    
         
             
                    set_files(project_info['project'])
         
     | 
| 
       34 
34 
     | 
    
         
             
                    set_locales(project_info['project'])
         
     | 
| 
       35 
     | 
    
         
            -
                    WebTranslateIt::Connection.turn_silent_on if configuration['silence_errors']
         
     | 
| 
       36 
35 
     | 
    
         
             
                    self.project_name = project_info['project']['name']
         
     | 
| 
       37 
36 
     | 
    
         
             
                  else
         
     | 
| 
       38 
37 
     | 
    
         
             
                    puts StringUtil.failure("\nNo configuration file found in #{File.expand_path(path_to_config_file, path)}")
         
     | 
| 
         @@ -42,13 +41,12 @@ module WebTranslateIt 
     | 
|
| 
       42 
41 
     | 
    
         | 
| 
       43 
42 
     | 
    
         
             
                # Reload project data
         
     | 
| 
       44 
43 
     | 
    
         
             
                #
         
     | 
| 
       45 
     | 
    
         
            -
                def reload 
     | 
| 
      
 44 
     | 
    
         
            +
                def reload
         
     | 
| 
       46 
45 
     | 
    
         
             
                  project_info = YAML.load WebTranslateIt::Project.fetch_info(api_key)
         
     | 
| 
       47 
46 
     | 
    
         
             
                  set_locales_to_ignore(configuration)
         
     | 
| 
       48 
47 
     | 
    
         
             
                  set_locales_needed(configuration)
         
     | 
| 
       49 
48 
     | 
    
         
             
                  set_files(project_info['project'])
         
     | 
| 
       50 
49 
     | 
    
         
             
                  set_locales(project_info['project'])
         
     | 
| 
       51 
     | 
    
         
            -
                  WebTranslateIt::Connection.turn_silent_on if configuration['silence_errors']
         
     | 
| 
       52 
50 
     | 
    
         
             
                  self.project_name = project_info['project']['name']
         
     | 
| 
       53 
51 
     | 
    
         
             
                end
         
     | 
| 
       54 
52 
     | 
    
         | 
| 
         @@ -70,7 +68,7 @@ module WebTranslateIt 
     | 
|
| 
       70 
68 
     | 
    
         
             
                def set_files(project) # rubocop:todo Metrics/AbcSize
         
     | 
| 
       71 
69 
     | 
    
         
             
                  self.files = []
         
     | 
| 
       72 
70 
     | 
    
         
             
                  project['project_files'].each do |project_file|
         
     | 
| 
       73 
     | 
    
         
            -
                    if project_file['name'].nil?  
     | 
| 
      
 71 
     | 
    
         
            +
                    if project_file['name'].nil? || (project_file['name'].strip == '')
         
     | 
| 
       74 
72 
     | 
    
         
             
                      puts "File #{project_file['id']} not set up"
         
     | 
| 
       75 
73 
     | 
    
         
             
                    elsif ignore_files&.any? { |glob| File.fnmatch(glob, project_file['name']) }
         
     | 
| 
       76 
74 
     | 
    
         
             
                      puts "Ignoring #{project_file['name']}"
         
     | 
| 
         @@ -1,15 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'English'
         
     | 
| 
       1 
2 
     | 
    
         
             
            module WebTranslateIt
         
     | 
| 
       2 
3 
     | 
    
         
             
              class Connection
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_reader :api_key, :http_connection
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       3 
6 
     | 
    
         
             
                require 'net/http'
         
     | 
| 
       4 
7 
     | 
    
         
             
                require 'net/https'
         
     | 
| 
       5 
8 
     | 
    
         
             
                require 'openssl'
         
     | 
| 
       6 
9 
     | 
    
         
             
                require 'uri'
         
     | 
| 
       7 
     | 
    
         
            -
                require 'ostruct'
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
       12 
     | 
    
         
            -
                @@silent = false
         
     | 
| 
      
 11 
     | 
    
         
            +
                @api_key = nil
         
     | 
| 
      
 12 
     | 
    
         
            +
                @http_connection = nil
         
     | 
| 
      
 13 
     | 
    
         
            +
                @debug = false
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
15 
     | 
    
         
             
                #
         
     | 
| 
       15 
16 
     | 
    
         
             
                # Initialize and yield a HTTPS Keep-Alive connection to WebTranslateIt.com
         
     | 
| 
         @@ -27,44 +28,32 @@ module WebTranslateIt 
     | 
|
| 
       27 
28 
     | 
    
         
             
                # end
         
     | 
| 
       28 
29 
     | 
    
         
             
                #
         
     | 
| 
       29 
30 
     | 
    
         
             
                def initialize(api_key) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
         
     | 
| 
       30 
     | 
    
         
            -
                   
     | 
| 
       31 
     | 
    
         
            -
                  proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) :  
     | 
| 
      
 31 
     | 
    
         
            +
                  @api_key = api_key
         
     | 
| 
      
 32 
     | 
    
         
            +
                  proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : Struct.new(:host, :port, :user, :password).new
         
     | 
| 
       32 
33 
     | 
    
         
             
                  http = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new('webtranslateit.com', 443)
         
     | 
| 
       33 
34 
     | 
    
         
             
                  http.use_ssl      = true
         
     | 
| 
       34 
35 
     | 
    
         
             
                  http.open_timeout = http.read_timeout = 60
         
     | 
| 
       35 
     | 
    
         
            -
                  http.set_debug_output($stderr) if  
     | 
| 
      
 36 
     | 
    
         
            +
                  http.set_debug_output($stderr) if @debug
         
     | 
| 
       36 
37 
     | 
    
         
             
                  begin
         
     | 
| 
       37 
     | 
    
         
            -
                    http.verify_mode 
     | 
| 
       38 
     | 
    
         
            -
                     
     | 
| 
       39 
     | 
    
         
            -
                    yield  
     | 
| 
      
 38 
     | 
    
         
            +
                    http.verify_mode = OpenSSL::SSL::VERIFY_PEER
         
     | 
| 
      
 39 
     | 
    
         
            +
                    @http_connection = http.start
         
     | 
| 
      
 40 
     | 
    
         
            +
                    yield @http_connection if block_given?
         
     | 
| 
       40 
41 
     | 
    
         
             
                  rescue OpenSSL::SSL::SSLError
         
     | 
| 
       41 
     | 
    
         
            -
                    puts 'Unable to verify SSL certificate.' unless  
     | 
| 
      
 42 
     | 
    
         
            +
                    puts 'Unable to verify SSL certificate.' unless @silent
         
     | 
| 
       42 
43 
     | 
    
         
             
                    http = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new('webtranslateit.com', 443)
         
     | 
| 
       43 
     | 
    
         
            -
                    http.set_debug_output($stderr) if  
     | 
| 
      
 44 
     | 
    
         
            +
                    http.set_debug_output($stderr) if @debug
         
     | 
| 
       44 
45 
     | 
    
         
             
                    http.use_ssl      = true
         
     | 
| 
       45 
46 
     | 
    
         
             
                    http.open_timeout = http.read_timeout = 60
         
     | 
| 
       46 
     | 
    
         
            -
                    http.verify_mode 
     | 
| 
       47 
     | 
    
         
            -
                     
     | 
| 
       48 
     | 
    
         
            -
                    yield  
     | 
| 
      
 47 
     | 
    
         
            +
                    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
         
     | 
| 
      
 48 
     | 
    
         
            +
                    @http_connection = http.start
         
     | 
| 
      
 49 
     | 
    
         
            +
                    yield @http_connection if block_given?
         
     | 
| 
       49 
50 
     | 
    
         
             
                  rescue
         
     | 
| 
       50 
     | 
    
         
            -
                    puts  
     | 
| 
      
 51 
     | 
    
         
            +
                    puts $ERROR_INFO
         
     | 
| 
       51 
52 
     | 
    
         
             
                  end
         
     | 
| 
       52 
53 
     | 
    
         
             
                end
         
     | 
| 
       53 
54 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
                def self.http_connection
         
     | 
| 
       55 
     | 
    
         
            -
                  @@http_connection
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
55 
     | 
    
         
             
                def self.turn_debug_on
         
     | 
| 
       59 
     | 
    
         
            -
                   
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                def self.turn_silent_on
         
     | 
| 
       63 
     | 
    
         
            -
                  @@silent = true
         
     | 
| 
       64 
     | 
    
         
            -
                end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                def self.api_key
         
     | 
| 
       67 
     | 
    
         
            -
                  @@api_key
         
     | 
| 
      
 56 
     | 
    
         
            +
                  @debug = true
         
     | 
| 
       68 
57 
     | 
    
         
             
                end
         
     | 
| 
       69 
58 
     | 
    
         
             
              end
         
     | 
| 
       70 
59 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,3 +1,4 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'English'
         
     | 
| 
       1 
2 
     | 
    
         
             
            module WebTranslateIt
         
     | 
| 
       2 
3 
     | 
    
         
             
              class Project
         
     | 
| 
       3 
4 
     | 
    
         
             
                def self.fetch_info(api_key) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
         
     | 
| 
         @@ -16,14 +17,14 @@ module WebTranslateIt 
     | 
|
| 
       16 
17 
     | 
    
         
             
                    end
         
     | 
| 
       17 
18 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       18 
19 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       19 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 20 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       20 
21 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       21 
22 
     | 
    
         
             
                      retry
         
     | 
| 
       22 
23 
     | 
    
         
             
                    else
         
     | 
| 
       23 
24 
     | 
    
         
             
                      success = false
         
     | 
| 
       24 
25 
     | 
    
         
             
                    end
         
     | 
| 
       25 
26 
     | 
    
         
             
                  rescue
         
     | 
| 
       26 
     | 
    
         
            -
                    puts  
     | 
| 
      
 27 
     | 
    
         
            +
                    puts $ERROR_INFO.inspect
         
     | 
| 
       27 
28 
     | 
    
         
             
                  end
         
     | 
| 
       28 
29 
     | 
    
         
             
                  success
         
     | 
| 
       29 
30 
     | 
    
         
             
                end
         
     | 
| 
         @@ -39,7 +40,7 @@ module WebTranslateIt 
     | 
|
| 
       39 
40 
     | 
    
         
             
                    end
         
     | 
| 
       40 
41 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       41 
42 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       42 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 43 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       43 
44 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       44 
45 
     | 
    
         
             
                      retry
         
     | 
| 
       45 
46 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -59,7 +60,7 @@ module WebTranslateIt 
     | 
|
| 
       59 
60 
     | 
    
         
             
                    Util.handle_response(Connection.http_connection.request(request), true)
         
     | 
| 
       60 
61 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       61 
62 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       62 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 63 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       63 
64 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       64 
65 
     | 
    
         
             
                      retry
         
     | 
| 
       65 
66 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -78,7 +79,7 @@ module WebTranslateIt 
     | 
|
| 
       78 
79 
     | 
    
         
             
                    Util.handle_response(Connection.http_connection.request(request), true)
         
     | 
| 
       79 
80 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       80 
81 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       81 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 82 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       82 
83 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       83 
84 
     | 
    
         
             
                      retry
         
     | 
| 
       84 
85 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -78,7 +78,7 @@ module WebTranslateIt 
     | 
|
| 
       78 
78 
     | 
    
         
             
                    return strings
         
     | 
| 
       79 
79 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       80 
80 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       81 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 81 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       82 
82 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       83 
83 
     | 
    
         
             
                      retry
         
     | 
| 
       84 
84 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -102,7 +102,7 @@ module WebTranslateIt 
     | 
|
| 
       102 
102 
     | 
    
         
             
                # to find and instantiate the String which ID is `1234`.
         
     | 
| 
       103 
103 
     | 
    
         
             
                #
         
     | 
| 
       104 
104 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
                def self.find(id) # rubocop:todo Metrics/MethodLength
         
     | 
| 
      
 105 
     | 
    
         
            +
                def self.find(id) # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
         
     | 
| 
       106 
106 
     | 
    
         
             
                  success = true
         
     | 
| 
       107 
107 
     | 
    
         
             
                  tries ||= 3
         
     | 
| 
       108 
108 
     | 
    
         
             
                  request = Net::HTTP::Get.new("/api/projects/#{Connection.api_key}/strings/#{id}.yaml")
         
     | 
| 
         @@ -116,7 +116,7 @@ module WebTranslateIt 
     | 
|
| 
       116 
116 
     | 
    
         
             
                    return string
         
     | 
| 
       117 
117 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       118 
118 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       119 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 119 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       120 
120 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       121 
121 
     | 
    
         
             
                      retry
         
     | 
| 
       122 
122 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -160,7 +160,7 @@ module WebTranslateIt 
     | 
|
| 
       160 
160 
     | 
    
         
             
                    Util.handle_response(Connection.http_connection.request(request), true, true)
         
     | 
| 
       161 
161 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       162 
162 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       163 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 163 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       164 
164 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       165 
165 
     | 
    
         
             
                      retry
         
     | 
| 
       166 
166 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -198,7 +198,7 @@ module WebTranslateIt 
     | 
|
| 
       198 
198 
     | 
    
         
             
                    return translation
         
     | 
| 
       199 
199 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       200 
200 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       201 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 201 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       202 
202 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       203 
203 
     | 
    
         
             
                      retry
         
     | 
| 
       204 
204 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -229,7 +229,7 @@ module WebTranslateIt 
     | 
|
| 
       229 
229 
     | 
    
         
             
                    Util.handle_response(Connection.http_connection.request(request), true, true)
         
     | 
| 
       230 
230 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       231 
231 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       232 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 232 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       233 
233 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       234 
234 
     | 
    
         
             
                      retry
         
     | 
| 
       235 
235 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -255,7 +255,7 @@ module WebTranslateIt 
     | 
|
| 
       255 
255 
     | 
    
         
             
                    return true
         
     | 
| 
       256 
256 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       257 
257 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       258 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 258 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       259 
259 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       260 
260 
     | 
    
         
             
                      retry
         
     | 
| 
       261 
261 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -69,7 +69,7 @@ module WebTranslateIt 
     | 
|
| 
       69 
69 
     | 
    
         
             
                    return terms
         
     | 
| 
       70 
70 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       71 
71 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       72 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 72 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       73 
73 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       74 
74 
     | 
    
         
             
                      retry
         
     | 
| 
       75 
75 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -93,7 +93,7 @@ module WebTranslateIt 
     | 
|
| 
       93 
93 
     | 
    
         
             
                # to find and instantiate the Term which ID is `1234`.
         
     | 
| 
       94 
94 
     | 
    
         
             
                #
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
                def self.find(term_id) # rubocop:todo Metrics/MethodLength
         
     | 
| 
      
 96 
     | 
    
         
            +
                def self.find(term_id) # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
         
     | 
| 
       97 
97 
     | 
    
         
             
                  success = true
         
     | 
| 
       98 
98 
     | 
    
         
             
                  tries ||= 3
         
     | 
| 
       99 
99 
     | 
    
         
             
                  request = Net::HTTP::Get.new("/api/projects/#{Connection.api_key}/terms/#{term_id}.yaml")
         
     | 
| 
         @@ -107,7 +107,7 @@ module WebTranslateIt 
     | 
|
| 
       107 
107 
     | 
    
         
             
                    return term
         
     | 
| 
       108 
108 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       109 
109 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       110 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 110 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       111 
111 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       112 
112 
     | 
    
         
             
                      retry
         
     | 
| 
       113 
113 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -151,7 +151,7 @@ module WebTranslateIt 
     | 
|
| 
       151 
151 
     | 
    
         
             
                    Util.handle_response(Connection.http_connection.request(request), true, true)
         
     | 
| 
       152 
152 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       153 
153 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       154 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 154 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       155 
155 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       156 
156 
     | 
    
         
             
                      retry
         
     | 
| 
       157 
157 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -193,7 +193,7 @@ module WebTranslateIt 
     | 
|
| 
       193 
193 
     | 
    
         
             
                    return translations
         
     | 
| 
       194 
194 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       195 
195 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       196 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 196 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       197 
197 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       198 
198 
     | 
    
         
             
                      retry
         
     | 
| 
       199 
199 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -221,7 +221,7 @@ module WebTranslateIt 
     | 
|
| 
       221 
221 
     | 
    
         
             
                    Util.handle_response(Connection.http_connection.request(request), true, true)
         
     | 
| 
       222 
222 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       223 
223 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       224 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 224 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       225 
225 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       226 
226 
     | 
    
         
             
                      retry
         
     | 
| 
       227 
227 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -245,7 +245,7 @@ module WebTranslateIt 
     | 
|
| 
       245 
245 
     | 
    
         
             
                    return true
         
     | 
| 
       246 
246 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       247 
247 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       248 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 248 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       249 
249 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       250 
250 
     | 
    
         
             
                      retry
         
     | 
| 
       251 
251 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -69,7 +69,7 @@ module WebTranslateIt 
     | 
|
| 
       69 
69 
     | 
    
         
             
                    return true
         
     | 
| 
       70 
70 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       71 
71 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       72 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 72 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       73 
73 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       74 
74 
     | 
    
         
             
                      retry
         
     | 
| 
       75 
75 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -89,7 +89,7 @@ module WebTranslateIt 
     | 
|
| 
       89 
89 
     | 
    
         
             
                    Util.handle_response(Connection.http_connection.request(request), true, true)
         
     | 
| 
       90 
90 
     | 
    
         
             
                  rescue Timeout::Error
         
     | 
| 
       91 
91 
     | 
    
         
             
                    puts 'Request timeout. Will retry in 5 seconds.'
         
     | 
| 
       92 
     | 
    
         
            -
                    if (tries -= 1) 
     | 
| 
      
 92 
     | 
    
         
            +
                    if (tries -= 1).positive?
         
     | 
| 
       93 
93 
     | 
    
         
             
                      sleep(5)
         
     | 
| 
       94 
94 
     | 
    
         
             
                      retry
         
     | 
| 
       95 
95 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -46,25 +46,25 @@ module WebTranslateIt 
     | 
|
| 
       46 
46 
     | 
    
         
             
                    display.push("*#{file_path}")
         
     | 
| 
       47 
47 
     | 
    
         
             
                  end
         
     | 
| 
       48 
48 
     | 
    
         
             
                  display.push "#{StringUtil.checksumify(local_checksum.to_s)}..#{StringUtil.checksumify(remote_checksum.to_s)}"
         
     | 
| 
       49 
     | 
    
         
            -
                  if !File.exist?(file_path)  
     | 
| 
      
 49 
     | 
    
         
            +
                  if !File.exist?(file_path) || force || (remote_checksum != local_checksum)
         
     | 
| 
       50 
50 
     | 
    
         
             
                    begin
         
     | 
| 
       51 
51 
     | 
    
         
             
                      request = Net::HTTP::Get.new(api_url)
         
     | 
| 
       52 
52 
     | 
    
         
             
                      WebTranslateIt::Util.add_fields(request)
         
     | 
| 
       53 
     | 
    
         
            -
                      FileUtils.mkpath(file_path.split('/')[0..-2].join('/')) unless File.exist?(file_path)  
     | 
| 
      
 53 
     | 
    
         
            +
                      FileUtils.mkpath(file_path.split('/')[0..-2].join('/')) unless File.exist?(file_path) || (file_path.split('/')[0..-2].join('/') == '')
         
     | 
| 
       54 
54 
     | 
    
         
             
                      begin
         
     | 
| 
       55 
55 
     | 
    
         
             
                        response = http_connection.request(request)
         
     | 
| 
       56 
56 
     | 
    
         
             
                        File.open(file_path, 'wb') { |file| file << response.body } if response.code.to_i == 200
         
     | 
| 
       57 
57 
     | 
    
         
             
                        display.push Util.handle_response(response)
         
     | 
| 
       58 
58 
     | 
    
         
             
                      rescue Timeout::Error
         
     | 
| 
       59 
59 
     | 
    
         
             
                        puts StringUtil.failure('Request timeout. Will retry in 5 seconds.')
         
     | 
| 
       60 
     | 
    
         
            -
                        if (tries -= 1) 
     | 
| 
      
 60 
     | 
    
         
            +
                        if (tries -= 1).positive?
         
     | 
| 
       61 
61 
     | 
    
         
             
                          sleep(5)
         
     | 
| 
       62 
62 
     | 
    
         
             
                          retry
         
     | 
| 
       63 
63 
     | 
    
         
             
                        else
         
     | 
| 
       64 
64 
     | 
    
         
             
                          success = false
         
     | 
| 
       65 
65 
     | 
    
         
             
                        end
         
     | 
| 
       66 
66 
     | 
    
         
             
                      rescue
         
     | 
| 
       67 
     | 
    
         
            -
                        display.push StringUtil.failure("An error occured: #{ 
     | 
| 
      
 67 
     | 
    
         
            +
                        display.push StringUtil.failure("An error occured: #{$ERROR_INFO}")
         
     | 
| 
       68 
68 
     | 
    
         
             
                        success = false
         
     | 
| 
       69 
69 
     | 
    
         
             
                      end
         
     | 
| 
       70 
70 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -97,7 +97,7 @@ module WebTranslateIt 
     | 
|
| 
       97 
97 
     | 
    
         
             
                  display.push(file_path)
         
     | 
| 
       98 
98 
     | 
    
         
             
                  display.push "#{StringUtil.checksumify(local_checksum.to_s)}..#{StringUtil.checksumify(remote_checksum.to_s)}"
         
     | 
| 
       99 
99 
     | 
    
         
             
                  if File.exist?(file_path)
         
     | 
| 
       100 
     | 
    
         
            -
                    if force  
     | 
| 
      
 100 
     | 
    
         
            +
                    if force || (remote_checksum != local_checksum)
         
     | 
| 
       101 
101 
     | 
    
         
             
                      File.open(file_path) do |file|
         
     | 
| 
       102 
102 
     | 
    
         
             
                        params = { 'file' => UploadIO.new(file, 'text/plain', file.path), 'merge' => merge, 'ignore_missing' => ignore_missing, 'label' => label, 'low_priority' => low_priority, 'minor_changes' => minor_changes }
         
     | 
| 
       103 
103 
     | 
    
         
             
                        params['name'] = destination_path unless destination_path.nil?
         
     | 
| 
         @@ -107,14 +107,14 @@ module WebTranslateIt 
     | 
|
| 
       107 
107 
     | 
    
         
             
                        display.push Util.handle_response(http_connection.request(request))
         
     | 
| 
       108 
108 
     | 
    
         
             
                      rescue Timeout::Error
         
     | 
| 
       109 
109 
     | 
    
         
             
                        puts StringUtil.failure('Request timeout. Will retry in 5 seconds.')
         
     | 
| 
       110 
     | 
    
         
            -
                        if (tries -= 1)  
     | 
| 
      
 110 
     | 
    
         
            +
                        if (tries -= 1).positive? # rubocop:todo Metrics/BlockNesting
         
     | 
| 
       111 
111 
     | 
    
         
             
                          sleep(5)
         
     | 
| 
       112 
112 
     | 
    
         
             
                          retry
         
     | 
| 
       113 
113 
     | 
    
         
             
                        else
         
     | 
| 
       114 
114 
     | 
    
         
             
                          success = false
         
     | 
| 
       115 
115 
     | 
    
         
             
                        end
         
     | 
| 
       116 
116 
     | 
    
         
             
                      rescue
         
     | 
| 
       117 
     | 
    
         
            -
                        display.push StringUtil.failure("An error occured: #{ 
     | 
| 
      
 117 
     | 
    
         
            +
                        display.push StringUtil.failure("An error occured: #{$ERROR_INFO}")
         
     | 
| 
       118 
118 
     | 
    
         
             
                        success = false
         
     | 
| 
       119 
119 
     | 
    
         
             
                      end
         
     | 
| 
       120 
120 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -156,14 +156,14 @@ module WebTranslateIt 
     | 
|
| 
       156 
156 
     | 
    
         
             
                      puts ArrayUtil.to_columns(display)
         
     | 
| 
       157 
157 
     | 
    
         
             
                    rescue Timeout::Error
         
     | 
| 
       158 
158 
     | 
    
         
             
                      puts StringUtil.failure('Request timeout. Will retry in 5 seconds.')
         
     | 
| 
       159 
     | 
    
         
            -
                      if (tries -= 1) 
     | 
| 
      
 159 
     | 
    
         
            +
                      if (tries -= 1).positive?
         
     | 
| 
       160 
160 
     | 
    
         
             
                        sleep(5)
         
     | 
| 
       161 
161 
     | 
    
         
             
                        retry
         
     | 
| 
       162 
162 
     | 
    
         
             
                      else
         
     | 
| 
       163 
163 
     | 
    
         
             
                        success = false
         
     | 
| 
       164 
164 
     | 
    
         
             
                      end
         
     | 
| 
       165 
165 
     | 
    
         
             
                    rescue
         
     | 
| 
       166 
     | 
    
         
            -
                      display.push StringUtil.failure("An error occured: #{ 
     | 
| 
      
 166 
     | 
    
         
            +
                      display.push StringUtil.failure("An error occured: #{$ERROR_INFO}")
         
     | 
| 
       167 
167 
     | 
    
         
             
                      success = false
         
     | 
| 
       168 
168 
     | 
    
         
             
                    end
         
     | 
| 
       169 
169 
     | 
    
         
             
                  else
         
     | 
| 
         @@ -187,14 +187,14 @@ module WebTranslateIt 
     | 
|
| 
       187 
187 
     | 
    
         
             
                      puts ArrayUtil.to_columns(display)
         
     | 
| 
       188 
188 
     | 
    
         
             
                    rescue Timeout::Error
         
     | 
| 
       189 
189 
     | 
    
         
             
                      puts StringUtil.failure('Request timeout. Will retry in 5 seconds.')
         
     | 
| 
       190 
     | 
    
         
            -
                      if (tries -= 1) 
     | 
| 
      
 190 
     | 
    
         
            +
                      if (tries -= 1).positive?
         
     | 
| 
       191 
191 
     | 
    
         
             
                        sleep(5)
         
     | 
| 
       192 
192 
     | 
    
         
             
                        retry
         
     | 
| 
       193 
193 
     | 
    
         
             
                      else
         
     | 
| 
       194 
194 
     | 
    
         
             
                        success = false
         
     | 
| 
       195 
195 
     | 
    
         
             
                      end
         
     | 
| 
       196 
196 
     | 
    
         
             
                    rescue
         
     | 
| 
       197 
     | 
    
         
            -
                      display.push StringUtil.failure("An error occured: #{ 
     | 
| 
      
 197 
     | 
    
         
            +
                      display.push StringUtil.failure("An error occured: #{$ERROR_INFO}")
         
     | 
| 
       198 
198 
     | 
    
         
             
                      success = false
         
     | 
| 
       199 
199 
     | 
    
         
             
                    end
         
     | 
| 
       200 
200 
     | 
    
         
             
                  else
         
     | 
| 
         @@ -10,7 +10,7 @@ module WebTranslateIt 
     | 
|
| 
       10 
10 
     | 
    
         
             
                end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                def self.calculate_percentage(processed, total)
         
     | 
| 
       13 
     | 
    
         
            -
                  return 0 if total 
     | 
| 
      
 13 
     | 
    
         
            +
                  return 0 if total.zero?
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                  ((processed * 10) / total).to_f.ceil * 10
         
     | 
| 
       16 
16 
     | 
    
         
             
                end
         
     | 
| 
         @@ -19,7 +19,7 @@ module WebTranslateIt 
     | 
|
| 
       19 
19 
     | 
    
         
             
                # rubocop:todo Metrics/MethodLength
         
     | 
| 
       20 
20 
     | 
    
         
             
                # rubocop:todo Metrics/AbcSize
         
     | 
| 
       21 
21 
     | 
    
         
             
                def self.handle_response(response, return_response = false, raise_exception = false) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
         
     | 
| 
       22 
     | 
    
         
            -
                  if response.code.to_i >= 400  
     | 
| 
      
 22 
     | 
    
         
            +
                  if (response.code.to_i >= 400) && (response.code.to_i < 500)
         
     | 
| 
       23 
23 
     | 
    
         
             
                    raise "Error: #{MultiJson.load(response.body)['error']}" if raise_exception
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                    puts StringUtil.failure(MultiJson.load(response.body)['error'])
         
     | 
| 
         @@ -80,13 +80,13 @@ module WebTranslateIt 
     | 
|
| 
       80 
80 
     | 
    
         
             
                # Ask a question. Returns an answer.
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
       82 
82 
     | 
    
         
             
                def self.ask(question, default = nil)
         
     | 
| 
       83 
     | 
    
         
            -
                  question  
     | 
| 
      
 83 
     | 
    
         
            +
                  question += " (Default: #{default})" unless default.nil?
         
     | 
| 
       84 
84 
     | 
    
         
             
                  print("#{question}  ")
         
     | 
| 
       85 
85 
     | 
    
         
             
                  $stdout.flush
         
     | 
| 
       86 
86 
     | 
    
         | 
| 
       87 
87 
     | 
    
         
             
                  result = $stdin.gets
         
     | 
| 
       88 
88 
     | 
    
         
             
                  result&.chomp!
         
     | 
| 
       89 
     | 
    
         
            -
                  result = default if result.nil?  
     | 
| 
      
 89 
     | 
    
         
            +
                  result = default if result.nil? || (result == '')
         
     | 
| 
       90 
90 
     | 
    
         
             
                  result
         
     | 
| 
       91 
91 
     | 
    
         
             
                end
         
     | 
| 
       92 
92 
     | 
    
         | 
    
        data/lib/web_translate_it.rb
    CHANGED
    
    | 
         @@ -13,6 +13,8 @@ require 'web_translate_it/auto_fetch' 
     | 
|
| 
       13 
13 
     | 
    
         
             
            require 'web_translate_it/command_line'
         
     | 
| 
       14 
14 
     | 
    
         
             
            require 'web_translate_it/project'
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
      
 16 
     | 
    
         
            +
            require 'English'
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
       16 
18 
     | 
    
         
             
            module WebTranslateIt
         
     | 
| 
       17 
19 
     | 
    
         
             
              def self.fetch_translations # rubocop:todo Metrics/AbcSize
         
     | 
| 
       18 
20 
     | 
    
         
             
                config = Configuration.new
         
     | 
    
        data/readme.md
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # WebTranslateIt Synchronization Tool : wti
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            [RubyDoc](https://rubydoc.info/github/webtranslateit/webtranslateit/master) | 
     | 
| 
       4 
     | 
    
         
            -
            [Report a bug](https://github.com/webtranslateit/webtranslateit/issues) | 
     | 
| 
      
 3 
     | 
    
         
            +
            [RubyDoc](https://rubydoc.info/github/webtranslateit/webtranslateit/master) |
         
     | 
| 
      
 4 
     | 
    
         
            +
            [Report a bug](https://github.com/webtranslateit/webtranslateit/issues) |
         
     | 
| 
       5 
5 
     | 
    
         
             
            [Support](https://webtranslateit.com/support) |
         
     | 
| 
       6 
6 
     | 
    
         
             
            [WebTranslateIt.com Homepage](https://webtranslateit.com)
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
         @@ -32,7 +32,7 @@ Fetching: web_translate_it-2.1.3.gem (100%) 
     | 
|
| 
       32 
32 
     | 
    
         
             
            Successfully installed web_translate_it-2.1.3
         
     | 
| 
       33 
33 
     | 
    
         
             
            1 gem installed
         
     | 
| 
       34 
34 
     | 
    
         
             
            ```
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       36 
36 
     | 
    
         
             
            At this point you should have the `wti` executable working:
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
            ``` bash
         
     | 
| 
         @@ -83,9 +83,9 @@ Please refer to [our documentation about syncing multiple projects](https://gith 
     | 
|
| 
       83 
83 
     | 
    
         
             
            Execute `wti --help` to see the usage:
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
85 
     | 
    
         
             
                Usage: wti <command> [options]+
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
       87 
87 
     | 
    
         
             
                The most commonly used wti commands are:
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
       89 
89 
     | 
    
         
             
                  pull        Pull target language file(s)
         
     | 
| 
       90 
90 
     | 
    
         
             
                  push        Push master language file(s)
         
     | 
| 
       91 
91 
     | 
    
         
             
                  match       Display matching of local files with File Manager
         
     | 
| 
         @@ -96,7 +96,7 @@ Execute `wti --help` to see the usage: 
     | 
|
| 
       96 
96 
     | 
    
         
             
                  init        Configure your project to sync      
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
                See `wti <command> --help` for more information on a specific command.
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
       100 
100 
     | 
    
         
             
                [options] are:
         
     | 
| 
       101 
101 
     | 
    
         
             
                  --config, -c <s>:   Path to a translation.yml file (default: .wti)
         
     | 
| 
       102 
102 
     | 
    
         
             
                     --version, -v:   Print version and exit
         
     | 
| 
         @@ -217,7 +217,7 @@ There are 4 hooks: 
     | 
|
| 
       217 
217 
     | 
    
         
             
            * `before_push`
         
     | 
| 
       218 
218 
     | 
    
         
             
            * `after_push`
         
     | 
| 
       219 
219 
     | 
    
         | 
| 
       220 
     | 
    
         
            -
            Check the [sample `.wti`](https://github.com/webtranslateit/webtranslateit/blob/master/examples/.wti# 
     | 
| 
      
 220 
     | 
    
         
            +
            Check the [sample `.wti`](https://github.com/webtranslateit/webtranslateit/blob/master/examples/.wti#L16-L21) file for implementation.
         
     | 
| 
       221 
221 
     | 
    
         | 
| 
       222 
222 
     | 
    
         
             
            ## Exit codes
         
     | 
| 
       223 
223 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: web_translate_it
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.6.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Edouard Briere
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-03-09 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: multi_json
         
     |