aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/options.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-05-04 22:19:42 -0400
committerRalph Amissah <ralph@amissah.com>2011-05-04 22:41:19 -0400
commit46eebe8bbf6c0102c2f921f65778a99121c91ff2 (patch)
treeffd8084f66aa9a7c57eaf24d336ba0501ab9c41f /lib/sisu/v3/options.rb
parentv3: concordance, output path, screen info correction (diff)
v3: options, language setting, based on directory structure or filename
* affects multiple libraries
Diffstat (limited to 'lib/sisu/v3/options.rb')
-rw-r--r--lib/sisu/v3/options.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb
index a1a448e6..110ebd85 100644
--- a/lib/sisu/v3/options.rb
+++ b/lib/sisu/v3/options.rb
@@ -61,10 +61,10 @@ module SiSU_commandline
require "pathname"
require_relative 'sysenv' # sysenv.rb
class Options
- attr_accessor :cmd,:mod,:act,:f_pths,:files,:paths,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what
+ attr_accessor :cmd,:mod,:act,:f_pths,:files,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what
def initialize(a)
@a=a
- @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what='','','','','','','','',''
+ @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng='','','','','','','','','',''
@f_pths,@files,@paths,@mod,@act=Array.new(5){[]}
@env=SiSU_Env::Info_env.new
r=Px[:lng_lst].join('|')
@@ -109,6 +109,7 @@ module SiSU_commandline
@paths = q[:paths]
@files = q[:files]
@f_pths = q[:f_pths]
+ @lngs = q[:lngs]
if @files.length > 0 \
and @cmd.empty? \
and @mod.length==0 #% if no other action called on filename given, default is sisu -0 [filename(s)] configured as flag default
@@ -122,7 +123,7 @@ module SiSU_commandline
end
def set_files_and_paths_and_general_extract(s)
c,w='',''
- m,f,pth,z,lng=[],[],[],[],[]
+ m,f,pth,z,lng,lngs=[],[],[],[],[],[]
a=s.split(/\s+/)
a.each do |x|
if x =~/^-[a-z0-5]+/i \
@@ -138,12 +139,20 @@ module SiSU_commandline
pt=Pathname.new(x)
pth << pt.split[0].realpath.to_s #remove?
f << pt.split[1].to_s #remove?
- u=/.+?\/([^\/]+)(?:(?:\/(?:en|fr|es)$)|$)/
- t=/.+\/(en|fr|es)/
- lng << (pt.split[0].realpath.to_s[t,1]) \
+ r=Px[:lng_lst].join('|')
+ u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/
+ t=/.+\/(#{r})$/
+ l_p = (pt.split[0].realpath.to_s[t,1]) \
? pt.split[0].realpath.to_s[t,1] \
: nil
#: ''
+ lng << l_p
+ lngs << if l_p
+ l_p
+ elsif x =~/~(#{r})\.ss[tm]/
+ $1
+ else 'en'
+ end
f_pths << {
pth: pt.split[0].realpath.to_s,
f: pt.split[1].to_s,
@@ -163,7 +172,7 @@ module SiSU_commandline
puts "#{x} in #{a.join(' ')}?"
end
end
- { cmd: c, mod: m, what: w, paths: pth, files: f, f_pths: f_pths, lng: lng }
+ { cmd: c, mod: m, what: w, paths: pth, files: f, f_pths: f_pths, lng: lng, lngs: lngs }
end
def expand_numeric_shortcuts(a)
shortcut=SiSU_Env::Info_processing_flag.new