diff options
author | Ralph Amissah <ralph@amissah.com> | 2010-07-10 11:18:39 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2010-07-10 11:35:56 -0400 |
commit | 063a3a502976dd25a8178522002e67e5af85dab7 (patch) | |
tree | 3bf4a30a02757b3a606c330edef6f526a85f5117 /lib | |
parent | sha256 (2.6.1) (diff) |
param, header reading more robust (re: commented out parts)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v2/param.rb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/sisu/v2/param.rb b/lib/sisu/v2/param.rb index 8b75edfc..a313fa1c 100644 --- a/lib/sisu/v2/param.rb +++ b/lib/sisu/v2/param.rb @@ -224,7 +224,7 @@ module SiSU_Param @h end def title - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def main s=@h['main'] @@ -269,7 +269,7 @@ module SiSU_Param self end def creator #there are sub categories that need to be catered for and sometimes more than one author etc.; implement array.to_s.length validation test later, current test on string approximate as string is not used - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def author @h['author']=(@h['author'] ? @h['author'] : @h['main']) @@ -378,7 +378,7 @@ module SiSU_Param self end def rights - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def copyright def text #you may wish to expand to take from all @@ -468,7 +468,7 @@ module SiSU_Param self end def classify - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def coverage s=@h['coverage'] @@ -528,14 +528,14 @@ module SiSU_Param self end def publisher - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) s=@h['main'] l,n=Db[:col_name],'publisher' validate_length(s,l,n) end def date - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def added_to_site s=@h['added_to_site'] @@ -575,7 +575,7 @@ module SiSU_Param self end def language # as things stand this should really be populated from title.language and original.language, resolve - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def document s=@h['document']=(@h['document'] ? @h['document'] : @h['main']) @@ -600,24 +600,24 @@ module SiSU_Param self end def make - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def headings lv=[] - s=@s - s=((s =~/;/) ? (s.split(/;\s*/)) : [ s ]) - lv[0]=s - lv1=s[0] ||='1~ ' #some arbitrary changes made + x=@h['headings'] + x=((x =~/;/) ? (x.split(/;\s*/)) : [ x ]) + lv[0]=x + lv1=x[0] ||='1~ ' #some arbitrary changes made lv[1]=/^#{lv1}/ - lv2=s[1] ||='2~ ' + lv2=x[1] ||='2~ ' lv[2]=/^#{lv2}/ - lv3=s[2] ||='3~ ' + lv3=x[2] ||='3~ ' lv[3]=/^#{lv3}/ - lv4=s[3] ||='4~ ' + lv4=x[3] ||='4~ ' lv[4]=/^#{lv4}/ - lv5=s[4] ||='5~ ' + lv5=x[4] ||='5~ ' lv[5]=/^#{lv5}/ - lv6=s[5] ||='6~ ' + lv6=x[5] ||='6~ ' lv[6]=/^#{lv6}/ lv end @@ -720,7 +720,7 @@ module SiSU_Param @s end def original - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def publisher s=@h['publisher'] @@ -755,11 +755,11 @@ module SiSU_Param self end def links - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) a end def notes - a=@s.split(/[ ]*\n[ ]*/m) + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def abstract @h['abstract'] |