winrm-fs 1.1.1 → 1.2.0
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/.rspec +0 -1
- data/.rubocop.yml +7 -2
- data/.rubocop_todo.yml +72 -0
- data/.travis.yml +2 -1
- data/Gemfile +0 -1
- data/Rakefile +2 -3
- data/VERSION +1 -1
- data/Vagrantfile +1 -2
- data/bin/rwinrmcp +0 -1
- data/changelog.md +3 -0
- data/lib/winrm-fs.rb +0 -1
- data/lib/winrm-fs/core/file_transporter.rb +9 -11
- data/lib/winrm-fs/core/tmp_zip.rb +3 -5
- data/lib/winrm-fs/exceptions.rb +0 -1
- data/lib/winrm-fs/file_manager.rb +16 -6
- data/lib/winrm-fs/scripts/download.ps1.erb +4 -1
- data/lib/winrm-fs/scripts/scripts.rb +2 -2
- data/spec/integration/file_manager_spec.rb +49 -4
- data/spec/integration/tmp_zip_spec.rb +4 -4
- data/spec/matchers.rb +0 -1
- data/spec/spec_helper.rb +3 -7
- data/spec/unit/tmp_zip_spec.rb +1 -2
- data/winrm-fs.gemspec +8 -9
- metadata +12 -11
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f0f709ab1c583eaa7566b5adc461aaf46cf2b65e
         | 
| 4 | 
            +
              data.tar.gz: c8cdda9ef2983370cbc964dc9d89eddf348dbd22
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b0d362238781bb50982b7b3f8947b754c3dde755fe4f727197579d943534c717db891b3a197150f2ad975661d12bfc8be66b2e6e9eee9f1395efa6e70cf15a39
         | 
| 7 | 
            +
              data.tar.gz: f5daea2da6036290bca6446936f6d79105578a8106746c809a3887725ba2d7171470451f5c7e0290a8ec4264f7f597af86e77dcb0b01697d697ca35dd433bcc9
         | 
    
        data/.rspec
    CHANGED
    
    
    
        data/.rubocop.yml
    CHANGED
    
    
    
        data/.rubocop_todo.yml
    ADDED
    
    | @@ -0,0 +1,72 @@ | |
| 1 | 
            +
            # This configuration was generated by
         | 
| 2 | 
            +
            # `rubocop --auto-gen-config`
         | 
| 3 | 
            +
            # on 2017-12-12 22:48:53 +0100 using RuboCop version 0.52.0.
         | 
| 4 | 
            +
            # The point is for the user to remove these configuration records
         | 
| 5 | 
            +
            # one by one as the offenses are removed from the code base.
         | 
| 6 | 
            +
            # Note that changes in the inspected code, or installation of new
         | 
| 7 | 
            +
            # versions of RuboCop, may require this file to be generated again.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Offense count: 1
         | 
| 10 | 
            +
            # Cop supports --auto-correct.
         | 
| 11 | 
            +
            # Configuration parameters: EnforcedStyle.
         | 
| 12 | 
            +
            # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
         | 
| 13 | 
            +
            Layout/IndentHeredoc:
         | 
| 14 | 
            +
              Exclude:
         | 
| 15 | 
            +
                - 'spec/matchers.rb'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            # Offense count: 6
         | 
| 18 | 
            +
            # Configuration parameters: CountComments, ExcludedMethods.
         | 
| 19 | 
            +
            Metrics/BlockLength:
         | 
| 20 | 
            +
              Max: 185
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            # Offense count: 3
         | 
| 23 | 
            +
            # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
         | 
| 24 | 
            +
            # URISchemes: http, https
         | 
| 25 | 
            +
            Metrics/LineLength:
         | 
| 26 | 
            +
              Max: 106
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            # Offense count: 4
         | 
| 29 | 
            +
            # Configuration parameters: Blacklist.
         | 
| 30 | 
            +
            # Blacklist: END, (?-mix:EO[A-Z]{1})
         | 
| 31 | 
            +
            Naming/HeredocDelimiterNaming:
         | 
| 32 | 
            +
              Exclude:
         | 
| 33 | 
            +
                - 'lib/winrm-fs/core/file_transporter.rb'
         | 
| 34 | 
            +
                - 'spec/matchers.rb'
         | 
| 35 | 
            +
                - 'winrm-fs.gemspec'
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            # Offense count: 2
         | 
| 38 | 
            +
            # Cop supports --auto-correct.
         | 
| 39 | 
            +
            # Configuration parameters: AutoCorrect.
         | 
