Module: Kitchen::Transport::Express::Archiver
- Included in:
- Kitchen::Transport::ExpressSsh::Connection
- Defined in:
- lib/kitchen/transport/express/archiver.rb
Overview
Mixin module that provides methods for creating and extracting archives locally and on the remote host.
Instance Method Summary collapse
-
#archive(path) ⇒ String
Creates the archive locally in the Kitchen cache location.
-
#extract(session, local, remote) ⇒ Object
Extracts the archive on the remote host.
Instance Method Details
#archive(path) ⇒ String
Creates the archive locally in the Kitchen cache location
30 31 32 33 34 35 36 37 38 |
# File 'lib/kitchen/transport/express/archiver.rb', line 30 def archive(path) archive_basename = ::File.basename(path) + ".tgz" archive_full_name = ::File.join(::File.dirname(path), archive_basename) file_count = ::Dir.glob(::File.join(path, "**/*")).size logger.debug("[#{Express::LOG_PREFIX}] #{path} contains #{file_count} files.") create_archive(path, archive_full_name) archive_full_name end |
#extract(session, local, remote) ⇒ Object
Extracts the archive on the remote host
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/kitchen/transport/express/archiver.rb', line 44 def extract(session, local, remote) return unless local.match(/.*\.tgz/) archive_basename = File.basename(local) logger.debug("[#{Express::LOG_PREFIX}] Extracting #{::File.join(remote, archive_basename)}") session.open_channel do |channel| channel.request_pty channel.exec("tar -xzf #{::File.join(remote, archive_basename)} -C #{remote} && rm -f #{File.join(remote, archive_basename)}") end session.loop end |