aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/ao_composite.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-07-01 00:45:40 -0400
committerRalph Amissah <ralph@amissah.com>2014-07-01 00:45:40 -0400
commit9347018753e818b49980651df3b77352c5f3792f (patch)
tree8393afd4fcb883b40228840a7c6acc5027f1a2f1 /lib/sisu/v6/ao_composite.rb
parentv5 v6: files renamed: ao_composite.rb, html_concordance.rb (diff)
v5 v6: ao, code cosmetic rearrangement
Diffstat (limited to 'lib/sisu/v6/ao_composite.rb')
-rw-r--r--lib/sisu/v6/ao_composite.rb70
1 files changed, 44 insertions, 26 deletions
diff --git a/lib/sisu/v6/ao_composite.rb b/lib/sisu/v6/ao_composite.rb
index f8c4b396..2f864228 100644
--- a/lib/sisu/v6/ao_composite.rb
+++ b/lib/sisu/v6/ao_composite.rb
@@ -74,7 +74,8 @@ module SiSU_Assemble
end
def download_images(images_info)
path="#{@env.processing_path.processing}/external_document/image"
- FileUtils::mkdir_p(path) unless FileTest.directory?(path)
+ FileUtils::mkdir_p(path) \
+ unless FileTest.directory?(path)
download_from=images_info.shift
images_info.each do |i|
image="#{path}/#{i}"
@@ -85,7 +86,8 @@ module SiSU_Assemble
imagefile.close
end
output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external"
- FileUtils::mkdir_p(output_path) unless FileTest.directory?(output_path)
+ FileUtils::mkdir_p(output_path) \
+ unless FileTest.directory?(output_path)
SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync
end
end
@@ -99,8 +101,8 @@ module SiSU_Assemble
begin
pwd=Dir.pwd
Dir.chdir(@opt.f_pth[:pth])
- @fns_array=IO.readlines(@opt.fno,'')
- assembled=insertions?
+ fns_array=IO.readlines(@opt.fno,'')
+ assembled=insertions?(fns_array)
write(assembled)
Dir.chdir(pwd)
rescue
@@ -141,7 +143,9 @@ module SiSU_Assemble
end
if not @code_flag \
and i !~/^%+\s/
- i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax)
+ i=i.
+ gsub(/^([123]|:?[ABCD])~\? /,
+ '% [conditional heading:] \1~ ') #off conditional heading (consider syntax)
if i =~/^@\S+?:/
i=i.gsub(/\n/m,"\n% ").
gsub(/\n%\s+$/m,'').
@@ -161,27 +165,36 @@ module SiSU_Assemble
end
file
end
- def insertions?
- data=@fns_array
+ def insertions?(fns_array)
tuned_file,imagedir=[],[]
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").grey_title_hi unless @opt.act[:quiet][:set]==:on
- data.each do |para|
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Composite Document',
+ "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}",
+ ).grey_title_hi unless @opt.act[:quiet][:set]==:on
+ fns_array.each do |para|
if para =~/^<<\s+(\S+?\.ss[it])$/
loadfile=$1.strip
- src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm')
if (@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'loading:',
+ loadfile,
+ ).txt_grey
end
- tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest
- imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch
+ tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest
+ imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/.
+ match(loadfile).captures.join +
+ '/_sisu/image' #watch
begin
require 'uri'
require 'open-uri'
require 'pp'
rescue LoadError
- SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri, open-uri or pp NOT FOUND (LoadError)')
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
+ error('uri, open-uri or pp NOT FOUND (LoadError)')
end
image_uri=URI.parse(imagedir)
insert=open(loadfile)
@@ -191,13 +204,12 @@ module SiSU_Assemble
@@imager[image_uri] ||=[]
@@imager[image_uri] << file[:images]
file[:prepared]
- elsif loadfile =~ /\.ss[ti]$/ \
+ elsif loadfile =~ /\.ss[it]$/ \
and FileTest.file?(loadfile)
insert_array=IO.readlines(loadfile,'')
file=insertion(loadfile,insert_array)
file[:prepared]
else
- cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX
STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"}
$process_document = :skip; break #remove this line to continue processing documents that have missing include files
para
@@ -225,8 +237,8 @@ module SiSU_Assemble
def read
begin
@opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub
- @fns_array=IO.readlines(@opt.fns,'')
- insertions?
+ fns_array=IO.readlines(@opt.fns,'')
+ insertions?(fns_array)
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -234,26 +246,32 @@ module SiSU_Assemble
ensure
end
end
- def insertions?
- data=@fns_array
+ def insertions?(fns_array)
tuned_file=[]
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',@opt.fno).grey_title_hi unless @opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Composite Document',
+ @opt.fno
+ ).grey_title_hi unless @opt.act[:quiet][:set]==:on
@ssm=[@opt.fns]
- data.each do |para|
+ fns_array.each do |para|
if para =~/^<<\s+(\S+?\.ss[it])$/
loadfile=$1.strip
if (@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'loading:',
+ loadfile,
+ ).txt_grey
end
- tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/
+ tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/
@ssm << loadfile
- elsif loadfile =~ /\.ss[ti]$/ \
+ elsif loadfile =~ /\.ss[it]$/ \
and FileTest.file?(loadfile)
@ssm << loadfile
else
- cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX
STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"}
$process_document = :skip; break #remove this line to continue processing documents that have missing include files
para