winrm-fs 1.3.4 → 1.3.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cf37aded4f1476cc49122bbbca6471a99f8aca993c576814b84cbc5c5df5a19
4
- data.tar.gz: 065cbd45d85cac20c802fb80658f2827973575a66fca2ebf3e4d7d89850e26f9
3
+ metadata.gz: 85111e8743dcffa4aafcf63f815eff675bda56e951ff83c0f7e63d7b97e4b25c
4
+ data.tar.gz: 29c072897a7d7372391d64446e1f7256d60e02a9846914f0b6decb497343b7c2
5
5
  SHA512:
6
- metadata.gz: c03405f8768546eb314bbac0ec02e0d41af49126c3686bc653cdbe8087d474805b293d278bce4951532d62d15638af7e9f4e06697a3d1cb11ee69900f40b00ac
7
- data.tar.gz: 9b2a13482f0aee40125d1879943ad526dc22a9d74f87a7e21f122474af7449033fa3006b2637e27ae8e26abc97f0122fcfacd8d422cc13250cc63d7060b088f2
6
+ metadata.gz: 658a0ee64bfb237dc03e31e6e2b25db8d90cf692452d82fe3c25fe09d41ab568611d588c6830b9a6496d582181b5221e9689994a5b4ce51af024188bdfa6c4ea
7
+ data.tar.gz: 4adf7ef9cd6ae186f402b0f8b8e29b09d37e5f325e0b9aa648a2ca4f2eb0c399793fab4e13c6866ba087fb464db09108bffef8fa0d7ebc0b368b57f7ce0727a6
data/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # File system operations over Windows Remote Management (WinRM) for Ruby
2
- [![Build Status](https://travis-ci.org/WinRb/winrm-fs.svg?branch=master)](https://travis-ci.org/WinRb/winrm-fs)
2
+
3
+ [![CI](https://github.com/WinRb/winrm-fs/actions/workflows/ci.yml/badge.svg)](https://github.com/WinRb/winrm-fs/actions/workflows/ci.yml)
3
4
  [![Gem Version](https://badge.fury.io/rb/winrm-fs.svg)](http://badge.fury.io/rb/winrm-fs)
4
- [![Build status](https://ci.appveyor.com/api/projects/status/wm6apa8ojfhfmwsf?svg=true)](https://ci.appveyor.com/project/winrb/winrm-fs)
5
5
 
6
6
  ## Uploading files
7
+
7
8
  Files may be copied from the local machine to the winrm endpoint. Individual files or directories, as well as arrays of files and directories may be specified. Data from a `StringIO` object may also be uploaded to a remote file.
9
+
8
10
  ```ruby
9
11
  require 'winrm-fs'
10
12
 
11
- connection = WinRM::Connection.new(...
13
+ connection = WinRM::Connection.new(...)
12
14
  file_manager = WinRM::FS::FileManager.new(connection)
13
15
 
14
16
  # upload file.txt from the current working directory
@@ -29,11 +31,14 @@ file_manager.upload([
29
31
  ```
30
32
 
31
33
  ### Optimizing WinRM settings
34
+
32
35
  Since winrm-fs 1.0/winrm 2.0, files are uploaded using the PSRP protocol and transfer speeds are dramatically improved from previous versions. This is largely due to the fact that the size of chunks that can be transferred at one time are now governed by the `MaxEnvelopeSizekb` winrm configuration setting on the endpoint. This default to 500 on Windows 2012 R2 and 150 on Windows 2008 R2. You may experience much faster transfer rates on 2008 R2 by increasing this setting.
33
36
 
34
37
  ### Handling progress events
38
+
35
39
  If you want to implement your own custom progress handling, you can pass a code
36
- block and use the proggress data that `upload` yields to this block:
40
+ block and use the progress data that `upload` yields to this block:
41
+
37
42
  ```ruby
38
43
  file_manager.upload('c:/dev/my_dir', '$env:AppData') do |bytes_copied, total_bytes, local_path, remote_path|
39
44
  puts "#{bytes_copied}bytes of #{total_bytes}bytes copied"
@@ -53,20 +58,20 @@ first.
53
58
  3. Run the unit and integration tests (bundle exec rake integration)
54
59
  4. Commit your changes (git commit -am "Added a sweet feature")
55
60
  5. Push to the branch (git push origin my_feature_branch)
56
- 6. Create a pull requst from your branch into master (Please be sure to provide enough detail for us to cipher what this change is doing)
61
+ 6. Create a pull request from your branch into main (Please be sure to provide enough detail for us to cipher what this change is doing)
57
62
 
58
63
  ### Running the tests
59
64
 
60
65
  We use Bundler to manage dependencies during development.
61
66
 
62
- ```
63
- $ bundle install
67
+ ```bash
68
+ bundle install
64
69
  ```
65
70
 
66
71
  Once you have the dependencies, you can run the unit tests with `rake`:
67
72
 
68
- ```
69
- $ bundle exec rake spec
73
+ ```bash
74
+ bundle exec rake spec
70
75
  ```
71
76
 
72
77
  To run the integration tests you will need a Windows box with the WinRM service properly configured. Its easiest to use the Vagrant Windows box in the Vagrantilfe of this repo.
@@ -76,6 +81,7 @@ To run the integration tests you will need a Windows box with the WinRM service
76
81
  3. Run `bundle exec rake integration`
77
82
 
78
83
  ## WinRM-fs Authors
84
+
79
85
  * Shawn Neal (https://github.com/sneal)
80
86
  * Matt Wrock (https://github.com/mwrock)
81
87
 
data/bin/rwinrmcp CHANGED
File without changes
@@ -17,11 +17,10 @@
17
17
  # See the License for the specific language governing permissions and
18
18
  # limitations under the License.
19
19
 
20
- require 'benchmark'
21
- require 'csv'
22
- require 'digest'
23
- require 'securerandom'
24
- require 'stringio'
20
+ require 'benchmark' unless defined?(Benchmark)
21
+ require 'digest' unless defined?(Digest)
22
+ require 'securerandom' unless defined?(SecureRandom)
23
+ require 'stringio' unless defined?(StringIO)
25
24
 
26
25
  require 'winrm/exceptions'
27
26
  require 'winrm-fs/core/tmp_zip'
@@ -67,6 +66,7 @@ module WinRM
67
66
  @shell = shell
68
67
  @logger = shell.logger
69
68
  @id_generator = opts.fetch(:id_generator) { -> { SecureRandom.uuid } }
69
+ require 'zip'
70
70
  Zip.unicode_names = true
71
71
  end
72
72
 
@@ -117,6 +117,10 @@ module WinRM
117
117
  [total_size, files]
118
118
  end
119
119
 
120
+ def close
121
+ shell.close
122
+ end
123
+
120
124
  private
121
125
 
122
126
  # @return [String] the Array pack template for Base64 encoding a stream
@@ -405,6 +409,8 @@ module WinRM
405
409
  "(exitcode: 0), but stderr present\n#{stderr}"
406
410
  end
407
411
 
412
+ require 'csv'
413
+
408
414
  logger.debug 'Parsing CSV Response'
409
415
  logger.debug output.stdout
410
416
 
@@ -18,9 +18,9 @@
18
18
  # limitations under the License.
19
19
 
20
20
  require 'delegate'
21
- require 'pathname'
22
- require 'tempfile'
23
- require 'zip'
21
+ require 'logger' unless defined?(Logger)
22
+ require 'pathname' unless defined?(Pathname)
23
+ require 'tempfile' unless defined?(Tempfile)
24
24
 
25
25
  module WinRM
26
26
  module FS
@@ -68,7 +68,8 @@ module WinRM
68
68
  # @param logger [#debug,#debug?] an optional logger/ui object that
69
69
  # responds to `#debug` and `#debug?` (default `nil`)
70
70
  def initialize(dir, logger = nil)
71
- @logger = logger || Logging.logger[self]
71
+ require 'zip'
72
+ @logger = logger || Logger.new(nil)
72
73
  @dir = clean_dirname(dir)
73
74
  @zip_io = Tempfile.open(['tmpzip-', '.zip'], binmode: true)
74
75
  write_zip
@@ -113,13 +114,7 @@ module WinRM
113
114
  # directory, excluding directories
114
115
  # @api private
115
116
  def entries
116
- Pathname.glob(dir.join('**/*')).delete_if(&:directory?).sort
117
- end
118
-
119
- # (see Logging.log_subject)
120
- # @api private
121
- def log_subject
122
- @log_subject ||= [self.class.to_s.split('::').last, path].join('::')
117
+ Pathname.glob(dir.join('**/.*')).push(*Pathname.glob(dir.join('**/*'))).delete_if(&:directory?).sort
123
118
  end
124
119
 
125
120
  # Adds all file entries to the Zip output stream.
@@ -149,12 +144,12 @@ module WinRM
149
144
  end
150
145
  end
151
146
 
147
+ # rubyzip 3.x takes optional Entry arguments as keywords
152
148
  def zip_entry(entry_path)
153
149
  Zip::Entry.new(
154
150
  zip_io.path,
155
151
  entry_path.to_s,
156
- nil, nil, nil, nil, nil, nil,
157
- ::Zip::DOSTime.new(2000)
152
+ time: ::Zip::DOSTime.new(2000)
158
153
  )
159
154
  end
160
155
 
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'winrm'
18
+ require 'winrm' unless defined?(WinRM::Connection)
19
19
  require_relative 'scripts/scripts'
20
20
  require_relative 'core/file_transporter'
21
21
 
@@ -37,7 +37,7 @@ module WinRM
37
37
  def checksum(path, digest = 'SHA1')
38
38
  @logger.debug("checksum with #{digest}: #{path}")
39
39
  script = WinRM::FS::Scripts.render('checksum', path: path, digest: digest)
40
- @connection.shell(:powershell) { |e| e.run(script).stdout.chomp }
40
+ ps_run(script).exitcode == 0
41
41
  end
42
42
 
43
43
  # Create the specifed directory recursively
@@ -46,7 +46,7 @@ module WinRM
46
46
  def create_dir(path)
47
47
  @logger.debug("create_dir: #{path}")
48
48
  script = WinRM::FS::Scripts.render('create_dir', path: path)
49
- @connection.shell(:powershell) { |e| e.run(script).exitcode == 0 }
49
+ ps_run(script).exitcode == 0
50
50
  end
51
51
 
52
52
  # Deletes the file or directory at the specified path
@@ -55,7 +55,7 @@ module WinRM
55
55
  def delete(path)
56
56
  @logger.debug("deleting: #{path}")
57
57
  script = WinRM::FS::Scripts.render('delete', path: path)
58
- @connection.shell(:powershell) { |e| e.run(script).exitcode == 0 }
58
+ ps_run(script).exitcode == 0
59
59
  end
60
60
 
61
61
  # Downloads the specified remote file to the specified local path
@@ -87,7 +87,7 @@ module WinRM
87
87
 
88
88
  def _output_from_file(remote_path, chunk_size, index)
89
89
  script = WinRM::FS::Scripts.render('download', path: remote_path, chunk_size: chunk_size, index: index)
90
- @connection.shell(:powershell) { |e| e.run(script) }
90
+ ps_run(script)
91
91
  end
92
92
 
93
93
  def _write_file(tofd, output)
@@ -106,7 +106,7 @@ module WinRM
106
106
  def exists?(path)
107
107
  @logger.debug("exists?: #{path}")
108
108
  script = WinRM::FS::Scripts.render('exists', path: path)
109
- @connection.shell(:powershell) { |e| e.run(script).exitcode == 0 }
109
+ ps_run(script).exitcode == 0
110
110
  end
111
111
 
112
112
  # Gets the current user's TEMP directory on the remote system, for example
@@ -114,7 +114,7 @@ module WinRM
114
114
  # @return [String] Full path to the temp directory
115
115
  def temp_dir
116
116
  @temp_dir ||= begin
117
- (@connection.shell(:powershell) { |e| e.run('$env:TEMP') }).stdout.chomp.tr('\\', '/')
117
+ ps_run('$env:TEMP').stdout.chomp.tr('\\', '/')
118
118
  end
119
119
  end
120
120
 
@@ -139,12 +139,25 @@ module WinRM
139
139
  def upload(local_path, remote_path, &block)
140
140
  @connection.shell(:powershell) do |shell|
141
141
  file_transporter ||= WinRM::FS::Core::FileTransporter.new(shell)
142
- file_transporter.upload(local_path, remote_path, &block)[0]
142
+ begin
143
+ file_transporter.upload(local_path, remote_path, &block)[0]
144
+ ensure
145
+ file_transporter.close
146
+ end
143
147
  end
144
148
  end
145
149
 
146
150
  private
147
151
 
152
+ def ps_run(cmd)
153
+ shell = @connection.shell(:powershell)
154
+ begin
155
+ shell.run(cmd)
156
+ ensure
157
+ shell.close
158
+ end
159
+ end
160
+
148
161
  def download_dir(remote_path, local_path, chunk_size, first)
149
162
  local_path = File.join(local_path, File.basename(remote_path.to_s)) if first
150
163
  FileUtils.mkdir_p(local_path) unless File.directory?(local_path)
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'erubi'
18
+ require 'erb'
19
19
 
20
20
  module WinRM
21
21
  module FS
@@ -40,7 +40,7 @@ module WinRM
40
40
  else
41
41
  raise ArgumentError
42
42
  end
43
- b.eval(Erubi::Engine.new(template).src)
43
+ ERB.new(template).result(b)
44
44
  end
45
45
  end
46
46
  end
data/lib/winrm-fs.rb CHANGED
@@ -15,9 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'winrm'
19
- require 'logger'
20
- require 'pathname'
18
+ require 'winrm' unless defined?(WinRM::Connection)
19
+ require 'pathname' unless defined?(Pathname)
21
20
  require_relative 'winrm-fs/exceptions'
22
21
  require_relative 'winrm-fs/file_manager'
23
22
 
metadata CHANGED
@@ -1,64 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winrm-fs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Neal
8
8
  - Matt Wrock
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2019-11-14 00:00:00.000000000 Z
11
+ date: 2026-09-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: erubi
14
+ name: benchmark
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: csv
16
29
  requirement: !ruby/object:Gem::Requirement
17
30
  requirements:
18
31
  - - "~>"
19
32
  - !ruby/object:Gem::Version
20
- version: '1.8'
33
+ version: '3.3'
21
34
  type: :runtime
22
35
  prerelease: false
23
36
  version_requirements: !ruby/object:Gem::Requirement
24
37
  requirements:
25
38
  - - "~>"
26
39
  - !ruby/object:Gem::Version
27
- version: '1.8'
40
+ version: '3.3'
28
41
  - !ruby/object:Gem::Dependency
29
- name: logging
42
+ name: logger
30
43
  requirement: !ruby/object:Gem::Requirement
31
44
  requirements:
32
45
  - - ">="
33
46
  - !ruby/object:Gem::Version
34
- version: 1.6.1
35
- - - "<"
36
- - !ruby/object:Gem::Version
37
- version: '3.0'
47
+ version: '0'
38
48
  type: :runtime
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
51
  requirements:
42
52
  - - ">="
43
53
  - !ruby/object:Gem::Version
44
- version: 1.6.1
45
- - - "<"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
54
+ version: '0'
48
55
  - !ruby/object:Gem::Dependency
49
56
  name: rubyzip
50
57
  requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - "~>"
53
60
  - !ruby/object:Gem::Version
54
- version: '2.0'
61
+ version: '3.4'
55
62
  type: :runtime
56
63
  prerelease: false
57
64
  version_requirements: !ruby/object:Gem::Requirement
58
65
  requirements:
59
66
  - - "~>"
60
67
  - !ruby/object:Gem::Version
61
- version: '2.0'
68
+ version: '3.4'
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: winrm
64
71
  requirement: !ruby/object:Gem::Requirement
@@ -96,7 +103,7 @@ dependencies:
96
103
  version: '10.3'
97
104
  - - "<"
98
105
  - !ruby/object:Gem::Version
99
- version: '13'
106
+ version: '14'
100
107
  type: :development
101
108
  prerelease: false
102
109
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +113,7 @@ dependencies:
106
113
  version: '10.3'
107
114
  - - "<"
108
115
  - !ruby/object:Gem::Version
109
- version: '13'
116
+ version: '14'
110
117
  - !ruby/object:Gem::Dependency
111
118
  name: rspec
112
119
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +134,14 @@ dependencies:
127
134
  requirements:
128
135
  - - "~>"
129
136
  - !ruby/object:Gem::Version
130
- version: 0.68.0
137
+ version: 1.26.0
131
138
  type: :development
132
139
  prerelease: false
133
140
  version_requirements: !ruby/object:Gem::Requirement
134
141
  requirements:
135
142
  - - "~>"
136
143
  - !ruby/object:Gem::Version
137
- version: 0.68.0
144
+ version: 1.26.0
138
145
  description: " Ruby library for file system operations via Windows Remote Management\n"
139
146
  email:
140
147
  - sneal@sneal.net
@@ -143,8 +150,8 @@ executables:
143
150
  - rwinrmcp
144
151
  extensions: []
145
152
  extra_rdoc_files:
146
- - README.md
147
153
  - LICENSE
154
+ - README.md
148
155
  files:
149
156
  - LICENSE
150
157
  - README.md
@@ -166,7 +173,6 @@ homepage: http://github.com/WinRb/winrm-fs
166
173
  licenses:
167
174
  - Apache-2.0
168
175
  metadata: {}
169
- post_install_message:
170
176
  rdoc_options:
171
177
  - "-x"
172
178
  - test/
@@ -178,16 +184,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
184
  requirements:
179
185
  - - ">="
180
186
  - !ruby/object:Gem::Version
181
- version: 2.4.0
187
+ version: 2.5.0
182
188
  required_rubygems_version: !ruby/object:Gem::Requirement
183
189
  requirements:
184
190
  - - ">="
185
191
  - !ruby/object:Gem::Version
186
192
  version: '0'
187
193
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.7.8
190
- signing_key:
194
+ rubygems_version: 3.6.9
191
195
  specification_version: 4
192
196
  summary: WinRM File System
193
197
  test_files: []