getlocal 0.0.3 → 0.0.4
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/lib/getlocal/cli.rb +38 -30
- data/lib/getlocal/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: 87a35bed0fc83dee63f750eca7f030ec2b9c3358
         | 
| 4 | 
            +
              data.tar.gz: aa2294ec8f166678697fef0b41107ac48c4591fe
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 25b7ae479b6a1f180c072bebc32d3adea867714e7d00bf4ba498fe8e193cc94a982df3e60dde267e6ae0734aa45e9d78a37022984ce99b970b2a96ecc3ef5cc3
         | 
| 7 | 
            +
              data.tar.gz: 4c1e5bf5862f18407b340995b5bb27065af472a8953581f6257d897bcc943fdd8f2f1bbd5f276bbf24786d724dda77ac4f5b871c6cc563dc72d4e3c610076884
         | 
    
        data/lib/getlocal/cli.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ | |
| 3 3 | 
             
            require 'zip'
         | 
| 4 4 | 
             
            require 'thread'
         | 
| 5 5 | 
             
            require 'io/console'
         | 
| 6 | 
            -
             | 
| 6 | 
            +
             | 
| 7 7 | 
             
            require 'thor'
         | 
| 8 8 | 
             
            require 'httmultiparty'
         | 
| 9 9 |  | 
| @@ -17,17 +17,18 @@ module Getlocal | |
| 17 17 |  | 
| 18 18 | 
             
                method_option :user, :required => true, :aliases => "-u"
         | 
| 19 19 | 
             
                method_option :password, :aliases => "-p"
         | 
| 20 | 
            +
                method_option :timeout, :aliases => "-t"
         | 
| 20 21 | 
             
                desc "fetch [PROJECT]", "Used to fetch the latest localisations"
         | 
| 21 22 | 
             
                def fetch(project)
         | 
| 22 | 
            -
             | 
| 23 | 
            +
             | 
| 23 24 | 
             
                  # Check if we are in the right place
         | 
| 24 25 | 
             
                  if Dir.glob('*.lproj').empty?
         | 
| 25 26 | 
             
                    puts "Wrong directory please select the directory that contains the .lproj folders"
         | 
| 26 27 | 
             
                    return
         | 
| 27 28 | 
             
                  end
         | 
| 28 | 
            -
             | 
| 29 | 
            +
             | 
| 29 30 | 
             
                  username = options[:user]
         | 
| 30 | 
            -
             | 
| 31 | 
            +
             | 
| 31 32 | 
             
                  # Check if we need to ask for a password
         | 
| 32 33 | 
             
                  if options[:password]
         | 
| 33 34 | 
             
                    password = options[:password]
         | 
| @@ -36,7 +37,7 @@ module Getlocal | |
| 36 37 | 
             
                    password = STDIN.noecho(&:gets).chomp
         | 
| 37 38 | 
             
                    puts ""
         | 
| 38 39 | 
             
                  end
         | 
| 39 | 
            -
             | 
| 40 | 
            +
             | 
| 40 41 | 
             
                  if !options[:verbose] then
         | 
| 41 42 | 
             
                    Thread.new do
         | 
| 42 43 | 
             
                      #set up spinner
         | 
| @@ -49,15 +50,22 @@ module Getlocal | |
| 49 50 | 
             
                      end
         | 
| 50 51 | 
             
                    end
         | 
| 51 52 | 
             
                  end
         | 
| 52 | 
            -
             | 
| 53 | 
            +
             | 
| 53 54 | 
             
                  auth = {:username => username, :password => password}
         | 
| 54 | 
            -
             | 
| 55 | 
            +
             | 
| 55 56 | 
             
                  puts "Fetching the zip. This may take a while" if options[:verbose]
         | 
| 56 | 
            -
             | 
| 57 | 
            +
             | 
| 57 58 | 
             
                  zipfile = Tempfile.new("file")
         | 
| 58 | 
            -
             | 
| 59 | 
            +
             | 
| 60 | 
            +
                  if options[:timeout] then
         | 
| 61 | 
            +
            	       timeout == options[:timeout]
         | 
| 62 | 
            +
                  else
         | 
| 63 | 
            +
            	       timeout == 600
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 59 66 | 
             
                  begin
         | 
| 60 | 
            -
             | 
| 67 | 
            +
             | 
| 68 | 
            +
              	  	response = HTTParty.get("https://api.getlocalization.com/#{project}/api/translations/zip/", :basic_auth => auth, :timeout => timeout)
         | 
| 61 69 | 
             
                  rescue
         | 
| 62 70 | 
             
                    puts "Oh no, somthing fucked up."
         | 
| 63 71 | 
             
                    return
         | 
| @@ -76,19 +84,19 @@ module Getlocal | |
| 76 84 | 
             
                  ensure
         | 
| 77 85 | 
             
                    zipfile.close
         | 
| 78 86 | 
             
                  end
         | 
| 79 | 
            -
             | 
| 87 | 
            +
             | 
| 80 88 | 
             
                  puts "Extracting the zip" if options[:verbose]
         | 
| 81 89 | 
             
                  Zip::File.open(zipfile.path) do |zipFile|
         | 
| 82 90 | 
             
                    # Handle entries one by one
         | 
| 83 91 | 
             
                    zipFile.each do |entry|
         | 
| 84 92 | 
             
                      # Extract to correct location
         | 
| 85 93 | 
             
                      pathComponents = entry.name.split("/")
         | 
| 86 | 
            -
             | 
| 94 | 
            +
             | 
| 87 95 | 
             
                      destFolder = pathComponents[0] + '.lproj'
         | 