| 40 | 
            +
            Performance/HashEachMethods:
         | 
| 41 | 
            +
              Exclude:
         | 
| 42 | 
            +
                - 'lib/winrm-fs/core/file_transporter.rb'
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            # Offense count: 1
         | 
| 45 | 
            +
            # Configuration parameters: .
         | 
| 46 | 
            +
            # SupportedStyles: annotated, template, unannotated
         | 
| 47 | 
            +
            Style/FormatStringToken:
         | 
| 48 | 
            +
              EnforcedStyle: unannotated
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            # Offense count: 4
         | 
| 51 | 
            +
            # Cop supports --auto-correct.
         | 
| 52 | 
            +
            # Configuration parameters: AutoCorrect, EnforcedStyle.
         | 
| 53 | 
            +
            # SupportedStyles: predicate, comparison
         | 
| 54 | 
            +
            Style/NumericPredicate:
         | 
| 55 | 
            +
              Exclude:
         | 
| 56 | 
            +
                - 'spec/**/*'
         | 
| 57 | 
            +
                - 'lib/winrm-fs/core/file_transporter.rb'
         | 
| 58 | 
            +
                - 'lib/winrm-fs/file_manager.rb'
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            # Offense count: 1
         | 
| 61 | 
            +
            # Cop supports --auto-correct.
         | 
| 62 | 
            +
            # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
         | 
| 63 | 
            +
            # SupportedStyles: slashes, percent_r, mixed
         | 
| 64 | 
            +
            Style/RegexpLiteral:
         | 
| 65 | 
            +
              Exclude:
         | 
| 66 | 
            +
                - 'lib/winrm-fs/core/tmp_zip.rb'
         | 
| 67 | 
            +
             | 
| 68 | 
            +
            # Offense count: 3
         | 
| 69 | 
            +
            # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
         | 
| 70 | 
            +
            # URISchemes: http, https
         | 
| 71 | 
            +
            Metrics/LineLength:
         | 
| 72 | 
            +
              Max: 106
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 1 | 
             
            require 'rubygems'
         | 
| 3 2 | 
             
            require 'bundler/setup'
         | 
| 4 3 | 
             
            require 'rspec/core/rake_task'
         | 
| @@ -23,6 +22,6 @@ end | |
| 23 22 |  | 
| 24 23 | 
             
            RuboCop::RakeTask.new
         | 
