Sha256: 642651891f86396e7fcfb57ed7cbb0f24c9cddf86559f61c9b7fee3c51ec7579

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

module DRbQS
  # Class for path of files to send from server to a node.
  class Transfer
    class FileList
      # Initialization is executed on server.
      # If :readonly option is true, nodes on same computer as server
      # does not copy files.
      # Therefore, if we edit the files then the change remains.
      # If :readonly option is not true then the files is copied,
      # so the original files are not changed.
      def initialize(*files)
        opts = (Hash === files[-1] ? files.pop : {})
        @readonly = opts[:readonly]
        @files = files.map do |path|
          epath = File.expand_path(path)
          unless File.exist?(epath)
            raise ArgumentError, "#{epath} does not exist."
          end
          epath
        end
        @downloaded = nil
        @path = nil
      end

      # This method is executed on a node.
      def download
        @downloaded = true
        @path = DRbQS::Transfer::Client.get.download(@files, @readonly)
      end
      private :download

      # Return an array of paths of downloaded files.
      # Note that this method is executed on a node.
      def path
        download unless @downloaded
        @path
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
drbqs-0.1.1 lib/drbqs/utility/transfer/transfer_file_list.rb
drbqs-0.1.0 lib/drbqs/utility/transfer/transfer_file_list.rb
drbqs-0.0.19 lib/drbqs/utility/transfer/transfer_file_list.rb
drbqs-0.0.18 lib/drbqs/utility/transfer/transfer_file_list.rb
drbqs-0.0.17 lib/drbqs/utility/transfer/transfer_file_list.rb
drbqs-0.0.16 lib/drbqs/utility/transfer/transfer_file_list.rb