class SiSU_Po4a::Source

Public Class Methods

new(opt,fn=nil) click to toggle source
# File lib/sisu/src_po4a_shelf.rb, line 70
def initialize(opt,fn=nil)
  @opt,@fn=opt,fn
  #unless @opt.fns =~/(.+?\.(?:-|ssm\.)?sst)$/
  #  puts "#{@opt.fns} not a processed file type"
  #end
  file_arr=SiSU_Info_Env::InfoEnv.new.source_file_processing_array(@opt.fns)
  SiSU_Param::Parameters::Instructions.new(file_arr,@opt).extract
  r=Px[:lng_lst_rgx].gsub(/\|en\|/,'|')
  @lang_regx=%r{(?:#{r})}
  if opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \
  and opt.f_pth[:lng]!=@opt.lng_base
    @@opt_src_=false
    @@opt_trn=opt
    @@md_trn=SiSU_Param::Parameters.new(opt).get
  else
    @@opt_src_=true
    @@opt_src=opt
    @@md_src=SiSU_Param::Parameters.new(opt).get
  end
end

Public Instance Methods

process_file(md,env,file,wrap_width,fn) click to toggle source
# File lib/sisu/src_po4a_shelf.rb, line 100
def process_file(md,env,file,wrap_width,fn)
  unless @opt.act[:quiet][:set]==:on
    tool=(@opt.act[:verbose][:set]==:on \
    || @opt.act[:verbose_plus][:set]==:on \
    || @opt.act[:maintenance][:set]==:on) \
    ? "#{env.program.text_editor} #{file.output_path.pot.dir}/"
    : @opt.fns
    (@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],
        'Pot po4a',
        tool
      ).green_hi_blue
    : SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Pot po4a',
        tool
      ).green_title_hi
    if (@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],
        @opt.fns,
        file.output_path.pot.dir
      ).flow
    end
  end
  if @opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \
  or @opt.f_pth[:lng] !=@opt.lng_base
    opt_lang_trn_fn=fn
    @ao_arr_lang_trans=
      SiSU_AO::Source.new(@opt,opt_lang_trn_fn,:po4a).get # ao file drawn here
    opt_lang_src_fn=(fn =~/\S+?~\S{2}(?:_\S{2})?\.ss[mti]/) \
    ? (fn.gsub(/(\S+?)~\S{2}(?:_\S{2})?(\.ss[mti])/,'\1\2')) #check i
    : fn
    transdir,srcdir=Dir.pwd,Dir.pwd
    if Dir.pwd.to_s =~/\/#{@lang_regx}$/
      transdir=Dir.pwd
      srcdir=transdir.
        gsub(/\/#{@lang_regx}$/,
          "/#{@opt.lng_base}")
      if FileTest.directory?(srcdir)
        Dir.chdir(srcdir)
      end
    else nil
    end
    if FileTest.file?("#{srcdir}/#{opt_lang_src_fn}")
      @ao_arr_lang_src=
        SiSU_AO::Source.new(
          @@opt_src,
          opt_lang_src_fn,
          :po4a
        ).get # ao file drawn here
    else
      puts "no identified source document"
      exit
    end
    Dir.chdir(transdir) if transdir
  else
    @ao_arr_lang_src=
      SiSU_AO::Source.new(
        @opt,
        fn,
        :po4a
      ).get # ao file drawn here
    @ao_arr_lang_trans=nil
  end
  SiSU_Po4a::Source::Scroll.new(
    fn,
    @ao_arr_lang_src,
    @ao_arr_lang_trans,
    @@md_src,
    @@md_trn,
    wrap_width
  ).songsheet
end
read() click to toggle source
# File lib/sisu/src_po4a_shelf.rb, line 179
def read
  begin
    src={}
    src[:pth]=@opt.f_pth[:pth]
    src[:files]=if @opt.fns =~ /\.(?:(?:-|ssm\.)sst|ssm)$/
      @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm')
      SiSU_Assemble::CompositeFileList.new(@opt).read
    else
      [@opt.fns]
    end
    md=SiSU_Param::Parameters.new(@opt).get
    env=SiSU_Env::InfoEnv.new(@opt.fns)
    file=SiSU_Env::FileOp.new(md)
    Po4aCfg.new(@opt,file).po4a_cfg
    wrap_width=wrap_width_set(md,env)
    src[:files].each do |fn|
      process_file(md,env,file,wrap_width,fn)
    end
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
  end
end
wrap_width_set(md,env) click to toggle source
# File lib/sisu/src_po4a_shelf.rb, line 90
def wrap_width_set(md,env)
  if defined? md.make.plaintext_wrap \
  and md.make.plaintext_wrap
    md.make.plaintext_wrap
  elsif defined? env.plaintext_wrap \
  and env.plaintext_wrap
    env.plaintext_wrap
  else 78
  end
end