| 25 24 |  | 
| 26 | 
            -
            task default: [ | 
| 25 | 
            +
            task default: %i[spec rubocop]
         | 
| 27 26 |  | 
| 28 | 
            -
            task all: [ | 
| 27 | 
            +
            task all: %i[default integration]
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1. | 
| 1 | 
            +
            1.2.0
         | 
    
        data/Vagrantfile
    CHANGED
    
    
    
        data/bin/rwinrmcp
    CHANGED
    
    
    
        data/changelog.md
    CHANGED
    
    
    
        data/lib/winrm-fs.rb
    CHANGED
    
    
| @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # -*- encoding: utf-8 -*-
         | 
| 2 1 | 
             
            #
         | 
| 3 2 | 
             
            # Author:: Fletcher (<fnichol@nichol.ca>)
         | 
| 4 3 | 
             
            #
         | 
| @@ -152,9 +151,7 @@ module WinRM | |
| 152 151 | 
             
                    # @api private
         | 
| 153 152 | 
             
                    def reconcile_destinations!(files)
         | 
| 154 153 | 
             
                      files.each do |_, data|
         | 
| 155 | 
            -
                        if data['target_is_folder'] == 'True'
         | 
| 156 | 
            -
                          data['dst'] = File.join(data['dst'], File.basename(data['src']))
         | 
| 157 | 
            -
                        end
         | 
| 154 | 
            +
                        data['dst'] = File.join(data['dst'], File.basename(data['src'])) if data['target_is_folder'] == 'True'
         | 
| 158 155 | 
             
                      end
         | 
| 159 156 | 
             
                    end
         | 
| 160 157 |  | 
| @@ -321,7 +318,7 @@ module WinRM | |
| 321 318 | 
             
                        elsif File.directory?(expanded)
         | 
| 322 319 | 
             
                          add_directory_hash!(hash, expanded, remote)
         | 
| 323 320 | 
             
                        else
         | 
| 324 | 
            -
                           | 
| 321 | 
            +
                          raise Errno::ENOENT, "No such file or directory #{expanded}"
         | 
| 325 322 | 
             
                        end
         | 
| 326 323 | 
             
                      end
         | 
| 327 324 | 
             
                      hash
         | 
| @@ -362,10 +359,10 @@ module WinRM | |
| 362 359 | 
             
                      stderr = output.stderr
         | 
| 363 360 |  | 
| 364 361 | 
             
                      if exitcode != 0
         | 
| 365 | 
            -
                         | 
| 362 | 
            +
                        raise FileTransporterFailed, "[#{self.class}] Upload failed " \
         | 
| 366 363 | 
             
                          "(exitcode: #{exitcode})\n#{stderr}"
         | 
| 367 364 | 
             
                      elsif stderr != '\r\n' && stderr != ''
         | 
| 368 | 
            -
                         | 
| 365 | 
            +
                        raise FileTransporterFailed, "[#{self.class}] Upload failed " \
         | 
| 369 366 | 
             
                          "(exitcode: 0), but stderr present\n#{stderr}"
         | 
| 370 367 | 
             
                      end
         | 
| 371 368 |  | 
| @@ -413,7 +410,8 @@ module WinRM | |
| 413 410 | 
             
                    # @api private
         | 
| 414 411 | 
             
                    def stream_upload(input_io, dest)
         | 
| 415 412 | 
             
                      read_size = ((max_encoded_write - dest.length) / 4) * 3
         | 
| 416 | 
            -
                      chunk | 
| 413 | 
            +
                      chunk = 1
         | 
| 414 | 
            +
                      bytes = 0
         | 
| 417 415 | 
             
                      buffer = ''
         | 
| 418 416 | 
             
                      shell.run(<<-EOS
         | 
| 419 417 | 
             
                        $to = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("#{dest}")
         | 
| @@ -425,7 +423,6 @@ module WinRM | |
| 425 423 | 
             
                            [System.io.FileAccess]::Write,
         | 
| 426 424 | 
             
                            [System.IO.FileShare]::ReadWrite
         | 
| 427 425 | 
             
                        )
         | 
| 428 | 
            -
             | 
| 429 426 | 
             
                        # Powershell caches ScrpitBlocks in a dictionary
         | 
| 430 427 | 
             
                        # keyed on the script block text. Thats just great
         | 
| 431 428 | 
             
                        # unless the script is super large and called a gillion
         | 
| @@ -436,7 +433,7 @@ module WinRM | |
| 436 433 | 
             
                        $bindingFlags= [Reflection.BindingFlags] "NonPublic,Static"
         | 
| 437 434 | 
             
                        $method = [scriptblock].GetMethod("ClearScriptBlockCache", $bindingFlags)
         | 
| 438 435 | 
             
                        EOS
         | 
| 439 | 
            -
             | 
| 436 | 
            +
                               )
         | 
| 440 437 |  | 
| 441 438 | 
             
                      while input_io.read(read_size, buffer)
         | 
| 442 439 | 
             
                        bytes += (buffer.bytesize / 3 * 4)
         | 
| @@ -468,7 +465,8 @@ module WinRM | |
| 468 465 | 
             
                    # @api private
         | 
| 469 466 | 
             
                    def stream_upload_file(src, dest, &block)
         | 
| 470 467 | 
             
                      logger.debug "Uploading #{src} to #{dest}"
         | 
| 471 | 
            -
                      chunks | 
| 468 | 
            +
                      chunks = 0
         | 
| 469 | 
            +
                      bytes = 0
         | 
| 472 470 | 
             
                      elapsed = Benchmark.measure do
         | 
| 473 471 | 
             
                        File.open(src, 'rb') do |io|
         | 
| 474 472 | 
             
                          chunks, bytes = stream_upload(io, dest, &block)
         | 
| @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # -*- encoding: utf-8 -*-
         | 
| 2 1 | 
             
            #
         | 
| 3 2 | 
             
            # Author:: Fletcher (<fnichol@nichol.ca>)
         | 
| 4 3 | 
             
            #
         | 
| @@ -103,9 +102,7 @@ module WinRM | |
| 103 102 | 
             
                    # @api private
         | 
| 104 103 | 
             
                    def clean_dirname(dir)
         | 
| 105 104 | 
             
                      paths = Pathname.glob(dir)
         | 
| 106 | 
            -
                      if paths.length != 1
         | 
| 107 | 
            -
                        fail "Expected Pathname.glob(dir) to return only dir, got #{paths}"
         | 
| 108 | 
            -
                      end
         | 
| 105 | 
            +
                      raise "Expected Pathname.glob(dir) to return only dir, got #{paths}" if paths.length != 1
         | 
| 109 106 | 
             
                      paths.first
         | 
| 110 107 | 
             
                    end
         | 
| 111 108 |  | 
| @@ -132,7 +129,8 @@ module WinRM | |
| 132 129 | 
             
                        logger.debug "+++ Adding #{entry_path}"
         | 
| 133 130 | 
             
                        zos.put_next_entry(
         | 
| 134 131 | 
             
                          zip_entry(entry_path),
         | 
| 135 | 
            -
                          nil, nil, ::Zip::Entry::DEFLATED, Zlib::BEST_COMPRESSION | 
| 132 | 
            +
                          nil, nil, ::Zip::Entry::DEFLATED, Zlib::BEST_COMPRESSION
         | 
| 133 | 
            +
                        )
         | 
| 136 134 | 
             
                        entry.open('rb') { |src| IO.copy_stream(src, zos) }
         | 
| 137 135 | 
             
                      end
         | 
| 138 136 | 
             
                      logger.debug '=== All files added.'
         | 
    
        data/lib/winrm-fs/exceptions.rb
    CHANGED
    
    
| @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 1 | 
             
            #
         | 
| 3 2 | 
             
            # Copyright 2015 Shawn Neal <sneal@sneal.net>
         | 
| 4 3 | 
             
            #
         | 
| @@ -60,14 +59,14 @@ module WinRM | |
| 60 59 | 
             
                  # Downloads the specified remote file to the specified local path
         | 
| 61 60 | 
             
                  # @param [String] The full path on the remote machine
         | 
| 62 61 | 
             
                  # @param [String] The full path to write the file to locally
         | 
| 63 | 
            -
                  def download(remote_path, local_path)
         | 
| 62 | 
            +
                  def download(remote_path, local_path, first = true)
         | 
| 64 63 | 
             
                    @logger.debug("downloading: #{remote_path} -> #{local_path}")
         | 
| 65 64 | 
             
                    script = WinRM::FS::Scripts.render('download', path: remote_path)
         | 
| 66 65 | 
             
                    output = @connection.shell(:powershell) { |e| e.run(script) }
         | 
| 67 | 
            -
                    return false if output.exitcode != 0
         | 
| 68 66 | 
             
                    contents = output.stdout.gsub('\n\r', '')
         | 
| 69 | 
            -
                     | 
| 70 | 
            -
                     | 
| 67 | 
            +
                    return false if output.exitcode != 0
         | 
| 68 | 
            +
                    download_dir(remote_path, local_path, first) if contents.empty?
         | 
| 69 | 
            +
                    IO.binwrite(local_path, Base64.decode64(contents)) unless contents.empty?
         | 
| 71 70 | 
             
                    true
         | 
| 72 71 | 
             
                  end
         | 
| 73 72 |  | 
| @@ -85,7 +84,7 @@ module WinRM | |
| 85 84 | 
             
                  # @return [String] Full path to the temp directory
         | 
| 86 85 | 
             
                  def temp_dir
         | 
| 87 86 | 
             
                    @guest_temp ||= begin
         | 
| 88 | 
            -
                      (@connection.shell(:powershell) { |e| e.run('$env:TEMP') }).stdout.chomp. | 
| 87 | 
            +
                      (@connection.shell(:powershell) { |e| e.run('$env:TEMP') }).stdout.chomp.tr('\\', '/')
         | 
| 89 88 | 
             
                    end
         | 
| 90 89 | 
             
                  end
         | 
| 91 90 |  | 
| @@ -113,6 +112,17 @@ module WinRM | |
| 113 112 | 
             
                      file_transporter.upload(local_path, remote_path, &block)[0]
         | 
| 114 113 | 
             
                    end
         | 
| 115 114 | 
             
                  end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                  private
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                  def download_dir(remote_path, local_path, first)
         | 
| 119 | 
            +
                    local_path = File.join(local_path, File.basename(remote_path)) if first
         | 
| 120 | 
            +
                    FileUtils.mkdir_p(local_path) unless File.directory?(local_path)
         | 
| 121 | 
            +
                    command = "Get-ChildItem #{remote_path} | Select-Object Name"
         | 
| 122 | 
            +
                    @connection.shell(:powershell) { |e| e.run(command) }.stdout.strip.split(/\n/).drop(2).each do |file|
         | 
| 123 | 
            +
                      download(File.join(remote_path.to_s, file.strip), File.join(local_path, file.strip), first = false)
         | 
| 124 | 
            +
                    end
         | 
| 125 | 
            +
                  end
         | 
| 116 126 | 
             
                end
         | 
| 117 127 | 
             
              end
         | 
| 118 128 | 
             
            end
         | 
| @@ -1,8 +1,11 @@ | |
| 1 1 | 
             
            $p = $ExecutionContext.SessionState.Path
         | 
| 2 2 | 
             
            $path = $p.GetUnresolvedProviderPathFromPSPath("<%= path %>")
         | 
| 3 | 
            -
             | 
| 3 | 
            +
            If (Test-Path $path -PathType Leaf) {
         | 
| 4 4 | 
             
              $bytes = [System.convert]::ToBase64String([System.IO.File]::ReadAllBytes($path))
         | 
| 5 5 | 
             
              Write-Host $bytes
         | 
| 6 6 | 
             
              exit 0
         | 
| 7 7 | 
             
            }
         | 
| 8 | 
            +
            ElseIf (Test-Path $path -PathType Container) {
         | 
| 9 | 
            +
              exit 0
         | 
| 10 | 
            +
            }
         | 
| 8 11 | 
             
            exit 1
         | 
| @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 1 | 
             
            #
         | 
| 3 2 | 
             
            # Copyright 2015 Shawn Neal <sneal@sneal.net>
         | 
| 4 3 | 
             
            #
         | 
| @@ -22,7 +21,8 @@ module WinRM | |
| 22 21 | 
             
                module Scripts
         | 
| 23 22 | 
             
                  def self.render(template, context)
         | 
| 24 23 | 
             
                    template_path = File.expand_path(
         | 
| 25 | 
            -
                      "#{File.dirname(__FILE__)}/#{template}.ps1.erb" | 
| 24 | 
            +
                      "#{File.dirname(__FILE__)}/#{template}.ps1.erb"
         | 
| 25 | 
            +
                    )
         | 
| 26 26 | 
             
                    template = File.read(template_path)
         | 
| 27 27 | 
             
                    Erubis::Eruby.new(template).result(context)
         | 
| 28 28 | 
             
                  end
         | 
| @@ -1,8 +1,9 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 1 | 
             
            require 'pathname'
         | 
| 3 2 |  | 
| 3 | 
            +
            # rubocop:disable BlockLength
         | 
| 4 4 | 
             
            describe WinRM::FS::FileManager do
         | 
| 5 | 
            -
              let(: | 
| 5 | 
            +
              let(:upload_dir) { "winrm_#{rand(2**16)}" }
         | 
| 6 | 
            +
              let(:dest_dir) { File.join(subject.temp_dir, upload_dir) }
         | 
| 6 7 | 
             
              let(:temp_upload_dir) { '$env:TEMP/winrm-upload' }
         | 
| 7 8 | 
             
              let(:spec_dir) { File.expand_path(File.dirname(File.dirname(__FILE__))) }
         | 
| 8 9 | 
             
              let(:this_file) { Pathname.new(__FILE__) }
         | 
| @@ -39,6 +40,50 @@ describe WinRM::FS::FileManager do | |
| 39 40 | 
             
                end
         | 
| 40 41 | 
             
              end
         | 
| 41 42 |  | 
| 43 | 
            +
              context 'download file' do
         | 
| 44 | 
            +
                let(:download_dir) { File.join(spec_dir, 'temp') }
         | 
| 45 | 
            +
                let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) }
         | 
