ports/textproc/ruby-htmltools/files/patch-install.rb
Pav Lucistnik 180ef443a6 Ruby-htmltools tools for parsing and manipulating HTML text in Ruby.
It can be used for programmatically access outside HTML-pages.
I hope to extend it to become a web-publishing framework in the future.

PR:		ports/79432
Submitted by:	Alexander Novitsky <alecn2002@yandex.ru>
2005-04-10 13:36:29 +00:00

45 lines
1.1 KiB
Ruby

--- install.rb.orig Sun Apr 10 15:32:16 2005
+++ install.rb Sun Apr 10 15:32:26 2005
@@ -10,6 +10,8 @@
# the GNU Lesser General Public License version 2.
#
+
+
### begin compat.rb
unless Enumerable.instance_methods(true).include? 'inject' then
@@ -32,6 +34,13 @@
end
### end compat.rb
+
+class String
+ def begin_with?( substr )
+ index( substr ) == 0
+ end
+end
+
### begin config.rb
if i = ARGV.index(/\A--rbconfig=/) then
@@ -308,7 +317,7 @@
module FileOperations
def mkdir_p( dname, prefix = nil )
- dname = prefix + dname if prefix
+ dname = File.join( prefix, dname ) if ( prefix and not dname.begin_with?( prefix ) )
$stderr.puts "mkdir -p #{dname}" if verbose?
return if no_harm?
@@ -371,7 +380,9 @@
$stderr.puts "install #{from} #{dest}" if verbose?
return if no_harm?
- realdest = prefix + dest if prefix
+ realdest = ( prefix and not dest.begin_with?( prefix ) ) ?
+ prefix + dest :
+ dest
if dir? realdest then
realdest += '/' + File.basename(from)
end