From 7bf74c7fb5d70b4880c11f782c07cf9e78127779 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 8 Jun 2011 22:00:27 -0400 Subject: v3: options, restrict glob rule checks to glob & find; carry lang info * restrict glob rule checks to when --glob (-G) or --find (-f) requested * carry information on document language (from filename and or directory) * (additional test) --- data/doc/sisu/CHANGELOG_v3 | 7 ++- data/sisu/v3/v/version.yml | 4 +- lib/sisu/v3/options.rb | 111 +++++++++++++++++++++++++-------------------- 3 files changed, 69 insertions(+), 53 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 24335adb..8a1da39a 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -13,13 +13,18 @@ Reverse Chronological: %% Development branch UNSTABLE v3 branch once stable will supersede & replace current stable v2 branch -%% 3.0.12.orig.tar.gz (2011-06-07:23/2) +%% 3.0.12.orig.tar.gz (2011-06-08:23/3) http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/debian/3.0.12-1 http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.12.orig.tar.gz sisu_3.0.12.orig.tar.gz sisu_3.0.12-1.dsc sisu_3.0.12-1.debian.tar.gz + * options + * restrict glob rule checks to when --glob (-G) or --find (-f) requested + * carry information on document language (from filename and or directory + * (additional test) + * help, s/Bul garian/Bulgarian/ (Closes: #619068) %% 3.0.11.orig.tar.gz (2011-05-29:21/7) diff --git a/data/sisu/v3/v/version.yml b/data/sisu/v3/v/version.yml index 671dca27..526b9b46 100644 --- a/data/sisu/v3/v/version.yml +++ b/data/sisu/v3/v/version.yml @@ -1,5 +1,5 @@ --- :version: 3.0.12-beta-rb1.9.2p180 -:date_stamp: 2011w23/2 -:date: "2011-06-07" +:date_stamp: 2011w23/3 +:date: "2011-06-08" :project: SiSU diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index 96ec3c4a..81d12db8 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -62,14 +62,17 @@ module SiSU_commandline require_relative 'sysenv' # sysenv.rb @@base_path=nil class Options - attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what + attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:base_stub,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what def initialize(a) - @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@base_path='','','','','','','','','','','' + @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@base_path,@base_stub='','','','','','','','','','','','' @f_pths,@files,@paths,@mod,@act=Array.new(5){[]} @env=SiSU_Env::Info_env.new @dir_structure_by=SiSU_Env::Env_call.new.output_dir_structure.by? @@base_path ||=Dir.pwd @base_path=@@base_path + r=Px[:lng_lst].join('|') + u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ + @base_stub=@base_path.gsub(u,'\1') @a=sisu_glob_rules(a) @a.freeze init @@ -97,7 +100,6 @@ module SiSU_commandline else Dir.glob("*#{g}*.ss[tm]") end - Px[:lng_lst].each do |d| if FileTest.directory?(d) x <<=if g =~/.ss[tm]/ @@ -113,40 +115,40 @@ module SiSU_commandline end end def sisu_glob_rules(a) - b=[] - f=[] - find_flag=false - a.each do |y| - if y =~ /^-/ \ - or y =~ /\.ss[tm]$/ - if y =~/^-/ \ - && y =~/[fG]|--find|--glob/ - find_flag=true + a=if a.inspect =~/"-\S*[fG]/ \ + or a.inspect =~/"--find"|"--glob"/ + b,f=[],[] + find_flag=false + a.each do |y| + if y =~ /^-/ + if y =~/^-/ \ + && y =~/[fG]|--find|--glob/ + find_flag=true + end + b << y + end + if find_flag \ + && y !~ /^-/ \ + && y =~ /\S+/ + f << y end - b << y - end - if find_flag \ - && y !~ /^-/ \ - && y =~ /\S+/ - f << y - elsif y =~ /^-/ - b << y end - end - r=Px[:lng_lst].join('|') - r.gsub!(/\|en\|/,'|') - @lang_regx=%r{(?:#{r})} - z=if find_flag - if f.length > 0 - b + find_select(find_flag,f) - else - find_all(find_flag,b) + r=Px[:lng_lst].join('|') + r.gsub!(/\|en\|/,'|') + @lang_regx=%r{(?:#{r})} + z=if find_flag + if f.length > 0 + b + find_select(find_flag,f) + else + find_all(find_flag,b) + end + elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ + && a.inspect =~/"#{@lang_regx}\/?"/ \ + && a.inspect =~/"en\/\S+?\.ss[tm]"/ + init_selected_lang_dirs(a) + else b end - elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ - && a.inspect =~/"#{@lang_regx}\/?"/ \ - && a.inspect =~/"en\/\S+?\.ss[tm]"/ - init_selected_lang_dirs(a) - else b + else a end end def init_selected_lang_dirs(a) @@ -164,20 +166,22 @@ module SiSU_commandline end def init a=@a - s=expand_numeric_shortcuts(a) - q=set_files_and_paths_and_general_extract(s) - @cmd,@mod=opt_cmd_and_mod_adjust(q[:cmd],q[:mod]) - @what=q[:what] unless q[:what].empty? - @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 - @cmd=shortcut.cf_0 - end - SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown if @cmd =~/[vVM]/ + if a.length > 0 + s=expand_numeric_shortcuts(a) + q=set_files_and_paths_and_general_extract(s) + @cmd,@mod=opt_cmd_and_mod_adjust(q[:cmd],q[:mod]) + @what=q[:what] unless q[:what].empty? + @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 + @cmd=shortcut.cf_0 + end + SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown if @cmd =~/[vVM]/ + end # @files.uniq! @act=opt_act @files @@ -187,7 +191,7 @@ module SiSU_commandline c,w='','' m,f,pth,z,lng,lngs=[],[],[],[],[],[] a=s.split(/\s+/) - a.each do |x| + a.uniq.each do |x| if x =~/^-[a-z0-5]+/i \ or x =~/^--\S+/ if x =~/^-([a-z0-5]+)/i; c << $1 @@ -215,13 +219,20 @@ module SiSU_commandline $1 else 'en' end + lng_is =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, pth_stub: pt.split[0].realpath.to_s[u,1], lng: (pt.split[0].realpath.to_s[t,1]) \ ? pt.split[0].realpath.to_s[t,1] \ - : nil + : nil, + lng_is: lng_is } # Dir.chdir(pt.split[0].realpath) else puts "file not found: #{x}" -- cgit v1.2.3