Sha256: 86e7d1c78eb71007f33194f603c93221d8016843669588d076ac4fad81ff62bc
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
# Copyright: Copyright (c) 2005 Nicolas Pouillard. All rights reserved. # Author: Nicolas Pouillard <ertai@lrde.epita.fr>. # License: Gnu General Public License. # $LastChangedBy: ertai $ # $Id: file.rb 213 2005-05-06 12:55:58Z ertai $ require 'uri_ex' module URI class File < Generic COMPONENT = [ :scheme, :path ].freeze def initialize ( *args ) super unless @host.nil? or @host.empty? raise ArgumentError, "You cannot neither setup a host (#{@host}), nor a relative path" end end def self.build ( args ) tmp = Util::make_components_hash(self, args) return super(tmp) end def checkout p = self.pathname raise CheckoutError, to_s unless p.exist? p end def commit ( aPath ) FileUtils.cp aPath.to_s, self.pathname.to_s end def save p = self.pathname raise SaveError, to_s unless p.exist? if p.directory? out = TempPath.new('save', "#{p.basename}.tar.gz") cmd = "tar czf #{out} #{p}" unless system cmd raise SaveError, "command failed: `#{cmd}' => #{$?}" end else out = TempPath.new('save', "#{p.basename}.gz") cmd = "gzip -c #{p} > #{out}" unless system cmd raise SaveError, "command failed: `#{cmd}' => #{$?}" end end out end end # class File @@schemes['FILE'] = File end # module URI
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vcs-0.2.148 | ruby_ex/uri/file.rb |