| 46 | 
            +
                let(:download_file) { Pathname.new(File.join(download_dir, File.basename(this_file))) }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                before(:each) do
         | 
| 49 | 
            +
                  expect(subject.delete(dest_dir)).to be true
         | 
| 50 | 
            +
                  FileUtils.rm_rf(Dir.glob("#{download_dir}/*"))
         | 
| 51 | 
            +
                  FileUtils.mkdir_p(download_dir)
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                it 'should download the specified file' do
         | 
| 55 | 
            +
                  subject.upload(this_file, dest_file)
         | 
| 56 | 
            +
                  subject.download(dest_file, download_file)
         | 
| 57 | 
            +
                  expect(File.open(download_file).read).to eq(File.open(this_file).read)
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              context 'download directory' do
         | 
| 62 | 
            +
                let(:download_dir) { File.join(spec_dir, 'temp') }
         | 
| 63 | 
            +
                let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) }
         | 
| 64 | 
            +
                let(:root_dir) { File.expand_path('../../', File.dirname(__FILE__)) }
         | 
| 65 | 
            +
                let(:winrm_fs_dir) { File.join(root_dir, 'lib/winrm-fs') }
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                before(:each) do
         | 
| 68 | 
            +
                  expect(subject.delete(dest_dir)).to be true
         | 
