Class: SiSU_SStm_AO_SStm::Source

Inherits:
Object
  • Object
show all
Includes:
SiSU_Languages_Selected, SiSU_Object_Munge, SiSU_Response
Defined in:
lib/sisu/src_po4a_sst_ao_sst.rb

Direct Known Subclasses

Output, Scroll

Defined Under Namespace

Classes: Output, Scroll

Constant Summary collapse

@@auto_translation_ =
:go

Instance Method Summary collapse

Methods included from SiSU_Response

#answer?, #available_selections_, #query, #response?, #response_short, #response_strict, #selection_options, #selections_available_

Methods included from SiSU_Languages_Selected

#language, #sisu_languages_available, #source_language_selected_str, #translation_languages_available, #translation_languages_selected, #translation_languages_selected_str, #translation_languages_selected_that_are_available, #translation_languages_selected_that_are_available_str

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.



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

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.fno)
  SiSU_Param::Parameters::Instructions.new(file_arr,@opt).extract
  r=Px[:lng_lst_rgx].gsub(/\|#{language.source_language_selected_str}\|/,'|')
  @lang_regx=%r{(?:#{r})}
  @@todo=if source_language_selected_str == opt.f_pth[:lng]
    :same_file
  else :compare
  end
  if opt.f_pth[:lng]==@opt.lng_base \
  and opt.f_pth[:lng]==source_language_selected_str
    @@md_master=SiSU_Param::Parameters.new(opt).get
  end
end

Instance Method Details

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



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/sisu/src_po4a_sst_ao_sst.rb', line 104

def process_file(md,env,file,wrap_width,fn)
  if source_language_selected_str == @opt.f_pth[:lng]
    @@ao_arr_lang_trans=
      SiSU_AO::Source.new(
        @opt,
        fn,
        :po4a
      ).get # ao file drawn here
  end
  @ao_arr_lang_src=
    SiSU_AO::Source.new(
      @opt,
      fn,
      :po4a
    ).get # ao file drawn here
  SiSU_SStm_AO_SStm::Source::Scroll.new(
    fn,
    @ao_arr_lang_src,
    @@ao_arr_lang_trans,
    @@md_src,
    @@md_master,
    wrap_width
  ).songsheet
end

#read_process_src_filesObject



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
# File 'lib/sisu/src_po4a_sst_ao_sst.rb', line 128

def read_process_src_files
  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)
    lng=/\/([^\/]+)$/.match(src[:pth])[1]
    if language.source_language_selected_str == lng
      SiSU_Po4a_Project::Po4aDistClean.new(@opt,file).song
    end
    wrap_width=wrap_width_set(md,env)
    lng = /\/([^\/]+)$/.match(src[:pth])[1]
    ans=response?('process files?')
    if ans
      src[:files].each do |fn|
        puts "[#{lng}] #{fn}"
        process_file(md,env,file,wrap_width,fn)
      end
    end
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
  end
end

#read_setupObject



161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/sisu/src_po4a_sst_ao_sst.rb', line 161

def read_setup
  begin
    md=SiSU_Param::Parameters.new(@opt).get
    file=SiSU_Env::FileOp.new(md)
    SiSU_Po4a_Project::Po4aCfg.new(@opt,file).song
    SiSU_Po4a_Project::Po4aProject.new(@opt,file).song
  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



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/sisu/src_po4a_sst_ao_sst.rb', line 93

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 # 78 use 75
    75
  else 75 #78
  end
end