class SiSU_HarvestTopics::Harvest
Public Class Methods
new(opt,env,data,filename,name,idx_array,lang)
click to toggle source
# File lib/sisu/html_harvest_topics.rb, line 113 def initialize(opt,env,data,filename,name,idx_array,lang) @opt, @env,@data,@filename,@name,@idx_array,@lang= opt,env, data, filename, name, idx_array, lang end
Public Instance Methods
extract_harvest()
click to toggle source
# File lib/sisu/html_harvest_topics.rb, line 117 def extract_harvest data, filename, name, idx_array, lang= @data,@filename,@name,@idx_array,@lang @idx_lst=@title=@subtitle=@fulltitle=@author=@author_format=nil rgx={} rgx[:author]=/^@creator:(?:[ ]+|.+?:author:[ ]+)(.+?)(?:\||\n)/m rgx[:title]=/^@title:[ ]+(.+)/ rgx[:subtitle]=/^@title:.+?:subtitle:[ ]+(.+?)\n/m rgx[:idx]=/^@classify:.+?:topic_register:[ ]+(.+?)(?:\n\n|\n\s+:\S|\n%)/m data.each do |para| if para=~ rgx[:idx] @idx_list=(rgx[:idx].match(para)[1]).split(/\s*\n\s*/).join end if para=~ rgx[:title] @title=rgx[:title].match(para)[1] end if para=~ rgx[:subtitle] @subtitle=rgx[:subtitle].match(para)[1] end if para=~ rgx[:author] @author_format=rgx[:author].match(para)[1] end break if @title && @subtitle && @author && @idx_lst end @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title if @title \ and @author_format \ and @idx_list creator=SiSU_FormatAuthor::Author.new(@author_format.strip).author_details @authors,@authorship=creator[:authors],creator[:authorship] file=if name=~/~[a-z]{2,3}\.ss[mt]$/ name.sub(/~[a-z]{2,3}\.ss[mt]$/,'') else name.sub(/\.ss[mt]$/,'') end page=if @env.output_dir_structure.by? == :language "#{lang}/sisu_manifest.html" else "sisu_manifest.#{lang}.html" end idx_array[lang] <<=if @idx_list =~/;/ g=@idx_list.scan(/[^;]+/) g.each.map do |i| i=i.strip { filename: filename, file: file, rough_idx: i, title: @fulltitle, author: creator, page: page, lang: lang } end else { filename: filename, file: file, rough_idx: @idx_list, title: @fulltitle, author: creator, page: page, lang: lang, } end else if (@opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) p "missing required field in #{@filename} - [title]: <<#{@title}>>; [author]: <<#{@author_format}>>; [idx]: <<#{@idx_list}>>" end end idx_array[lang]=idx_array[lang].flatten idx_array end