Class: SiSU_Param::Parameters::Md
- Inherits:
-
Object
- Object
- SiSU_Param::Parameters::Md
- Defined in:
- lib/sisu/dp.rb
Instance Method Summary collapse
- #abstract ⇒ Object
- #added_to_site ⇒ Object
- #all ⇒ Object
- #audio ⇒ Object
- #audio_detail ⇒ Object
- #author ⇒ Object
- #author_detail ⇒ Object
- #available ⇒ Object
- #build_hash(arr) ⇒ Object
- #classify ⇒ Object
- #comment ⇒ Object
- #contributor ⇒ Object
- #contributor_detail ⇒ Object
- #copyright ⇒ Object
- #copyright_and_license ⇒ Object
- #coverage ⇒ Object
- #created ⇒ Object
-
#creator ⇒ Object
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.
-
#current_publisher ⇒ Object
def language # as things stand this should really be populated from title.language and original.language, resolve [email protected](/n%s.+?$|[ ]*n[ ]*/m) @h=build_hash(a) def document s=@h=(@h ? @h : @h) l,n=Db,‘language.document’ validate_length(s,l,n) end def document_char s=@h=(@h ? @h : nil) l,n=Db,‘language.document_char’ validate_length(s,l,n) end def original s=@h l,n=Db,‘language.original’ validate_length(s,l,n) end def original_char s=@h l,n=Db,‘language.original_char’ validate_length(s,l,n) end self end.
- #date ⇒ Object
- #description ⇒ Object
- #dewey ⇒ Object
- #digitization ⇒ Object
- #digitized_by ⇒ Object
- #digitized_by_detail ⇒ Object
- #edition ⇒ Object
- #editor ⇒ Object
- #editor_detail ⇒ Object
- #format ⇒ Object
- #full ⇒ Object
- #history ⇒ Object
- #identifier ⇒ Object
- #illustrations ⇒ Object
- #illustrator ⇒ Object
- #illustrator_detail ⇒ Object
-
#initialize(str, opt, env) ⇒ Md
constructor
A new instance of Md.
- #institution ⇒ Object
- #isbn ⇒ Object
- #issued ⇒ Object
- #keywords ⇒ Object
- #language ⇒ Object
-
#language_char ⇒ Object
look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:n :language_char: fi)].
- #license ⇒ Object
- #loc ⇒ Object
- #main ⇒ Object
- #modified ⇒ Object
- #name_format(name) ⇒ Object
- #nationality ⇒ Object
- #note ⇒ Object
- #notes ⇒ Object
- #oclc ⇒ Object
- #original ⇒ Object
- #pg ⇒ Object
- #photographer ⇒ Object
- #photographer_detail ⇒ Object
- #photographs ⇒ Object
- #prefix ⇒ Object
- #prepared_by ⇒ Object
- #prepared_by_detail ⇒ Object
- #published ⇒ Object
- #publisher ⇒ Object
- #relation ⇒ Object
- #rights ⇒ Object
- #sep(str) ⇒ Object
- #short ⇒ Object
- #source ⇒ Object
- #sub ⇒ Object
- #subject ⇒ Object
-
#text ⇒ Object
you may wish to expand to take from all.
- #title ⇒ Object
- #topic_register ⇒ Object
- #translation ⇒ Object
- #translator ⇒ Object
- #translator_detail ⇒ Object
- #type ⇒ Object
- #valid ⇒ Object
- #validate_length(s, l, n) ⇒ Object
Constructor Details
#initialize(str, opt, env) ⇒ Md
Returns a new instance of Md.
196 197 198 |
# File 'lib/sisu/dp.rb', line 196 def initialize(str,opt,env) @s,@opt,@env=str,opt,env end |
Instance Method Details
#abstract ⇒ Object
850 851 852 853 854 |
# File 'lib/sisu/dp.rb', line 850 def abstract s=@h['abstract'] l,n=Db[:col_info_note],'notes.abstract' validate_length(s,l,n) end |
#added_to_site ⇒ Object
742 743 744 745 746 |
# File 'lib/sisu/dp.rb', line 742 def added_to_site s=@h['added_to_site'] l,n=Db[:col_date_text],'date.added_to_site' validate_length(s,l,n) end |
#all ⇒ Object
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
# File 'lib/sisu/dp.rb', line 620 def all s=if @h['all'] then @h['all'] else s='' if defined? copyright.text \ and copyright.text \ and not copyright.text.empty? v=sep(copyright.text) s +='Copyright: ' + copyright.text + v end if defined? copyright.translation \ and copyright.translation \ and not copyright.translation.empty? v=sep(copyright.translation) s +='translation: ' + copyright.translation + v end if defined? copyright.illustrations \ and copyright.illustrations \ and not copyright.illustrations.empty? v=sep(copyright.illustrations) s +='illustrations: ' + copyright.illustrations + v end if defined? copyright.photographs \ and copyright.photographs \ and not copyright.photographs.empty? v=sep(copyright.photographs) s +='photographs: ' + copyright.photographs + v end if defined? copyright.digitization \ and copyright.digitization \ and not copyright.digitization.empty? v=sep(copyright.digitization) s +='digitization: ' + copyright.digitization + v end if defined? copyright.audio \ and copyright.audio \ and not copyright.audio.empty? v=sep(copyright.audio) s +='audio: ' + copyright.audio + v end if defined? copyright.license \ and copyright.license \ and not copyright.license.empty? s +='License: ' + copyright.license end if s.empty? SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Rights information missing; provide @rights: :copyright:' ).warn if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) end s=s.gsub(/ [\\]+\s+$/,'') end s end |
#audio ⇒ Object
457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/sisu/dp.rb', line 457 def audio names=@h['audio'] \ ? name_format(@h['audio']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.audio' validate_length(s,l,n) else nil end end |
#audio_detail ⇒ Object
470 471 472 473 474 475 476 477 |
# File 'lib/sisu/dp.rb', line 470 def audio_detail names=@h['audio'] \ ? name_format(@h['audio']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end |
#author ⇒ Object
336 337 338 339 340 341 342 343 344 |
# File 'lib/sisu/dp.rb', line 336 def @h['author']=(@h['author'] \ ? @h['author'] : @h['main']) names=name_format(@h['author']) s=names[:name_str] l,n=Db[:col_name],'creator.author' validate_length(s,l,n) end |
#author_detail ⇒ Object
345 346 347 348 349 350 351 |
# File 'lib/sisu/dp.rb', line 345 def s=@h['author'] \ ? @h['author'] : @h['main'] names=name_format(s) names[:name_a_h] end |
#available ⇒ Object
747 748 749 750 751 |
# File 'lib/sisu/dp.rb', line 747 def available s=@h['available'] l,n=Db[:col_date_text],'date.available' validate_length(s,l,n) end |
#build_hash(arr) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/sisu/dp.rb', line 260 def build_hash(arr) @h={} arr.each_with_index do |x,i| a,b=nil,nil if x =~/^%\s/ #ignore comment elsif x =~/:(\S+?):\s+(.+)/ a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] b=b.gsub(/\s*<br(?: \/)?>\s*/,' \\\\\\ ') b=if b =~/\n/m (b =~/;\n/m) \ ? (b.split(/;\s*\n\s*/).join(';')) : (b.split(/\s*\n\s*/).join(' ')) else b end elsif i == 0 a='main' b=x else end @h[a]=b end @h end |
#classify ⇒ Object
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
# File 'lib/sisu/dp.rb', line 702 def classify a=@s.split(/(\n%\s.+?$|[ ]*)(?:\n[ ]*(?=:)|\Z)/m) @h=build_hash(a) def topic_register s=@h['topic_register'] l,n=Db[:col_info_note],'classify.topic_register' validate_length(s,l,n) end def subject s=@h['subject'] l,n=Db[:col_txt_long],'classify.subject' validate_length(s,l,n) end def keywords s=@h['keywords'] l,n=Db[:col_txt_long],'classify.keywords' validate_length(s,l,n) end def loc s=@h['loc'] l,n=Db[:col_library],'classify.loc' validate_length(s,l,n) end def dewey s=@h['dewey'] l,n=Db[:col_library],'classify.dewey' validate_length(s,l,n) end self end |
#comment ⇒ Object
855 856 857 858 859 |
# File 'lib/sisu/dp.rb', line 855 def comment s=@h['comment'] l,n=Db[:col_info_note],'notes.comment' validate_length(s,l,n) end |
#contributor ⇒ Object
373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/sisu/dp.rb', line 373 def contributor names=@h['contributor'] \ ? name_format(@h['contributor']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.author' validate_length(s,l,n) else nil end end |
#contributor_detail ⇒ Object
386 387 388 389 390 391 392 393 |
# File 'lib/sisu/dp.rb', line 386 def contributor_detail names=@h['contributor'] \ ? name_format(@h['contributor']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end |
#copyright ⇒ Object
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/sisu/dp.rb', line 526 def copyright def text #you may wish to expand to take from all s=if @h['copyright'] then @h['copyright'] elsif @h['text'] then @h['text'] elsif @h['main'] then @h['main'] else SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Copyright missing; provide @rights: :copyright:' ).warn if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) '' end l,n=Db[:col_info_note],'rights.copyright.text' validate_length(s,l,n) end def translation s=@h['translation'] \ ? @h['translation'] : nil l,n=Db[:col_info_note],'rights.copyright.translation' validate_length(s,l,n) end def illustrations s=@h['illustrations'] \ ? @h['illustrations'] : nil l,n=Db[:col_info_note],'rights.copyright.illustrations' validate_length(s,l,n) end def photographs s=@h['photographs'] \ ? @h['photographs'] : nil l,n=Db[:col_info_note],'rights.copyright.photographs' validate_length(s,l,n) end def digitization s=@h['digitization'] \ ? @h['digitization'] : nil l,n=Db[:col_info_note],'rights.copyright.digitization' validate_length(s,l,n) end def audio s=@h['audio'] \ ? @h['audio'] : nil l,n=Db[:col_info_note],'rights.copyright.audio' validate_length(s,l,n) end self end |
#copyright_and_license ⇒ Object
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/sisu/dp.rb', line 590 def copyright_and_license s=if @h['copyright_and_license'] then @h['copyright_and_license'] else s='' if defined? copyright.text \ and copyright.text \ and not copyright.text.empty? v=sep(copyright.text) s +=copyright.text + v end if defined? copyright.license \ and copyright.license \ and not copyright.license.empty? s +=copyright.license end if s.empty? SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Rights information missing; provide @rights: :copyright:' ).warn if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) end s=s.gsub(/ [\\]+\s+$/,'') end s end |
#coverage ⇒ Object
860 861 862 863 864 |
# File 'lib/sisu/dp.rb', line 860 def coverage s=@h['coverage'] l,n=Db[:col_info_note],'notes.coverage' validate_length(s,l,n) end |
#created ⇒ Object
752 753 754 755 756 |
# File 'lib/sisu/dp.rb', line 752 def created s=@h['created'] l,n=Db[:col_date_text],'date.created' validate_length(s,l,n) end |
#creator ⇒ Object
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
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/sisu/dp.rb', line 333 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%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def @h['author']=(@h['author'] \ ? @h['author'] : @h['main']) names=name_format(@h['author']) s=names[:name_str] l,n=Db[:col_name],'creator.author' validate_length(s,l,n) end def s=@h['author'] \ ? @h['author'] : @h['main'] names=name_format(s) names[:name_a_h] end def editor names=@h['editor'] \ ? name_format(@h['editor']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.editor' validate_length(s,l,n) else nil end end def editor_detail names=@h['editor'] \ ? name_format(@h['editor']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end def contributor names=@h['contributor'] \ ? name_format(@h['contributor']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.author' validate_length(s,l,n) else nil end end def contributor_detail names=@h['contributor'] \ ? name_format(@h['contributor']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end def illustrator names=@h['illustrator'] \ ? name_format(@h['illustrator']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.illustrator' validate_length(s,l,n) else nil end end def illustrator_detail names=@h['illustrator'] \ ? name_format(@h['illustrator']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end def photographer names=@h['photographer'] \ ? name_format(@h['photographer']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.photographer' validate_length(s,l,n) else nil end end def photographer_detail names=@h['photographer'] \ ? name_format(@h['photographer']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end def translator names=@h['translator'] \ ? name_format(@h['translator']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.translator' validate_length(s,l,n) else nil end end def translator_detail names=@h['translator'] \ ? name_format(@h['translator']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end def audio names=@h['audio'] \ ? name_format(@h['audio']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.audio' validate_length(s,l,n) else nil end end def audio_detail names=@h['audio'] \ ? name_format(@h['audio']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end def digitized_by names=@h['digitized_by'] \ ? name_format(@h['digitized_by']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.digitized_by' validate_length(s,l,n) else nil end end def digitized_by_detail names=@h['digitized_by'] \ ? name_format(@h['digitized_by']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end def prepared_by names=@h['prepared_by'] \ ? name_format(@h['prepared_by']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.prepared_by' validate_length(s,l,n) else nil end end def prepared_by_detail names=@h['prepared_by'] \ ? name_format(@h['prepared_by']) : nil names=name_format(@h['prepared_by']) (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end self end |
#current_publisher ⇒ Object
def language # as things stand this should really be populated from title.language and original.language, resolve
a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
@h=build_hash(a)
def document
s=@h['document']=(@h['document'] ? @h['document'] : @h['main'])
l,n=Db[:col_language],'language.document'
validate_length(s,l,n)
end
def document_char
s=@h['document_char']=(@h['document_char'] ? @h['document_char'] : nil)
l,n=Db[:col_language_char],'language.document_char'
validate_length(s,l,n)
end
def original
s=@h['original']
l,n=Db[:col_language],'language.original'
validate_length(s,l,n)
end
def original_char
s=@h['original_char']
l,n=Db[:col_language_char],'language.original_char'
validate_length(s,l,n)
end
self
end
804 805 806 |
# File 'lib/sisu/dp.rb', line 804 def current_publisher @s end |
#date ⇒ Object
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File 'lib/sisu/dp.rb', line 739 def date a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def added_to_site s=@h['added_to_site'] l,n=Db[:col_date_text],'date.added_to_site' validate_length(s,l,n) end def available s=@h['available'] l,n=Db[:col_date_text],'date.available' validate_length(s,l,n) end def created s=@h['created'] l,n=Db[:col_date_text],'date.created' validate_length(s,l,n) end def issued s=@h['issued'] l,n=Db[:col_date_text],'date.issued' validate_length(s,l,n) end def modified s=@h['modified'] l,n=Db[:col_date_text],'date.modified' validate_length(s,l,n) end def published s=@h['published']=(@h['published'] ? @h['published'] : @h['main']) l,n=Db[:col_date_text],'date.published' validate_length(s,l,n) end def valid s=@h['valid'] l,n=Db[:col_date_text],'date.valid' validate_length(s,l,n) end self end |
#description ⇒ Object
845 846 847 848 849 |
# File 'lib/sisu/dp.rb', line 845 def description s=@h['description'] l,n=Db[:col_info_note],'notes.description' validate_length(s,l,n) end |
#dewey ⇒ Object
725 726 727 728 729 |
# File 'lib/sisu/dp.rb', line 725 def dewey s=@h['dewey'] l,n=Db[:col_library],'classify.dewey' validate_length(s,l,n) end |
#digitization ⇒ Object
564 565 566 567 568 569 570 |
# File 'lib/sisu/dp.rb', line 564 def digitization s=@h['digitization'] \ ? @h['digitization'] : nil l,n=Db[:col_info_note],'rights.copyright.digitization' validate_length(s,l,n) end |
#digitized_by ⇒ Object
478 479 480 481 482 483 484 485 486 487 488 489 490 |
# File 'lib/sisu/dp.rb', line 478 def digitized_by names=@h['digitized_by'] \ ? name_format(@h['digitized_by']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.digitized_by' validate_length(s,l,n) else nil end end |
#digitized_by_detail ⇒ Object
491 492 493 494 495 496 497 498 |
# File 'lib/sisu/dp.rb', line 491 def digitized_by_detail names=@h['digitized_by'] \ ? name_format(@h['digitized_by']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end |
#edition ⇒ Object
297 298 299 300 301 |
# File 'lib/sisu/dp.rb', line 297 def edition s=@h['edition'] l,n=Db[:col_title_edition],'title.edition' validate_length(s,l,n) end |
#editor ⇒ Object
352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/sisu/dp.rb', line 352 def editor names=@h['editor'] \ ? name_format(@h['editor']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.editor' validate_length(s,l,n) else nil end end |
#editor_detail ⇒ Object
365 366 367 368 369 370 371 372 |
# File 'lib/sisu/dp.rb', line 365 def editor_detail names=@h['editor'] \ ? name_format(@h['editor']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end |
#format ⇒ Object
885 886 887 888 889 |
# File 'lib/sisu/dp.rb', line 885 def format s=@h['format'] l,n=Db[:col_txt_short],'notes.format' validate_length(s,l,n) end |
#full ⇒ Object
314 315 316 317 318 319 320 |
# File 'lib/sisu/dp.rb', line 314 def full s=@h['subtitle'] \ ? (@h['main'] + ' - ' + @h['subtitle']) : @h['main'] l,n=Db[:col_title],'title.full' validate_length(s,l,n) end |
#history ⇒ Object
875 876 877 878 879 |
# File 'lib/sisu/dp.rb', line 875 def history s=@h['history'] l,n=Db[:col_txt_long],'notes.history' validate_length(s,l,n) end |
#identifier ⇒ Object
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
# File 'lib/sisu/dp.rb', line 682 def identifier a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def oclc s=@h['oclc'] l,n=Db[:col_library],'identifier.oclc' validate_length(s,l,n) end def isbn s=@h['isbn'] l,n=Db[:col_small],'identifier.isbn' validate_length(s,l,n) end def pg s=@h['pg'] l,n=Db[:col_small],'identifier.pg' validate_length(s,l,n) end self end |
#illustrations ⇒ Object
550 551 552 553 554 555 556 |
# File 'lib/sisu/dp.rb', line 550 def illustrations s=@h['illustrations'] \ ? @h['illustrations'] : nil l,n=Db[:col_info_note],'rights.copyright.illustrations' validate_length(s,l,n) end |
#illustrator ⇒ Object
394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/sisu/dp.rb', line 394 def illustrator names=@h['illustrator'] \ ? name_format(@h['illustrator']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.illustrator' validate_length(s,l,n) else nil end end |
#illustrator_detail ⇒ Object
407 408 409 410 411 412 413 414 |
# File 'lib/sisu/dp.rb', line 407 def illustrator_detail names=@h['illustrator'] \ ? name_format(@h['illustrator']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end |
#institution ⇒ Object
830 831 832 833 834 |
# File 'lib/sisu/dp.rb', line 830 def institution s=@h['institution'] l,n=Db[:col_name],'original.institution' validate_length(s,l,n) end |
#isbn ⇒ Object
690 691 692 693 694 |
# File 'lib/sisu/dp.rb', line 690 def isbn s=@h['isbn'] l,n=Db[:col_small],'identifier.isbn' validate_length(s,l,n) end |
#issued ⇒ Object
757 758 759 760 761 |
# File 'lib/sisu/dp.rb', line 757 def issued s=@h['issued'] l,n=Db[:col_date_text],'date.issued' validate_length(s,l,n) end |
#keywords ⇒ Object
715 716 717 718 719 |
# File 'lib/sisu/dp.rb', line 715 def keywords s=@h['keywords'] l,n=Db[:col_txt_long],'classify.keywords' validate_length(s,l,n) end |
#language ⇒ Object
321 322 323 324 325 |
# File 'lib/sisu/dp.rb', line 321 def language s=@h['language'] l,n=Db[:col_language],'title.language' validate_length(s,l,n) end |
#language_char ⇒ Object
look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:n :language_char: fi)]
326 327 328 329 330 |
# File 'lib/sisu/dp.rb', line 326 def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n :language_char: fi)] s=@h['language_char'] l,n=Db[:col_language_char],'title.language_char' validate_length(s,l,n) end |
#license ⇒ Object
580 581 582 583 584 585 586 |
# File 'lib/sisu/dp.rb', line 580 def license s=@h['license'] \ ? @h['license'] : nil l,n=Db[:col_info_note],'rights.license' validate_length(s,l,n) end |
#loc ⇒ Object
720 721 722 723 724 |
# File 'lib/sisu/dp.rb', line 720 def loc s=@h['loc'] l,n=Db[:col_library],'classify.loc' validate_length(s,l,n) end |
#main ⇒ Object
287 288 289 290 291 |
# File 'lib/sisu/dp.rb', line 287 def main s=@h['main'] l,n=Db[:col_title_part],'title.main' validate_length(s,l,n) end |
#modified ⇒ Object
762 763 764 765 766 |
# File 'lib/sisu/dp.rb', line 762 def modified s=@h['modified'] l,n=Db[:col_date_text],'date.modified' validate_length(s,l,n) end |
#name_format(name) ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/sisu/dp.rb', line 218 def name_format(name) if name name=name.strip @name_a_h=[] =name.scan(/[^;]+/) .each_with_index do |a,i| b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) if b[0] =~/"(.+?)"/ @name_a_h << { the: $1 } else x=b[0].scan(/[^,]+/) if x.length==1 @name_a_h << { the: x[0].strip } elsif x.length==2 @name_a_h << { the: x[0].strip, others: x[1].strip } else #p x.length end end b.delete_at(0) b.each do |d| k,c=nil k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d @name_a_h[i][:hon]=c.strip if k=='hon' @name_a_h[i][:affiliation]=c.strip if k=='affiliation' @name_a_h[i][:nationality]=c.strip if k=='nationality' end end l=@name_a_h.length name_str='' @name_a_h.each_with_index do |a,i| name_str += if a[:others] z=(((l - i) > 1) ? ', ' : '') "#{a[:others].strip} #{a[:the].strip}" + z else z=(((l - i) > 2) ? ', ' : '') "#{a[:the].strip}" + z end end { name_a_h: @name_a_h, name_str: name_str } else nil end end |
#nationality ⇒ Object
835 836 837 838 839 |
# File 'lib/sisu/dp.rb', line 835 def nationality s=@h['nationality'] l,n=Db[:col_language],'original.nationality' validate_length(s,l,n) end |
#note ⇒ Object
302 303 304 305 306 |
# File 'lib/sisu/dp.rb', line 302 def note s=@h['note'] l,n=Db[:col_info_note],'title.note' validate_length(s,l,n) end |
#notes ⇒ Object
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
# File 'lib/sisu/dp.rb', line 842 def notes a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def description s=@h['description'] l,n=Db[:col_info_note],'notes.description' validate_length(s,l,n) end def abstract s=@h['abstract'] l,n=Db[:col_info_note],'notes.abstract' validate_length(s,l,n) end def comment s=@h['comment'] l,n=Db[:col_info_note],'notes.comment' validate_length(s,l,n) end def coverage s=@h['coverage'] l,n=Db[:col_info_note],'notes.coverage' validate_length(s,l,n) end def relation s=@h['relation'] l,n=Db[:col_info_note],'notes.relation' validate_length(s,l,n) end def source s=@h['source'] l,n=Db[:col_txt_long],'notes.source' validate_length(s,l,n) end def history s=@h['history'] l,n=Db[:col_txt_long],'notes.history' validate_length(s,l,n) end def type s=@h['type'] l,n=Db[:col_txt_long],'notes.relation' validate_length(s,l,n) end def format s=@h['format'] l,n=Db[:col_txt_short],'notes.format' validate_length(s,l,n) end def prefix @h['prefix'] end self end |
#oclc ⇒ Object
685 686 687 688 689 |
# File 'lib/sisu/dp.rb', line 685 def oclc s=@h['oclc'] l,n=Db[:col_library],'identifier.oclc' validate_length(s,l,n) end |
#original ⇒ Object
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/sisu/dp.rb', line 807 def original a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def publisher s=@h['publisher'] l,n=Db[:col_name],'original.publisher' validate_length(s,l,n) end def language s=@h['language'] l,n=Db[:col_language],'original.language' validate_length(s,l,n) end def language_char s=@h['language_char'] l,n=Db[:col_language_char],'original.language_char' validate_length(s,l,n) end def source s=@h['source'] l,n=Db[:col_name],'original.source' validate_length(s,l,n) end def institution s=@h['institution'] l,n=Db[:col_name],'original.institution' validate_length(s,l,n) end def nationality s=@h['nationality'] l,n=Db[:col_language],'original.nationality' validate_length(s,l,n) end self end |
#pg ⇒ Object
695 696 697 698 699 |
# File 'lib/sisu/dp.rb', line 695 def pg s=@h['pg'] l,n=Db[:col_small],'identifier.pg' validate_length(s,l,n) end |
#photographer ⇒ Object
415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/sisu/dp.rb', line 415 def photographer names=@h['photographer'] \ ? name_format(@h['photographer']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.photographer' validate_length(s,l,n) else nil end end |
#photographer_detail ⇒ Object
428 429 430 431 432 433 434 435 |
# File 'lib/sisu/dp.rb', line 428 def photographer_detail names=@h['photographer'] \ ? name_format(@h['photographer']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end |
#photographs ⇒ Object
557 558 559 560 561 562 563 |
# File 'lib/sisu/dp.rb', line 557 def photographs s=@h['photographs'] \ ? @h['photographs'] : nil l,n=Db[:col_info_note],'rights.copyright.photographs' validate_length(s,l,n) end |
#prefix ⇒ Object
890 891 892 |
# File 'lib/sisu/dp.rb', line 890 def prefix @h['prefix'] end |
#prepared_by ⇒ Object
499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/sisu/dp.rb', line 499 def prepared_by names=@h['prepared_by'] \ ? name_format(@h['prepared_by']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.prepared_by' validate_length(s,l,n) else nil end end |
#prepared_by_detail ⇒ Object
512 513 514 515 516 517 518 519 520 |
# File 'lib/sisu/dp.rb', line 512 def prepared_by_detail names=@h['prepared_by'] \ ? name_format(@h['prepared_by']) : nil names=name_format(@h['prepared_by']) (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end |
#published ⇒ Object
767 768 769 770 771 |
# File 'lib/sisu/dp.rb', line 767 def published s=@h['published']=(@h['published'] ? @h['published'] : @h['main']) l,n=Db[:col_date_text],'date.published' validate_length(s,l,n) end |
#publisher ⇒ Object
732 733 734 735 736 737 738 |
# File 'lib/sisu/dp.rb', line 732 def publisher 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 |
#relation ⇒ Object
865 866 867 868 869 |
# File 'lib/sisu/dp.rb', line 865 def relation s=@h['relation'] l,n=Db[:col_info_note],'notes.relation' validate_length(s,l,n) end |
#rights ⇒ Object
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
# File 'lib/sisu/dp.rb', line 523 def rights a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def copyright def text #you may wish to expand to take from all s=if @h['copyright'] then @h['copyright'] elsif @h['text'] then @h['text'] elsif @h['main'] then @h['main'] else SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Copyright missing; provide @rights: :copyright:' ).warn if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) '' end l,n=Db[:col_info_note],'rights.copyright.text' validate_length(s,l,n) end def translation s=@h['translation'] \ ? @h['translation'] : nil l,n=Db[:col_info_note],'rights.copyright.translation' validate_length(s,l,n) end def illustrations s=@h['illustrations'] \ ? @h['illustrations'] : nil l,n=Db[:col_info_note],'rights.copyright.illustrations' validate_length(s,l,n) end def photographs s=@h['photographs'] \ ? @h['photographs'] : nil l,n=Db[:col_info_note],'rights.copyright.photographs' validate_length(s,l,n) end def digitization s=@h['digitization'] \ ? @h['digitization'] : nil l,n=Db[:col_info_note],'rights.copyright.digitization' validate_length(s,l,n) end def audio s=@h['audio'] \ ? @h['audio'] : nil l,n=Db[:col_info_note],'rights.copyright.audio' validate_length(s,l,n) end self end def license s=@h['license'] \ ? @h['license'] : nil l,n=Db[:col_info_note],'rights.license' validate_length(s,l,n) end def sep(str) ' \\\\ ' end def copyright_and_license s=if @h['copyright_and_license'] then @h['copyright_and_license'] else s='' if defined? copyright.text \ and copyright.text \ and not copyright.text.empty? v=sep(copyright.text) s +=copyright.text + v end if defined? copyright.license \ and copyright.license \ and not copyright.license.empty? s +=copyright.license end if s.empty? SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Rights information missing; provide @rights: :copyright:' ).warn if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) end s=s.gsub(/ [\\]+\s+$/,'') end s end def all s=if @h['all'] then @h['all'] else s='' if defined? copyright.text \ and copyright.text \ and not copyright.text.empty? v=sep(copyright.text) s +='Copyright: ' + copyright.text + v end if defined? copyright.translation \ and copyright.translation \ and not copyright.translation.empty? v=sep(copyright.translation) s +='translation: ' + copyright.translation + v end if defined? copyright.illustrations \ and copyright.illustrations \ and not copyright.illustrations.empty? v=sep(copyright.illustrations) s +='illustrations: ' + copyright.illustrations + v end if defined? copyright.photographs \ and copyright.photographs \ and not copyright.photographs.empty? v=sep(copyright.photographs) s +='photographs: ' + copyright.photographs + v end if defined? copyright.digitization \ and copyright.digitization \ and not copyright.digitization.empty? v=sep(copyright.digitization) s +='digitization: ' + copyright.digitization + v end if defined? copyright.audio \ and copyright.audio \ and not copyright.audio.empty? v=sep(copyright.audio) s +='audio: ' + copyright.audio + v end if defined? copyright.license \ and copyright.license \ and not copyright.license.empty? s +='License: ' + copyright.license end if s.empty? SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Rights information missing; provide @rights: :copyright:' ).warn if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) end s=s.gsub(/ [\\]+\s+$/,'') end s end self end |
#sep(str) ⇒ Object
587 588 589 |
# File 'lib/sisu/dp.rb', line 587 def sep(str) ' \\\\ ' end |
#short ⇒ Object
307 308 309 310 311 312 313 |
# File 'lib/sisu/dp.rb', line 307 def short s=@h['short'] \ ? @h['short'] : @h['main'] l,n=Db[:col_title_part],'title.short' validate_length(s,l,n) end |
#source ⇒ Object
825 826 827 828 829 |
# File 'lib/sisu/dp.rb', line 825 def source s=@h['source'] l,n=Db[:col_name],'original.source' validate_length(s,l,n) end |
#sub ⇒ Object
292 293 294 295 296 |
# File 'lib/sisu/dp.rb', line 292 def sub s=@h['subtitle'] l,n=Db[:col_title_part],'title.subtitle' validate_length(s,l,n) end |
#subject ⇒ Object
710 711 712 713 714 |
# File 'lib/sisu/dp.rb', line 710 def subject s=@h['subject'] l,n=Db[:col_txt_long],'classify.subject' validate_length(s,l,n) end |
#text ⇒ Object
you may wish to expand to take from all
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/sisu/dp.rb', line 527 def text #you may wish to expand to take from all s=if @h['copyright'] then @h['copyright'] elsif @h['text'] then @h['text'] elsif @h['main'] then @h['main'] else SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Copyright missing; provide @rights: :copyright:' ).warn if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) '' end l,n=Db[:col_info_note],'rights.copyright.text' validate_length(s,l,n) end |
#title ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/sisu/dp.rb', line 284 def title a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @h=build_hash(a) def main s=@h['main'] l,n=Db[:col_title_part],'title.main' validate_length(s,l,n) end def sub s=@h['subtitle'] l,n=Db[:col_title_part],'title.subtitle' validate_length(s,l,n) end def edition s=@h['edition'] l,n=Db[:col_title_edition],'title.edition' validate_length(s,l,n) end def note s=@h['note'] l,n=Db[:col_info_note],'title.note' validate_length(s,l,n) end def short s=@h['short'] \ ? @h['short'] : @h['main'] l,n=Db[:col_title_part],'title.short' validate_length(s,l,n) end def full s=@h['subtitle'] \ ? (@h['main'] + ' - ' + @h['subtitle']) : @h['main'] l,n=Db[:col_title],'title.full' validate_length(s,l,n) end def language s=@h['language'] l,n=Db[:col_language],'title.language' validate_length(s,l,n) end def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n :language_char: fi)] s=@h['language_char'] l,n=Db[:col_language_char],'title.language_char' validate_length(s,l,n) end self end |
#topic_register ⇒ Object
705 706 707 708 709 |
# File 'lib/sisu/dp.rb', line 705 def topic_register s=@h['topic_register'] l,n=Db[:col_info_note],'classify.topic_register' validate_length(s,l,n) end |
#translation ⇒ Object
543 544 545 546 547 548 549 |
# File 'lib/sisu/dp.rb', line 543 def translation s=@h['translation'] \ ? @h['translation'] : nil l,n=Db[:col_info_note],'rights.copyright.translation' validate_length(s,l,n) end |
#translator ⇒ Object
436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/sisu/dp.rb', line 436 def translator names=@h['translator'] \ ? name_format(@h['translator']) : nil s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s l,n=Db[:col_name],'creator.translator' validate_length(s,l,n) else nil end end |
#translator_detail ⇒ Object
449 450 451 452 453 454 455 456 |
# File 'lib/sisu/dp.rb', line 449 def translator_detail names=@h['translator'] \ ? name_format(@h['translator']) : nil (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end |
#type ⇒ Object
880 881 882 883 884 |
# File 'lib/sisu/dp.rb', line 880 def type s=@h['type'] l,n=Db[:col_txt_long],'notes.relation' validate_length(s,l,n) end |
#valid ⇒ Object
772 773 774 775 776 |
# File 'lib/sisu/dp.rb', line 772 def valid s=@h['valid'] l,n=Db[:col_date_text],'date.valid' validate_length(s,l,n) end |
#validate_length(s, l, n) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/sisu/dp.rb', line 199 def validate_length(s,l,n) #s=(s.length <= l) ? s : nil s=if s.is_a?(String) \ and s.length <= l s elsif s.is_a?(NilClass) nil elsif s.class !=String STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" s else SiSU_Screen::Ansi.new( 'v', "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", @opt.fns ).warn unless @opt.act[:quiet][:set]==:on nil end end |