| 69 | 
            +
                  FileUtils.rm_rf(Dir.glob("#{download_dir}/*"))
         | 
| 70 | 
            +
                  FileUtils.mkdir_p(download_dir)
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                it 'downloads the directory contents recursively' do
         | 
| 74 | 
            +
                  subject.upload(winrm_fs_dir, dest_dir)
         | 
| 75 | 
            +
                  subject.download(dest_dir, download_dir)
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  Dir.glob(winrm_fs_dir + '/**/*.rb').each do |host_file|
         | 
| 78 | 
            +
                    host_file_rel = Pathname.new(host_file).relative_path_from(
         | 
| 79 | 
            +
                      Pathname.new(winrm_fs_dir)
         | 
| 80 | 
            +
                    ).to_s
         | 
| 81 | 
            +
                    download_file = File.join(download_dir, upload_dir, host_file_rel)
         | 
| 82 | 
            +
                    expect(File.open(download_file).read).to eq(File.open(host_file).read)
         | 
| 83 | 
            +
                  end
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
              end
         | 
| 86 | 
            +
             | 
| 42 87 | 
             
              context 'upload file' do
         | 
| 43 88 | 
             
                let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) }
         | 
| 44 89 |  | 
| @@ -110,8 +155,7 @@ describe WinRM::FS::FileManager do | |
| 110 155 | 
             
                it 'yields progress data' do
         | 
