crowdin-cli 0.2.1 → 0.2.2
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/README.md +33 -4
- data/bin/crowdin-cli +64 -17
- data/lib/crowdin-cli/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1a40088adbb46116f854dd825f0ab1ee5878d519
         | 
| 4 | 
            +
              data.tar.gz: 85e6f9ac041ebf563ec341b445b0c3255eb3bdff
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 86edeaa994d9fd05d9bee7e6cb6dbb8dad84aed51fd3327f0ee993bf05c0660d5581898503e00bb0b405d73d624973d99bb24c8fe0a1f3633753c411ea596482
         | 
| 7 | 
            +
              data.tar.gz: 3857ea6a1abf25fe55f0c34a257a0fe3f856db5c556ee06baf11c615b1399e0ad6ce01dc4a23bb9c496112e0d03f49a4a723e4e090f15d479676ce700f998592
         | 
    
        data/README.md
    CHANGED
    
    | @@ -87,12 +87,24 @@ Here's patterns you can use: | |
| 87 87 |  | 
| 88 88 | 
             
            * `*` (asterisk)
         | 
| 89 89 |  | 
| 90 | 
            -
             Match zero or more characters in file name. A glob consisting of only the asterisk and no other characters will match all files in the directory. If you specified a `*.json` it will include all files like `messages.json`, `about_us.json` and anything that ends with `.json`. 
         | 
| 90 | 
            +
             Match zero or more characters in file name. A glob consisting of only the asterisk and no other characters will match all files in the directory. If you specified a `*.json` it will include all files like `messages.json`, `about_us.json` and anything that ends with `.json`.c* will match all files beginning with c; `*c` will match all files ending with c; and `*c*` will match all files that have c in them (including at the beginning or end). Equivalent to `/ .* /x` in regexp.
         | 
| 91 91 |  | 
| 92 92 | 
             
            * `**` (doubled asterisk)
         | 
| 93 93 |  | 
| 94 94 | 
             
             Match all directories recursively. Note that you can use `**` in `source` and in `translation` pattern. When using `**` in `translation` pattern it will always contain sub-path from `source` for certain file. The mask `**` can be used only once in the pattern and must be surrounded by backslashes `/`.
         | 
| 95 95 |  | 
| 96 | 
            +
            * `?` (question mark)
         | 
| 97 | 
            +
             | 
| 98 | 
            +
             Matches any one character.
         | 
| 99 | 
            +
             | 
| 100 | 
            +
            * `[set]`
         | 
| 101 | 
            +
             | 
| 102 | 
            +
             Matches any one character in set. Behaves exactly like character sets in `Regexp`, including set negation (`[^a-z]`).
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            * `\` (backslash)
         | 
| 105 | 
            +
             | 
| 106 | 
            +
             Escapes the next metacharacter.
         | 
| 107 | 
            +
             | 
| 96 108 | 
             
             Say, you can have source: `/en/**/*.po` to upload all `*.po` files to Crowdin recursively. `translation` pattern will be `/translations/%two_letters_code%/**/%original_file_name%'`.
         | 
| 97 109 |  | 
| 98 110 | 
             
            See sample configuration below::
         | 
| @@ -140,8 +152,9 @@ You can also override language codes for other placeholders like `%android_code% | |
| 140 152 |  | 
| 141 153 | 
             
            ### Ignoring directories
         | 
| 142 154 |  | 
| 143 | 
            -
            From time to time there are directories you don't want translate on Crowdin.
         | 
| 155 | 
            +
            From time to time there are files and directories you don't want translate on Crowdin.
         | 
| 144 156 | 
             
            Local per-file rules can be added to the config file in your project.
         | 
| 157 | 
            +
             | 
| 145 158 | 
             
            ```
         | 
| 146 159 | 
             
            files:
         | 
| 147 160 | 
             
              -
         | 
| @@ -149,8 +162,24 @@ files: | |
| 149 162 | 
             
                translation: /locale/%two_letters_code%/**/%original_file_name%
         | 
| 150 163 | 
             
                ignore:
         | 
| 151 164 | 
             
                  - /locale/en/templates
         | 
| 152 | 
            -
                  - /locale/en | 
