Class: SiSU_Po4a::Source::Output

Inherits:
SiSU_Po4a::Source show all
Includes:
SiSU_Env, SiSU_Param
Defined in:
lib/sisu/src_po4a_shelf.rb

Instance Method Summary collapse

Methods inherited from SiSU_Po4a::Source

#process_file, #read, #wrap_width_set

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(fn, content, md, process = :complete) ⇒ Output

Returns a new instance of Output.



1145
1146
1147
1148
# File 'lib/sisu/src_po4a_shelf.rb', line 1145

def initialize(fn,content,md,process=:complete)
  @fn,@content,@md,@process=fn,content,md,process
  @file=SiSU_Env::FileOp.new(md,fn)
end

Instance Method Details

#po4aObject

%pot output



1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
# File 'lib/sisu/src_po4a_shelf.rb', line 1149

def po4a                                                                 #%pot output
  file_pot=(@md.opt.f_pth[:lng] == @md.opt.lng_base) \
  ? @file.write_file.pot
  : @file.write_file.po
  @sisu=[]
  emptyline=0
  @content.each do |para|                                                # this is a hack
    if para.is_a?(Array) \
    and para.length > 0
      para.each do |line|
        if line
          line=line.gsub(/\s+$/m,'').
            gsub(/^\A[ ]*\Z/m,'')
          if line=~/^\A[ ]*\Z/m
            emptyline+=1
          else emptyline=0
          end
          file_pot.puts line if emptyline < 2                     #remove extra line spaces (fix upstream)
        end
      end
    else file_pot.puts para          #unix plaintext # /^([*=-]|\.){5}/
    end
  end
  file_pot.close
  SiSU_Po4aUtils::PotNumber.new.reset
  po4a_git
end

#po4a_gitObject



1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
# File 'lib/sisu/src_po4a_shelf.rb', line 1176

def po4a_git
  unless @md.opt.act[:maintenance][:set]==:on
    require_relative 'git'                           # git.rb
    git=SiSU_Git::Source.new(@md.opt,@process)
    unless FileTest.directory?(@file.output_path.pot_git.dir)
      git.create_file_structure_git
    end
    if @md.opt.f_pth[:lng] == @md.opt.lng_base
      FileUtils::cp(
        @file.place_file.pot.dir,
        @file.output_path.pot_git.dir
      )
    else # naive, work on -->
      FileUtils::cp(
        @file.place_file.po.dir,
        @file.output_path.po_git.dir
      ) #unless FileTest.file?(@file.place_file.po_git.dir)
    end
    git.read
  end
end