lib/buildr/core/transports.rb in vic-buildr-1.3.3 vs lib/buildr/core/transports.rb in vic-buildr-1.3.4

- old
+ new

@@ -12,43 +12,26 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. -require 'cgi' +require 'uri' require 'net/http' -require 'net/https' +Net.autoload :HTTPS, 'net/https' # PATCH: On Windows, Net::SSH 2.0.2 attempts to load the Pageant DLLs which break on JRuby. -$LOADED_FEATURES.unshift 'net/ssh/authentication/pageant' if RUBY_PLATFORM =~ /java/ -require 'net/ssh' -require 'net/sftp' -require 'uri' -require 'digest/md5' -require 'digest/sha1' +$LOADED_FEATURES << 'net/ssh/authentication/pageant.rb' if RUBY_PLATFORM =~ /java/ +gem 'net-ssh' ; Net.autoload :SSH, 'net/ssh' +gem 'net-sftp' ; Net.autoload :SFTP, 'net/sftp' +autoload :CGI, 'cgi' +module Digest + autoload :MD5, 'digest/md5' + autoload :SHA1, 'digest/sha1' +end require 'stringio' -require 'tempfile' -require 'buildr/core/progressbar' +autoload :ProgressBar, 'buildr/core/progressbar' -# Monkeypatching: SFTP never defines the mkdir method on its session or the underlying -# driver, it just redirect calls through method_missing. Rake, on the other hand, decides -# to define mkdir on Object, and so routes our calls to FileUtils. -module Net #:nodoc:all - class Session - def mkdir(path, attrs = {}) - method_missing :mkdir, path, attrs - end - end - - class SFTP::Protocol::Driver - def mkdir(first, path, attrs = {}) - method_missing :mkdir, first, path, attrs - end - end -end - - # Not quite open-uri, but similar. Provides read and write methods for the resource represented by the URI. # Currently supports reads for URI::HTTP and writes for URI::SFTP. Also provides convenience methods for # downloads and uploads. module URI @@ -171,11 +154,11 @@ Tempfile.open File.basename(target) do |temp| temp.binmode read({:progress=>verbose}.merge(options || {}).merge(:modified=>modified)) { |chunk| temp.write chunk } end mkpath File.dirname(target) - File.move temp.path, target + FileUtils.mv temp.path, target when File read({:progress=>verbose}.merge(options || {}).merge(:modified=>target.mtime)) { |chunk| target.write chunk } target.flush else raise ArgumentError, 'Expecting a target that is either a file name (string, task) or object that responds to write (file, pipe).' unless target.respond_to?(:write) @@ -564,10 +547,10 @@ end end end real_path.tap do |path| mkpath File.dirname(path) - File.move temp.path, path + FileUtils.mv temp.path, path end end @@schemes['FILE'] = FILE