| 165 | 
            +
                  - /locale/en/**/test-*.po
         | 
| 166 | 
            +
                  - /locale/en/**/[^abc]*.po
         | 
| 167 | 
            +
             | 
| 168 | 
            +
            ```
         | 
| 153 169 |  | 
| 170 | 
            +
            ### Preserving directories hierarchy
         | 
| 171 | 
            +
             | 
| 172 | 
            +
            By default CLI tool tries to optimize your Crowdin project hierarchy and do not repeats complete path of local files online. In case you need to keep directories structure same at Crowdin and locally you can add `preserve_hierarchy: true` option in main section of the configuration file. 
         | 
| 173 | 
            +
             | 
| 174 | 
            +
            Sample configuration below:
         | 
| 175 | 
            +
             | 
| 176 | 
            +
            ```
         | 
| 177 | 
            +
            ---
         | 
| 178 | 
            +
            project_identifier: test
         | 
| 179 | 
            +
            api_key: KeepTheAPIkeySecret
         | 
| 180 | 
            +
            base_url: http://api.crowdin.net
         | 
| 181 | 
            +
            base_path: /path/to/your/project
         | 
| 182 | 
            +
            preserve_hierarchy: true
         | 
| 154 183 | 
             
            ```
         | 
| 155 184 |  | 
| 156 185 | 
             
            ### Uploading CSV files via API
         | 
| @@ -295,4 +324,4 @@ Author: Anton Maminov (anton.maminov@gmail.com) | |
| 295 324 |  | 
| 296 325 | 
             
            Copyright: 2012-2013 [Crowdin.net](http://crowdin.net/)
         | 
| 297 326 |  | 
| 298 | 
            -
            This project is licensed under the MIT license, a copy of which can be found in the LICENSE file.
         | 
| 327 | 
            +
            This project is licensed under the MIT license, a copy of which can be found in the LICENSE file.
         | 
    
        data/bin/crowdin-cli
    CHANGED
    
    | @@ -104,34 +104,72 @@ def construct_export_pattern(path, source, translation) | |
| 104 104 | 
             
              return export_pattern
         | 
| 105 105 | 
             
            end
         | 
| 106 106 |  | 
| 107 | 
            -
            #  | 
| 107 | 
            +
            # This is a partial translation of the algorithm defined in fnmatch.py
         | 
| 108 | 
            +
            # https://github.com/python-git/python/blob/master/Lib/fnmatch.py
         | 
| 109 | 
            +
            # Provides a partial implementation of translate a glob +pat+ to a regular expression
         | 
| 110 | 
            +
            #
         | 
| 111 | 
            +
            # Patterns are Unix shell style:
         | 
| 112 | 
            +
            # *       matches everything
         | 
| 113 | 
            +
            # ?       matches any single character
         | 
| 114 | 
            +
            # [seq]   matches any character in seq
         | 
| 115 | 
            +
            # [^seq]  matches any char not in seq
         | 
| 116 | 
            +
            #
         | 
| 108 117 | 
             
            # NOTE:
         | 
| 109 | 
            -
            # `**` surrounded by backslashes `/` in the + | 
| 110 | 
            -
            # `**` used only once in the + | 
| 118 | 
            +
            # `**` surrounded by backslashes `/` in the +pat+
         | 
| 119 | 
            +
            # `**` used only once in the +pat+
         | 
| 111 120 | 
             
            #
         | 
| 112 | 
            -
            def translate_pattern_to_regexp( | 
| 121 | 
            +
            def translate_pattern_to_regexp(pat)
         | 
| 113 122 | 
             
              i = 0
         | 
| 114 | 
            -
              n =  | 
| 123 | 
            +
              n = pat.size
         | 
| 115 124 | 
             
              res = ''
         | 
| 116 125 | 
             
              while i < n
         | 
| 117 | 
            -
                c =  | 
| 126 | 
            +
                c = pat[i]
         | 
| 118 127 | 
             
                i = i + 1
         | 
| 119 128 | 
             
                if c == '*'
         | 
| 120 129 | 
             
                  j = i
         | 
| 121 | 
            -
                  if j < n and  | 
| 130 | 
            +
                  if j < n and pat[j] == '*'
         | 
| 122 131 | 
             
                    res[-1] = '(\/)?(?<double_asterisk>.*)?'
         | 
| 123 132 | 
             
                    i = j + 1
         | 
| 124 133 | 
             
                  else
         | 
| 125 | 
            -
                    res  | 
| 134 | 
            +
                    res = res + '.*'
         | 
| 126 135 | 
             
                  end
         | 
| 127 136 | 
             
                elsif c == '?'
         | 
| 128 | 
            -
                  res  | 
| 137 | 
            +
                  res = res + '.'
         | 
| 138 | 
            +
                elsif c == '['
         | 
| 139 | 
            +
                  j = i
         | 
| 140 | 
            +
                  # The following two statements check if the sequence we stumbled
         | 
| 141 | 
            +
                  # upon is '[]' or '[^]' because those are not valid character
         | 
| 142 | 
            +
                  # classes.
         | 
| 143 | 
            +
                  if j < n and pat[j] == '^'
         | 
| 144 | 
            +
                    j = j + 1
         | 
| 145 | 
            +
                  end
         | 
| 146 | 
            +
                  if j < n and pat[j] == ']'
         | 
| 147 | 
            +
                    j = j + 1
         | 
| 148 | 
            +
                  end
         | 
| 149 | 
            +
                  # Look for the closing ']' right off the bat. If one is not found,
         | 
| 150 | 
            +
                  # escape the opening '[' and continue.  If it is found, process
         | 
| 151 | 
            +
                  # he contents of '[...]'.
         | 
| 152 | 
            +
                  while j < n and pat[j] != ']'
         | 
| 153 | 
            +
                    j = j + 1
         | 
| 154 | 
            +
                  end
         | 
| 155 | 
            +
                  if j >= n
         | 
| 156 | 
            +
                    res = res + '\\['
         | 
| 157 | 
            +
                  else
         | 
| 158 | 
            +
                    stuff = pat[i...j].gsub('\\', '\\\\')
         | 
| 159 | 
            +
                    i = j + 1
         | 
| 160 | 
            +
                    #if stuff[0] == '!'
         | 
| 161 | 
            +
                    #  stuff = '^' + stuff[1..-1]
         | 
| 162 | 
            +
                    #elsif stuff[0] == '^'
         | 
| 163 | 
            +
                    #  stuff = '\\' + stuff
         | 
| 164 | 
            +
                    #end
         | 
| 165 | 
            +
                    res = "#{res}[#{stuff}]"
         | 
| 166 | 
            +
                  end
         | 
| 129 167 | 
             
                else
         | 
| 130 | 
            -
                  res  | 
| 168 | 
            +
                  res = res + Regexp.escape(c)
         | 
| 131 169 | 
             
                end
         | 
| 132 170 | 
             
              end
         | 
| 133 171 |  | 
| 134 | 
            -
              return Regexp.new(res)
         | 
| 172 | 
            +
              return Regexp.new(res + '$')
         | 
| 135 173 | 
             
            end
         | 
| 136 174 |  | 
| 137 175 | 
             
            def android_locale_code(locale_code)
         | 
| @@ -262,6 +300,8 @@ command :upload do |c| | |
| 262 300 | 
             
                      puts "Warning: #{placeholder} is not valid variable supported by Crowdin. See http://crowdin.net/page/cli-tool#configuration-file for more details."
         | 
| 263 301 | 
             
                    end
         | 
| 264 302 |  | 
| 303 | 
            +
                    ignores = file['ignore'] || []
         | 
| 304 | 
            +
             | 
| 265 305 | 
             
                    if File.exist?(File.join(@base_path, file['source']))
         | 
| 266 306 | 
             
                      dest = file['source']
         | 
| 267 307 | 
             
                      dest_files << dest
         | 
| @@ -277,13 +317,14 @@ command :upload do |c| | |
| 277 317 | 
             
                        dest = source_path.sub(@base_path, '') # relative path in Crowdin
         | 
| 278 318 |  | 
| 279 319 | 
             
                        if File.directory?(source_path)
         | 
| 280 | 
            -
                          ignores  | 
| 281 | 
            -
                          if ignores.include?(dest)
         | 
| 320 | 
            +
                          if ignores.any?{ |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
         | 
| 282 321 | 
             
                            Find.prune # Don't look any further into this directory
         | 
| 283 322 | 
             
                          else
         | 
| 284 323 | 
             
                            next
         | 
| 285 324 | 
             
                          end
         | 
| 286 325 | 
             
                        elsif File.fnmatch?(file['source'], dest, File::FNM_PATHNAME)
         | 
| 326 | 
            +
                          next if ignores.any?{ |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
         | 
| 327 | 
            +
                          
         | 
| 287 328 | 
             
                          dest_files << dest
         | 
| 288 329 |  | 
| 289 330 | 
             
                          export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
         | 
| @@ -416,6 +457,8 @@ EOS | |
| 416 457 | 
             
                      puts "Warning: #{placeholder} is not valid variable supported by Crowdin. See http://crowdin.net/page/cli-tool#configuration-file for more details."
         | 
| 417 458 | 
             
                    end
         | 
| 418 459 |  | 
| 460 | 
            +
                    ignores = file['ignore'] || []
         | 
| 461 | 
            +
             | 
| 419 462 | 
             
                    languages_mapping = file['languages_mapping']
         | 
| 420 463 |  | 
| 421 464 | 
             
                    # CSV files only (default: false)
         | 
| @@ -440,13 +483,14 @@ EOS | |
| 440 483 | 
             
                        dest = source_path.sub(@base_path, '') # relative path in Crowdin
         | 
| 441 484 |  | 
| 442 485 | 
             
                        if File.directory?(source_path)
         | 
| 443 | 
            -
                          ignores  | 
| 444 | 
            -
                          if ignores.include?(dest)
         | 
| 486 | 
            +
                          if ignores.any?{ |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
         | 
| 445 487 | 
             
                            Find.prune # Don't look any further into this directory
         | 
| 446 488 | 
             
                          else
         | 
| 447 489 | 
             
                            next
         | 
| 448 490 | 
             
                          end
         | 
| 449 491 | 
             
                        elsif File.fnmatch?(file['source'], dest, File::FNM_PATHNAME)
         | 
| 492 | 
            +
                          next if ignores.any?{ |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
         | 
| 493 | 
            +
             | 
| 450 494 | 
             
                          dest_files << dest
         | 
| 451 495 |  | 
| 452 496 | 
             
                          export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
         | 
| @@ -543,6 +587,8 @@ command :download do |c| | |
| 543 587 | 
             
                @config['files'].each do |file|
         | 
| 544 588 | 
             
                  languages_mapping = file['languages_mapping'] # Hash or NilClass
         | 
| 545 589 |  | 
| 590 | 
            +
                  ignores = file['ignore'] || []
         | 
| 591 | 
            +
             | 
| 546 592 | 
             
                  # CSV files only (default: false)
         | 
| 547 593 | 
             
                  multilingual_spreadsheet = file['multilingual_spreadsheet'] || false
         | 
| 548 594 |  | 
| @@ -567,13 +613,14 @@ command :download do |c| | |
| 567 613 | 
             
                      dest = source_path.sub(@base_path, '') # relative path in Crowdin
         | 
| 568 614 |  | 
| 569 615 | 
             
                      if File.directory?(source_path)
         | 
| 570 | 
            -
                        ignores  | 
| 571 | 
            -
                        if ignores.include?(dest)
         | 
| 616 | 
            +
                        if ignores.any?{ |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
         | 
| 572 617 | 
             
                          Find.prune # Don't look any further into this directory
         | 
| 573 618 | 
             
                        else
         | 
| 574 619 | 
             
                          next
         | 
| 575 620 | 
             
                        end
         | 
| 576 621 | 
             
                      elsif File.fnmatch?(file['source'], dest, File::FNM_PATHNAME)
         | 
| 622 | 
            +
                        next if ignores.any?{ |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
         | 
| 623 | 
            +
             | 
| 577 624 | 
             
                        export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
         | 
| 578 625 |  | 
| 579 626 | 
             
                        file_translation_languages.each do |lang|
         | 
    
        data/lib/crowdin-cli/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: crowdin-cli
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Crowdin
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2013-09- | 
| 11 | 
            +
            date: 2013-09-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rake
         |