From 178ce66b4335fe51d2e18e729744be751e9d6280 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 17 Apr 2010 20:59:07 -0400 Subject: param, information on missing author, title, or copyright --- lib/sisu/v2/param.rb | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/lib/sisu/v2/param.rb b/lib/sisu/v2/param.rb index c50a55ee..ef91f10d 100644 --- a/lib/sisu/v2/param.rb +++ b/lib/sisu/v2/param.rb @@ -149,8 +149,8 @@ module SiSU_Param end end class Md - def initialize(str) - @s=str + def initialize(str,opt) + @s,@opt=str,opt end def validate_length(s,l,n) #s=(s.length <= l) ? s : nil @@ -388,7 +388,10 @@ module SiSU_Param @h['text'] elsif @h['main'] @h['main'] - else p 'provide copyright' + else + tell=SiSU_Screen::Ansi.new(@cmd,'WARNING Document Copyright missing; provide @rights: :copyright:') + tell.warn unless @opt.cmd =~/q/ + '' end end def translation @@ -439,6 +442,10 @@ module SiSU_Param and copyright.license s +=' License: ' + copyright.license end + if s.empty? + tell=SiSU_Screen::Ansi.new(@cmd,'WARNING Document Rights information missing; provide @rights: :copyright:') + tell.warn unless @opt.cmd =~/q/ + end s end s @@ -878,23 +885,23 @@ module SiSU_Param case para when /^@ocn:\s+(.+?)$/m; @ocn=$1 #% processing when /^@title:(.+)/m #% metainfo DC - @title=Md.new($1.strip).title + @title=Md.new($1.strip,@opt).title when /^@creator:(.+)/m #% metainfo DC - @creator=Md.new($1.strip).creator + @creator=Md.new($1.strip,@opt).creator @authorship=@author=@creator.author @authors=@creator.author_detail when /^@classify:(.+)/m; classify=$1 - @classify=Md.new($1.strip).classify + @classify=Md.new($1.strip,@opt).classify when /^@publisher:\s+(.+)/m - @publisher=Md.new($1.strip).current_publisher + @publisher=Md.new($1.strip,@opt).current_publisher when /^@original:(.+)/m - @original=Md.new($1.strip).original + @original=Md.new($1.strip,@opt).original @source=@original.source when /^@writing_focus[:.]nationality:\s+(.+?)$/; @writing_focus=$1 # e.g. Finland (where and article on Finnish law) when /^@date:(.+)/m #% metainfo DC - @date=Md.new($1.strip).date + @date=Md.new($1.strip,@opt).date when /^@rights:(.+)/m; #@rights=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC copyright, public domain, copyleft, creative commons, etc. - @rights=Md.new($1.strip).rights + @rights=Md.new($1.strip,@opt).rights when /^@papersize:\s+(.+?)$/m #% metainfo DC l=$1 if @mod.inspect !~/--papersize[=-]\S+/ @@ -902,7 +909,7 @@ module SiSU_Param @papersize=l end when /^@make:(.+)/m #% metainfo DC - @make=Md.new($1.strip).make + @make=Md.new($1.strip,@opt).make if defined? @make.breaks \ and @make.breaks[:page_new] #clearpage @pagenew=@make.breaks[:page_new] @@ -934,7 +941,7 @@ module SiSU_Param @man_section=(defined? @make.manpage.section) ? @make.manpage.section : 1 end when /^@links:\s+(.+?)\Z/m #% processing - doc_links=Md.new($1.strip).links + doc_links=Md.new($1.strip,@opt).links count=1 @lnk=[] doc_links.each do |doc_link| @@ -945,7 +952,7 @@ module SiSU_Param end end when /^@notes?:\s(.+)/ #% metainfo - Md.new($1.strip).notes + Md.new($1.strip,@opt).notes when /^@base_program:\s+(.+?)$/; @base_program=$1 #% processing end @lv1 ||=/^1~/ @@ -1153,12 +1160,12 @@ module SiSU_Param footnote_conversion_errors << "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" end if @title.main !~/[\S]/ - tell=SiSU_Screen::Ansi.new(@cmd,'Document Title Missing','please provide it') - tell.warn if @cmd =~/v/ + tell=SiSU_Screen::Ansi.new(@cmd,'WARNING Document Title missing','please provide @title:') + tell.warn unless @cmd =~/q/ end if @author !~/[\S]/ - tell=SiSU_Screen::Ansi.new(@cmd,'Document Author/Creator Missing','please provide it') - tell.warn if @cmd =~/v/ + tell=SiSU_Screen::Ansi.new(@cmd,'Warning Document Author missing','please provide @creator: :author:') + tell.warn unless @cmd =~/q/ end # Elementary Document Structure Analysis - adds complexity may remove - need to develop - appears to work, proof of concept if @title.nil? @@ -1259,7 +1266,7 @@ module SiSU_Param def store File.unlink(@pstorefile) if FileTest.file?(@pstorefile) tell=SiSU_Screen::Ansi.new(@md.cmd,"PStore -> #{@pstorefile}") - tell.txt_grey if @md.cmd =~/v/ + tell.txt_grey if @md.cmd =~/[MV]/ store=PStore.new(@pstorefile) store.transaction do store['md']=@md -- cgit v1.2.3