From d17e7245922a9bdc9233ccfa0137dfdab5747356 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Nov 2011 00:08:04 -0500 Subject: v3: FileUtils, make explicit calls (more verbose, easier to find) --- lib/sisu/v3/sysenv.rb | 160 +++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 80 deletions(-) (limited to 'lib/sisu/v3/sysenv.rb') diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index cb7b94df..dd17b41e 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -838,10 +838,10 @@ module SiSU_Env end end def rm - if @cmd =~/^-Z[mMvVq]*$/; rm_rf(@input) - elsif @cmd =~/V/; rm(@input) - elsif @cmd !~/q/; rm(@input) - elsif @cmd =~/q/; rm(@input) + if @cmd =~/^-Z[mMvVq]*$/; FileUtils::rm_rf(@input) + elsif @cmd =~/V/; FileUtils::rm(@input) + elsif @cmd !~/q/; FileUtils::rm(@input) + elsif @cmd =~/q/; FileUtils::rm(@input) else puts "\tWARN: operation ignored" end end @@ -1113,7 +1113,7 @@ module SiSU_Env lng_dirs=[] if FileTest.directory?(spp) \ or FileTest.file?(spp) - rm_rf(spp) + FileUtils::rm_rf(spp) end paths=[] flv=Env_call.new(opt.fns).document_language_versions_found @@ -1131,7 +1131,7 @@ module SiSU_Env #<< "#{spp}/video" \ paths.each do |x| unless FileTest.directory?(x) - mkdir_p(x) + FileUtils::mkdir_p(x) end end if FileTest.directory?(sppc) @@ -1157,7 +1157,7 @@ module SiSU_Env sisupod_processing_path="#{processing_path.processing}/sisupod" if FileTest.directory?(sisupod_processing_path) \ or FileTest.file?(sisupod_processing_path) - rm_rf(sisupod_processing_path) + FileUtils::rm_rf(sisupod_processing_path) end paths=[] paths=[ @@ -1166,7 +1166,7 @@ module SiSU_Env "#{processing_path.processing}/sisupod/_sisu/skin/site", "#{processing_path.processing}/sisupod/_sisu/image" ] - paths.each {|x| mkdir_p(x) unless FileTest.directory?(x) } + paths.each {|x| FileUtils::mkdir_p(x) unless FileTest.directory?(x) } end def defaults #multiple default directories @default_dir ||=@sys.default_dir #DEFAULT_DIR @@ -1712,7 +1712,7 @@ WOK end man_path_head=man_path.gsub(/(\S+)\/[^\/\s]+$/,'\1') unless FileTest.directory?(man_path) - mkdir_p(man_path) if File.writable?("#{man_path_head}/.") + FileUtils::mkdir_p(man_path) if File.writable?("#{man_path_head}/.") end @webserv_path=if defined? man_path \ and File.writable?("#{man_path}/.") @@ -1722,14 +1722,14 @@ WOK defaults[:webserv_path] else #create default directory under home and place output there unless FileTest.directory?(defaults[:output_local]) - mkdir_p(defaults[:output_local]) + FileUtils::mkdir_p(defaults[:output_local]) end defaults[:output_local] end end def webserv_stub_ensure - mkdir_p(path.webserv) unless FileTest.directory?(path.webserv) - mkdir_p("#{path.webserv}/#{@stub_pwd}") unless FileTest.directory?("#{path.webserv}/#{@stub_pwd}") + FileUtils::mkdir_p(path.webserv) unless FileTest.directory?(path.webserv) + FileUtils::mkdir_p("#{path.webserv}/#{@stub_pwd}") unless FileTest.directory?("#{path.webserv}/#{@stub_pwd}") end def webserv_map_pwd #dir "#{path.webserv}/#{stub_pwd}" @@ -1814,7 +1814,7 @@ WOK def processing_path def encoding pth="#{processing}/#{defaults[:processing_encoding]}" - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def processing_base_tmp @@ -1863,15 +1863,15 @@ WOK end def processing #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc) unless FileTest.directory?(root_dir) - mkdir_p(root_dir) + FileUtils::mkdir_p(root_dir) File.chmod(0777,root_dir) end if usr_dir? processing_path_usr="#{root_dir}/#{user}" - mkdir_p(processing_path_usr) unless FileTest.directory?(processing_path_usr) + FileUtils::mkdir_p(processing_path_usr) unless FileTest.directory?(processing_path_usr) File.chmod(0700,processing_path_usr) end - mkdir_p(stub_dir) unless FileTest.directory?(stub_dir) + FileUtils::mkdir_p(stub_dir) unless FileTest.directory?(stub_dir) File.chmod(0700,stub_dir) path_processing=[stub_dir,defaults[:processing_path],defaults[:processing_path_home]] processing=nil @@ -1879,7 +1879,7 @@ WOK processing=v unless FileTest.directory?(processing) puts "a processing directory (#{processing}) is being created for use by sisu" - mkdir_p(processing) + FileUtils::mkdir_p(processing) File.chmod(0700,processing) end break @@ -1893,7 +1893,7 @@ WOK "#{processing}/#{@rc['processing']['dal']}" else "#{processing}/#{defaults[:processing_dal]}" end - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def tune @@ -1903,12 +1903,12 @@ WOK "#{processing}/#{@rc['processing']['tune']}" else "#{processing}/#{defaults[:processing_tune]}" end - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def composite_file pth=processing_path.dal #"#{processing}/composite" - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def git @@ -1921,7 +1921,7 @@ WOK else defaults[:processing_git] end unless FileTest.directory?(pth) - mkdir_p(pth) + FileUtils::mkdir_p(pth) File.chmod(0700,pth) end pth @@ -1935,42 +1935,42 @@ WOK end def odt pth=odf_pth + '/odt' - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def odf pth="#{processing}/odf" - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def odt_bld - rm_rf(processing_path.odt) - mkdir_p(processing_path.odt) unless FileTest.directory?(processing_path.odt) - mkdir_p("#{processing_path.odt}/Configurations2") unless FileTest.directory?("#{processing_path.odt}/Configurations2") - mkdir_p("#{processing_path.odt}/META-INF") unless FileTest.directory?("#{processing_path.odt}/META-INF") - mkdir_p("#{processing_path.odt}/Pictures") unless FileTest.directory?("#{processing_path.odt}/Pictures") - mkdir_p("#{processing_path.odt}/Thumbnails") unless FileTest.directory?("#{processing_path.odt}/Thumbnails") + FileUtils::rm_rf(processing_path.odt) + FileUtils::mkdir_p(processing_path.odt) unless FileTest.directory?(processing_path.odt) + FileUtils::mkdir_p("#{processing_path.odt}/Configurations2") unless FileTest.directory?("#{processing_path.odt}/Configurations2") + FileUtils::mkdir_p("#{processing_path.odt}/META-INF") unless FileTest.directory?("#{processing_path.odt}/META-INF") + FileUtils::mkdir_p("#{processing_path.odt}/Pictures") unless FileTest.directory?("#{processing_path.odt}/Pictures") + FileUtils::mkdir_p("#{processing_path.odt}/Thumbnails") unless FileTest.directory?("#{processing_path.odt}/Thumbnails") processing_path.odt end def epub "#{processing}/epub/#{@fnb}" end def epub_bld #(md) - rm_rf(processing_path.epub) if FileTest.directory?(processing_path.epub) - mkdir_p(processing_path.epub) unless FileTest.directory?(processing_path.epub) - mkdir_p("#{processing_path.epub}/META-INF") unless FileTest.directory?("#{processing_path.epub}/META-INF") - mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/image") unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/image") - mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/css") unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/css") + FileUtils::rm_rf(processing_path.epub) if FileTest.directory?(processing_path.epub) + FileUtils::mkdir_p(processing_path.epub) unless FileTest.directory?(processing_path.epub) + FileUtils::mkdir_p("#{processing_path.epub}/META-INF") unless FileTest.directory?("#{processing_path.epub}/META-INF") + FileUtils::mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/image") unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/image") + FileUtils::mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/css") unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/css") images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png] processing_path.epub end def epub_cp_images(md) pth="#{processing_path.epub}/#{Ep[:d_oebps]}/image" - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) src="#{path.share}/image" images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png] images.each do |i| #move to avoid repeated tests - cp("#{src}/#{i}","#{pth}/#{i}") unless FileTest.file?("#{pth}/#{i}") + FileUtils::cp("#{src}/#{i}","#{pth}/#{i}") unless FileTest.file?("#{pth}/#{i}") end pth end @@ -1981,7 +1981,7 @@ WOK "#{processing}/#{@rc['processing']['latex']}" else "#{processing}/#{defaults[:processing_latex]}" end - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def texi @@ -1991,7 +1991,7 @@ WOK "#{processing}/#{@rc['processing']['texinfo']}" else "#{processing}/#{defaults[:processing_texinfo]}" end - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def texinfo #texinfo webserv, check @@ -2007,12 +2007,12 @@ WOK "#{processing}/#{@rc['processing']['lout']}" else "#{processing}/#{defaults[:processing_lout]}" end - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def sql pth="#{processing}/sql" - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def sqlite @@ -2022,7 +2022,7 @@ WOK "#{processing}/#{@rc['processing']['sqlite']}" else "#{processing}/#{defaults[:processing_sqlite]}" end - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end def postgresql @@ -2032,7 +2032,7 @@ WOK "#{processing}/#{@rc['processing']['postgresql']}" else "#{processing}/#{defaults[:processing_postgresql]}" end - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end self @@ -2275,7 +2275,7 @@ WOK if @@image_flag images=Dir.glob("#{image_external}/*.{png,jpg,gif}") pth="#{path.webserv}/#{@stub_pwd}" - mkdir_p("#{pth}/_sisu/image_external") unless FileTest.directory?("#{pth}/_sisu/image_external") + FileUtils::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 @@ -2489,8 +2489,8 @@ WOK : (defaults[:papersize].downcase) end def odf_structure - rm_rf(processing_path.processing_path.odf_pth) - mkdir_p(processing_path.processing_path.odf_pth) + FileUtils::rm_rf(processing_path.processing_path.odf_pth) + FileUtils::mkdir_p(processing_path.processing_path.odf_pth) system("unzip -q #{path.share}/#{SiSU_version_dir}/odf/odt.zip -d #{processing_path.odf_pth}") end def sisupod_gen(fns_pod) @@ -2501,10 +2501,10 @@ WOK sisupod_processing_path="#{processing_path.processing}/sisupod" if FileTest.directory?(sisupod_processing_path) \ or FileTest.file?(sisupod_processing_path) - rm_rf(sisupod_processing_path) + FileUtils::rm_rf(sisupod_processing_path) end unless FileTest.directory?(sisupod_processing_path) - mkdir_p(sisupod_processing_path) + FileUtils::mkdir_p(sisupod_processing_path) end f_pod=if FileTest.file?("#{Dir.pwd}/#{fns_pod}") "#{Dir.pwd}/#{fns_pod}" @@ -2532,10 +2532,10 @@ WOK sisupod_processing_path="#{processing_path.processing}/sisupod" if FileTest.directory?(sisupod_processing_path) \ or FileTest.file?(sisupod_processing_path) - rm_rf(sisupod_processing_path) + FileUtils::rm_rf(sisupod_processing_path) end unless FileTest.directory?(sisupod_processing_path) - mkdir_p(sisupod_processing_path) + FileUtils::mkdir_p(sisupod_processing_path) end (FileTest.file?(fns_pod)) \ ? system("unzip -q #{fns_pod} -d #{processing_path.processing}") @@ -2754,30 +2754,30 @@ WOK def zap def main_output (@zap !~/\/\//) \ - ? (rm_rf(@zap) if FileTest.directory?(@zap)) + ? (FileUtils::rm_rf(@zap) if FileTest.directory?(@zap)) : (puts 'suspect zap request, ignored') end def site_map if @opt.fnb \ and not @opt.fnb.empty? sm="#{@env.path.output}/sitemaps/sitemap_#{@opt.fnb}.xml" - rm(sm) if FileTest.file?(sm) + FileUtils::rm(sm) if FileTest.file?(sm) end end def epub if @opt.fnb \ and not @opt.fnb.empty? sm="#{@env.path.output}/epub/#{@opt.fnb}.epub" - rm(sm) if FileTest.file?(sm) + FileUtils::rm(sm) if FileTest.file?(sm) end end def src # consider if @opt.fnb \ and not @opt.fnb.empty? sm="#{@env.path.output}/src/pod/#{@opt.fns}.txz" - rm(sm) if FileTest.file?(sm) + FileUtils::rm(sm) if FileTest.file?(sm) sm="#{@env.path.output}/src/#{@opt.fns}" - rm(sm) if FileTest.file?(sm) + FileUtils::rm(sm) if FileTest.file?(sm) end end self @@ -3236,7 +3236,7 @@ WOK end def images unless FileTest.directory?("#{@env.path.output}/_sisu") - mkdir_p("#{@env.path.output}/_sisu") + FileUtils::mkdir_p("#{@env.path.output}/_sisu") end unless File.exist?("#{@env.path.output}/_sisu/image_sys") \ or File.symlink?("#{@env.path.output}/_sisu/image_sys") @@ -3278,7 +3278,7 @@ WOK end end def make_path(path) - mkdir_p(path) unless FileTest.directory?(path) + FileUtils::mkdir_p(path) unless FileTest.directory?(path) end def marshal def dal_content @@ -3319,10 +3319,10 @@ WOK def mkdir #check moved from SiSU_file, existing mkdir def processing def dal - mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal) + FileUtils::mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal) end def tune - mkdir_p(@env.processing_path.tune) unless FileTest.directory?(@env.processing_path.tune) + FileUtils::mkdir_p(@env.processing_path.tune) unless FileTest.directory?(@env.processing_path.tune) end self end @@ -3354,20 +3354,20 @@ WOK self end def mkdir_initialize # not used but consider using - mkdir_p(output_path.base.dir) unless FileTest.directory?(output_path.base.dir) - mkdir_p("#{output_path.base.dir}/#{@md.fnb}") unless FileTest.directory?("#{output_path.base.dir}/#{@md.fnb}") - mkdir_p("#{output_path.base.dir}/#{@env.path.style}") unless FileTest.directory?("#{output_path.base.dir}/#{@env.path.style}") - mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal) - mkdir_p(@env.processing_path.tune) unless FileTest.directory?(@env.processing_path.tune) + FileUtils::mkdir_p(output_path.base.dir) unless FileTest.directory?(output_path.base.dir) + FileUtils::mkdir_p("#{output_path.base.dir}/#{@md.fnb}") unless FileTest.directory?("#{output_path.base.dir}/#{@md.fnb}") + FileUtils::mkdir_p("#{output_path.base.dir}/#{@env.path.style}") unless FileTest.directory?("#{output_path.base.dir}/#{@env.path.style}") + FileUtils::mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal) + FileUtils::mkdir_p(@env.processing_path.tune) unless FileTest.directory?(@env.processing_path.tune) end def mkdir txt_path="#{output_path.base.dir}/#{@md.fnb}" def output def base - mkdir_p(output_path.base.dir) unless FileTest.directory?(output_path.base.dir) + FileUtils::mkdir_p(output_path.base.dir) unless FileTest.directory?(output_path.base.dir) end def css - mkdir_p("#{output_path.base.dir}/#{@env.path.style}") unless FileTest.directory?("#{output_path.base.dir}/#{@env.path.style}") + FileUtils::mkdir_p("#{output_path.base.dir}/#{@env.path.style}") unless FileTest.directory?("#{output_path.base.dir}/#{@env.path.style}") end def epub path=output_path.epub.dir @@ -4258,7 +4258,7 @@ WOK end def dir pth=@env.processing_path.git + '/' + @md.fnb + '/' + ft + '/' + @md.opt.lng - mkdir_p(pth) unless FileTest.directory?(pth) + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end self @@ -5166,11 +5166,11 @@ WOK break end end - mkdir_p("#{@env.path.webserv}/#{@env.path.stub_pwd}") unless FileTest.directory?("#{@env.path.webserv}/#{@env.path.stub_pwd}") + FileUtils::mkdir_p("#{@env.path.webserv}/#{@env.path.stub_pwd}") unless FileTest.directory?("#{@env.path.webserv}/#{@env.path.stub_pwd}") if homepage_path \ and FileTest.file?(homepage_path) - cp(homepage_path,"#{@env.path.webserv}/#{@env.path.stub_pwd}/index.html") - cp(homepage_path,"#{@env.path.webserv}/#{@env.path.stub_pwd}/toc.html") + FileUtils::cp(homepage_path,"#{@env.path.webserv}/#{@env.path.stub_pwd}/index.html") + FileUtils::cp(homepage_path,"#{@env.path.webserv}/#{@env.path.stub_pwd}/toc.html") else doc_skin=nil sk_doc='doc/skin_sisu.rb' @@ -5189,15 +5189,15 @@ WOK end def cp_images(src_path,dest_path) if FileTest.directory?(src_path) - cd(src_path) + FileUtils::cd(src_path) source=Dir.glob("*.{png,jpg,gif,ico}") - mkdir_p(dest_path) unless FileTest.directory?(dest_path) - chmod(0755,dest_path) + FileUtils::mkdir_p(dest_path) unless FileTest.directory?(dest_path) + FileUtils::chmod(0755,dest_path) source.each do |i| - cp_r(i,"#{dest_path}/#{i}") - chmod(0644,"#{dest_path}/#{i}") + FileUtils::cp_r(i,"#{dest_path}/#{i}") + FileUtils::chmod(0644,"#{dest_path}/#{i}") end - cd(@pwd) + FileUtils::cd(@pwd) else puts "\tWARN, did not find - #{src_path}" end end @@ -5227,19 +5227,19 @@ WOK cp_images(src,dest) end def cp_css - mkdir_p("#{@env.path.output}/#{@env.path.style}") unless FileTest.directory?("#{@env.path.output}/#{@env.path.style}") + FileUtils::mkdir_p("#{@env.path.output}/#{@env.path.style}") unless FileTest.directory?("#{@env.path.output}/#{@env.path.style}") css_path=['/etc/sisu/css',"#{@home}/.sisu/css","#{@pwd}/_sisu/css"] #BROKEN if defined? @rc['permission_set']['css_modify'] \ and @rc['permission_set']['css_modify'] SiSU_Screen::Ansi.new(@cmd,"modify is css set to: #{@rc['permission_set']['css_modify']}").warn if @cmd=~/[MV]/ css_path.each do |x| if FileTest.directory?(x) - cd(x) + FileUtils::cd(x) source=Dir.glob("*.{css}") source.each do |i| - cp(i,"#{@env.path.output}/#{@env.path.style}") + FileUtils::cp(i,"#{@env.path.output}/#{@env.path.style}") end - cd(@pwd) + FileUtils::cd(@pwd) end end else SiSU_Screen::Ansi.new(@cmd,"modify css is not set or is set to: false").warn if @cmd=~/[MV]/ @@ -5247,7 +5247,7 @@ WOK fn_css=SiSU_Env::CSS_default.new css=SiSU_Style::CSS.new path_style="#{@env.path.output}/#{@env.path.style}" - mkdir_p(path_style) unless FileTest.directory?(path_style) + FileUtils::mkdir_p(path_style) unless FileTest.directory?(path_style) style=File.new("#{path_style}/#{fn_css.homepage}",'w') style << css.homepage style.close -- cgit v1.2.3