From b5712bc3650a2c2d38ec5e8e4021ff4b5965dd87 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 5 Sep 2011 10:48:00 -0400 Subject: v3: Dir.chdir, remove "system cd" (change directory) use Dir.chdir --- lib/sisu/v3/epub.rb | 19 +++++++++++-------- lib/sisu/v3/git.rb | 20 +++++++++++++------- lib/sisu/v3/odf.rb | 15 +++++++++------ lib/sisu/v3/texpdf.rb | 14 +++++++++----- 4 files changed, 42 insertions(+), 26 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index 42bc6cd9..12ec1ce0 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -670,14 +670,17 @@ module SiSU_EPUB end def output_zip mkdir_p(@md.file.output_path.epub.dir) unless FileTest.directory?(@md.file.output_path.epub.dir) - system(" - cd #{@md.env.processing_path.epub} - zip -qXr9D #{@epub_doc} * - mv #{@epub_doc} #{@md.file.place_file.epub.dir} - cd #{Dir.pwd} - ") - unless @md.opt.cmd.inspect =~/M/ - system("rm -r #{@md.env.processing_path.epub}") + if FileTest.directory?(@md.env.processing_path.epub) + pwd=Dir.pwd + Dir.chdir(@md.env.processing_path.epub) + system(" + zip -qXr9D #{@epub_doc} * + mv #{@epub_doc} #{@md.file.place_file.epub.dir} + ") + Dir.chdir(pwd) + unless @md.opt.cmd.inspect =~/M/ + system("rm -r #{@md.env.processing_path.epub}") + end end end def segtoc diff --git a/lib/sisu/v3/git.rb b/lib/sisu/v3/git.rb index 322b5846..2e76fa4a 100644 --- a/lib/sisu/v3/git.rb +++ b/lib/sisu/v3/git.rb @@ -136,16 +136,22 @@ module SiSU_Git end def git_init unless FileTest.directory?("#{@git_path[:fnb]}/.git") - system("cd #{@git_path[:fnb]}\ - && git init - ") + pwd=Dir.pwd + Dir.chdir(@git_path[:fnb]) + system("git init ") + Dir.chdir(pwd) end end def git_commit - system("cd #{@git_path[:fnb]} \ - && git add . \ - && git commit -a - ") + if FileTest.directory?("#{@git_path[:fnb]}") + pwd=Dir.pwd + Dir.chdir(@git_path[:fnb]) + system(" + git add . \ + && git commit -a + ") + Dir.chdir(pwd) + end end def populate def identify_language_versions diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index 8ff98db5..1919fa08 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -714,12 +714,15 @@ module SiSU_ODF od.close opendoc=@md.fn[:odf] mkdir_p(@md.file.output_path.odt.dir) unless FileTest.directory?(@md.file.output_path.odt.dir) - system(" - cd #{@env.processing_path.odf} - zip -qr #{opendoc} * - mv #{opendoc} #{@md.file.place_file.odt.dir} - cd #{Dir.pwd} - ") + if FileTest.directory?(@env.processing_path.odf) + pwd=Dir.pwd + Dir.chdir(@env.processing_path.odf) + system(" + zip -qr #{opendoc} * + mv #{opendoc} #{@md.file.place_file.odt.dir} + ") + Dir.chdir(pwd) + end end end end diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index 155d063a..ab7995f4 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -238,11 +238,15 @@ module SiSU_TeX "#{@md.fnb}.portrait.pdf" else 'portrait.pdf' end - system(" - cd #{@md.file.output_path.pdf.dir} - rm #{mklnk} - ln -s #{pdf_p} #{mklnk} - ") + if FileTest.directory?(@md.file.output_path.pdf.dir) + pwd=Dir.pwd + Dir.chdir(@md.file.output_path.pdf.dir) + system(" + rm #{mklnk} + ln -s #{pdf_p} #{mklnk} + ") + Dir.chdir(pwd) + end end if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{pdf_l}") mklnk=if @md.file.output_dir_structure.by_language_code? \ -- cgit v1.2.3