aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/dal_hash_digest.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/dal_hash_digest.rb')
-rw-r--r--lib/sisu/v3/dal_hash_digest.rb41
1 files changed, 21 insertions, 20 deletions
diff --git a/lib/sisu/v3/dal_hash_digest.rb b/lib/sisu/v3/dal_hash_digest.rb
index 2c983919..ad201752 100644
--- a/lib/sisu/v3/dal_hash_digest.rb
+++ b/lib/sisu/v3/dal_hash_digest.rb
@@ -56,29 +56,30 @@
** Description: system environment, resource control and configuration details
=end
-module SiSU_hash
+module SiSU_DAL_Hash
require_relative 'shared_markup_alt.rb' #shared_markup_alt.rb
- class Object_digest
+ class ObjectDigest
def initialize(md,data,env=nil)
@md,@data,@env=md,data,env
- @env ||=SiSU_Env::Info_env.new(@md.fns)
+ @env ||=SiSU_Env::InfoEnv.new(@md.fns)
end
def object_digest
# 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes
# 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph)
# 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?])
# [digests should not include other digests]
- data=@data
+ data=@data.compact
@tuned_file=[]
- data.compact!
sha_ =(@env.digest.type=='sha256' ? true : false)
sha_ ? (require 'digest/sha2') : (require 'digest/md5')
data.each do |t_o|
unless t_o.obj.class==Array
- t_o.obj.strip!
+ t_o.obj=t_o.obj.strip
end
- if t_o.of !~/structure|comment|layout/ \
- and t_o.ocn.class==Fixnum
+ if (t_o.of !=:structure \
+ && t_o.of !=:comment \
+ && t_o.of !=:layout) \
+ && t_o.ocn.class==Fixnum
if sha_
for hash_class in [ Digest::SHA256 ]
@tuned_file << stamped(t_o,hash_class)
@@ -101,7 +102,7 @@ module SiSU_hash
when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/
if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/
t_o_txt,en_open,en_txt,en_close=/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.match(en_plus)[1..4]
- stripped_en=SiSU_text_representation::Alter.new(en_txt).strip_clean_of_markup
+ stripped_en=SiSU_TextRepresentation::Alter.new(en_txt).strip_clean_of_markup
digest_en_strip=if @env.digest.type =~/sha256/
Digest::SHA256.hexdigest(stripped_en)
else
@@ -116,16 +117,16 @@ module SiSU_hash
t_o_bit.join
end
def stamped(t_o,hash_class) #decide what hash information is most useful, is compromise necessary?
- t_o.obj=SiSU_text_representation::Alter.new(t_o).strip_clean_of_extra_spaces
+ t_o.obj=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_extra_spaces
t_obj=t_o.inspect.sub(/:0x[0-9a-f]{8}\s/,': ')
- stripped=SiSU_text_representation::Alter.new(t_o).strip_clean_of_markup
- markup=SiSU_text_representation::Alter.new(t_o).semi_revert_markup
- digests=SiSU_text_representation::Modified_text_plus_Hash_digest.new(@md,t_o).composite.dgst
- unless t_o.is=='code'
+ stripped=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_markup
+ markup=SiSU_TextRepresentation::Alter.new(t_o).semi_revert_markup
+ digests=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst
+ unless t_o.is==:code
case t_o.obj
when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m
en_and_t_o,en_and_t_o_digest=[],[]
- t_o.obj.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch
+ t_o.obj=t_o.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch
t_o_plus_en=t_o.obj.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m)
t_o_tail=if t_o.obj =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m
/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+.*/m.match(t_o.obj)[1]
@@ -144,11 +145,11 @@ module SiSU_hash
def strip_clean_extra_spaces(s) # dal output tuned
s=s.dup
s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/
- s=s.gsub(/ [ ]+/,' ')
- s=s.gsub(/^ [ ]+/,'')
- s=s.gsub(/ [ ]+$/,'')
- s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2')
- s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2')
+ s=s.gsub(/ [ ]+/,' ').
+ gsub(/^ [ ]+/,'').
+ gsub(/ [ ]+$/,'').
+ gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2').
+ gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2')
end
end
end