Class: SiSU_Po4a::Source

Inherits:
Object
  • Object
show all
Includes:
SiSU_Object_Munge
Defined in:
lib/sisu/src_po4a_shelf.rb

Direct Known Subclasses

Output, Scroll

Defined Under Namespace

Classes: Output, Po4aCfg, Scroll

Constant Summary collapse

@@auto_translation_ =
:go

Instance Method Summary collapse

Methods included from SiSU_Object_Munge

#block_, #clean_text, #code_, #extract_endnotes, #footnotes_inline, #footnotes_ref_and_note, #i_ao_o_src_markup_restore, #i_ao_o_strip_markup, #i_src_o_strip_markup, #object_marks, #objects, #src_markup, #textface_marks, #textface_marks_po4a

Constructor Details

#initialize(opt, fn = nil) ⇒ Source

Returns a new instance of Source.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/sisu/src_po4a_shelf.rb', line 72

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

Instance Method Details

#process_file(md, env, file, wrap_width, fn) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/sisu/src_po4a_shelf.rb', line 102

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

#readObject



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/sisu/src_po4a_shelf.rb', line 181

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) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/sisu/src_po4a_shelf.rb', line 92

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