aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v4
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-02-07 18:10:21 -0500
committerRalph Amissah <ralph@amissah.com>2013-02-07 18:10:21 -0500
commit75dc380f544c55d38765a7679c464e6c71125fb6 (patch)
tree6d512214476ce79c2a088a4f70bee8e4462b6a33 /lib/sisu/v4
parentv4: options, param, pdf papersize, command-line options to override sisurc (diff)
v4: options, for pdf, concentrate & simplify matching of orientation & papersize
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r--lib/sisu/v4/options.rb89
1 files changed, 51 insertions, 38 deletions
diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb
index 8f07e0c4..3dca5253 100644
--- a/lib/sisu/v4/options.rb
+++ b/lib/sisu/v4/options.rb
@@ -462,6 +462,37 @@ module SiSU_Commandline
end
def opt_cmd_and_mod_adjust(c,m)
cmd,mod,files=@cmd,@mod,@files
+ if not m.empty? \
+ and m.inspect =~/"--pdf-/
+ ps,psa='',[]
+ mod << '--pdf'
+ m.each do |m|
+ if m =~ /^--pdf-(?:(?:l|landscape)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:l|landscape))$/
+ mod << '--landscape'
+ end
+ if m =~ /^--pdf-(?:(?:p|portrait)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:p|portrait))$/
+ mod << '--portrait'
+ end
+ if m =~ /^--pdf(?:-(?:a4|letter|a5|b5|legal)(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))(?:-(?:a4|letter|a5|b5|legal)))$/
+ if m =~ /^--pdf(?:-a4(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a4)$/
+ mod << '--papersize-a4'
+ end
+ if m =~ /^--pdf(?:-a5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a5)$/
+ mod << '--papersize-a5'
+ end
+ if m =~ /^--pdf(?:-b5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-b5)$/
+ mod << '--papersize-b5'
+ end
+ if m =~ /^--pdf(?:-letter(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-letter)$/
+ mod << '--papersize-letter'
+ end
+ if m =~ /^--pdf(?:-legal(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-legal)$/
+ mod << '--papersize-legal'
+ end
+ end
+ end
+ mod=mod.uniq
+ end
unless m.empty?
m.each do |m|
case m
@@ -477,13 +508,9 @@ module SiSU_Commandline
when /^--(?:od[ft])$/; c=c+'o'
when /^--(?:pdf)$/; c=c+'p'
when /^--pdf-(?:a4|a5|b5|legal|letter)$/; c=c+'p'
- mod << m
when /^--pdf-(?:p|l|portrait|landscape)$/; c=c+'L'
- mod << m
when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/; c=c+'L'
- mod << m
when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/; c=c+'L'
- mod << m
when /^--(?:concordance|wordmap)$/; c=c+'w'
when /^--(?:manpage|man)$/; c=c+'i'
when /^--(?:texinfo)$/; c=c+'I'
@@ -788,73 +815,59 @@ module SiSU_Commandline
|| mod.inspect =~/"--images"/) \
? { bool: true, set: :on }
: { bool: false, set: :na }
- act[:pdf]=if (cmd =~/p/ \
- || mod.inspect =~/"--pdf"|"--pdf-(?:a4|a5|b5|letter|legal)"/)
+ if (cmd =~/p/ \
+ || mod.inspect =~/"--pdf"/)
if mod.inspect =~/"--portrait"/
- act[:pdf_p]={ bool: true, set: :on }
+ act[:pdf]= { bool: false, set: :na }
act[:pdf_l]={ bool: false, set: :na }
- { bool: false, set: :na }
+ act[:pdf_p]={ bool: true, set: :on }
elsif mod.inspect =~/"--landscape"/
+ act[:pdf]= { bool: false, set: :na }
act[:pdf_l]={ bool: true, set: :on }
act[:pdf_p]={ bool: false, set: :na }
- { bool: false, set: :na }
else
- act[:pdf_p]={ bool: true, set: :on }
+ act[:pdf]= { bool: true, set: :on }
act[:pdf_l]={ bool: true, set: :on }
- { bool: true, set: :on }
+ act[:pdf_p]={ bool: true, set: :on }
end
else
- act[:pdf_p]=(mod.inspect =~/"--pdf-(?:p|portrait)"/) \
- || (mod.inspect =~/"--pdf(?:-p(?:ortrait)?-(?:a4|a5|b5|letter|legal))"/) \
- || (mod.inspect =~/"--pdf-(?:a4|a5|b5|letter|legal)(?:-p(?:ortrait)?)"/) \
- ? { bool: true, set: :on }
- : { bool: false, set: :na }
- act[:pdf_l]=(mod.inspect =~/"--pdf-(?:l|landscape)"/) \
- || (mod.inspect =~/"--pdf(?:-l(?:andscape)?-(?:a4|a5|b5|letter|legal))"/) \
- || (mod.inspect =~/"--pdf-(?:a4|a5|b5|letter|legal)(?:-l(?:andscape)?)"/) \
- ? { bool: true, set: :on }
- : { bool: false, set: :na }
- { bool: false, set: :na }
+ act[:pdf]= { bool: false, set: :na }
+ act[:pdf_p]= { bool: false, set: :na }
+ act[:pdf_l]= { bool: false, set: :na }
+ act[:pdf_a4]= { bool: false, set: :na }
+ act[:pdf_a5]= { bool: false, set: :na }
+ act[:pdf_b5]= { bool: false, set: :na }
+ act[:pdf_letter]={ bool: false, set: :na }
+ act[:pdf_legal]= { bool: false, set: :na }
end
if act[:pdf][:set]==:on \
or act[:pdf_p][:set]==:on \
or act[:pdf_l][:set]==:on
- #mod.inspect =~/"--pdf-([pl]-|portrait-|landscape-)?(?:a4|a5|b5|letter|legal)"/
- act[:pdf_a4]=if mod.inspect =~/"--pdf(?:-[pl]|-portrait|-landscape)?-a4"/ \
- or mod.inspect =~/"--pdf-a4(?:-[pl]|-portrait|-landscape)?"/ \
- or mod.inspect =~/"--a4"|--papersize-a4"/ \
+ act[:pdf_a4]=if mod.inspect =~/"--a4"|--papersize-a4"/ \
or mod.inspect =~/"--papersize=\S*a4\b\S*"/ #--papersize=a4,a5
{ bool: true, set: :on }
else
{ bool: false, set: :na }
end
- act[:pdf_a5]=if mod.inspect =~/"--pdf(?:-[pl]|-portrait|-landscape)?-a5"/ \
- or mod.inspect =~/"--pdf-a5(?:-[pl]|-portrait|-landscape)?"/ \
- or mod.inspect =~/"--a5"|"--papersize-a5"/ \
+ act[:pdf_a5]=if mod.inspect =~/"--a5"|"--papersize-a5"/ \
or mod.inspect =~/"--papersize=\S*a5\b\S*"/ #--papersize=a4,a5
{ bool: true, set: :on }
else
{ bool: false, set: :na }
end
- act[:pdf_b5]=if mod.inspect =~/"--pdf(-[pl]|-portrait|-landscape)?-b5"/ \
- or mod.inspect =~/"--pdf-b5(?:-[pl]|-portrait|-landscape)?"/ \
- or mod.inspect =~/"--b5"|"--papersize-b5"/ \
+ act[:pdf_b5]=if mod.inspect =~/"--b5"|"--papersize-b5"/ \
or mod.inspect =~/"--papersize=\S*b5\b\S*"/
{ bool: true, set: :on }
else
{ bool: false, set: :na }
end
- act[:pdf_letter]=if mod.inspect =~/"--pdf(-[pl]|-portrait|-landscape)?-letter"/ \
- or mod.inspect =~/"--pdf-letter(?:-[pl]|-portrait|-landscape)?"/ \
- or mod.inspect =~/"--letter"|"--papersize-letter"/ \
+ act[:pdf_letter]=if mod.inspect =~/"--letter"|"--papersize-letter"/ \
or mod.inspect =~/"--papersize=\S*letter\b\S*"/
{ bool: true, set: :on }
else
{ bool: false, set: :na }
end
- act[:pdf_legal]=if mod.inspect =~/"--pdf(-[pl]|-portrait|-landscape)?-legal"/ \
- or mod.inspect =~/"--pdf-legal(?:-[pl]|-portrait|-landscape)?"/ \
- or mod.inspect =~/"--legal"|"--papersize-legal"/ \
+ act[:pdf_legal]=if mod.inspect =~/"--legal"|"--papersize-legal"/ \
or mod.inspect =~/"--papersize=\S*legal\b\S*"/
{ bool: true, set: :on }
else