From d6b580c9f67a9ee4b5f57310f34c28799d616da1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 19 Jan 2008 03:19:08 +0000 Subject: mkdir_p, and again close running of ruby 1.9 * mkdir_p, [instead of ftools file.mkpath] * running against ruby 1.9 closed for now raise request for use of version 1.8 branch * manual update version --- lib/sisu/v0/composite.rb | 10 ++--- lib/sisu/v0/concordance.rb | 2 +- lib/sisu/v0/conf.rb | 2 +- lib/sisu/v0/embedded.rb | 6 +-- lib/sisu/v0/html_segments.rb | 2 +- lib/sisu/v0/param.rb | 3 -- lib/sisu/v0/share_src.rb | 4 +- lib/sisu/v0/share_src_kdissert.rb | 4 +- lib/sisu/v0/sisupod_make.rb | 6 +-- lib/sisu/v0/sitemaps.rb | 2 +- lib/sisu/v0/sysenv.rb | 77 +++++++++++++++++---------------------- lib/sisu/v0/termsheet.rb | 2 +- 12 files changed, 54 insertions(+), 66 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/composite.rb b/lib/sisu/v0/composite.rb index fb393384..e0b53bb5 100644 --- a/lib/sisu/v0/composite.rb +++ b/lib/sisu/v0/composite.rb @@ -71,7 +71,7 @@ module SiSU_Assemble end def download_images(download_from,images_array) path="#{@env.path.processing}/external_document/image" - File.mkpath(path) unless FileTest.directory?(path) + mkdir_p(path) unless FileTest.directory?(path) images_array.each do |i| image="#{path}/#{i}" imagefile=File.new(image,'w+') @@ -81,12 +81,12 @@ module SiSU_Assemble imagefile.close end output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" - File.mkpath(output_path) unless FileTest.directory?(output_path) + mkdir_p(output_path) unless FileTest.directory?(output_path) SiSU_Env::System_call.new("#{path}/*",output_path,'q').rsync end def download_doc_skin(doc_skin) #first element in array is source url path="#{@env.path.processing}/external_document/skin/doc" - File.mkpath(path) unless FileTest.directory?(path) + mkdir_p(path) unless FileTest.directory?(path) download_from=doc_skin.shift doc_skin.each do |i| skin="#{path}/#{i}.rb" @@ -122,7 +122,7 @@ module SiSU_Assemble end def download_images(download_from,images_array) path="#{@env.path.processing}/external_document/image" - File.mkpath(path) unless FileTest.directory?(path) + mkdir_p(path) unless FileTest.directory?(path) images_array.each do |i| image="#{path}/#{i}" unless FileTest.exists?(image) @@ -136,7 +136,7 @@ module SiSU_Assemble end def download_doc_skin(doc_skin) #first element in array is source url path="#{@env.path.processing}/external_document/skin/doc" - File.mkpath(path) unless FileTest.directory?(path) + mkdir_p(path) unless FileTest.directory?(path) download_from=doc_skin.shift doc_skin.each do |i| skin="#{path}/#{i}.rb" diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index 814e2b88..8408deaf 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -208,7 +208,7 @@ WOK end def songsheet begin - File.mkpath(@path) unless FileTest.directory?(@path) + mkdir_p(@path) unless FileTest.directory?(@path) @file_index_all=File.open("#@path/#{@md.fn[:concordance]}",'w') map_para rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error diff --git a/lib/sisu/v0/conf.rb b/lib/sisu/v0/conf.rb index a11cb807..2e76d3de 100644 --- a/lib/sisu/v0/conf.rb +++ b/lib/sisu/v0/conf.rb @@ -139,7 +139,7 @@ module SiSU_Initialize tell=SiSU_Screen::Ansi.new(@opt.cmd,'invert','Configuring DTDs','') tell.colorize unless @opt.cmd =~/q/ @rxng=SiSU_relaxng::RelaxNG.new - @path.each { |d| File.mkpath(d[1]) unless FileTest.directory?(d[1]) } + @path.each { |d| mkdir_p(d[1]) unless FileTest.directory?(d[1]) } #ugly code, sort later if @rxng.methods.join =~/[^_]dtd_sax\b/ if @rxng.dtd_sax.length > 200 diff --git a/lib/sisu/v0/embedded.rb b/lib/sisu/v0/embedded.rb index 82c0317f..2bd295e2 100644 --- a/lib/sisu/v0/embedded.rb +++ b/lib/sisu/v0/embedded.rb @@ -90,7 +90,7 @@ module SiSU_Embedded rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/image" if @md.cmd.inspect =~/[vVMR]/ \ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) + mkdir_p(ldest) unless FileTest.directory?(ldest) src_ec="#{src}/" + @md.ec[:image].join(" #{src}/") unless @opt.fns =~/\.-sst$/ SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync @@ -109,7 +109,7 @@ module SiSU_Embedded rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/mm/audio" if @md.cmd.inspect =~/[vVMR]/ \ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) + mkdir_p(ldest) unless FileTest.directory?(ldest) src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/") SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync if @md.cmd.inspect =~/R/ #rsync to remote audio directory @@ -126,7 +126,7 @@ module SiSU_Embedded rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/mm/video" if @md.cmd.inspect =~/[vVMR]/ \ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) + mkdir_p(ldest) unless FileTest.directory?(ldest) src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/") SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync if @md.cmd.inspect =~/R/ #rsync to remote video directory diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index c170aa81..7972619a 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -146,7 +146,7 @@ module SiSU_HTML_seg if para =~/^4~\S+/ \ or para =~/^|^/ # @@level4 if tracking != 0 - File.mkpath(@md.dir_out) unless FileTest.directory?(@md.dir_out) #bug - added specifically for nav! not needed by regular seg, check !!! + mkdir_p(@md.dir_out) unless FileTest.directory?(@md.dir_out) #bug - added specifically for nav! not needed by regular seg, check !!! Seg.new('',@md).tail segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking-1]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}" @@filename_seg=File.new(segfilename,'w') if @@seg_name_html[tracking-1] diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index 2f2043fb..546606af 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -60,9 +60,6 @@ module SiSU_Param require 'uri' require 'pstore' - if RUBY_VERSION < '1.9' - require 'ftools' - end require "#{SiSU_lib}/sysenv" include SiSU_Env require "#{SiSU_lib}/param_identify_markup" diff --git a/lib/sisu/v0/share_src.rb b/lib/sisu/v0/share_src.rb index 81897bcb..e7a23e6c 100644 --- a/lib/sisu/v0/share_src.rb +++ b/lib/sisu/v0/share_src.rb @@ -76,8 +76,8 @@ module SiSU_Markup tell.green_hi_blue unless @opt.cmd =~/q/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"Copy sisu markup file to output directory","#{@opt.fns} -> #@output_path") tell.warn unless @opt.cmd =~/q/ - File.mkpath("#{@env.path.output}/src") unless FileTest.directory?("#{@env.path.output}/src") - File.mkpath(@output_path) unless FileTest.directory?(@output_path) + mkdir_p("#{@env.path.output}/src") unless FileTest.directory?("#{@env.path.output}/src") + mkdir_p(@output_path) unless FileTest.directory?(@output_path) if FileTest.directory?(@output_path) unless @opt.fns =~/\.ssm$/; cp(@opt.fns,@output_path) else diff --git a/lib/sisu/v0/share_src_kdissert.rb b/lib/sisu/v0/share_src_kdissert.rb index 43814331..fe7985fd 100644 --- a/lib/sisu/v0/share_src_kdissert.rb +++ b/lib/sisu/v0/share_src_kdissert.rb @@ -74,8 +74,8 @@ module SiSU_Kdi_source tell.green_hi_blue unless @opt.cmd =~/q/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"Copy kdissert file to output directory","#{@opt.fnb} -> #@output_path") tell.warn unless @opt.cmd =~/q/ - File.mkpath(@env.path.output) unless FileTest.directory?(@env.path.output) - File.mkpath(@output_path) unless FileTest.directory?(@output_path) + mkdir_p(@env.path.output) unless FileTest.directory?(@env.path.output) + mkdir_p(@output_path) unless FileTest.directory?(@output_path) if FileTest.directory?(@output_path) if @opt.fns =~/\.kdi\._sst$/ \ and FileTest.file?(@opt.fnb) diff --git a/lib/sisu/v0/sisupod_make.rb b/lib/sisu/v0/sisupod_make.rb index a4a97241..669ff49f 100644 --- a/lib/sisu/v0/sisupod_make.rb +++ b/lib/sisu/v0/sisupod_make.rb @@ -79,7 +79,7 @@ module SiSU_Doc @zipfile=if @opt.fns =~/\.ssm\.sst$/; @opt.fns.gsub(/(?:\~\S{2,3})?\.ssm\.sst$/,'.ssm') else @opt.fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1') end - File.mkpath(pod_path) unless FileTest.directory?(pod_path) + mkdir_p(pod_path) unless FileTest.directory?(pod_path) rm_rf("#{@env.path.processing}sisupod/*") if FileTest.directory?("#{@env.path.processing}sisupod") end def read @@ -260,7 +260,7 @@ module SiSU_Doc end #NB not all possibilies met, revisit, also in case of composite file may wish to add README end def sisupod_7zip #look at later - File.mkpath(@local_path) unless FileTest.directory?(@local_path) + mkdir_p(@local_path) unless FileTest.directory?(@local_path) system(%{ cd #{@env.path.processing} echo "SiSU sisupod #{@ver[:version]}" > sisu_zip.txt @@ -275,7 +275,7 @@ module SiSU_Doc tell.blue_tab unless @opt.cmd =~/q/ end def sisupod_zip - File.mkpath(@local_path) unless FileTest.directory?(@local_path) + mkdir_p(@local_path) unless FileTest.directory?(@local_path) system(%{ cd #{@env.path.processing} echo "SiSU sisupod #{@ver[:version]}" > sisu_zip.txt diff --git a/lib/sisu/v0/sitemaps.rb b/lib/sisu/v0/sitemaps.rb index 9838e60b..3742a786 100644 --- a/lib/sisu/v0/sitemaps.rb +++ b/lib/sisu/v0/sitemaps.rb @@ -104,7 +104,7 @@ module SiSU_Sitemaps end end def make_path(path) - File.mkpath(path) unless FileTest.directory?(path) + mkdir_p(path) unless FileTest.directory?(path) end def output_map(sitemap) path="#{@env.path.output}/#{@md.fnb}" diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index 4187f6e9..28dc088b 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -869,7 +869,7 @@ module SiSU_Env end paths=[] paths=["#{path.processing}/sisupod/_sisu/skin/doc","#{path.processing}/sisupod/_sisu/skin/dir","#{path.processing}/sisupod/_sisu/skin/site","#{path.processing}/sisupod/_sisu/image"] - paths.each {|x| File.mkpath(x) unless FileTest.directory?(x) } + paths.each {|x| mkdir_p(x) unless FileTest.directory?(x) } end def defaults #multiple default directories @default_dir ||=@sys.default_dir #DEFAULT_DIR @@ -1290,14 +1290,14 @@ WOK defaults[:webserv_path] else #create default directory under home and place output there unless FileTest.directory?(defaults[:output_local]) - File.mkpath(defaults[:output_local]) + mkdir_p(defaults[:output_local]) end defaults[:output_local] end end def webserv_stub_ensure - File.mkpath(path.webserv) unless FileTest.directory?(path.webserv) - File.mkpath("#{path.webserv}/#@stub_pwd") unless FileTest.directory?("#{path.webserv}/#@stub_pwd") + mkdir_p(path.webserv) unless FileTest.directory?(path.webserv) + mkdir_p("#{path.webserv}/#@stub_pwd") unless FileTest.directory?("#{path.webserv}/#@stub_pwd") end def webserv_map_pwd #dir "#{path.webserv}/#{stub_pwd}" @@ -1329,7 +1329,7 @@ WOK end def encoding pth="#{processing}/#{defaults[:processing_encoding]}" - File.mkpath(pth) unless FileTest.directory?(pth) + mkdir_p(pth) unless FileTest.directory?(pth) pth end def processing_base_tmp @@ -1380,15 +1380,15 @@ WOK end def processing #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc) unless FileTest.directory?(processing_path_root) - File.mkpath(processing_path_root) + mkdir_p(processing_path_root) File.chmod(0777,processing_path_root) end if processing_path_usr? processing_path_usr="#{processing_path_root}/#{user}" - File.mkpath(processing_path_usr) unless FileTest.directory?(processing_path_usr) + mkdir_p(processing_path_usr) unless FileTest.directory?(processing_path_usr) File.chmod(0700,processing_path_usr) end - File.mkpath(processing_path) unless FileTest.directory?(processing_path) + mkdir_p(processing_path) unless FileTest.directory?(processing_path) File.chmod(0700,processing_path) path_processing=[processing_path,defaults[:processing_path],defaults[:processing_path_home]] processing=nil @@ -1396,7 +1396,7 @@ WOK processing=v unless FileTest.directory?(processing) puts "a processing directory (#{processing}) is being created for use by sisu" - File.mkpath(processing) + mkdir_p(processing) File.chmod(0700,processing) end break @@ -1405,21 +1405,21 @@ WOK end def composite_file pth=path.dal #"#{processing}/composite" - File.mkpath(pth) unless FileTest.directory?(pth) + mkdir_p(pth) unless FileTest.directory?(pth) pth end def dal pth=if defined? @rc['processing']['dal']; "#{processing}/#{@rc['processing']['dal']}" else "#{processing}/#{defaults[:processing_dal]}" end - File.mkpath(pth) unless FileTest.directory?(pth) + mkdir_p(pth) unless FileTest.directory?(pth) pth end def tune pth=if defined? @rc['processing']['tune']; "#{processing}/#{@rc['processing']['tune']}" else "#{processing}/#{defaults[:processing_tune]}" end - File.mkpath(pth) unless FileTest.directory?(pth) + mkdir_p(pth) unless FileTest.directory?(pth) pth end def odf @@ -1429,14 +1429,14 @@ WOK pth=if defined? @rc['processing']['latex']; "#{processing}/#{@rc['processing']['latex']}" else "#{processing}/#{defaults[:processing_latex]}" end - File.mkpath(pth) unless FileTest.directory?(pth) + mkdir_p(pth) unless FileTest.directory?(pth) pth end def texi pth=if defined? @rc['processing']['texinfo']; "#{processing}/#{@rc['processing']['texinfo']}" else "#{processing}/#{defaults[:processing_texinfo]}" end - File.mkpath(pth) unless FileTest.directory?(pth) + mkdir_p(pth) unless FileTest.directory?(pth) pth end def texinfo #texinfo webserv, check @@ -1446,7 +1446,7 @@ WOK pth=if defined? @rc['processing']['lout']; "#{processing}/#{@rc['processing']['lout']}" else "#{processing}/#{defaults[:processing_lout]}" end - File.mkpath(pth) unless FileTest.directory?(pth) + mkdir_p(pth) unless FileTest.directory?(pth) pth end def feed @@ -1705,12 +1705,9 @@ WOK def images_local if FileTest.directory?(defaults[:image_local]) if @@image_flag - if RUBY_VERSION < '1.9' - require 'ftools' - end images=Dir.glob("#{defaults[:image_local]}/*.{png,jpg,gif}") pth="#{path.webserv}/#@stub_pwd" - File.mkpath("#{pth}/_sisu/image") unless FileTest.directory?("#{pth}/_sisu/image") + mkdir_p("#{pth}/_sisu/image") unless FileTest.directory?("#{pth}/_sisu/image") images.each { |i| File.install(i,"#{pth}/#{i}") } unless images.length > 0 @@image_flag=false end @@ -1733,12 +1730,9 @@ WOK def images_external if FileTest.directory?(image_external) if @@image_flag - if RUBY_VERSION < '1.9' - require 'ftools' - end images=Dir.glob("#{image_external}/*.{png,jpg,gif}") pth="#{path.webserv}/#@stub_pwd" - File.mkpath("#{pth}/_sisu/image_external") unless FileTest.directory?("#{pth}/_sisu/image_external") + mkdir_p("#{pth}/_sisu/image_external") unless FileTest.directory?("#{pth}/_sisu/image_external") images.each { |i| File.install(i,"#{pth}/#{i}") } unless images.length > 0 @@image_flag=false end @@ -2002,7 +1996,7 @@ WOK rm_rf(sisupod_processing_path) end unless FileTest.directory?(sisupod_processing_path) - File.mkpath(sisupod_processing_path) + mkdir_p(sisupod_processing_path) end if FileTest.file?("#{Dir.pwd}/#{fns_pod}") system("unzip -q #{Dir.pwd}/#{fns_pod} -d #{path.processing}") @@ -2537,9 +2531,6 @@ WOK class Info_version