winrm-fs 0.3.2 → 0.4.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.
data/README.md CHANGED
@@ -1,86 +1,86 @@
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)
3
- [![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
-
6
- ## Uploading files
7
- 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:
8
- ```ruby
9
- require 'winrm-fs'
10
-
11
- service = WinRM::WinRMWebService.new(...
12
- file_manager = WinRM::FS::FileManager.new(service)
13
-
14
- # upload file.txt from the current working directory
15
- file_manager.upload('file.txt', 'c:/file.txt')
16
-
17
- # upload the my_dir directory to c:/foo/my_dir
18
- file_manager.upload('/Users/sneal/my_dir', 'c:/foo/my_dir')
19
-
20
- # upload multiple directories and a file to c:\programData
21
- file_manager.upload([
22
- '/Users/sneal/foo1',
23
- '/Users/sneal/foo2'
24
- '/Users/sneal/fluffy.txt'
25
- ], '$env:ProgramData')
26
- ```
27
-
28
- ### Handling progress events
29
- If you want to implemnt your own custom progress handling, you can pass a code
30
- block and use the proggress data that `upload` yields to this block:
31
- ```ruby
32
- file_manager.upload('c:/dev/my_dir', '$env:AppData') do |bytes_copied, total_bytes, local_path, remote_path|
33
- puts "#{bytes_copied}bytes of #{total_bytes}bytes copied"
34
- end
35
- ```
36
-
37
- ## Troubleshooting
38
-
39
- If you're having trouble, first of all its most likely a network or WinRM configuration
40
- issue. Take a look at the [WinRM gem troubleshooting](https://github.com/WinRb/WinRM#troubleshooting)
41
- first.
42
-
43
- The most [common error](https://github.com/WinRb/winrm-fs/issues/1) with this gem is getting a 500 error because your maxConcurrentOperationsPerUser limit has been reached.
44
-
45
- ```
46
- The WS-Management service cannot process the request. This user is allowed a
47
- maximum number of 1500 concurrent operations, which has been exceeded. Close
48
- existing operations for this user, or raise the quota for this user.
49
- ```
50
-
51
- You can workaround this by increasing your operations per user quota.
52
-
53
- ## Contributing
54
-
55
- 1. Fork it.
56
- 2. Create a branch (git checkout -b my_feature_branch)
57
- 3. Run the unit and integration tests (bundle exec rake integration)
58
- 4. Commit your changes (git commit -am "Added a sweet feature")
59
- 5. Push to the branch (git push origin my_feature_branch)
60
- 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
-
62
- ### Running the tests
63
-
64
- We use Bundler to manage dependencies during development.
65
-
66
- ```
67
- $ bundle install
68
- ```
69
-
70
- Once you have the dependencies, you can run the unit tests with `rake`:
71
-
72
- ```
73
- $ bundle exec rake spec
74
- ```
75
-
76
- 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.
77
-
78
- 1. Create a Windows VM with WinRM configured (see above).
79
- 2. Copy the config-example.yml to config.yml - edit this file with your WinRM connection details.
80
- 3. Run `bundle exec rake integration`
81
-
82
- ## WinRM-fs Authors
83
- * Shawn Neal (https://github.com/sneal)
84
- * Matt Wrock (https://github.com/mwrock)
85
-
86
- [Contributors](https://github.com/WinRb/winrm-fs/graphs/contributors)
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)
3
+ [![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
+
6
+ ## Uploading files
7
+ 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:
8
+ ```ruby
9
+ require 'winrm-fs'
10
+
11
+ service = WinRM::WinRMWebService.new(...
12
+ file_manager = WinRM::FS::FileManager.new(service)
13
+
14
+ # upload file.txt from the current working directory
15
+ file_manager.upload('file.txt', 'c:/file.txt')
16
+
17
+ # upload the my_dir directory to c:/foo/my_dir
18
+ file_manager.upload('/Users/sneal/my_dir', 'c:/foo/my_dir')
19
+
20
+ # upload multiple directories and a file to c:\programData
21
+ file_manager.upload([
22
+ '/Users/sneal/foo1',
23
+ '/Users/sneal/foo2'
24
+ '/Users/sneal/fluffy.txt'
25
+ ], '$env:ProgramData')
26
+ ```
27
+
28
+ ### Handling progress events
29
+ If you want to implement your own custom progress handling, you can pass a code
30
+ block and use the proggress data that `upload` yields to this block:
31
+ ```ruby
32
+ file_manager.upload('c:/dev/my_dir', '$env:AppData') do |bytes_copied, total_bytes, local_path, remote_path|
33
+ puts "#{bytes_copied}bytes of #{total_bytes}bytes copied"
34
+ end
35
+ ```
36
+
37
+ ## Troubleshooting
38
+
39
+ If you're having trouble, first of all its most likely a network or WinRM configuration
40
+ issue. Take a look at the [WinRM gem troubleshooting](https://github.com/WinRb/WinRM#troubleshooting)
41
+ first.
42
+
43
+ The most [common error](https://github.com/WinRb/winrm-fs/issues/1) with this gem is getting a 500 error because your maxConcurrentOperationsPerUser limit has been reached.
44
+
45
+ ```
46
+ The WS-Management service cannot process the request. This user is allowed a
47
+ maximum number of 1500 concurrent operations, which has been exceeded. Close
48
+ existing operations for this user, or raise the quota for this user.
49
+ ```
50
+
51
+ You can workaround this by increasing your operations per user quota.
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it.
56
+ 2. Create a branch (git checkout -b my_feature_branch)
57
+ 3. Run the unit and integration tests (bundle exec rake integration)
58
+ 4. Commit your changes (git commit -am "Added a sweet feature")
59
+ 5. Push to the branch (git push origin my_feature_branch)
60
+ 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
+
62
+ ### Running the tests
63
+
64
+ We use Bundler to manage dependencies during development.
65
+
66
+ ```
67
+ $ bundle install
68
+ ```
69
+
70
+ Once you have the dependencies, you can run the unit tests with `rake`:
71
+
72
+ ```
73
+ $ bundle exec rake spec
74
+ ```
75
+
76
+ 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.
77
+
78
+ 1. Create a Windows VM with WinRM configured (see above).
79
+ 2. Copy the config-example.yml to config.yml - edit this file with your WinRM connection details.
80
+ 3. Run `bundle exec rake integration`
81
+
82
+ ## WinRM-fs Authors
83
+ * Shawn Neal (https://github.com/sneal)
84
+ * Matt Wrock (https://github.com/mwrock)
85
+
86
+ [Contributors](https://github.com/WinRb/winrm-fs/graphs/contributors)
data/Rakefile CHANGED
@@ -1,28 +1,28 @@
1
- # encoding: UTF-8
2
- require 'rubygems'
3
- require 'bundler/setup'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
6
-
7
- # Change to the directory of this file.
8
- Dir.chdir(File.expand_path('../', __FILE__))
9
-
10
- # For gem creation and bundling
11
- require 'bundler/gem_tasks'
12
-
13
- RSpec::Core::RakeTask.new(:spec) do |task|
14
- task.pattern = 'spec/unit/*_spec.rb'
15
- task.rspec_opts = ['--color', '-f documentation']
16
- end
17
-
18
- # Run the integration test suite
19
- RSpec::Core::RakeTask.new(:integration) do |task|
20
- task.pattern = 'spec/integration/*_spec.rb'
21
- task.rspec_opts = ['--color', '-f documentation']
22
- end
23
-
24
- RuboCop::RakeTask.new
25
-
26
- task default: [:spec, :rubocop]
27
-
28
- task all: [:default, :integration]
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ # Change to the directory of this file.
8
+ Dir.chdir(File.expand_path('../', __FILE__))
9
+
10
+ # For gem creation and bundling
11
+ require 'bundler/gem_tasks'
12
+
13
+ RSpec::Core::RakeTask.new(:spec) do |task|
14
+ task.pattern = 'spec/unit/*_spec.rb'
15
+ task.rspec_opts = ['--color', '-f documentation']
16
+ end
17
+
18
+ # Run the integration test suite
19
+ RSpec::Core::RakeTask.new(:integration) do |task|
20
+ task.pattern = 'spec/integration/*_spec.rb'
21
+ task.rspec_opts = ['--color', '-f documentation']
22
+ end
23
+
24
+ RuboCop::RakeTask.new
25
+
26
+ task default: [:spec, :rubocop]
27
+
28
+ task all: [:default, :integration]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.4.0
data/Vagrantfile CHANGED
@@ -1,9 +1,9 @@
1
- # encoding: UTF-8
2
- # -*- mode: ruby -*-
3
- # vi: set ft=ruby :
4
-
5
- VAGRANTFILE_API_VERSION = '2'
6
-
7
- Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
- config.vm.box = 'mwrock/Windows2012R2'
9
- end
1
+ # encoding: UTF-8
2
+ # -*- mode: ruby -*-
3
+ # vi: set ft=ruby :
4
+
5
+ VAGRANTFILE_API_VERSION = '2'
6
+
7
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
+ config.vm.box = 'mwrock/Windows2012R2'
9
+ end
data/appveyor.yml CHANGED
@@ -1,39 +1,39 @@
1
- version: "master-{build}"
2
-
3
- os: Windows Server 2012 R2
4
- platform:
5
- - x64
6
-
7
- environment:
8
- winrm_user: test_user
9
- winrm_pass: Pass@word1
10
-
11
- matrix:
12
- - ruby_version: "21"
13
- winrm_endpoint: http://localhost:5985/wsman
14
-
15
- clone_folder: c:\projects\winrm-fs
16
- clone_depth: 1
17
- branches:
18
- only:
19
- - master
20
-
21
- install:
22
- - ps: net user /add $env:winrm_user $env:winrm_pass
23
- - ps: net localgroup administrators $env:winrm_user /add
24
- - ps: winrm set winrm/config/client/auth '@{Basic="true"}'
25
- - ps: winrm set winrm/config/service/auth '@{Basic="true"}'
26
- - ps: winrm set winrm/config/service '@{AllowUnencrypted="true"}'
27
- - ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
28
- - ps: Write-Host $env:PATH
29
- - ps: ruby --version
30
- - ps: gem --version
31
- - ps: gem install bundler --quiet --no-ri --no-rdoc
32
- - ps: bundler --version
33
-
34
- build_script:
35
- - bundle install || bundle install || bundle install
36
-
37
- test_script:
38
- - SET SPEC_OPTS=--format progress
39
- - bundle exec rake integration
1
+ version: "master-{build}"
2
+
3
+ os: Windows Server 2012 R2
4
+ platform:
5
+ - x64
6
+
7
+ environment:
8
+ winrm_user: test_user
9
+ winrm_pass: Pass@word1
10
+
11
+ matrix:
12
+ - ruby_version: "21"
13
+ winrm_endpoint: http://localhost:5985/wsman
14
+
15
+ clone_folder: c:\projects\winrm-fs
16
+ clone_depth: 1
17
+ branches:
18
+ only:
19
+ - master
20
+
21
+ install:
22
+ - ps: net user /add $env:winrm_user $env:winrm_pass
23
+ - ps: net localgroup administrators $env:winrm_user /add
24
+ - ps: winrm set winrm/config/client/auth '@{Basic="true"}'
25
+ - ps: winrm set winrm/config/service/auth '@{Basic="true"}'
26
+ - ps: winrm set winrm/config/service '@{AllowUnencrypted="true"}'
27
+ - ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
28
+ - ps: Write-Host $env:PATH
29
+ - ps: ruby --version
30
+ - ps: gem --version
31
+ - ps: gem install bundler --quiet --no-ri --no-rdoc
32
+ - ps: bundler --version
33
+
34
+ build_script:
35
+ - bundle install || bundle install || bundle install
36
+
37
+ test_script:
38
+ - SET SPEC_OPTS=--format progress
39
+ - bundle exec rake integration
data/bin/rwinrmcp CHANGED
@@ -1,86 +1,86 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
- #
4
- # Copyright 2014 Shawn Neal <sneal@sneal.net>
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- # TODO: refactor this
19
- # rubocop:disable all
20
-
21
- $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
22
-
23
- require 'io/console'
24
- require 'winrm-fs'
25
-
26
- def help_msg
27
- puts 'Usage: rwinrmcp sourcefile user@host:directory/targetfile'
28
- puts ''
29
- end
30
-
31
- def parse_options
32
- options = {}
33
- fail 'Missing required options' unless ARGV.length == 2
34
-
35
- options[:source_path] = ARGV[0]
36
- fail "Cannot find source file: #{options[:source_path]}" unless \
37
- File.exist?(options[:source_path])
38
-
39
- m = /^(?<user>[a-z0-9\.\!\$ _-]+)@{1}(?<host>[a-z0-9\.\-]+)(?<port>:[0-9]+)?:{1}(?<file>.+)/i.match(ARGV[1])
40
- fail "#{ARGV[1]} is an invalid destination" unless m
41
- options[:user] = m[:user]
42
- options[:endpoint] = "http://#{m[:host]}#{m[:port] || ':5985'}/wsman"
43
- options[:dest_path] = m[:file]
44
-
45
- # Get the password
46
- print 'Password: '
47
- options[:pass] = STDIN.noecho(&:gets).chomp
48
- puts
49
-
50
- # Set some defaults required by WinRM WS
51
- options[:auth_type] = :plaintext
52
- options[:basic_auth_only] = true
53
-
54
- options
55
- rescue StandardError => e
56
- puts e.message
57
- help_msg
58
- exit 1
59
- end
60
-
61
- def file_manager(options)
62
- service = WinRM::WinRMWebService.new(
63
- options[:endpoint],
64
- options[:auth_type].to_sym,
65
- options)
66
- WinRM::FS::FileManager.new(service)
67
- end
68
-
69
- def run(options)
70
- bytes = file_manager(options).upload(options[:source_path], options[:dest_path])
71
- puts "#{bytes} total bytes transfered"
72
- exit 0
73
- rescue Interrupt
74
- puts 'exiting'
75
- # ctrl-c
76
- rescue WinRM::WinRMAuthorizationError
77
- puts 'Authentication failed, bad user name or password'
78
- exit 1
79
- rescue StandardError => e
80
- puts e.message
81
- exit 1
82
- end
83
-
84
- run(parse_options)
85
-
86
- # rubocop:enable all
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # Copyright 2014 Shawn Neal <sneal@sneal.net>
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ # TODO: refactor this
19
+ # rubocop:disable all
20
+
21
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
22
+
23
+ require 'io/console'
24
+ require 'winrm-fs'
25
+
26
+ def help_msg
27
+ puts 'Usage: rwinrmcp sourcefile user@host:directory/targetfile'
28
+ puts ''
29
+ end
30
+
31
+ def parse_options
32
+ options = {}
33
+ fail 'Missing required options' unless ARGV.length == 2
34
+
35
+ options[:source_path] = ARGV[0]
36
+ fail "Cannot find source file: #{options[:source_path]}" unless \
37
+ File.exist?(options[:source_path])
38
+
39
+ m = /^(?<user>[a-z0-9\.\!\$ _-]+)@{1}(?<host>[a-z0-9\.\-]+)(?<port>:[0-9]+)?:{1}(?<file>.+)/i.match(ARGV[1])
40
+ fail "#{ARGV[1]} is an invalid destination" unless m
41
+ options[:user] = m[:user]
42
+ options[:endpoint] = "http://#{m[:host]}#{m[:port] || ':5985'}/wsman"
43
+ options[:dest_path] = m[:file]
44
+
45
+ # Get the password
46
+ print 'Password: '
47
+ options[:pass] = STDIN.noecho(&:gets).chomp
48
+ puts
49
+
50
+ # Set some defaults required by WinRM WS
51
+ options[:auth_type] = :plaintext
52
+ options[:basic_auth_only] = true
53
+
54
+ options
55
+ rescue StandardError => e
56
+ puts e.message
57
+ help_msg
58
+ exit 1
59
+ end
60
+
61
+ def file_manager(options)
62
+ service = WinRM::WinRMWebService.new(
63
+ options[:endpoint],
64
+ options[:auth_type].to_sym,
65
+ options)
66
+ WinRM::FS::FileManager.new(service)
67
+ end
68
+
69
+ def run(options)
70
+ bytes = file_manager(options).upload(options[:source_path], options[:dest_path])
71
+ puts "#{bytes} total bytes transfered"
72
+ exit 0
73
+ rescue Interrupt
74
+ puts 'exiting'
75
+ # ctrl-c
76
+ rescue WinRM::WinRMAuthorizationError
77
+ puts 'Authentication failed, bad user name or password'
78
+ exit 1
79
+ rescue StandardError => e
80
+ puts e.message
81
+ exit 1
82
+ end
83
+
84
+ run(parse_options)
85
+
86
+ # rubocop:enable all