web_translate_it 2.2.0 → 2.2.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 +4 -0
- data/lib/web_translate_it/command_line.rb +12 -3
- data/lib/web_translate_it/configuration.rb +7 -1
- data/license +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: 255cee3843737732023933b96f1139214af761e2
         | 
| 4 | 
            +
              data.tar.gz: 39a4ad19cd6ffa90b0316f9e17de1e560f45b34d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d0779b7176c462a30efbd7cf412c4e924247b28577ff3481abda2794121c0bf183e1f806992a1c7a5cf839d074e15e8486f637623067fc250af930436c704eed
         | 
| 7 | 
            +
              data.tar.gz: 3865f41d37f0d1436db49c4bdd579db5fe58817d7db99bf6cb3959fab5c74799520283c4ac856cd36418f8750d3448ed3e53084756b6306541f30dfa0a2d866a
         | 
    
        data/history.md
    CHANGED
    
    
| @@ -246,8 +246,14 @@ module WebTranslateIt | |
| 246 246 | 
             
                    end
         | 
| 247 247 | 
             
                    locales = command_options.locale.split
         | 
| 248 248 | 
             
                  else
         | 
| 249 | 
            -
                     | 
| 250 | 
            -
             | 
| 249 | 
            +
                    if configuration.needed_locales.any?
         | 
| 250 | 
            +
                      locales = configuration.needed_locales
         | 
| 251 | 
            +
                    else
         | 
| 252 | 
            +
                      locales = configuration.target_locales
         | 
| 253 | 
            +
                      if configuration.ignore_locales.any?
         | 
| 254 | 
            +
                        configuration.ignore_locales.each{ |locale_to_delete| locales.delete(locale_to_delete) }
         | 
| 255 | 
            +
                      end
         | 
| 256 | 
            +
                    end
         | 
| 251 257 | 
             
                  end
         | 
| 252 258 | 
             
                  locales.push(configuration.source_locale) if command_options.all
         | 
| 253 259 | 
             
                  return locales.uniq
         | 
| @@ -293,11 +299,14 @@ module WebTranslateIt | |
| 293 299 | 
             
                  file = <<-FILE
         | 
| 294 300 | 
             
            api_key: #{api_key}
         | 
| 295 301 |  | 
| 296 | 
            -
            # Optional: locales not to sync with  | 
| 302 | 
            +
            # Optional: locales not to sync with WebTranslateIt.
         | 
| 297 303 | 
             
            # Takes a string, a symbol, or an array of string or symbol.
         | 
| 298 304 | 
             
            # More information here: https://github.com/AtelierConvivialite/webtranslateit/wiki
         | 
| 299 305 | 
             
            # ignore_locales: '#{project_info["source_locale"]["code"]}'
         | 
| 300 306 |  | 
| 307 | 
            +
            # Or if you prefer a list of locales to sync with WebTranslateIt:
         | 
| 308 | 
            +
            # needed_locales: #{project_info["target_locales"].map {|locale| locale["code"]}.to_s}
         | 
| 309 | 
            +
             | 
| 301 310 | 
             
            # Optional
         | 
| 302 311 | 
             
            # before_pull: "echo 'some unix command'"   # Command executed before pulling files
         | 
| 303 312 | 
             
            # after_pull:  "touch tmp/restart.txt"      # Command executed after pulling files
         | 
| @@ -10,7 +10,7 @@ module WebTranslateIt | |
| 10 10 | 
             
              class Configuration
         | 
| 11 11 | 
             
                require 'yaml'
         | 
| 12 12 | 
             
                require 'fileutils'
         | 
| 13 | 
            -
                attr_accessor :path, :api_key, :source_locale, :target_locales, :files, :ignore_locales
         | 
| 13 | 
            +
                attr_accessor :path, :api_key, :source_locale, :target_locales, :files, :ignore_locales, :needed_locales
         | 
| 14 14 | 
             
                attr_accessor :logger, :before_pull, :after_pull, :before_push, :after_push, :project_name
         | 
| 15 15 |  | 
| 16 16 | 
             
                # Load configuration file from the path.
         | 
| @@ -26,6 +26,7 @@ module WebTranslateIt | |
| 26 26 | 
             
                    self.after_push     = configuration['after_push']
         | 
| 27 27 | 
             
                    project_info        = YAML.load WebTranslateIt::Project.fetch_info(api_key)
         | 
| 28 28 | 
             
                    set_locales_to_ignore(configuration)
         | 
| 29 | 
            +
                    set_locales_needed(configuration)
         | 
| 29 30 | 
             
                    set_files(project_info['project'])
         | 
| 30 31 | 
             
                    set_locales(project_info['project'])
         | 
| 31 32 | 
             
                    self.project_name = project_info['project']['name']
         | 
| @@ -65,6 +66,11 @@ module WebTranslateIt | |
| 65 66 | 
             
                def set_locales_to_ignore(configuration)
         | 
| 66 67 | 
             
                  self.ignore_locales = Array(configuration['ignore_locales']).map{ |locale| locale.to_s }
         | 
| 67 68 | 
             
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                # Set locales to specifically pull from the configuration file, if set
         | 
| 71 | 
            +
                def set_locales_needed(configuration)
         | 
| 72 | 
            +
                  self.needed_locales = Array(configuration['needed_locales']).map{ |locale| locale.to_s }
         | 
| 73 | 
            +
                end
         | 
| 68 74 |  | 
| 69 75 | 
             
                # Convenience method which returns the endpoint for fetching a list of locales for a project.
         | 
| 70 76 | 
             
                def api_url
         | 
    
        data/license
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            The MIT License (MIT)
         | 
| 2 2 |  | 
| 3 | 
            -
            Copyright (c) 2009- | 
| 3 | 
            +
            Copyright (c) 2009-2014 Atelier Convivialite
         | 
| 4 4 |  | 
| 5 5 | 
             
            Permission is hereby granted, free of charge, to any person obtaining a copy of
         | 
| 6 6 | 
             
            this software and associated documentation files (the "Software"), to deal in
         | 
    
        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.2. | 
| 4 | 
            +
              version: 2.2.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: 2014-01- | 
| 11 | 
            +
            date: 2014-01-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: multipart-post
         |