class SiSU_AO::Source

Public Class Methods

new(opt,fnx=nil,process=:complete) click to toggle source
# File lib/sisu/ao.rb, line 85
def initialize(opt,fnx=nil,process=:complete)
  @opt,@fnx,@process=opt,fnx,process
  @per ||=SiSU_AO_Persist::Persist.new.persist_init
  @per.fns ||=opt.fns
  fn_use=if fnx \
  and fnx =~/\.ss[tmi]$/
    fnx
  elsif opt.fns =~/\.ssm$/
    opt.fns + '.sst'
  else
    opt.fns
  end
  @make_fns=SiSU_Env::InfoFile.new(fn_use)
  @fnm=@make_fns.marshal.ao_metadata
  @fnc=@make_fns.marshal.ao_content
  @idx_sst=@make_fns.marshal.ao_idx_sst_rel_html_seg
  @idx_raw=@make_fns.marshal.ao_idx_sst_rel
  @idx_html=@make_fns.marshal.ao_idx_html
  @idx_xhtml=@make_fns.marshal.ao_idx_xhtml
  @map_nametags=@make_fns.marshal.ao_map_nametags
  @map_ocn_htmlseg=@make_fns.marshal.ao_map_ocn_htmlseg
  @env=SiSU_Env::InfoEnv.new
end

Public Instance Methods

get() click to toggle source
# File lib/sisu/ao.rb, line 125
def get                                                                    #reads ao, unless does not exist then creates first
  begin
    ao=[]
    unless @per.fns==@opt.fns \
    or @per.fns==@fnx
      @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
      ? @fnx
      : @opt.fns
      @per.ao_arr=[]
    end
    ao=(@per.ao_arr.empty?) \
    ? read_fnc
    : @per.ao_arr.dup
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    SiSU_AO::Instantiate.new
  end
end
get_idx_html() click to toggle source
# File lib/sisu/ao.rb, line 188
def get_idx_html                                                           #reads ao idx.html, #unless does not exist then creates first
  begin
    ao=[]
    unless @per.fns==@opt.fns \
    or @per.fns==@fnx
      @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
      ? @fnx
      : @opt.fns
      @per.idx_arr_html=[]
    end
    ao=(@per.idx_arr_html.empty?) \
    ? read_idx_html
    : @per.idx_arr_html.dup
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    SiSU_AO::Instantiate.new
  end
end
get_idx_raw() click to toggle source
# File lib/sisu/ao.rb, line 167
def get_idx_raw
  begin
    ao=[]
    unless @per.fns==@opt.fns \
    or @per.fns==@fnx
      @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
      ? @fnx
      : @opt.fns
      @per.idx_arr_tex=[]
    end
    ao=(@per.idx_arr_tex.empty?) \
    ? read_idx_raw
    : @per.idx_arr_tex.dup #check
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    SiSU_AO::Instantiate.new
  end
end
get_idx_sst() click to toggle source
# File lib/sisu/ao.rb, line 146
def get_idx_sst                                                            #reads ao idx.sst, #unless does not exist then creates first
  begin
    ao=[]
    unless @per.fns==@opt.fns \
    or @per.fns==@fnx
      @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
      ? @fnx
      : @opt.fns
      @per.idx_arr_sst=[]
    end
    ao=(@per.idx_arr_sst.empty?) \
    ? read_idx_sst
    : @per.idx_arr_sst.dup #check
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    SiSU_AO::Instantiate.new
  end
end
get_idx_xhtml() click to toggle source
# File lib/sisu/ao.rb, line 209
def get_idx_xhtml                                                          #reads ao idx.xhtml, #unless does not exist then creates first
  begin
    ao=[]
    unless @per.fns==@opt.fns \
    or @per.fns==@fnx
      @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
      ? @fnx
      : @opt.fns
      @per.idx_arr_xhtml=[] #...
    end
    ao=(@per.idx_arr_xhtml.empty?) \
    ? read_idx_xhtml
    : @per.idx_arr_xhtml.dup
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    SiSU_AO::Instantiate.new
  end
end
get_map_nametags() click to toggle source
# File lib/sisu/ao.rb, line 230
def get_map_nametags                                                       #reads ao map.nametags, #unless does not exist then creates first
  begin
    ao=[]
    unless @per.fns==@opt.fns \
    or @per.fns==@fnx
      @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
      ? @fnx
      : @opt.fns
      @per.map_arr_nametags=[]
    end
    ao=(@per.map_arr_nametags.empty?) \
    ? read_map_nametags
    : @per.map_arr_nametags.dup
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    SiSU_AO::Instantiate.new
  end
end
get_map_ocn_htmlseg() click to toggle source
# File lib/sisu/ao.rb, line 251
def get_map_ocn_htmlseg                                                    #reads ao map.ocn_htmlseg, #unless does not exist then creates first
  begin
    ao=[]
    unless @per.fns==@opt.fns \
    or @per.fns==@fnx
      @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
      ? @fnx
      : @opt.fns
      @per.map_arr_ocn_htmlseg=[]
    end
    ao=(@per.map_arr_ocn_htmlseg.empty?) \
    ? read_map_ocn_htmlseg
    : @per.map_arr_ocn_htmlseg.dup
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    SiSU_AO::Instantiate.new
  end
