sshkit 1.14.0 → 1.15.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/CHANGELOG.md +16 -1
- data/EXAMPLES.md +13 -2
- data/Gemfile +5 -0
- data/lib/sshkit/backends/local.rb +2 -0
- data/lib/sshkit/backends/netssh.rb +2 -0
- data/lib/sshkit/version.rb +1 -1
- data/test/functional/backends/test_local.rb +17 -0
- data/test/functional/backends/test_netssh.rb +17 -0
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 45f49f25df22edea1abf8c5db3edda63255ddbb2
         | 
| 4 | 
            +
              data.tar.gz: 71642fd8de408f19d9e40fad80ce7315ca553235
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2483400c0e519f6ea60432371a04d77c523a965db7cf117c611056aa052f87125ccb605ec1ae241bec4f24ec1e75f03ef2927dce8d0a64757147a4fe0ce8e4f0
         | 
| 7 | 
            +
              data.tar.gz: 360df78c26c2e413e54d02f0152279f968f25ad3373e3f0fd36086d6bc867f1aa473937e84e7be0602047307042c45426d35833e8c0c5be803da243d95ced76b
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -7,6 +7,20 @@ appear at the top. | |
| 7 7 |  | 
| 8 8 | 
             
              * Your contribution here!
         | 
| 9 9 |  | 
| 10 | 
            +
            ## [1.15.0][] (2017-11-03)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ### New features
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              * [#408](https://github.com/capistrano/sshkit/pull/408): upload! and download! now respect `within` - [@sj26](https://github.com/sj26)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            ### Potentially breaking changes
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              * `upload!` and `download!` now support remote paths which are
         | 
| 19 | 
            +
                relative to the `within` working directory. They were previously documented
         | 
| 20 | 
            +
                as only supporting absolute paths, but relative paths still worked relative
         | 
| 21 | 
            +
                to the remote working directory. If you rely on the previous behaviour you
         | 
| 22 | 
            +
                may need to adjust your code.
         | 
| 23 | 
            +
             | 
| 10 24 | 
             
            ## [1.14.0][] (2017-06-30)
         | 
| 11 25 |  | 
| 12 26 | 
             
            ### Breaking changes
         | 
| @@ -707,7 +721,8 @@ version `0.0.5`. | |
| 707 721 |  | 
| 708 722 | 
             
            First release.
         | 
| 709 723 |  | 
| 710 | 
            -
            [Unreleased]: https://github.com/capistrano/sshkit/compare/v1. | 
| 724 | 
            +
            [Unreleased]: https://github.com/capistrano/sshkit/compare/v1.15.0...HEAD
         | 
| 725 | 
            +
            [1.15.0]: https://github.com/capistrano/sshkit/compare/v1.14.0...v1.15.0
         | 
| 711 726 | 
             
            [1.14.0]: https://github.com/capistrano/sshkit/compare/v1.13.1...v1.14.0
         | 
| 712 727 | 
             
            [1.13.1]: https://github.com/capistrano/sshkit/compare/v1.13.0...v1.13.1
         | 
| 713 728 | 
             
            [1.13.0]: https://github.com/capistrano/sshkit/compare/v1.12.0...v1.13.0
         | 
    
        data/EXAMPLES.md
    CHANGED
    
    | @@ -90,6 +90,7 @@ end | |
| 90 90 | 
             
            ```
         | 
| 91 91 |  | 
| 92 92 | 
             
            ## Download a file from disk
         | 
| 93 | 
            +
             | 
| 93 94 | 
             
            ```ruby
         | 
| 94 95 | 
             
            on roles(:all) do
         | 
| 95 96 | 
             
              puts 'Downloading DB Backup File'
         | 
| @@ -106,8 +107,18 @@ on hosts do |host| | |
| 106 107 | 
             
            end
         | 
| 107 108 | 
             
            ```
         | 
| 108 109 |  | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 110 | 
            +
            Upload and download will respect the `within()` directories:
         | 
| 111 | 
            +
             | 
| 112 | 
            +
            ```ruby
         | 
| 113 | 
            +
            on hosts do |host|
         | 
| 114 | 
            +
              within 'my/app/directory' do
         | 
| 115 | 
            +
                upload! 'database.yml', 'config/database.yml'
         | 
| 116 | 
            +
              end
         | 
| 117 | 
            +
            end
         | 
| 118 | 
            +
            ```
         | 
| 119 | 
            +
             | 
| 120 | 
            +
            **Note:** The `upload!()` method doesn't honor the values of `as()` etc, this
         | 
| 121 | 
            +
            will be improved as the library matures, but we're not there yet.
         | 
| 111 122 |  | 
| 112 123 | 
             
            ## Upload a file from a stream
         | 
| 113 124 |  | 
    
        data/Gemfile
    CHANGED
    
    | @@ -13,3 +13,8 @@ end | |
| 13 13 | 
             
            if Gem::Requirement.new('>= 2.1.0').satisfied_by?(Gem::Version.new(RUBY_VERSION))
         | 
| 14 14 | 
             
              gem 'chandler', '>= 0.1.1'
         | 
| 15 15 | 
             
            end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            # public_suffix 3+ requires ruby 2.1+
         | 
| 18 | 
            +
            if Gem::Requirement.new('< 2.1').satisfied_by?(Gem::Version.new(RUBY_VERSION))
         | 
| 19 | 
            +
              gem 'public_suffix', '< 3'
         | 
| 20 | 
            +
            end
         | 
| @@ -11,6 +11,7 @@ module SSHKit | |
| 11 11 | 
             
                  end
         | 
| 12 12 |  | 
| 13 13 | 
             
                  def upload!(local, remote, options = {})
         | 
| 14 | 
            +
                    remote = File.join(pwd_path, remote) unless remote.start_with?("/")
         | 
| 14 15 | 
             
                    if local.is_a?(String)
         | 
| 15 16 | 
             
                      if options[:recursive]
         | 
| 16 17 | 
             
                        FileUtils.cp_r(local, remote)
         | 
| @@ -25,6 +26,7 @@ module SSHKit | |
| 25 26 | 
             
                  end
         | 
| 26 27 |  | 
| 27 28 | 
             
                  def download!(remote, local=nil, _options = {})
         | 
| 29 | 
            +
                    remote = File.join(pwd_path, remote) unless remote.start_with?("/")
         | 
| 28 30 | 
             
                    if local.nil?
         | 
| 29 31 | 
             
                      FileUtils.cp(remote, File.basename(remote))
         | 
| 30 32 | 
             
                    else
         | 
| @@ -63,6 +63,7 @@ module SSHKit | |
| 63 63 |  | 
| 64 64 | 
             
                  def upload!(local, remote, options = {})
         | 
| 65 65 | 
             
                    summarizer = transfer_summarizer('Uploading', options)
         | 
| 66 | 
            +
                    remote = File.join(pwd_path, remote) unless remote.start_with?("/")
         | 
| 66 67 | 
             
                    with_ssh do |ssh|
         | 
| 67 68 | 
             
                      ssh.scp.upload!(local, remote, options, &summarizer)
         | 
| 68 69 | 
             
                    end
         | 
| @@ -70,6 +71,7 @@ module SSHKit | |
| 70 71 |  | 
| 71 72 | 
             
                  def download!(remote, local=nil, options = {})
         | 
| 72 73 | 
             
                    summarizer = transfer_summarizer('Downloading', options)
         | 
| 74 | 
            +
                    remote = File.join(pwd_path, remote) unless remote.start_with?("/")
         | 
| 73 75 | 
             
                    with_ssh do |ssh|
         | 
| 74 76 | 
             
                      ssh.scp.download!(remote, local, options, &summarizer)
         | 
| 75 77 | 
             
                    end
         | 
    
        data/lib/sshkit/version.rb
    CHANGED
    
    
| @@ -20,6 +20,23 @@ module SSHKit | |
| 20 20 | 
             
                    end
         | 
| 21 21 | 
             
                  end
         | 
| 22 22 |  | 
| 23 | 
            +
                  def test_upload_within
         | 
| 24 | 
            +
                    file_contents = "Some Content"
         | 
| 25 | 
            +
                    actual_file_contents = nil
         | 
| 26 | 
            +
                    Dir.mktmpdir do |dir|
         | 
| 27 | 
            +
                      Local.new do
         | 
| 28 | 
            +
                        within dir do
         | 
| 29 | 
            +
                          execute(:mkdir, "-p", "foo")
         | 
| 30 | 
            +
                          within "foo" do
         | 
| 31 | 
            +
                            upload!(StringIO.new(file_contents), "bar")
         | 
| 32 | 
            +
                          end
         | 
| 33 | 
            +
                        end
         | 
| 34 | 
            +
                        actual_file_contents = capture(:cat, File.join(dir, "foo", "bar"))
         | 
| 35 | 
            +
                      end.run
         | 
| 36 | 
            +
                      assert_equal file_contents, actual_file_contents
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 23 40 | 
             
                  def test_upload_recursive
         | 
| 24 41 | 
             
                    Dir.mktmpdir do |dir|
         | 
| 25 42 | 
             
                      Dir.mkdir("#{dir}/local")
         | 
| @@ -103,6 +103,23 @@ module SSHKit | |
| 103 103 | 
             
                    assert_equal "Some Content\nWith a newline and trailing spaces    \n ", actual_file_contents
         | 
| 104 104 | 
             
                  end
         | 
| 105 105 |  | 
| 106 | 
            +
                  def test_upload_within
         | 
| 107 | 
            +
                    file_name = SecureRandom.uuid
         | 
| 108 | 
            +
                    file_contents = "Some Content"
         | 
| 109 | 
            +
                    dir_name = SecureRandom.uuid
         | 
| 110 | 
            +
                    actual_file_contents = ""
         | 
| 111 | 
            +
                    Netssh.new(a_host) do |_host|
         | 
| 112 | 
            +
                      within("/tmp") do
         | 
| 113 | 
            +
                        execute :mkdir, "-p", dir_name
         | 
| 114 | 
            +
                        within(dir_name) do
         | 
| 115 | 
            +
                          upload!(StringIO.new(file_contents), file_name)
         | 
| 116 | 
            +
                        end
         | 
| 117 | 
            +
                      end
         | 
| 118 | 
            +
                      actual_file_contents = capture(:cat, "/tmp/#{dir_name}/#{file_name}", strip: false)
         | 
| 119 | 
            +
                    end.run
         | 
| 120 | 
            +
                    assert_equal file_contents, actual_file_contents
         | 
| 121 | 
            +
                  end
         | 
| 122 | 
            +
             | 
| 106 123 | 
             
                  def test_upload_string_io
         | 
| 107 124 | 
             
                    file_contents = ""
         | 
| 108 125 | 
             
                    Netssh.new(a_host) do |_host|
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sshkit
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.15.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Lee Hambley
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2017- | 
| 12 | 
            +
            date: 2017-11-03 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: net-ssh
         | 
| @@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 293 293 | 
             
                  version: '0'
         | 
| 294 294 | 
             
            requirements: []
         | 
| 295 295 | 
             
            rubyforge_project: 
         | 
| 296 | 
            -
            rubygems_version: 2.6. | 
| 296 | 
            +
            rubygems_version: 2.6.14
         | 
| 297 297 | 
             
            signing_key: 
         | 
| 298 298 | 
             
            specification_version: 4
         | 
| 299 299 | 
             
            summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
         |