diff options
| author | Ralph Amissah <ralph@amissah.com> | 2012-10-01 16:12:14 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2012-10-01 16:12:14 -0400 | 
| commit | 52e870e3e04b3848d024e144ffb2a7f26b078cb3 (patch) | |
| tree | e33e864b661903a4eb59c399ff160a53d4824028 | |
| parent | v3: some fixes, cleaning, removing (diff) | |
v3: dal, sysenv, file processing, split objects; remove ref to old ruby
* markup file processing, change to sourcefile readlines & split of sourcefile array
* removal of RUBY_VERSION references to older versions of ruby
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v3 | 4 | ||||
| -rw-r--r-- | lib/sisu/v3/dal.rb | 41 | ||||
| -rw-r--r-- | lib/sisu/v3/dal_doc_str.rb | 7 | ||||
| -rw-r--r-- | lib/sisu/v3/dal_idx.rb | 63 | ||||
| -rw-r--r-- | lib/sisu/v3/sysenv.rb | 19 | 
5 files changed, 59 insertions, 75 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 40cd979b..6a3e78f4 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -71,6 +71,10 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.3.3.orig.tar.xz  * v3: html, epub, fix    * group text, bullet +* v3: dal, sysenv +  * markup file processing, change to sourcefile readlines & split of sourcefile array +  * removal of RUBY_VERSION references to older versions of ruby +  * v3: dal_syntax, new syntax: =\\= page new & -\\- page break    alias for <:pn> and <:pb> respectively diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index a03ed55c..0e816091 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -273,13 +273,7 @@ module SiSU_DAL        if @opt.fno =~/\.txz$/          Dir.chdir(@opt.f_pth[:pth])        end -      file_array=@env.read_source_file(fn) -      file_array.each do |l| -        if l =~/\r\n/ then l.gsub!(/\r\n/,"\n") -        end -      end -      meta=file_array.dup -      meta=meta.join.split("\n\n") #check whether can be eliminated, some of these are large objects to have twice +      meta=file_array=@env.source_file_processing_array(fn)        @md=SiSU_Param::Parameters::Instructions.new(meta,@opt).extract        meta=nil        dal=SiSU_DAL::Make.new(fn,@md,file_array).song @@ -294,72 +288,56 @@ module SiSU_DAL      def read_fnm        dal=[]        dal=if FileTest.file?(@fnm) -        (RUBY_VERSION < '1.9') \ -        ? (File.open(@fnm){ |f| dal=Marshal.load(f)}) -        : (File.open(@fnm,'r:utf-8'){ |f| dal=Marshal.load(f)}) +        File.open(@fnm,'r:utf-8'){ |f| dal=Marshal.load(f)}        else SiSU_DAL::Source.new(@opt).create_dal        end      end      def read_fnc        dal=[]        dal=if FileTest.file?(@fnc) -        (RUBY_VERSION < '1.9') \ -        ? (File.open(@fnc){ |f| dal=Marshal.load(f)}) -        : (File.open(@fnc,'r:utf-8'){ |f| dal=Marshal.load(f)}) +        File.open(@fnc,'r:utf-8'){ |f| dal=Marshal.load(f)}        else SiSU_DAL::Source.new(@opt).create_dal        end      end      def read_idx_sst        m=[]        m=if FileTest.file?(@idx_sst) -        (RUBY_VERSION < '1.9') \ -        ? (File.open(@idx_sst){ |f| m=Marshal.load(f)}) -        : (File.open(@idx_sst,'r:utf-8'){ |f| m=Marshal.load(f)}) +        File.open(@idx_sst,'r:utf-8'){ |f| m=Marshal.load(f)}        else nil        end      end      def read_idx_raw        m=[]        m=if FileTest.file?(@idx_raw) -        (RUBY_VERSION < '1.9') \ -        ? (File.open(@idx_raw){ |f| m=Marshal.load(f)}) -        : (File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)}) +        File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)}        else nil        end      end      def read_idx_html        m=[]        m=if FileTest.file?(@idx_html) -        (RUBY_VERSION < '1.9') \ -        ? (File.open(@idx_html){ |f| m=Marshal.load(f)}) -        : (File.open(@idx_html,'r:utf-8'){ |f| m=Marshal.load(f)}) +        File.open(@idx_html,'r:utf-8'){ |f| m=Marshal.load(f)}        else nil        end      end      def read_idx_xhtml        m=[]        m=if FileTest.file?(@idx_xhtml) -        (RUBY_VERSION < '1.9') \ -        ? (File.open(@idx_xhtml){ |f| m=Marshal.load(f)}) -        : (File.open(@idx_xhtml,'r:utf-8'){ |f| m=Marshal.load(f)}) +        File.open(@idx_xhtml,'r:utf-8'){ |f| m=Marshal.load(f)}        else nil        end      end      def read_map_nametags        m=[]        m=if FileTest.file?(@map_nametags) -        (RUBY_VERSION < '1.9') \ -        ? (File.open(@map_nametags){ |f| m=Marshal.load(f)}) -        : (File.open(@map_nametags,'r:utf-8'){ |f| m=Marshal.load(f)}) +        File.open(@map_nametags,'r:utf-8'){ |f| m=Marshal.load(f)}        else nil        end      end      def read_map_ocn_htmlseg        m=[]        m=if FileTest.file?(@map_ocn_htmlseg) -        (RUBY_VERSION < '1.9') \ -        ? (File.open(@map_ocn_htmlseg){ |f| m=Marshal.load(f)}) -        : (File.open(@map_ocn_htmlseg,'r:utf-8'){ |f| m=Marshal.load(f)}) +        File.open(@map_ocn_htmlseg,'r:utf-8'){ |f| m=Marshal.load(f)}        else nil        end      end @@ -501,7 +479,6 @@ module SiSU_DAL      def song        reset        data=@data -      data=data.join.split("\n\n")        data=SiSU_DAL_Insertions::Insertions.new(@md,data).expand_insertions?                                              # dal_expand_insertions.rb        data=SiSU_DAL_SubstituteAndInsert::SI.new(@md,data).substitutions_and_insertions?                                  # dal_substitutions_and_insertions.rb        data,metadata=SiSU_DAL_DocumentStructureExtract::Build.new(@md,data).identify_parts                                # dal_doc_str.rb diff --git a/lib/sisu/v3/dal_doc_str.rb b/lib/sisu/v3/dal_doc_str.rb index 6bde88e2..012e7a33 100644 --- a/lib/sisu/v3/dal_doc_str.rb +++ b/lib/sisu/v3/dal_doc_str.rb @@ -857,10 +857,9 @@ module SiSU_DAL_DocumentStructureExtract        tuned_file=tuned_file.flatten      end      def tags(o) -      tag=if o[:status]=='open' -        %{<#{o[:lv]} id="#{o[:node]}">} -      else "</#{o[:lv]}>" -      end +      tag=(o[:status]=='open') \ +      ? %{<#{o[:lv]} id="#{o[:node]}">} +      : "</#{o[:lv]}>"        ln=case o[:lv]        when 'A'; 1        when 'B'; 2 diff --git a/lib/sisu/v3/dal_idx.rb b/lib/sisu/v3/dal_idx.rb index a90217c4..db4ba9c1 100644 --- a/lib/sisu/v3/dal_idx.rb +++ b/lib/sisu/v3/dal_idx.rb @@ -117,35 +117,42 @@ module SiSU_DAL_BookIndex      def construct_book_index(idx_array)        the_idx={}        idx_array.each do |idx| -        idx_lst=idx[:rough_idx].scan(/[^|:]+/) -        idx_lst[0]=idx_lst[0].strip -        if idx_lst[0] =~/.+?\+\d+/ -          use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] -        else use=idx_lst[0] -        end -        use=use[0].chr.capitalize + use[1,use.length] -        the_idx[use]={} unless the_idx[use] and defined? the_idx[use] -        idx_lst.each do |i| -          i=i.strip -          i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ -          x=if idx_lst.length==1 or idx_lst[0].gsub(/\+\d+/,'')==i -            the_idx[use]['term_node_lev1']=[] unless the_idx[use]['term_node_lev1'] and defined? the_idx[use]['term_node_lev1'] -            x=if r -              the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] } -              "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" -            else -              the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], seg: idx[:seg] } -              "#{i} #{idx[:ocn]}" -            end -          else -            the_idx[use]['term_node_lev2']={} unless the_idx[use]['term_node_lev2'] and defined? the_idx[use]['term_node_lev2'] -            the_idx[use]['term_node_lev2'][i]=[] unless the_idx[use]['term_node_lev2'][i] and defined? the_idx[use]['term_node_lev2'][i] -            x=if r -              the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] } -              "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" +        if idx[:rough_idx] =~/[|]/ \ +        && idx[:rough_idx] !~/[:]/ +          if @md.opt.cmd =~/[MVv]/ +            p 'book index error? --> ' + idx[:rough_idx] +          end +        else +          idx_lst=idx[:rough_idx].scan(/[^|:]+/) +          idx_lst[0]=idx_lst[0].strip +          if idx_lst[0] =~/.+?\+\d+/ +            use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] +          else use=idx_lst[0] +          end +          use=use[0].chr.capitalize + use[1,use.length] +          the_idx[use]={} unless the_idx[use] and defined? the_idx[use] +          idx_lst.each do |i| +            i=i.strip +            i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ +            x=if idx_lst.length==1 or idx_lst[0].gsub(/\+\d+/,'')==i +              the_idx[use]['term_node_lev1']=[] unless the_idx[use]['term_node_lev1'] and defined? the_idx[use]['term_node_lev1'] +              x=if r +                the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] } +                "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" +              else +                the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], seg: idx[:seg] } +                "#{i} #{idx[:ocn]}" +              end              else -              the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], seg: idx[:seg] } -              "#{idx_lst[0]}:#{i} #{idx[:ocn]}" +              the_idx[use]['term_node_lev2']={} unless the_idx[use]['term_node_lev2'] and defined? the_idx[use]['term_node_lev2'] +              the_idx[use]['term_node_lev2'][i]=[] unless the_idx[use]['term_node_lev2'][i] and defined? the_idx[use]['term_node_lev2'][i] +              x=if r +                the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] } +                "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" +              else +                the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], seg: idx[:seg] } +                "#{idx_lst[0]}:#{i} #{idx[:ocn]}" +              end              end            end          end diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 40880701..c4b364ad 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -973,7 +973,7 @@ module SiSU_Env        include FileUtils      attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:stub_src,:webserv_host_cgi,:webserv_port_cgi,:processing,:processing_git,:etc,:yamlrc_dir      @@image_flag,@@local_image=true,true   #warning on @@image_flag -    @@fb=@@man_path=nil,nil +    @@fb,@@man_path=nil,nil      def initialize(fns='',md=nil)        super() #you may not want to re-execute this static info so frequently!        @fns,@md=fns,md @@ -1739,18 +1739,15 @@ WOK        self      end      def read_source_file(fns) -      fns_array=if RUBY_VERSION < '1.9' -        x=unless fns =~/\.ssm.sst$/ -          IO.readlines(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("#{processing_path.composite_file}/#{fns}",'r:utf-8') -        end +      fns_array=unless fns =~/\.ssm.sst$/ +        IO.readlines(fns, mode: 'r:utf-8', cr_newline: true) +      else +        IO.readlines("#{processing_path.composite_file}/#{fns}", mode: 'r:utf-8', cr_newline: true)        end      end +    def source_file_processing_array(fns) +      sf=read_source_file(fns).join.split(/\s*\n\s*\n/m) +    end      def path                                                                     #dir        def home          @sys.home  | 
