aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/sysenv.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-03-01 20:46:02 -0500
committerRalph Amissah <ralph@amissah.com>2011-03-01 20:46:02 -0500
commit5abc572129ac49178aa77ea59cb8e5d611e6374f (patch)
tree9c3402a3d8fa17d1a3c7a4c8bcc81230d12cc2be /lib/sisu/v3/sysenv.rb
parentv3: space between each and opening curly brace e.g. "x.each {|y| p y}" (diff)
v3: sysenv, separate out processing_path method plus consequences
Diffstat (limited to 'lib/sisu/v3/sysenv.rb')
-rw-r--r--lib/sisu/v3/sysenv.rb311
1 files changed, 155 insertions, 156 deletions
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb
index 1383b728..d4d0f16d 100644
--- a/lib/sisu/v3/sysenv.rb
+++ b/lib/sisu/v3/sysenv.rb
@@ -114,7 +114,7 @@ module SiSU_Env
"#{@@home}/#{prcss_dir_stub}"
else prcss_dir_stub
end
- processing_path=tmp_processing_individual
+ processing_pth=tmp_processing_individual
processing_dir=prcss_dir
processing_git="#{Dir.pwd}/#{Gt[:grotto]}"
user=ENV['USER']
@@ -184,9 +184,9 @@ module SiSU_Env
WEBSERV_SQLITE => out + '/www/sqlite',
OUTPUT_LOCAL => @@home + '/sisu_www',
PROCESSING_DIR => processing_dir,
- PROCESSING_PATH => processing_path,
+ PROCESSING_PATH => processing_pth,
PROCESSING_DIR_TMP_ROOT => prcss_dir_tmp_root,
- PROCESSING_PATH_TMP_BASE => processing_path,
+ PROCESSING_PATH_TMP_BASE => processing_pth,
PROCESSING_DAL => 'dal',
PROCESSING_TUNE => 'tune',
PROCESSING_LATEX => 'tex',
@@ -979,7 +979,7 @@ module SiSU_Env
@stub_pod
end
def sisupod
- #path.processing
+ #processing_path.processing
# sisupod
# sisu
# content.sst [file content]
@@ -989,13 +989,13 @@ module SiSU_Env
# skin/
# doc [relevant skin if any other than default]
# image [all images for specific document gathered here]
- sisupod_processing_path="#{path.processing}/sisupod"
+ sisupod_processing_path="#{processing_path.processing}/sisupod"
if FileTest.directory?(sisupod_processing_path) \
or FileTest.file?(sisupod_processing_path)
rm_rf(sisupod_processing_path)
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=["#{processing_path.processing}/sisupod/_sisu/skin/doc","#{processing_path.processing}/sisupod/_sisu/skin/dir","#{processing_path.processing}/sisupod/_sisu/skin/site","#{processing_path.processing}/sisupod/_sisu/image"]
paths.each {|x| mkdir_p(x) unless FileTest.directory?(x) }
end
def defaults #multiple default directories
@@ -1328,7 +1328,7 @@ WOK
def source_file_path
file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst')
pth=unless file =~/\.ssm\.sst$/; "#{Dir.pwd}"
- else "#{path.composite_file}"
+ else "#{processing_path.composite_file}"
end
end
def source_file_with_path
@@ -1339,12 +1339,12 @@ WOK
fns_array=if RUBY_VERSION < '1.9'
x=unless fns =~/\.ssm.sst$/
IO.readlines(fns,'')
- else IO.readlines("#{path.composite_file}/#{fns}",'')
+ else IO.readlines("#{processing_path.composite_file}/#{fns}",'')
end
else #ruby version >= '1.9'
x=unless fns =~/\.ssm.sst$/
IO.readlines(fns,'r:utf-8')
- else IO.readlines("#{path.composite_file}/#{fns}",'r:utf-8')
+ else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8')
end
end
end
@@ -1478,19 +1478,80 @@ WOK
def output #web/webserv output directory... subdirectory into which further subdirectories are made based on file names
"#{path.webserv}/#{@stub_pwd}"
end
+ def feed
+ (defined? @rc['webserv']['feed']) \
+ ? ("#{public_output}/#{@rc['webserv']['feed']}") \
+ : (defaults[:webserv_feed])
+ end
+ def feed_home
+ "#{public_output}/#{@rc['webserv']['feed_home']}"
+ end
+ def scripts #used previously only to include tla version info
+ if defined? @rc['project']['path']; "#{home}/#{@rc['project']['path']}"
+ end
+ end
+ def cgi
+ (defined? @rc['webserv']['cgi']) \
+ ? "#{@rc['webserv']['cgi']}" \
+ : (defaults[:webserv_cgi])
+ end
+ def php
+ (defined? @rc['webserv']['php']) \
+ ? "#{public_output}/#{@rc['webserv']['php']}" \
+ : (defaults[:webserv_php])
+ end
+ # programs
+ def output_tell
+ url.webserv_map_pwd
+ end
+ def image_source #image repository source directory
+ image_path=if defined? @rc['image']['path'] \
+ and defined? @rc['image']['public']
+ pth="#{@rc['image']['path']}"
+ "#{pth}/#{@rc['image']['public']}"
+ else "#{share}/image"
+ end
+ end
+ def image_source_sisu_includes
+ "#{share}/image"
+ end
+ def image_source_include #image repository source directory
+ image_path=if defined? @rc['image']['path'] \
+ and defined? @rc['image']['public'] \
+ and FileTest.directory?("#{@rc['image']['path']}/#{@rc['image']['public']}")==true
+ "#{@rc['image']['path']}/#{@rc['image']['public']}"
+ elsif FileTest.directory?("#{@@pwd}/#{defaults[:image_stub]}")==true
+ "#{@@pwd}/#{defaults[:image_stub]}"
+ else
+ "#{share}/image"
+ end
+ end
+ def image_external
+ "#{processing}/external_document/image"
+ end
+ def image_source_include_local
+ if FileTest.directory?(defaults[:image_local]); defaults[:image_local]
+ end
+ end
+ def image_source_include_remote
+ if FileTest.directory?(image_external); image_external
+ end
+ end
+ self
+ end
+ def processing_path
def encoding
pth="#{processing}/#{defaults[:processing_encoding]}"
mkdir_p(pth) unless FileTest.directory?(pth)
pth
end
-#def processing
def processing_base_tmp
defaults[:processing_path_tmp_base]
end
- def processing_dir_tmp_root
+ def tmp_root_dir
defaults[:processing_dir_tmp_root]
end
- def processing_path_root
+ def root_dir
proposed_path_base=if defined? @rc['processing']['path'] \
and not @rc['processing']['path'].nil? \
and not @rc['processing']['path'].empty?
@@ -1517,30 +1578,30 @@ WOK
else defaults[:processing_dir_tmp_root]
end
end
- def processing_path_usr?
- case processing_path_root
+ def usr_dir?
+ case root_dir
when /^\/home/; false
else true
end
end
- def processing_path
- (processing_path_usr?) \
- ? ("#{processing_path_root}/#{user}/#{stub_pwd}") \
- : ("#{processing_path_root}/#{stub_pwd}") # see defaults[:processing_path]
+ def stub_dir
+ (usr_dir?) \
+ ? ("#{root_dir}/#{user}/#{stub_pwd}") \
+ : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path]
end
def processing #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc)
- unless FileTest.directory?(processing_path_root)
- mkdir_p(processing_path_root)
- File.chmod(0777,processing_path_root)
+ unless FileTest.directory?(root_dir)
+ mkdir_p(root_dir)
+ File.chmod(0777,root_dir)
end
- if processing_path_usr?
- processing_path_usr="#{processing_path_root}/#{user}"
+ if usr_dir?
+ processing_path_usr="#{root_dir}/#{user}"
mkdir_p(processing_path_usr) unless FileTest.directory?(processing_path_usr)
File.chmod(0700,processing_path_usr)
end
- 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]]
+ 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
path_processing.each do |v| #
processing=v
@@ -1553,36 +1614,6 @@ WOK
end
processing
end
- def processing_path_git
- proposed_dir=if defined? @rc['git']['dir'] \
- and not @rc['git']['dir'].nil? \
- and not @rc['git']['dir'].empty?
- x=(@rc['git']['dir'] =~/^(?:~|home)$/) \
- ? home + '/' + 'sisu:' \
- : @rc['git']['dir'] + '/' + 'sisu:'
- else defaults[:processing_git]
- end
- end
- def processing_git
- unless FileTest.directory?(processing_path_git)
- mkdir_p(processing_path_git)
- File.chmod(0700,processing_path_git)
- end
- processing_path_git
- end
- def epub
- "#{processing}/epub/#{@fnb}"
- end
- def sql
- pth="#{processing}/sql"
- mkdir_p(pth) unless FileTest.directory?(pth)
- pth
- end
- def composite_file
- pth=path.dal #"#{processing}/composite"
- mkdir_p(pth) unless FileTest.directory?(pth)
- pth
- end
def dal
pth=if defined? @rc['processing']['dal'] \
and not @rc['processing']['dal'].nil? \
@@ -1603,21 +1634,44 @@ WOK
mkdir_p(pth) unless FileTest.directory?(pth)
pth
end
- def processing_odf
+ def composite_file
+ pth=processing_path.dal #"#{processing}/composite"
+ mkdir_p(pth) unless FileTest.directory?(pth)
+ pth
+ end
+ def git
+ pth=if defined? @rc['git']['dir'] \
+ and not @rc['git']['dir'].nil? \
+ and not @rc['git']['dir'].empty?
+ x=(@rc['git']['dir'] =~/^(?:~|home)$/) \
+ ? home + '/' + 'sisu:' \
+ : @rc['git']['dir'] + '/' + 'sisu:'
+ else defaults[:processing_git]
+ end
+ unless FileTest.directory?(pth)
+ mkdir_p(git)
+ File.chmod(0700,git)
+ end
+ pth
+ end
+ def odf
pth="#{processing}/odf"
mkdir_p(pth) unless FileTest.directory?(pth)
pth
end
+ def epub
+ "#{processing}/epub/#{@fnb}"
+ end
def epub_bld #(md)
- mkdir_p(path.epub) unless FileTest.directory?(path.epub)
- mkdir_p("#{path.epub}/META-INF") unless FileTest.directory?("#{path.epub}/META-INF")
- mkdir_p("#{path.epub}/OPS/image") unless FileTest.directory?("#{path.epub}/OPS/image")
- mkdir_p("#{path.epub}/OPS/css") unless FileTest.directory?("#{path.epub}/OPS/css")
+ 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}/OPS/image") unless FileTest.directory?("#{processing_path.epub}/OPS/image")
+ mkdir_p("#{processing_path.epub}/OPS/css") unless FileTest.directory?("#{processing_path.epub}/OPS/css")
images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png]
- path.epub
+ processing_path.epub
end
def epub_cp_images(md)
- pth="#{path.epub}/OPS/image"
+ pth="#{processing_path.epub}/OPS/image"
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]
@@ -1626,7 +1680,7 @@ WOK
end
pth
end
- def processing_tex
+ def tex
pth=if defined? @rc['processing']['latex'] \
and not @rc['processing']['latex'].nil? \
and not @rc['processing']['latex'].empty?
@@ -1662,6 +1716,11 @@ WOK
mkdir_p(pth) unless FileTest.directory?(pth)
pth
end
+ def sql
+ pth="#{processing}/sql"
+ mkdir_p(pth) unless FileTest.directory?(pth)
+ pth
+ end
def sqlite
pth=if defined? @rc['processing']['sqlite'] \
and not @rc['processing']['sqlite'].nil? \
@@ -1682,66 +1741,6 @@ WOK
mkdir_p(pth) unless FileTest.directory?(pth)
pth
end
-#end
- def feed
- (defined? @rc['webserv']['feed']) \
- ? ("#{public_output}/#{@rc['webserv']['feed']}") \
- : (defaults[:webserv_feed])
- end
- def feed_home
- "#{public_output}/#{@rc['webserv']['feed_home']}"
- end
- def scripts #used previously only to include tla version info
- if defined? @rc['project']['path']; "#{home}/#{@rc['project']['path']}"
- end
- end
- def cgi
- (defined? @rc['webserv']['cgi']) \
- ? "#{@rc['webserv']['cgi']}" \
- : (defaults[:webserv_cgi])
- end
- def php
- (defined? @rc['webserv']['php']) \
- ? "#{public_output}/#{@rc['webserv']['php']}" \
- : (defaults[:webserv_php])
- end
- # programs
- def output_tell
- url.webserv_map_pwd
- end
- def image_source #image repository source directory
- image_path=if defined? @rc['image']['path'] \
- and defined? @rc['image']['public']
- pth="#{@rc['image']['path']}"
- "#{pth}/#{@rc['image']['public']}"
- else "#{share}/image"
- end
- end
- def image_source_sisu_includes
- "#{share}/image"
- end
- def image_source_include #image repository source directory
- image_path=if defined? @rc['image']['path'] \
- and defined? @rc['image']['public'] \
- and FileTest.directory?("#{@rc['image']['path']}/#{@rc['image']['public']}")==true
- "#{@rc['image']['path']}/#{@rc['image']['public']}"
- elsif FileTest.directory?("#{@@pwd}/#{defaults[:image_stub]}")==true
- "#{@@pwd}/#{defaults[:image_stub]}"
- else
- "#{share}/image"
- end
- end
- def image_external
- "#{processing}/external_document/image"
- end
- def image_source_include_local
- if FileTest.directory?(defaults[:image_local]); defaults[:image_local]
- end
- end
- def image_source_include_remote
- if FileTest.directory?(image_external); image_external
- end
- end
self
end
def url
@@ -2197,12 +2196,12 @@ WOK
: (defaults[:papersize].downcase)
end
def odf_structure
- rm_rf("#{path.processing}/odf")
- system("unzip -q #{path.share}/#{SiSU_version_dir}/odf/odt.zip -d #{path.processing}")
+ rm_rf("#{processing_path.processing}/odf")
+ system("unzip -q #{path.share}/#{SiSU_version_dir}/odf/odt.zip -d #{processing_path.processing}")
end
def sisupod_gen(fns_pod)
pwd=Dir.pwd
- sisupod_processing_path="#{path.processing}/sisupod"
+ sisupod_processing_path="#{processing_path.processing}/sisupod"
if FileTest.directory?(sisupod_processing_path) \
or FileTest.file?(sisupod_processing_path)
rm_rf(sisupod_processing_path)
@@ -2211,7 +2210,7 @@ WOK
mkdir_p(sisupod_processing_path)
end
if FileTest.file?("#{Dir.pwd}/#{fns_pod}")
- system("unzip -q #{Dir.pwd}/#{fns_pod} -d #{path.processing}")
+ system("unzip -q #{Dir.pwd}/#{fns_pod} -d #{processing_path.processing}")
else
SiSU_Screen::Ansi.new('',"file not found: #{fns_pod}").warn unless @cmd=~/q/
end
@@ -2840,37 +2839,37 @@ WOK
end
def marshal
def dal_content
- "#{@env.path.dal}/#{@fns}.content.rbm"
+ "#{@env.processing_path.dal}/#{@fns}.content.rbm"
end
def dal_idx_sst_rel_html_seg
- "#{@env.path.dal}/#{@fns}.idx_sst.rbm"
+ "#{@env.processing_path.dal}/#{@fns}.idx_sst.rbm"
end
def dal_idx_sst_rel
- "#{@env.path.dal}/#{@fns}.idx_tex.rbm"
+ "#{@env.processing_path.dal}/#{@fns}.idx_tex.rbm"
end
def dal_idx_html
- "#{@env.path.dal}/#{@fns}.idx_html.rbm"
+ "#{@env.processing_path.dal}/#{@fns}.idx_html.rbm"
end
def dal_idx_xhtml
- "#{@env.path.dal}/#{@fns}.idx_xhtml.rbm"
+ "#{@env.processing_path.dal}/#{@fns}.idx_xhtml.rbm"
end
def dal_metadata
- "#{@env.path.dal}/#{@fns}.metadata.rbm"
+ "#{@env.processing_path.dal}/#{@fns}.metadata.rbm"
end
def dal_map_nametags
- "#{@env.path.dal}/#{@fns}.map_name_tags.rbm"
+ "#{@env.processing_path.dal}/#{@fns}.map_name_tags.rbm"
end
def dal_map_ocn_htmlseg
- "#{@env.path.dal}/#{@fns}.map_ocn_htmlseg.rbm"
+ "#{@env.processing_path.dal}/#{@fns}.map_ocn_htmlseg.rbm"
end
def html_tune
- "#{@env.path.tune}/#{@fns}.marshal_tune"
+ "#{@env.processing_path.tune}/#{@fns}.marshal_tune"
end
self
end
def write_file_processing
def html_tune
- File.new("#{@env.path.tune}/#{@fns}.tune",'w+')
+ File.new("#{@env.processing_path.tune}/#{@fns}.tune",'w+')
end
self
end
@@ -2952,10 +2951,10 @@ WOK
def mkdir #check moved from SiSU_file, existing mkdir
def processing
def dal
- mkdir_p(@env.path.dal) unless FileTest.directory?(@env.path.dal)
+ mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal)
end
def tune
- mkdir_p(@env.path.tune) unless FileTest.directory?(@env.path.tune)
+ mkdir_p(@env.processing_path.tune) unless FileTest.directory?(@env.processing_path.tune)
end
self
end
@@ -2990,8 +2989,8 @@ WOK
mkdir_p(output_path.base) unless FileTest.directory?(output_path.base)
mkdir_p("#{output_path.base}/#{@md.fnb}") unless FileTest.directory?("#{output_path.base}/#{@md.fnb}")
mkdir_p("#{output_path.base}/#{@env.path.style}") unless FileTest.directory?("#{output_path.base}/#{@env.path.style}")
- mkdir_p(@env.path.dal) unless FileTest.directory?(@env.path.dal)
- mkdir_p(@env.path.tune) unless FileTest.directory?(@env.path.tune)
+ 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)
end
def mkdir
txt_path="#{output_path.base}/#{@md.fnb}"
@@ -3409,13 +3408,13 @@ WOK
end
def po_git
ft=Gt[:po]
- pth=@env.path.processing_path_git + '/' + @md.fnb + '/' + ft + '/' + lang_part
+ pth=@env.processing_path.git + '/' + @md.fnb + '/' + ft + '/' + lang_part
mkdir_p(pth) unless FileTest.directory?(pth)
pth
end
def pot_git
ft=Gt[:pot]
- @env.path.processing_path_git + '/' + @md.fnb + '/' + ft
+ @env.processing_path.git + '/' + @md.fnb + '/' + ft
end
def md_harvest
"#{output_path.base}/sisu_site_metadata"
@@ -3501,7 +3500,7 @@ WOK
#@env.path.output
end
def mkdir_pdf
- Dir.mkdir(@env.path.tex) unless FileTest.directory?(@env.path.tex)
+ Dir.mkdir(@env.processing_path.tex) unless FileTest.directory?(@env.processing_path.tex)
end
def file_generic(output_file='')
filename="#{@env.path.output}/#{@fnb}/#{output_file}"
@@ -3511,17 +3510,17 @@ WOK
File.new('/tmp/errorlog.sisu','w+')
end
def file_txt
- File.new("#{@env.path.dal}/#{@fns}.txt",'w+')
+ File.new("#{@env.processing_path.dal}/#{@fns}.txt",'w+')
end
def file_debug
- File.new("#{@env.path.dal}/#{@fns}.debug.txt",'w+')
+ File.new("#{@env.processing_path.dal}/#{@fns}.debug.txt",'w+')
end
def metaverse
def file_meta
- File.new("#{@env.path.dal}/#{@fns}.meta",'w+')
+ File.new("#{@env.processing_path.dal}/#{@fns}.meta",'w+')
end
def file_meta_idx_html
- File.new("#{@env.path.dal}/#{@fns}.idx.html",'w+')
+ File.new("#{@env.processing_path.dal}/#{@fns}.idx.html",'w+')
end
self
end
@@ -3529,7 +3528,7 @@ WOK
File.new("#{Dir.pwd}/#{@fns}.fn",'w+')
end
def meta
- "#{@env.path.dal}/#{@fns}.meta"
+ "#{@env.processing_path.dal}/#{@fns}.meta"
end
def file_semantic
filename_semantic="./semantic.yaml"
@@ -3540,7 +3539,7 @@ WOK
@@filename_rss=File.new(filename_rss,'w+')
end
def epub
- @pth=@env.path.epub
+ @pth=@env.processing_path.epub
def xhtml_index
filename_index="#{@pth}/OPS/index.xhtml"
File.new(filename_index,'w+')
@@ -3567,7 +3566,7 @@ WOK
self
end
def file_texinfo
- File.new("#{@env.path.texinfo}/#{@fnb}.texinfo",'w+')
+ File.new("#{@env.processing_path.texinfo}/#{@fnb}.texinfo",'w+')
end
end
class Clear <Info_env #todo unify with SiSU_file
@@ -3737,7 +3736,7 @@ WOK
load "#{SiSU_lib}/defaults.rb"
skin_path=[]
@env.sys.rc_path.each {|x| skin_path << "#{x}/skin"}
- skin_path << "#{@env.path.processing}/external_document/skin"
+ skin_path << "#{@env.processing_path.processing}/external_document/skin"
skin=true
if @pwd_stub =~/^sisupod$/ \
and @md.mod.inspect !~/--trust/
@@ -3959,7 +3958,7 @@ WOK
cp_images(src,dest)
end
def cp_external_images
- src="#{@env.path.processing}/external_document/image"
+ src="#{@env.processing_path.processing}/external_document/image"
dest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external"
cp_images(src,dest)
end
@@ -4041,7 +4040,7 @@ fns_array=unless fns =~/\.ssm.sst$/
end
else
if RUBY_VERSION < '1.9'
- IO.readlines("#{path.composite_file}/#{fns}",'')
- else IO.readlines("#{path.composite_file}/#{fns}",'r:utf-8')
+ IO.readlines("#{processing_path.composite_file}/#{fns}",'')
+ else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8')
end
end