| 111 156 | 
             
                  block_called = false
         | 
| 112 157 | 
             
                  total_bytes_copied = 0
         | 
| 113 | 
            -
                  total = subject.upload(this_file, dest_file) do  | 
| 114 | 
            -
                    |bytes_copied, total_bytes, local_path, remote_path|
         | 
| 158 | 
            +
                  total = subject.upload(this_file, dest_file) do |bytes_copied, total_bytes, local_path, remote_path|
         | 
| 115 159 | 
             
                    expect(total_bytes).to be > 0
         | 
| 116 160 | 
             
                    total_bytes_copied = bytes_copied
         | 
| 117 161 | 
             
                    expect(local_path).to eq(this_file.to_s)
         | 
| @@ -222,3 +266,4 @@ describe WinRM::FS::FileManager do | |
| 222 266 | 
             
                end
         | 
| 223 267 | 
             
              end
         | 
| 224 268 | 
             
            end
         | 
| 269 | 
            +
            # rubocop:enable BlockLength
         | 
| @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 1 | 
             
            require_relative '../../lib/winrm-fs/core/tmp_zip'
         | 
| 3 2 |  | 
| 4 3 | 
             
            describe WinRM::FS::Core::TmpZip do
         | 
| @@ -18,9 +17,10 @@ describe WinRM::FS::Core::TmpZip do | |
| 18 17 | 
             
              context 'create zip' do
         | 
| 19 18 | 
             
                it 'should add all files in directory to the zip recursively' do
         | 
| 20 19 | 
             
                  expect(subject).to contain_zip_entries([
         | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 20 | 
            +
                                                           'exceptions.rb',
         | 
| 21 | 
            +
                                                           'core/tmp_zip.rb',
         | 
| 22 | 
            +
                                                           'scripts/checksum.ps1.erb'
         | 
| 23 | 
            +
                                                         ])
         | 
| 24 24 | 
             
                end
         | 
| 25 25 | 
             
              end
         | 
| 26 26 | 
             
            end
         | 
    
        data/spec/matchers.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 1 | 
             
            require 'rubygems'
         | 
| 3 2 | 
             
            require 'bundler/setup'
         | 
| 4 3 | 
             
            require 'winrm-fs'
         | 
| @@ -7,7 +6,6 @@ require_relative 'matchers' | |
| 7 6 |  | 
| 8 7 | 
             
            # Creates a WinRM connection for integration tests
         | 
| 9 8 | 
             
            module ConnectionHelper
         | 
| 10 | 
            -
              # rubocop:disable AbcSize
         | 
| 11 9 | 
             
              def winrm_connection
         | 
| 12 10 | 
             
                WinRM::Connection.new(config)
         | 
| 13 11 | 
             
              end
         | 
| @@ -15,8 +13,8 @@ module ConnectionHelper | |
| 15 13 |  | 
| 16 14 | 
             
              def config
         | 
| 17 15 | 
             
                @config ||= begin
         | 