end
read() click to toggle source
# File lib/sisu/ao.rb, line 108
def read                                                                   #creates ao
  begin
    @per=SiSU_AO_Persist::Persist.new
    @per.ao_arr=[]
    @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
    ? @fnx
    : @opt.fns
    create_ao
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections,@per.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    SiSU_AO_Persist::Persist.new.persist_init
    SiSU_AO::Instantiate.new
  end
end

Protected Instance Methods

create_ao() click to toggle source
# File lib/sisu/ao.rb, line 273
def create_ao
  ao_array=[]
  fnp = @fnx ? "#{@opt.fno} #{@fnx}" : @opt.fno
  unless @opt.act[:quiet][:set]==:on
    tell=(@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],
        'Document Abstraction'
      )
    : SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Document Abstraction',
        "[#{@opt.f_pth[:lng_is]}] #{fnp}"
      )
    tell.blue_title_hi
  end
  fn=(@fnx && @fnx =~/\.ss[tmi]$/) \
  ? @fnx
  : @opt.fns
  if @opt.fno =~/\.txz$/
    Dir.chdir(@opt.f_pth[:pth])
  end
  meta=file_array=@env.source_file_processing_array(fn)
  @md=SiSU_Param::Parameters::Instructions.new(meta,@opt).extract
  meta=nil
  ao=SiSU_AO::Make.new(fn,@md,file_array,@fnx,@process).song
  if (@opt.act[:verbose][:set]==:on \
  || @opt.act[:verbose_plus][:set]==:on \
  || @opt.act[:maintenance][:set]==:on)
    cf=SiSU_Env::CreateFile.new(fn)
    if (@opt.act[:verbose][:set]==:on \
    || @opt.act[:verbose_plus][:set]==:on)
        SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        @opt.fns,
        "~meta/#{@opt.fns}.meta"
      ).output
    elsif @opt.act[:maintenance][:set]==:on
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        "ao -> #{cf.meta}"
      ).txt_grey
    end
  end
  ao.each {|s| ao_array << s}
  if @opt.act[:maintenance][:set]==:on
    ao_array.each do |obj|
      if defined? obj.parent
        if defined? obj.ln
          if defined? obj.node
            puts %{#{obj.ln}: #{obj.ocn} : #{obj.parent} : #{obj.node} - #{obj.lc}}
          else
            puts %{#{obj.ln}: #{obj.ocn} : #{obj.parent}}
          end
        else
          if defined? obj.node
            puts %{   #{obj.ocn} : #{obj.parent} : #{obj.node} - #{obj.lc}}
          else
            puts %{   #{obj.ocn} : #{obj.parent}}
          end
        end
      end
    end
  end
  ao_array
end
read_fnc() click to toggle source
# File lib/sisu/ao.rb, line 347
def read_fnc
  ao=[]
  ao=(FileTest.file?(@fnc)) \
  ? (File.open(@fnc,'r:utf-8'){ |f| ao=Marshal.load(f)})
  : SiSU_AO::Source.new(@opt,@fnx,@process).create_ao
end
read_fnm() click to toggle source
# File lib/sisu/ao.rb, line 341
def read_fnm
  ao=[]
  ao=(FileTest.file?(@fnm)) \
  ? (File.open(@fnm,'r:utf-8'){ |f| ao=Marshal.load(f)})
  : SiSU_AO::Source.new(@opt).create_ao
end
read_idx_html() click to toggle source
# File lib/sisu/ao.rb, line 365
def read_idx_html
  m=[]
  m=(FileTest.file?(@idx_html)) \
  ? (File.open(@idx_html,'r:utf-8'){ |f| m=Marshal.load(f)})
  : nil
end
read_idx_raw() click to toggle source
# File lib/sisu/ao.rb, line 359
def read_idx_raw
  m=[]
  m=(FileTest.file?(@idx_raw)) \
  ? (File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)})
  : nil
end
read_idx_sst() click to toggle source
# File lib/sisu/ao.rb, line 353
def read_idx_sst
  m=[]
  m=(FileTest.file?(@idx_sst)) \
  ? (File.open(@idx_sst,'r:utf-8'){ |f| m=Marshal.load(f)})
  : nil
end
read_idx_xhtml() click to toggle source
# File lib/sisu/ao.rb, line 371
def read_idx_xhtml
  m=[]
  m=(FileTest.file?(@idx_xhtml)) \
  ? (File.open(@idx_xhtml,'r:utf-8'){ |f| m=Marshal.load(f)})
  : nil
end
read_map_nametags() click to toggle source
# File lib/sisu/ao.rb, line 377
def read_map_nametags
  m=[]
  m=(FileTest.file?(@map_nametags)) \
  ? (File.open(@map_nametags,'r:utf-8'){ |f| m=Marshal.load(f)})
  : nil
end
read_map_ocn_htmlseg() click to toggle source
# File lib/sisu/ao.rb, line 383
def read_map_ocn_htmlseg
  m=[]
  m=(FileTest.file?(@map_ocn_htmlseg)) \
  ? (File.open(@map_ocn_htmlseg,'r:utf-8'){ |f| m=Marshal.load(f)})
  : nil
end