Hello community, here is the log from the commit of package rubygem-winrm-fs for openSUSE:Factory checked in at 2018-03-06 10:46:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-winrm-fs (Old) and /work/SRC/openSUSE:Factory/.rubygem-winrm-fs.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-winrm-fs" Tue Mar 6 10:46:33 2018 rev:4 rq:581516 version:1.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-winrm-fs/rubygem-winrm-fs.changes 2017-10-27 14:01:57.674503106 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-winrm-fs.new/rubygem-winrm-fs.changes 2018-03-06 10:46:35.549791522 +0100 @@ -1,0 +2,12 @@ +Tue Feb 27 05:41:16 UTC 2018 - factory-a...@kulow.org + +- updated to version 1.2.0 + see installed changelog.md + + # 1.2.0 + - Add ability to download directories + + # 1.1.1 + - Remove empty items from powershell pipeline when extracting zip files + +------------------------------------------------------------------- Old: ---- winrm-fs-1.1.0.gem New: ---- winrm-fs-1.2.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-winrm-fs.spec ++++++ --- /var/tmp/diff_new_pack.pViXBa/_old 2018-03-06 10:46:36.265765658 +0100 +++ /var/tmp/diff_new_pack.pViXBa/_new 2018-03-06 10:46:36.269765514 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-winrm-fs # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,12 +24,12 @@ # Name: rubygem-winrm-fs -Version: 1.1.0 +Version: 1.2.0 Release: 0 %define mod_name winrm-fs %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{ruby >= 1.9.0} +BuildRequires: %{ruby >= 2.1.0} BuildRequires: %{rubygem gem2rpm} BuildRequires: %{rubygem rdoc > 3.10} BuildRequires: ruby-macros >= 5 ++++++ winrm-fs-1.1.0.gem -> winrm-fs-1.2.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rspec new/.rspec --- old/.rspec 2017-10-12 19:22:04.000000000 +0200 +++ new/.rspec 2018-01-13 01:06:30.000000000 +0100 @@ -1,3 +1,2 @@ --color ---format nested --require spec_helper diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop.yml new/.rubocop.yml --- old/.rubocop.yml 2017-10-12 19:22:04.000000000 +0200 +++ new/.rubocop.yml 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,6 @@ -Style/FileName: +inherit_from: .rubocop_todo.yml + +Naming/FileName: Exclude: - 'lib/winrm-fs.rb' @@ -6,4 +8,7 @@ Enabled: true Metrics/LineLength: - Max: 100 + Max: 120 + +Metrics/AbcSize: + Max: 25 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop_todo.yml new/.rubocop_todo.yml --- old/.rubocop_todo.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/.rubocop_todo.yml 2018-01-13 01:06:30.000000000 +0100 @@ -0,0 +1,72 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2017-12-12 22:48:53 +0100 using RuboCop version 0.52.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent +Layout/IndentHeredoc: + Exclude: + - 'spec/matchers.rb' + +# Offense count: 6 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 185 + +# Offense count: 3 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 106 + +# Offense count: 4 +# Configuration parameters: Blacklist. +# Blacklist: END, (?-mix:EO[A-Z]{1}) +Naming/HeredocDelimiterNaming: + Exclude: + - 'lib/winrm-fs/core/file_transporter.rb' + - 'spec/matchers.rb' + - 'winrm-fs.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. +Performance/HashEachMethods: + Exclude: + - 'lib/winrm-fs/core/file_transporter.rb' + +# Offense count: 1 +# Configuration parameters: . +# SupportedStyles: annotated, template, unannotated +Style/FormatStringToken: + EnforcedStyle: unannotated + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/winrm-fs/core/file_transporter.rb' + - 'lib/winrm-fs/file_manager.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'lib/winrm-fs/core/tmp_zip.rb' + +# Offense count: 3 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 106 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2017-10-12 19:22:04.000000000 +0200 +++ new/.travis.yml 2018-01-13 01:06:30.000000000 +0100 @@ -1,7 +1,8 @@ language: ruby rvm: - - 2.0.0 - 2.1.0 + - 2.3.4 + - 2.4.1 # This prevents testing branches that are created just for PRs branches: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 2017-10-12 19:22:04.000000000 +0200 +++ new/Gemfile 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 source 'https://rubygems.org' gemspec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2017-10-12 19:22:04.000000000 +0200 +++ new/Rakefile 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 require 'rubygems' require 'bundler/setup' require 'rspec/core/rake_task' @@ -23,6 +22,6 @@ RuboCop::RakeTask.new -task default: [:spec, :rubocop] +task default: %i[spec rubocop] -task all: [:default, :integration] +task all: %i[default integration] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/VERSION new/VERSION --- old/VERSION 2017-10-12 19:22:04.000000000 +0200 +++ new/VERSION 2018-01-13 01:06:30.000000000 +0100 @@ -1 +1 @@ -1.1.0 +1.2.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Vagrantfile new/Vagrantfile --- old/Vagrantfile 2017-10-12 19:22:04.000000000 +0200 +++ new/Vagrantfile 2018-01-13 01:06:30.000000000 +0100 @@ -1,8 +1,7 @@ -# encoding: UTF-8 # -*- mode: ruby -*- # vi: set ft=ruby : -VAGRANTFILE_API_VERSION = '2' +VAGRANTFILE_API_VERSION = '2'.freeze Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = 'mwrock/WindowsNano' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/appveyor.yml new/appveyor.yml --- old/appveyor.yml 2017-10-12 19:22:04.000000000 +0200 +++ new/appveyor.yml 2018-01-13 01:06:30.000000000 +0100 @@ -28,7 +28,6 @@ - ps: Write-Host $env:PATH - ps: ruby --version - ps: gem --version - - ps: gem install bundler --quiet --no-ri --no-rdoc - ps: bundler --version build_script: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bin/rwinrmcp new/bin/rwinrmcp --- old/bin/rwinrmcp 2017-10-12 19:22:04.000000000 +0200 +++ new/bin/rwinrmcp 2018-01-13 01:06:30.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 # # Copyright 2014 Shawn Neal <sn...@sneal.net> # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/changelog.md new/changelog.md --- old/changelog.md 2017-10-12 19:22:04.000000000 +0200 +++ new/changelog.md 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,10 @@ # WinRM-fs Gem Changelog +# 1.2.0 +- Add ability to download directories + +# 1.1.1 +- Remove empty items from powershell pipeline when extracting zip files + # 1.1.0 - Convert MD5 hashes to SHA1. Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/core/file_transporter.rb new/lib/winrm-fs/core/file_transporter.rb --- old/lib/winrm-fs/core/file_transporter.rb 2017-10-12 19:22:04.000000000 +0200 +++ new/lib/winrm-fs/core/file_transporter.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Author:: Fletcher (<fnic...@nichol.ca>) # @@ -152,9 +151,7 @@ # @api private def reconcile_destinations!(files) files.each do |_, data| - if data['target_is_folder'] == 'True' - data['dst'] = File.join(data['dst'], File.basename(data['src'])) - end + data['dst'] = File.join(data['dst'], File.basename(data['src'])) if data['target_is_folder'] == 'True' end end @@ -321,7 +318,7 @@ elsif File.directory?(expanded) add_directory_hash!(hash, expanded, remote) else - fail Errno::ENOENT, "No such file or directory #{expanded}" + raise Errno::ENOENT, "No such file or directory #{expanded}" end end hash @@ -362,10 +359,10 @@ stderr = output.stderr if exitcode != 0 - fail FileTransporterFailed, "[#{self.class}] Upload failed " \ + raise FileTransporterFailed, "[#{self.class}] Upload failed " \ "(exitcode: #{exitcode})\n#{stderr}" elsif stderr != '\r\n' && stderr != '' - fail FileTransporterFailed, "[#{self.class}] Upload failed " \ + raise FileTransporterFailed, "[#{self.class}] Upload failed " \ "(exitcode: 0), but stderr present\n#{stderr}" end @@ -413,7 +410,8 @@ # @api private def stream_upload(input_io, dest) read_size = ((max_encoded_write - dest.length) / 4) * 3 - chunk, bytes = 1, 0 + chunk = 1 + bytes = 0 buffer = '' shell.run(<<-EOS $to = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("#{dest}") @@ -425,7 +423,6 @@ [System.io.FileAccess]::Write, [System.IO.FileShare]::ReadWrite ) - # Powershell caches ScrpitBlocks in a dictionary # keyed on the script block text. Thats just great # unless the script is super large and called a gillion @@ -436,7 +433,7 @@ $bindingFlags= [Reflection.BindingFlags] "NonPublic,Static" $method = [scriptblock].GetMethod("ClearScriptBlockCache", $bindingFlags) EOS - ) + ) while input_io.read(read_size, buffer) bytes += (buffer.bytesize / 3 * 4) @@ -468,7 +465,8 @@ # @api private def stream_upload_file(src, dest, &block) logger.debug "Uploading #{src} to #{dest}" - chunks, bytes = 0, 0 + chunks = 0 + bytes = 0 elapsed = Benchmark.measure do File.open(src, 'rb') do |io| chunks, bytes = stream_upload(io, dest, &block) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/core/tmp_zip.rb new/lib/winrm-fs/core/tmp_zip.rb --- old/lib/winrm-fs/core/tmp_zip.rb 2017-10-12 19:22:04.000000000 +0200 +++ new/lib/winrm-fs/core/tmp_zip.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Author:: Fletcher (<fnic...@nichol.ca>) # @@ -103,9 +102,7 @@ # @api private def clean_dirname(dir) paths = Pathname.glob(dir) - if paths.length != 1 - fail "Expected Pathname.glob(dir) to return only dir, got #{paths}" - end + raise "Expected Pathname.glob(dir) to return only dir, got #{paths}" if paths.length != 1 paths.first end @@ -132,7 +129,8 @@ logger.debug "+++ Adding #{entry_path}" zos.put_next_entry( zip_entry(entry_path), - nil, nil, ::Zip::Entry::DEFLATED, Zlib::BEST_COMPRESSION) + nil, nil, ::Zip::Entry::DEFLATED, Zlib::BEST_COMPRESSION + ) entry.open('rb') { |src| IO.copy_stream(src, zos) } end logger.debug '=== All files added.' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/exceptions.rb new/lib/winrm-fs/exceptions.rb --- old/lib/winrm-fs/exceptions.rb 2017-10-12 19:22:04.000000000 +0200 +++ new/lib/winrm-fs/exceptions.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Copyright 2015 Shawn Neal <sn...@sneal.net> # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/file_manager.rb new/lib/winrm-fs/file_manager.rb --- old/lib/winrm-fs/file_manager.rb 2017-10-12 19:22:04.000000000 +0200 +++ new/lib/winrm-fs/file_manager.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Copyright 2015 Shawn Neal <sn...@sneal.net> # @@ -60,14 +59,14 @@ # Downloads the specified remote file to the specified local path # @param [String] The full path on the remote machine # @param [String] The full path to write the file to locally - def download(remote_path, local_path) + def download(remote_path, local_path, first = true) @logger.debug("downloading: #{remote_path} -> #{local_path}") script = WinRM::FS::Scripts.render('download', path: remote_path) output = @connection.shell(:powershell) { |e| e.run(script) } - return false if output.exitcode != 0 contents = output.stdout.gsub('\n\r', '') - out = Base64.decode64(contents) - IO.binwrite(local_path, out) + return false if output.exitcode != 0 + download_dir(remote_path, local_path, first) if contents.empty? + IO.binwrite(local_path, Base64.decode64(contents)) unless contents.empty? true end @@ -85,7 +84,7 @@ # @return [String] Full path to the temp directory def temp_dir @guest_temp ||= begin - (@connection.shell(:powershell) { |e| e.run('$env:TEMP') }).stdout.chomp.gsub('\\', '/') + (@connection.shell(:powershell) { |e| e.run('$env:TEMP') }).stdout.chomp.tr('\\', '/') end end @@ -113,6 +112,17 @@ file_transporter.upload(local_path, remote_path, &block)[0] end end + + private + + def download_dir(remote_path, local_path, first) + local_path = File.join(local_path, File.basename(remote_path)) if first + FileUtils.mkdir_p(local_path) unless File.directory?(local_path) + command = "Get-ChildItem #{remote_path} | Select-Object Name" + @connection.shell(:powershell) { |e| e.run(command) }.stdout.strip.split(/\n/).drop(2).each do |file| + download(File.join(remote_path.to_s, file.strip), File.join(local_path, file.strip), first = false) + end + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/scripts/download.ps1.erb new/lib/winrm-fs/scripts/download.ps1.erb --- old/lib/winrm-fs/scripts/download.ps1.erb 2017-10-12 19:22:04.000000000 +0200 +++ new/lib/winrm-fs/scripts/download.ps1.erb 2018-01-13 01:06:30.000000000 +0100 @@ -1,8 +1,11 @@ $p = $ExecutionContext.SessionState.Path $path = $p.GetUnresolvedProviderPathFromPSPath("<%= path %>") -if (Test-Path $path -PathType Leaf) { +If (Test-Path $path -PathType Leaf) { $bytes = [System.convert]::ToBase64String([System.IO.File]::ReadAllBytes($path)) Write-Host $bytes exit 0 } +ElseIf (Test-Path $path -PathType Container) { + exit 0 +} exit 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/scripts/extract_files.ps1.erb new/lib/winrm-fs/scripts/extract_files.ps1.erb --- old/lib/winrm-fs/scripts/extract_files.ps1.erb 2017-10-12 19:22:04.000000000 +0200 +++ new/lib/winrm-fs/scripts/extract_files.ps1.erb 2018-01-13 01:06:30.000000000 +0100 @@ -38,7 +38,7 @@ catch { Try { $s = New-Object -ComObject Shell.Application - ($s.NameSpace($unpack)).CopyHere(($s.NameSpace($src)).Items(), 0x610) + ($s.NameSpace($unpack)).CopyHere(($s.NameSpace($src)).Items(), 0x610) | Out-Null } Finally { [void][Runtime.Interopservices.Marshal]::ReleaseComObject($s) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/scripts/scripts.rb new/lib/winrm-fs/scripts/scripts.rb --- old/lib/winrm-fs/scripts/scripts.rb 2017-10-12 19:22:04.000000000 +0200 +++ new/lib/winrm-fs/scripts/scripts.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Copyright 2015 Shawn Neal <sn...@sneal.net> # @@ -22,7 +21,8 @@ module Scripts def self.render(template, context) template_path = File.expand_path( - "#{File.dirname(__FILE__)}/#{template}.ps1.erb") + "#{File.dirname(__FILE__)}/#{template}.ps1.erb" + ) template = File.read(template_path) Erubis::Eruby.new(template).result(context) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs.rb new/lib/winrm-fs.rb --- old/lib/winrm-fs.rb 2017-10-12 19:22:04.000000000 +0200 +++ new/lib/winrm-fs.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Copyright 2015 Shawn Neal <sn...@sneal.net> # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2017-10-12 19:22:04.000000000 +0200 +++ new/metadata 2018-01-13 01:06:30.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: winrm-fs version: !ruby/object:Gem::Version - version: 1.1.0 + version: 1.2.0 platform: ruby authors: - Shawn Neal @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2017-10-12 00:00:00.000000000 Z +date: 2018-01-12 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: erubis @@ -88,47 +88,47 @@ - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency - name: rspec + name: rake requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 3.0.0 + version: '10.3' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 3.0.0 + version: '10.3' - !ruby/object:Gem::Dependency - name: rake + name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 10.3.2 + version: '3.0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 10.3.2 + version: '3.0' - !ruby/object:Gem::Dependency name: rubocop requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 0.28.0 + version: '0.51' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 0.28.0 + version: '0.51' description: " Ruby library for file system operations via Windows Remote Management\n" email: - sn...@sneal.net @@ -143,6 +143,7 @@ - ".gitignore" - ".rspec" - ".rubocop.yml" +- ".rubocop_todo.yml" - ".travis.yml" - Gemfile - LICENSE @@ -188,7 +189,7 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: 1.9.0 + version: 2.1.0 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/integration/file_manager_spec.rb new/spec/integration/file_manager_spec.rb --- old/spec/integration/file_manager_spec.rb 2017-10-12 19:22:04.000000000 +0200 +++ new/spec/integration/file_manager_spec.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,8 +1,9 @@ -# encoding: UTF-8 require 'pathname' +# rubocop:disable BlockLength describe WinRM::FS::FileManager do - let(:dest_dir) { File.join(subject.temp_dir, "winrm_#{rand(2**16)}") } + let(:upload_dir) { "winrm_#{rand(2**16)}" } + let(:dest_dir) { File.join(subject.temp_dir, upload_dir) } let(:temp_upload_dir) { '$env:TEMP/winrm-upload' } let(:spec_dir) { File.expand_path(File.dirname(File.dirname(__FILE__))) } let(:this_file) { Pathname.new(__FILE__) } @@ -39,6 +40,50 @@ end end + context 'download file' do + let(:download_dir) { File.join(spec_dir, 'temp') } + let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) } + let(:download_file) { Pathname.new(File.join(download_dir, File.basename(this_file))) } + + before(:each) do + expect(subject.delete(dest_dir)).to be true + FileUtils.rm_rf(Dir.glob("#{download_dir}/*")) + FileUtils.mkdir_p(download_dir) + end + + it 'should download the specified file' do + subject.upload(this_file, dest_file) + subject.download(dest_file, download_file) + expect(File.open(download_file).read).to eq(File.open(this_file).read) + end + end + + context 'download directory' do + let(:download_dir) { File.join(spec_dir, 'temp') } + let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) } + let(:root_dir) { File.expand_path('../../', File.dirname(__FILE__)) } + let(:winrm_fs_dir) { File.join(root_dir, 'lib/winrm-fs') } + + before(:each) do + expect(subject.delete(dest_dir)).to be true + FileUtils.rm_rf(Dir.glob("#{download_dir}/*")) + FileUtils.mkdir_p(download_dir) + end + + it 'downloads the directory contents recursively' do + subject.upload(winrm_fs_dir, dest_dir) + subject.download(dest_dir, download_dir) + + Dir.glob(winrm_fs_dir + '/**/*.rb').each do |host_file| + host_file_rel = Pathname.new(host_file).relative_path_from( + Pathname.new(winrm_fs_dir) + ).to_s + download_file = File.join(download_dir, upload_dir, host_file_rel) + expect(File.open(download_file).read).to eq(File.open(host_file).read) + end + end + end + context 'upload file' do let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) } @@ -110,8 +155,7 @@ it 'yields progress data' do block_called = false total_bytes_copied = 0 - total = subject.upload(this_file, dest_file) do \ - |bytes_copied, total_bytes, local_path, remote_path| + total = subject.upload(this_file, dest_file) do |bytes_copied, total_bytes, local_path, remote_path| expect(total_bytes).to be > 0 total_bytes_copied = bytes_copied expect(local_path).to eq(this_file.to_s) @@ -222,3 +266,4 @@ end end end +# rubocop:enable BlockLength diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/integration/tmp_zip_spec.rb new/spec/integration/tmp_zip_spec.rb --- old/spec/integration/tmp_zip_spec.rb 2017-10-12 19:22:04.000000000 +0200 +++ new/spec/integration/tmp_zip_spec.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative '../../lib/winrm-fs/core/tmp_zip' describe WinRM::FS::Core::TmpZip do @@ -18,9 +17,10 @@ context 'create zip' do it 'should add all files in directory to the zip recursively' do expect(subject).to contain_zip_entries([ - 'exceptions.rb', - 'core/tmp_zip.rb', - 'scripts/checksum.ps1.erb']) + 'exceptions.rb', + 'core/tmp_zip.rb', + 'scripts/checksum.ps1.erb' + ]) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/matchers.rb new/spec/matchers.rb --- old/spec/matchers.rb 2017-10-12 19:22:05.000000000 +0200 +++ new/spec/matchers.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 require 'rspec/expectations' RSpec::Matchers.define :have_created do |remote_file| diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb --- old/spec/spec_helper.rb 2017-10-12 19:22:05.000000000 +0200 +++ new/spec/spec_helper.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 require 'rubygems' require 'bundler/setup' require 'winrm-fs' @@ -7,7 +6,6 @@ # Creates a WinRM connection for integration tests module ConnectionHelper - # rubocop:disable AbcSize def winrm_connection WinRM::Connection.new(config) end @@ -15,8 +13,8 @@ def config @config ||= begin - cfg = symbolize_keys(YAML.load(File.read(winrm_config_path))) - cfg.merge!(basic_auth_only: true) unless cfg[:transport].eql? :kerberos + cfg = symbolize_keys(YAML.safe_load(File.read(winrm_config_path))) + cfg[:basic_auth_only] = true unless cfg[:transport].eql? :kerberos merge_environment!(cfg) cfg end @@ -26,9 +24,7 @@ merge_config_option_from_environment(config, 'user') merge_config_option_from_environment(config, 'password') merge_config_option_from_environment(config, 'no_ssl_peer_verification') - if ENV['use_ssl_peer_fingerprint'] - config[:options][:ssl_peer_fingerprint] = ENV['winrm_cert'] - end + config[:options][:ssl_peer_fingerprint] = ENV['winrm_cert'] if ENV['use_ssl_peer_fingerprint'] config[:endpoint] = ENV['winrm_endpoint'] if ENV['winrm_endpoint'] config[:transport] = ENV['winrm_transport'] if ENV['winrm_transport'] end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/unit/tmp_zip_spec.rb new/spec/unit/tmp_zip_spec.rb --- old/spec/unit/tmp_zip_spec.rb 2017-10-12 19:22:05.000000000 +0200 +++ new/spec/unit/tmp_zip_spec.rb 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Author:: Fletcher (<fnic...@nichol.ca>) # @@ -36,7 +35,7 @@ let(:tmp_zip) { WinRM::FS::Core::TmpZip.new(src_dir) } - before { @tmpdirs = [] } + before { @tmpdirs = [] } after do @tmpdirs.each(&:rmtree) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/winrm-fs.gemspec new/winrm-fs.gemspec --- old/winrm-fs.gemspec 2017-10-12 19:22:05.000000000 +0200 +++ new/winrm-fs.gemspec 2018-01-13 01:06:30.000000000 +0100 @@ -1,4 +1,3 @@ -# encoding: UTF-8 require 'date' version = File.read(File.expand_path('../VERSION', __FILE__)).strip @@ -7,7 +6,7 @@ s.platform = Gem::Platform::RUBY s.name = 'winrm-fs' s.version = version - s.date = Date.today.to_s + s.date = Date.today.to_s s.author = ['Shawn Neal', 'Matt Wrock'] s.email = ['sn...@sneal.net', 'm...@mattwrock.com'] @@ -20,18 +19,18 @@ s.files = `git ls-files`.split(/\n/) s.require_path = 'lib' - s.rdoc_options = %w(-x test/ -x examples/) - s.extra_rdoc_files = %w(README.md LICENSE) + s.rdoc_options = %w[-x test/ -x examples/] + s.extra_rdoc_files = %w[README.md LICENSE] s.bindir = 'bin' - s.executables = ['rwinrmcp'] - s.required_ruby_version = '>= 1.9.0' + s.executables = ['rwinrmcp'] + s.required_ruby_version = '>= 2.1.0' s.add_runtime_dependency 'erubis', '~> 2.7' s.add_runtime_dependency 'logging', ['>= 1.6.1', '< 3.0'] s.add_runtime_dependency 'rubyzip', '~> 1.1' s.add_runtime_dependency 'winrm', '~> 2.0' s.add_development_dependency 'pry' - s.add_development_dependency 'rspec', '~> 3.0.0' - s.add_development_dependency 'rake', '~> 10.3.2' - s.add_development_dependency 'rubocop', '~> 0.28.0' + s.add_development_dependency 'rake', '~> 10.3' + s.add_development_dependency 'rspec', '~> 3.0' + s.add_development_dependency 'rubocop', '~> 0.51' end