| 18 | 
            -
                  cfg = symbolize_keys(YAML. | 
| 19 | 
            -
                  cfg | 
| 16 | 
            +
                  cfg = symbolize_keys(YAML.safe_load(File.read(winrm_config_path)))
         | 
| 17 | 
            +
                  cfg[:basic_auth_only] = true unless cfg[:transport].eql? :kerberos
         | 
| 20 18 | 
             
                  merge_environment!(cfg)
         | 
| 21 19 | 
             
                  cfg
         | 
| 22 20 | 
             
                end
         | 
| @@ -26,9 +24,7 @@ module ConnectionHelper | |
| 26 24 | 
             
                merge_config_option_from_environment(config, 'user')
         | 
| 27 25 | 
             
                merge_config_option_from_environment(config, 'password')
         | 
| 28 26 | 
             
                merge_config_option_from_environment(config, 'no_ssl_peer_verification')
         | 
| 29 | 
            -
                if ENV['use_ssl_peer_fingerprint']
         | 
| 30 | 
            -
                  config[:options][:ssl_peer_fingerprint] = ENV['winrm_cert']
         | 
| 31 | 
            -
                end
         | 
| 27 | 
            +
                config[:options][:ssl_peer_fingerprint] = ENV['winrm_cert'] if ENV['use_ssl_peer_fingerprint']
         | 
| 32 28 | 
             
                config[:endpoint] = ENV['winrm_endpoint'] if ENV['winrm_endpoint']
         | 
| 33 29 | 
             
                config[:transport] = ENV['winrm_transport'] if ENV['winrm_transport']
         | 
| 34 30 | 
             
              end
         | 
    
        data/spec/unit/tmp_zip_spec.rb
    CHANGED
    
    | @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # -*- encoding: utf-8 -*-
         | 
| 2 1 | 
             
            #
         | 
| 3 2 | 
             
            # Author:: Fletcher (<fnichol@nichol.ca>)
         | 
| 4 3 | 
             
            #
         | 
| @@ -36,7 +35,7 @@ describe WinRM::FS::Core::TmpZip do | |
| 36 35 |  | 
| 37 36 | 
             
              let(:tmp_zip) { WinRM::FS::Core::TmpZip.new(src_dir) }
         | 
| 38 37 |  | 
| 39 | 
            -
              before | 
| 38 | 
            +
              before { @tmpdirs = [] }
         | 
| 40 39 |  | 
| 41 40 | 
             
              after do
         | 
| 42 41 | 
             
                @tmpdirs.each(&:rmtree)
         | 
    
        data/winrm-fs.gemspec
    CHANGED
    
    | @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # encoding: UTF-8
         | 
| 2 1 | 
             
            require 'date'
         | 
| 3 2 |  | 
| 4 3 | 
             
            version = File.read(File.expand_path('../VERSION', __FILE__)).strip
         | 
| @@ -7,7 +6,7 @@ Gem::Specification.new do |s| | |
| 7 6 | 
             
              s.platform = Gem::Platform::RUBY
         | 
| 8 7 | 
             
              s.name = 'winrm-fs'
         | 
| 9 8 | 
             
              s.version = version
         | 
| 10 | 
            -
              s.date | 
| 9 | 
            +
              s.date	= Date.today.to_s
         | 
| 11 10 |  | 
| 12 11 | 
             
              s.author = ['Shawn Neal', 'Matt Wrock']
         | 
| 13 12 | 
             
              s.email = ['sneal@sneal.net', 'matt@mattwrock.com']
         | 
| @@ -20,18 +19,18 @@ Gem::Specification.new do |s| | |
| 20 19 |  | 
| 21 20 | 
             
              s.files = `git ls-files`.split(/\n/)
         | 
| 22 21 | 
             
              s.require_path = 'lib'
         | 
| 23 | 
            -
              s.rdoc_options	= %w | 
| 24 | 
            -
              s.extra_rdoc_files = %w | 
| 22 | 
            +
              s.rdoc_options	= %w[-x test/ -x examples/]
         | 
| 23 | 
            +
              s.extra_rdoc_files = %w[README.md LICENSE]
         | 
| 25 24 |  | 
| 26 25 | 
             
              s.bindir = 'bin'
         | 
| 27 | 
            -
              s.executables | 
| 28 | 
            -
              s.required_ruby_version	= '>= 1. | 
| 26 | 
            +
              s.executables = ['rwinrmcp']
         | 
| 27 | 
            +
              s.required_ruby_version	= '>= 2.1.0'
         | 
| 29 28 | 
             
              s.add_runtime_dependency 'erubis', '~> 2.7'
         | 
| 30 29 | 
             
              s.add_runtime_dependency 'logging', ['>= 1.6.1', '< 3.0']
         | 
| 31 30 | 
             
              s.add_runtime_dependency 'rubyzip', '~> 1.1'
         | 
| 32 31 | 
             
              s.add_runtime_dependency 'winrm', '~> 2.0'
         | 
| 33 32 | 
             
              s.add_development_dependency 'pry'
         | 
| 34 | 
            -
              s.add_development_dependency ' | 
| 35 | 
            -
              s.add_development_dependency ' | 
| 36 | 
            -
              s.add_development_dependency 'rubocop', '~> 0. | 
| 33 | 
            +
              s.add_development_dependency 'rake', '~> 10.3'
         | 
| 34 | 
            +
              s.add_development_dependency 'rspec', '~> 3.0'
         | 
| 35 | 
            +
              s.add_development_dependency 'rubocop', '~> 0.51'
         | 
| 37 36 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: winrm-fs
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Shawn Neal
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2018-01-12 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: erubis
         | 
| @@ -88,47 +88,47 @@ dependencies: | |
| 88 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 89 | 
             
                    version: '0'
         | 
| 90 90 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 91 | 
            -
              name:  | 
| 91 | 
            +
              name: rake
         | 
| 92 92 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 93 93 | 
             
                requirements:
         | 
| 94 94 | 
             
                - - "~>"
         | 
| 95 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            -
                    version: 3 | 
| 96 | 
            +
                    version: '10.3'
         | 
| 97 97 | 
             
              type: :development
         | 
| 98 98 | 
             
              prerelease: false
         | 
| 99 99 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 100 100 | 
             
                requirements:
         | 
| 101 101 | 
             
                - - "~>"
         | 
| 102 102 | 
             
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            -
                    version: 3 | 
| 103 | 
            +
                    version: '10.3'
         | 
| 104 104 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 105 | 
            -
              name:  | 
| 105 | 
            +
              name: rspec
         | 
| 106 106 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 107 107 | 
             
                requirements:
         | 
| 108 108 | 
             
                - - "~>"
         | 
| 109 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            -
                    version:  | 
| 110 | 
            +
                    version: '3.0'
         | 
| 111 111 | 
             
              type: :development
         | 
| 112 112 | 
             
              prerelease: false
         | 
| 113 113 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 114 114 | 
             
                requirements:
         | 
| 115 115 | 
             
                - - "~>"
         | 
| 116 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            -
                    version:  | 
| 117 | 
            +
                    version: '3.0'
         | 
| 118 118 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 119 119 | 
             
              name: rubocop
         | 
| 120 120 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 121 121 | 
             
                requirements:
         | 
| 122 122 | 
             
                - - "~>"
         | 
| 123 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            -
                    version: 0. | 
| 124 | 
            +
                    version: '0.51'
         | 
| 125 125 | 
             
              type: :development
         | 
| 126 126 | 
             
              prerelease: false
         | 
| 127 127 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 128 128 | 
             
                requirements:
         | 
| 129 129 | 
             
                - - "~>"
         | 
| 130 130 | 
             
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            -
                    version: 0. | 
| 131 | 
            +
                    version: '0.51'
         | 
| 132 132 | 
             
            description: "    Ruby library for file system operations via Windows Remote Management\n"
         | 
| 133 133 | 
             
            email:
         | 
| 134 134 | 
             
            - sneal@sneal.net
         | 
| @@ -143,6 +143,7 @@ files: | |
| 143 143 | 
             
            - ".gitignore"
         | 
| 144 144 | 
             
            - ".rspec"
         | 
| 145 145 | 
             
            - ".rubocop.yml"
         | 
| 146 | 
            +
            - ".rubocop_todo.yml"
         | 
| 146 147 | 
             
            - ".travis.yml"
         | 
| 147 148 | 
             
            - Gemfile
         | 
| 148 149 | 
             
            - LICENSE
         | 
| @@ -188,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 188 189 | 
             
              requirements:
         | 
| 189 190 | 
             
              - - ">="
         | 
| 190 191 | 
             
                - !ruby/object:Gem::Version
         | 
| 191 | 
            -
                  version: 1. | 
| 192 | 
            +
                  version: 2.1.0
         | 
| 192 193 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 193 194 | 
             
              requirements:
         | 
| 194 195 | 
             
              - - ">="
         |