| 88 96 | 
             
                      destFile = pathComponents[1]
         | 
| 89 | 
            -
             | 
| 97 | 
            +
             | 
| 90 98 | 
             
                      destPath = destFolder + '/' + destFile
         | 
| 91 | 
            -
             | 
| 99 | 
            +
             | 
| 92 100 | 
             
                      if Dir.exists?(destFolder)
         | 
| 93 101 | 
             
                        puts "Extracting #{destFile} to #{destPath}" if options[:verbose]
         | 
| 94 102 | 
             
                        File.delete(destPath) if File.exist?(destPath)
         | 
| @@ -96,18 +104,18 @@ module Getlocal | |
| 96 104 | 
             
                      else
         | 
| 97 105 | 
             
                        puts destFolder + " folder not found. Couldn't import " + destFile if options[:verbose]
         | 
| 98 106 | 
             
                      end
         | 
| 99 | 
            -
             | 
| 107 | 
            +
             | 
| 100 108 | 
             
                    end
         | 
| 101 109 | 
             
                  end
         | 
| 102 | 
            -
             | 
| 110 | 
            +
             | 
| 103 111 | 
             
                end
         | 
| 104 | 
            -
             | 
| 112 | 
            +
             | 
| 105 113 | 
             
                method_option :user, :required => true, :aliases => "-u"
         | 
| 106 114 | 
             
                method_option :password, :aliases => "-p"
         | 
| 107 115 | 
             
                desc "update [PROJECT]", "Used to send the latest localisations to get localization"
         | 
| 108 116 | 
             
                def update(project)
         | 
| 109 117 | 
             
                  username = options[:user]
         | 
| 110 | 
            -
             | 
| 118 | 
            +
             | 
| 111 119 | 
             
                  # Check if we need to ask for a password
         | 
| 112 120 | 
             
                  if options[:password]
         | 
| 113 121 | 
             
                    password = options[:password]
         | 
| @@ -116,7 +124,7 @@ module Getlocal | |
| 116 124 | 
             
                    password = STDIN.noecho(&:gets).chomp
         | 
| 117 125 | 
             
                    puts ""
         | 
| 118 126 | 
             
                  end
         | 
| 119 | 
            -
             | 
| 127 | 
            +
             | 
| 120 128 | 
             
                  if !options[:verbose] then
         | 
| 121 129 | 
             
                    Thread.new do
         | 
| 122 130 | 
             
                      #set up spinner
         | 
| @@ -129,12 +137,12 @@ module Getlocal | |
| 129 137 | 
             
                      end
         | 
| 130 138 | 
             
                    end
         | 
| 131 139 | 
             
                  end
         | 
| 132 | 
            -
             | 
| 140 | 
            +
             | 
| 133 141 | 
             
                  auth = {:username => username, :password => password}
         | 
| 134 | 
            -
             | 
| 142 | 
            +
             | 
| 135 143 | 
             
                  puts "Requesting the list of master files" if options[:verbose]
         | 
| 136 144 | 
             
                  response = HTTParty.get("https://api.getlocalization.com/#{project}/api/list-master/json/", :basic_auth => auth)
         | 
| 137 | 
            -
             | 
| 145 | 
            +
             | 
| 138 146 | 
             
                  if response.code == 200 then
         | 
| 139 147 | 
             
                    parsedResponse = JSON.parse(response.body)
         | 
| 140 148 | 
             
                    if parsedResponse['success'] == "1"
         | 
| @@ -148,14 +156,14 @@ module Getlocal | |
| 148 156 | 
             
                    puts "couldn't fetch list of master files"
         | 
| 149 157 | 
             
                    return
         | 
| 150 158 | 
             
                  end
         | 
| 151 | 
            -
             | 
| 159 | 
            +
             | 
| 152 160 | 
             
                  Dir.glob("Base.lproj/*.strings") do |stringFilePath|
         | 
| 153 | 
            -
             | 
| 161 | 
            +
             | 
| 154 162 | 
             
                    alreadyExists = currentMasterFiles.include?(stringFilePath.gsub("Base.lproj/", ""))
         | 
| 155 | 
            -
             | 
| 163 | 
            +
             | 
| 156 164 | 
             
                    body = {"file" => File.new(stringFilePath)}
         | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 165 | 
            +
             | 
| 166 | 
            +
             | 
| 159 167 | 
             
                    if alreadyExists
         | 
| 160 168 | 
             
                      # Update master
         | 
| 161 169 | 
             
                      puts "Updateing " + stringFilePath if options[:verbose]
         | 
| @@ -165,11 +173,11 @@ module Getlocal | |
| 165 173 | 
             
                      puts "Creating " + stringFilePath if options[:verbose]
         | 
| 166 174 | 
             
                      response = HTTMultiParty.post("https://api.getlocalization.com/#{project}/api/create-master/ios/en/", :basic_auth => auth, :query => body)
         | 
| 167 175 | 
             
                    end
         | 
| 168 | 
            -
             | 
| 176 | 
            +
             | 
| 169 177 | 
             
                    puts "Upload complete with responce code #{response.code}" if options[:verbose]
         | 
| 170 178 | 
             
                    puts "" if options[:verbose]
         | 
| 171 179 | 
             
                  end
         | 
| 172 | 
            -
             | 
| 180 | 
            +
             | 
| 173 181 | 
             
                end
         | 
| 174 182 | 
             
              end
         | 
| 175 | 
            -
            end
         | 
| 183 | 
            +
            end
         | 
    
        data/lib/getlocal/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: getlocal
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Benjamin Briggs
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2015-01-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |