lib/pe_build/transfer.rb in vagrant-pe_build-0.8.8 vs lib/pe_build/transfer.rb in vagrant-pe_build-0.9.0

- old
+ new

@@ -14,18 +14,37 @@ 'ftp' => PEBuild::Transfer::OpenURI, 'file' => PEBuild::Transfer::File, nil => PEBuild::Transfer::File, # Assume that URIs without a scheme are files } - def self.generate(src, dst) + # @param src [URI] The local file path path to the file to copy + # @param dst [String] The path to destination of the copied file + def self.copy(src, dst) scheme = src.scheme - if (klass = IMPLEMENTATIONS[scheme]) - klass.new(src, dst) + if (mod = IMPLEMENTATIONS[scheme]) + mod.copy(src, dst) else raise UnhandledURIScheme, :scheme => scheme, :supported => IMPLEMENTATIONS.keys end end + + # Return the contents of a local or remote file. + # + # @param src [URI] The URI of the source file. + # @raises [UnhandledURIScheme] If the URI uses an unsupported scheme. + # @return [String] The contents of the source file. + # + # @since 0.9.0 + def self.read(src) + scheme = src.scheme + + if (mod = IMPLEMENTATIONS[scheme]) + mod.read(src) + else + raise UnhandledURIScheme, :scheme => scheme, + :supported => IMPLEMENTATIONS.keys + end + end end end -