elibri_onix_generator 0.1.12 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/elibri_onix_generator.rb +141 -105
- data/lib/elibri_onix_generator/version.rb +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3270120d4942f7762c8324084c3e350c633f8fdd
|
4
|
+
data.tar.gz: a411edca6e46396de9f3fccccda13f67a6b91073
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47755cfe49aa15405887c930c389d19422543c2a014705a23c491150a7594ba67c1acea96c6a424e4f1dcd624a39bbb61221b1664dde1edcd7441c6a3de497e1
|
7
|
+
data.tar.gz: c0b454eed0221156594e9f4cbc79924a844329a0fb8b478425cf70daf8eb5ca78aeedc30441c95735f283a37ae4420a349d3b189c5beffb973fcfc33e1e8e8e5
|
@@ -206,7 +206,7 @@ module Elibri
|
|
206
206
|
export_languages!(product) #PR.10
|
207
207
|
export_extent!(product) #PR.11
|
208
208
|
export_subjects!(product) #PR.12
|
209
|
-
export_audience_range!(product) if product.audience_range_present? #PR.13
|
209
|
+
export_audience_range!(product) if product.respond_to?(:audience_range_present?) && product.audience_range_present? #PR.13
|
210
210
|
end
|
211
211
|
end
|
212
212
|
if @xml_variant.includes_other_texts? || @xml_variant.includes_media_files?
|
@@ -227,12 +227,12 @@ module Elibri
|
|
227
227
|
export_publisher_info!(product) #P.19
|
228
228
|
export_publishing_status!(product) #PR.20
|
229
229
|
export_territorial_rights!(product)
|
230
|
-
export_sale_restrictions!(product) if product.sale_restricted? #PR.21
|
230
|
+
export_sale_restrictions!(product) if product.respond_to?(:sale_restricted?) && product.sale_restricted? #PR.21
|
231
231
|
end
|
232
232
|
remove_tag_if_empty!(:PublishingDetail)
|
233
|
-
|
233
|
+
|
234
234
|
#P.23 - related products
|
235
|
-
if product.facsimiles.present?
|
235
|
+
if product.respond_to?(:facsimiles) && product.facsimiles.present?
|
236
236
|
export_related_products!(product)
|
237
237
|
end
|
238
238
|
#P.24 - Market
|
@@ -287,7 +287,7 @@ module Elibri
|
|
287
287
|
tag(:DeletionText, product.deletion_text)
|
288
288
|
end
|
289
289
|
|
290
|
-
if product.isbn_value
|
290
|
+
if product.respond_to?(:isbn_value) && product.isbn_value
|
291
291
|
comment 'ISBN', :kind => :onix_record_identifiers
|
292
292
|
tag(:ProductIdentifier) do
|
293
293
|
tag(:ProductIDType, Elibri::ONIX::Dict::Release_3_0::ProductIDType::ISBN13) #lista 5
|
@@ -295,7 +295,7 @@ module Elibri
|
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
|
-
if product.ean.present? && product.ean != product.isbn_value
|
298
|
+
if product.respond_to?(:ean) && product.ean.present? && product.ean != product.isbn_value
|
299
299
|
comment 'EAN-13 - gdy inny niż ISBN', :kind => :onix_record_identifiers
|
300
300
|
|
301
301
|
tag(:ProductIdentifier) do
|
@@ -304,14 +304,24 @@ module Elibri
|
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
|
+
if product.respond_to?(:external_identifier) && product.external_identifier
|
308
|
+
tag(:ProductIdentifier) do
|
309
|
+
tag(:ProductIDType, Elibri::ONIX::Dict::Release_3_0::ProductIDType::PROPRIETARY) #lista 5
|
310
|
+
tag(:IDTypeName, product.external_identifier.type_name)
|
311
|
+
tag(:IDValue, product.external_identifier.value)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
307
315
|
if @xml_variant.includes_stocks?
|
308
|
-
product.product_availabilities
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
tag(:
|
313
|
-
|
314
|
-
|
316
|
+
if product.respond_to?(:product_availabilities)
|
317
|
+
product.product_availabilities.each do |pa|
|
318
|
+
if pa.supplier_identifier.present?
|
319
|
+
comment "Identyfikator dostawcy: #{pa.supplier.name}", :kind => :onix_record_identifiers
|
320
|
+
tag(:ProductIdentifier) do
|
321
|
+
tag(:ProductIDType, Elibri::ONIX::Dict::Release_3_0::ProductIDType::PROPRIETARY) #lista 5
|
322
|
+
tag(:IDTypeName, pa.supplier.name)
|
323
|
+
tag(:IDValue, pa.supplier_identifier)
|
324
|
+
end
|
315
325
|
end
|
316
326
|
end
|
317
327
|
end
|
@@ -361,24 +371,24 @@ module Elibri
|
|
361
371
|
# Przykład użycia w pierwszym przykładzie.
|
362
372
|
#
|
363
373
|
def export_epub_details!(product)
|
364
|
-
if product.product_form_detail_onix_codes.present? #lista 175
|
374
|
+
if product.respond_to?(:product_form_detail_onix_codes) && product.product_form_detail_onix_codes.present? #lista 175
|
365
375
|
comment_dictionary "Dostępne formaty produktu", :ProductFormDetail, :indent => 10, :kind => :onix_epub_details
|
366
376
|
product.product_form_detail_onix_codes.each do |onix_code|
|
367
377
|
tag(:ProductFormDetail, onix_code)
|
368
378
|
end
|
369
379
|
end
|
370
|
-
|
371
|
-
if product.digital?
|
380
|
+
|
381
|
+
if product.respond_to?(:digital?) && product.digital?
|
372
382
|
if product.epub_technical_protection
|
373
383
|
comment_dictionary "Zabezpieczenie", :EpubTechnicalProtection, :indent => 10, :kind => :onix_epub_details
|
374
384
|
tag(:EpubTechnicalProtection, product.epub_technical_protection_onix_code)
|
375
385
|
end
|
376
|
-
|
386
|
+
|
377
387
|
if product.epub_fragment_info?
|
378
388
|
tag(:EpubUsageConstraint) do
|
379
389
|
comment "Rodzaj ograniczenia - w tym przypadku zawsze dotyczy dostępności fragmentu książki", :indent => 12, :kind => :onix_epub_details
|
380
390
|
tag(:EpubUsageType, Elibri::ONIX::Dict::Release_3_0::EpubUsageType::PREVIEW)
|
381
|
-
|
391
|
+
|
382
392
|
comment_dictionary "Jaka jest decyzja wydawcy?", :EpubUsageStatus, :indent => 12, :kind => :onix_epub_details
|
383
393
|
tag(:EpubUsageStatus, product.epub_publication_preview_usage_status_onix_code)
|
384
394
|
if product.epub_publication_preview_usage_status_onix_code == Elibri::ONIX::Dict::Release_3_0::EpubUsageStatus::LIMITED
|
@@ -403,25 +413,26 @@ module Elibri
|
|
403
413
|
# Następujące atrybuty są udostępniane: wysokość, szerokość, grubość oraz masę produktu. Pierwsze trzy podajemy zawsze w milimetrach, masę w gramach.
|
404
414
|
# W przypadku map eksportujemy również jej skalę w tagu <MapScale>
|
405
415
|
def export_measurement!(product)
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
416
|
+
if product.respond_to?(:kind_of_measurable?) && product.kind_of_measurable?
|
417
|
+
[[product.height, Elibri::ONIX::Dict::Release_3_0::MeasureType::HEIGHT, Product::HEIGHT_UNIT, 'Wysokość'],
|
418
|
+
[product.width, Elibri::ONIX::Dict::Release_3_0::MeasureType::WIDTH, Product::WIDTH_UNIT, 'Szerokość'],
|
419
|
+
[product.thickness, Elibri::ONIX::Dict::Release_3_0::MeasureType::THICKNESS, Product::THICKNESS_UNIT, 'Grubość'],
|
420
|
+
[product.weight, Elibri::ONIX::Dict::Release_3_0::MeasureType::WEIGHT, Product::WEIGHT_UNIT, 'Masa']
|
421
|
+
].each do |value, measure_type_code, unit_code, name|
|
422
|
+
if value
|
423
|
+
tag(:Measure) do
|
424
|
+
comment "#{name}: #{value}#{unit_code}", :kind => :onix_measurement
|
425
|
+
tag(:MeasureType, measure_type_code) #lista 48
|
426
|
+
tag(:Measurement, value)
|
427
|
+
tag(:MeasureUnitCode, unit_code)
|
428
|
+
end
|
418
429
|
end
|
419
|
-
|
420
|
-
end
|
430
|
+
end
|
421
431
|
|
422
|
-
|
423
|
-
|
424
|
-
|
432
|
+
if product.respond_to?(:kind_of_map?) && product.respond_to?(:map_scale) && product.kind_of_map? and product.map_scale
|
433
|
+
comment 'Skala mapy - tylko dla produktów typu mapa'
|
434
|
+
tag(:MapScale, product.map_scale)
|
435
|
+
end
|
425
436
|
end
|
426
437
|
end
|
427
438
|
|
@@ -481,13 +492,12 @@ module Elibri
|
|
481
492
|
end
|
482
493
|
end
|
483
494
|
|
484
|
-
distribution_start
|
485
|
-
if distribution_start
|
495
|
+
if product.respond_to?(:distribution_start) && product.distribution_start
|
486
496
|
tag(:PublishingDate) do
|
487
497
|
comment "Jeśli 27 - to data początku przyjmowania zamówień na dany tytuł"
|
488
498
|
tag(:PublishingDateRole, Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::PREORDER_EMBARGO_DATE) #lista 163
|
489
499
|
tag(:DateFormat, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDD)
|
490
|
-
tag(:Date, distribution_start.strftime("%Y%m%d"))
|
500
|
+
tag(:Date, product.distribution_start.strftime("%Y%m%d"))
|
491
501
|
end
|
492
502
|
end
|
493
503
|
end
|
@@ -498,14 +508,16 @@ module Elibri
|
|
498
508
|
# albo pozwolić na sprzedaż na całym świecie. Poniżej dwa przykłady, jeden dla wyłączości na terenie Polski, drugi
|
499
509
|
# dopuszczający sprzedaż na całym świecie. Informacja o ograniczeniu jest zawarta w obręcie <strong><SalesRights></strong>
|
500
510
|
def export_territorial_rights!(product)
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
511
|
+
if product.respond_to?(:sale_restricted_to_poland?)
|
512
|
+
tag(:SalesRights) do
|
513
|
+
comment "Typ restrykcji - sprzedaż tylko w wymienionym kraju, regionie, zawsze '01'", :kind => :onix_territorial_rights
|
514
|
+
tag(:SalesRightsType, "01")
|
515
|
+
tag(:Territory) do
|
516
|
+
if product.sale_restricted_to_poland?
|
517
|
+
tag(:CountriesIncluded, "PL")
|
518
|
+
else
|
519
|
+
tag(:RegionsIncluded, "WORLD")
|
520
|
+
end
|
509
521
|
end
|
510
522
|
end
|
511
523
|
end
|
@@ -568,29 +580,31 @@ module Elibri
|
|
568
580
|
# Jeśli wydawnictwo uzupełnia nazwę imprintu, to powinna być ona traktowana jako nazwa wydawnictwa przy prezentacji
|
569
581
|
# książki klientowi końcowemu.
|
570
582
|
def export_publisher_info!(product)
|
571
|
-
if product.
|
583
|
+
if product.respond_to?(:imprint_for_onix) && product.imprint_for_onix
|
572
584
|
tag(:Imprint) do
|
573
585
|
comment "Nazwa imprintu", :kind => :onix_publisher_info
|
574
|
-
tag(:ImprintName, product.
|
586
|
+
tag(:ImprintName, product.imprint_for_onix.name)
|
575
587
|
end
|
576
588
|
end
|
577
589
|
|
578
|
-
if product.
|
590
|
+
if product.respond_to?(:publisher_name_for_onix) && product.publisher_name_for_onix
|
579
591
|
tag(:Publisher) do
|
580
592
|
comment "Wydawca - używamy tylko kodu 01 (główny wydawca)", :kind => :onix_publisher_info
|
581
593
|
tag(:PublishingRole, '01') # Publisher, lista 45 #TODO jeszcze może być współwydawca
|
582
|
-
|
583
|
-
tag(:
|
584
|
-
|
585
|
-
|
594
|
+
if product.respond_to?(:publisher_id_for_onix)
|
595
|
+
tag(:PublisherIdentifier) do
|
596
|
+
tag(:PublisherIDType, '01') #prioprietary
|
597
|
+
tag(:IDTypeName, 'ElibriPublisherCode')
|
598
|
+
tag(:IDValue, product.publisher_id_for_onix)
|
599
|
+
end
|
586
600
|
end
|
587
|
-
tag(:PublisherName, product.
|
601
|
+
tag(:PublisherName, product.publisher_name_for_onix)
|
588
602
|
end
|
589
603
|
end
|
590
604
|
|
591
|
-
if product.city_of_publication.present?
|
605
|
+
if product.respond_to?(:city_of_publication) && product.city_of_publication.present?
|
592
606
|
tag(:CityOfPublication, product.city_of_publication)
|
593
|
-
elsif product.publisher.city.present?
|
607
|
+
elsif product.respond_to?(:publisher) && product.publisher.city.present?
|
594
608
|
tag(:CityOfPublication, product.publisher.city)
|
595
609
|
end
|
596
610
|
end
|
@@ -607,7 +621,7 @@ module Elibri
|
|
607
621
|
# I przykład dla audiobook-a, z czasem trwania nagrania:
|
608
622
|
# @render onix_audiobook_extent_example
|
609
623
|
def export_extent!(product)
|
610
|
-
if product.digital? and product.file_size
|
624
|
+
if product.respond_to?(:digital?) && product.respond_to?(:file_size) && product.digital? and product.file_size
|
611
625
|
tag(:Extent) do
|
612
626
|
comment 'Rozmiar pliku (w MB) - tylko dla produktów cyfrowych (e-book, audiobook)', :kind => :onix_extent
|
613
627
|
tag(:ExtentType, Elibri::ONIX::Dict::Release_3_0::ExtentType::FILE_SIZE)
|
@@ -617,7 +631,7 @@ module Elibri
|
|
617
631
|
end
|
618
632
|
end
|
619
633
|
|
620
|
-
if product.kind_of_audio? and product.duration
|
634
|
+
if product.respond_to?(:kind_of_audio?) && product.respond_to?(:duration) && product.kind_of_audio? and product.duration
|
621
635
|
tag(:Extent) do
|
622
636
|
comment 'Czas trwania (w minutach) - tylko dla produktów typu audio', :kind => :onix_extent
|
623
637
|
tag(:ExtentType, Elibri::ONIX::Dict::Release_3_0::ExtentType::DURATION)
|
@@ -627,7 +641,8 @@ module Elibri
|
|
627
641
|
end
|
628
642
|
end
|
629
643
|
|
630
|
-
if
|
644
|
+
if product.respond_to?(:kind_of_book?) && product.respond_to?(:kind_of_ebook?) && product.respond_to?(:number_of_pages) &&
|
645
|
+
(product.kind_of_book? or product.kind_of_ebook?) && product.number_of_pages #number_of_pages to int
|
631
646
|
tag(:Extent) do
|
632
647
|
comment 'Liczba stron - tylko dla produktów typu książka', :kind => :onix_extent
|
633
648
|
tag(:ExtentType, Elibri::ONIX::Dict::Release_3_0::ExtentType::PAGE_COUNT)
|
@@ -635,8 +650,8 @@ module Elibri
|
|
635
650
|
tag(:ExtentUnit, Elibri::ONIX::Dict::Release_3_0::ExtentUnit::PAGES)
|
636
651
|
end
|
637
652
|
end
|
638
|
-
|
639
|
-
|
653
|
+
if product.respond_to?(:kind_of_book?) && product.respond_to?(:kind_of_ebook?) && product.respond_to?(:number_of_illustrations) &&
|
654
|
+
(product.kind_of_book? or product.kind_of_ebook?) and product.number_of_illustrations
|
640
655
|
comment 'Liczba ilustracji - tylko dla produktów typu książka', :kind => :onix_extent
|
641
656
|
tag(:NumberOfIllustrations, product.number_of_illustrations)
|
642
657
|
end
|
@@ -648,29 +663,30 @@ module Elibri
|
|
648
663
|
# eLibri stosuje wewnętrzną hierarchę kategorii, ich lista dostępna jest
|
649
664
|
# = link_to "tutaj", doc_api_path("categories")
|
650
665
|
def export_subjects!(product)
|
651
|
-
if product.elibri_product_categories.present? or product.publisher_product_categories.present?
|
652
|
-
comment 'Stosujemy wewnętrzną kategoryzację.'
|
653
|
-
end
|
654
666
|
|
655
667
|
# Kategorie wg. eLibri
|
656
|
-
product.elibri_product_categories
|
657
|
-
|
658
|
-
tag(:
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
668
|
+
if product.respond_to?(:elibri_product_categories)
|
669
|
+
product.elibri_product_categories.each_with_index do |product_category, i|
|
670
|
+
tag(:Subject) do
|
671
|
+
tag(:MainSubject) if i.zero?
|
672
|
+
tag(:SubjectSchemeIdentifier, Elibri::ONIX::Dict::Release_3_0::SubjectSchemeIdentifier::PROPRIETARY)
|
673
|
+
tag(:SubjectSchemeName, 'elibri.com.pl')
|
674
|
+
tag(:SubjectSchemeVersion, '1.0')
|
675
|
+
tag(:SubjectCode, product_category.id)
|
676
|
+
tag(:SubjectHeadingText, product_category.full_node_path_name)
|
677
|
+
end
|
664
678
|
end
|
665
679
|
end
|
666
680
|
|
667
681
|
# Kategorie wg. wydawnictwa
|
668
|
-
product.publisher_product_categories
|
669
|
-
|
670
|
-
tag(:
|
671
|
-
|
672
|
-
|
673
|
-
|
682
|
+
if product.respond_to?(:publisher_product_categories)
|
683
|
+
product.publisher_product_categories.each do |product_category|
|
684
|
+
tag(:Subject) do
|
685
|
+
tag(:SubjectSchemeIdentifier, Elibri::ONIX::Dict::Release_3_0::SubjectSchemeIdentifier::PROPRIETARY)
|
686
|
+
tag(:SubjectSchemeName, product.publisher_name)
|
687
|
+
tag(:SubjectCode, product_category.id)
|
688
|
+
tag(:SubjectHeadingText, product_category.name)
|
689
|
+
end
|
674
690
|
end
|
675
691
|
end
|
676
692
|
end
|
@@ -712,20 +728,23 @@ module Elibri
|
|
712
728
|
if product.authorship_kind.user_given?
|
713
729
|
comment 'Gdy wyszczególniono autorów', :kind => :onix_contributors if product.contributors.present?
|
714
730
|
product.contributors.each_with_index do |contributor, idx|
|
715
|
-
|
731
|
+
options = {}
|
732
|
+
options[:sourcename] = "contributorid:#{contributor.id}" if contributor.respond_to?(:id)
|
733
|
+
options[:datestamp] = contributor.updated_at.to_s(:onix) if contributor.respond_to?(:updated_at)
|
734
|
+
tag(:Contributor, options) do
|
716
735
|
tag(:SequenceNumber, idx + 1)
|
717
736
|
comment_dictionary 'Rola autora', :ContributorRole, :indent => 10, :kind => :onix_contributors
|
718
737
|
tag(:ContributorRole, contributor.role_onix_code) #lista 17
|
719
738
|
comment 'Tylko w przypadku tłumaczy:', :kind => :onix_contributors
|
720
|
-
tag(:FromLanguage, contributor.language_onix_code) if contributor.language_onix_code
|
739
|
+
tag(:FromLanguage, contributor.language_onix_code) if contributor.respond_to?(:language_onix_code) && contributor.language_onix_code.present?
|
721
740
|
tag(:PersonName, contributor.generated_full_name) #zawsze jest TODO - dodać takie pole do bazy danych
|
722
741
|
|
723
|
-
tag(:TitlesBeforeNames, contributor.title) if contributor.title.present? #tytuł
|
724
|
-
tag(:NamesBeforeKey, contributor.name) if contributor.name.present? #imię
|
725
|
-
tag(:PrefixToKey, contributor.last_name_prefix) if contributor.last_name_prefix.present? #van, von
|
726
|
-
tag(:KeyNames, contributor.last_name) if contributor.last_name.present?
|
727
|
-
tag(:NamesAfterKey, contributor.last_name_postfix) if contributor.last_name_postfix.present?
|
728
|
-
tag(:BiographicalNote, contributor.biography.text) if contributor.biography
|
742
|
+
tag(:TitlesBeforeNames, contributor.title) if contributor.respond_to?(:title) && contributor.title.present? #tytuł
|
743
|
+
tag(:NamesBeforeKey, contributor.name) if contributor.respond_to?(:name) && contributor.name.present? #imię
|
744
|
+
tag(:PrefixToKey, contributor.last_name_prefix) if contributor.respond_to?(:last_name_prefix) && contributor.last_name_prefix.present? #van, von
|
745
|
+
tag(:KeyNames, contributor.last_name) if contributor.respond_to?(:last_name) && contributor.last_name.present?
|
746
|
+
tag(:NamesAfterKey, contributor.last_name_postfix) if contributor.respond_to?(:last_name_postfix) && contributor.last_name_postfix.present?
|
747
|
+
tag(:BiographicalNote, contributor.biography.text) if contributor.respond_to?(:biography) && contributor.biography
|
729
748
|
end
|
730
749
|
end
|
731
750
|
end
|
@@ -782,7 +801,7 @@ module Elibri
|
|
782
801
|
end
|
783
802
|
end
|
784
803
|
end
|
785
|
-
if product.original_title.present?
|
804
|
+
if product.respond_to?(:original_title) && product.original_title.present?
|
786
805
|
tag(:TitleDetail) do
|
787
806
|
comment "Tytuł w języku oryginału - #{Elibri::ONIX::Dict::Release_3_0::TitleType::DISTINCTIVE_TITLE}", :kind => :onix_titles
|
788
807
|
tag(:TitleType, Elibri::ONIX::Dict::Release_3_0::TitleType::ORIGINAL_TITLE)
|
@@ -793,7 +812,7 @@ module Elibri
|
|
793
812
|
end
|
794
813
|
end
|
795
814
|
end
|
796
|
-
if product.trade_title.present?
|
815
|
+
if product.respond_to?(:trade_title) && product.trade_title.present?
|
797
816
|
tag(:TitleDetail) do
|
798
817
|
comment "Tytuł handlowy używany przez wydawnictwo - #{Elibri::ONIX::Dict::Release_3_0::TitleType::DISTRIBUTORS_TITLE}", :kind => :onix_titles
|
799
818
|
tag(:TitleType, Elibri::ONIX::Dict::Release_3_0::TitleType::DISTRIBUTORS_TITLE) #tytuł produktu
|
@@ -810,7 +829,7 @@ module Elibri
|
|
810
829
|
# @hidden_tags RecordReference NotificationType ProductIdentifier ProductComposition ProductForm TitleDetail
|
811
830
|
# @title Opis wydania
|
812
831
|
def export_edition!(product)
|
813
|
-
if product.edition_statement.present?
|
832
|
+
if product.respond_to?(:edition_statement) && product.edition_statement.present?
|
814
833
|
comment 'Opis wydania', :kind => :onix_edition
|
815
834
|
tag(:EditionStatement, product.edition_statement)
|
816
835
|
end
|
@@ -821,11 +840,13 @@ module Elibri
|
|
821
840
|
# @title Języki
|
822
841
|
# Języki, w których dostępny jest produkt.
|
823
842
|
def export_languages!(product)
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
tag(:
|
828
|
-
|
843
|
+
if product.respond_to?(:languages)
|
844
|
+
comment_dictionary 'Rola języka', :LanguageRole, :indent => 10, :kind => :onix_languages if product.languages.present?
|
845
|
+
product.languages.each do |language|
|
846
|
+
tag(:Language) do
|
847
|
+
tag(:LanguageRole, language.role_onix_code) #lista 22
|
848
|
+
tag(:LanguageCode, language.language_onix_code) #lista 74
|
849
|
+
end
|
829
850
|
end
|
830
851
|
end
|
831
852
|
end
|
@@ -842,12 +863,15 @@ module Elibri
|
|
842
863
|
#jeśli jest pusty tekst, nie nadaje się do umieszczania w ONIX albo tekst dotyczy autora (type_onix_code.blank?) -> nie exportuj
|
843
864
|
next if other_text.text.blank? || other_text.type_onix_code.blank? || !other_text.exportable?
|
844
865
|
|
845
|
-
|
866
|
+
options = {}
|
867
|
+
options[:sourcename] = "textid:#{other_text.id}" if other_text.respond_to?(:id)
|
868
|
+
options[:datestamp] = other_text.updated_at.to_s(:onix) if other_text.respond_to?(:updated_at)
|
869
|
+
tag(:TextContent, options) do
|
846
870
|
tag(:TextType, other_text.type_onix_code) #lista 153
|
847
871
|
comment "Zawsze #{Elibri::ONIX::Dict::Release_3_0::ContentAudience::UNRESTRICTED} - Unrestricted", :kind => :onix_texts
|
848
872
|
tag(:ContentAudience, Elibri::ONIX::Dict::Release_3_0::ContentAudience::UNRESTRICTED)
|
849
873
|
|
850
|
-
if other_text.is_a_review? && other_text.resource_link.present?
|
874
|
+
if other_text.respond_to?(:is_a_review?) && other_text.respond_to?(:resource_link) && other_text.is_a_review? && other_text.resource_link.present?
|
851
875
|
text_source = {:sourcename => other_text.resource_link}
|
852
876
|
else
|
853
877
|
text_source = {}
|
@@ -857,8 +881,8 @@ module Elibri
|
|
857
881
|
builder.cdata!(other_text.text)
|
858
882
|
end
|
859
883
|
|
860
|
-
tag(:TextAuthor, other_text.text_author) if other_text.text_author.present?
|
861
|
-
tag(:SourceTitle, other_text.source_title) if other_text.source_title.present?
|
884
|
+
tag(:TextAuthor, other_text.text_author) if other_text.respond_to?(:text_author) && other_text.text_author.present?
|
885
|
+
tag(:SourceTitle, other_text.source_title) if other_text.respond_to?(:source_title) && other_text.source_title.present?
|
862
886
|
end
|
863
887
|
end
|
864
888
|
end
|
@@ -871,7 +895,10 @@ module Elibri
|
|
871
895
|
def export_supporting_resources!(product)
|
872
896
|
product.attachments.each do |attachment|
|
873
897
|
if attachment.onix_resource_mode #jeśli klient coś dzikiego wgrał, to ignoruj to
|
874
|
-
|
898
|
+
options = {}
|
899
|
+
options[:sourcename] = "resourceid:#{attachment.id}" if attachment.respond_to?(:id)
|
900
|
+
options[:datestamp] = attachment.updated_at.to_s(:onix) if attachment.respond_to?(:updated_at)
|
901
|
+
tag(:SupportingResource, options) do
|
875
902
|
comment_dictionary 'Typ załącznika', :ResourceContentType, :indent => 12, :kind => :onix_supporting_resources
|
876
903
|
tag(:ResourceContentType, attachment.attachment_type_code) #lista 158
|
877
904
|
comment 'Zawsze 00 - Unrestricted', :kind => :onix_supporting_resources
|
@@ -882,7 +909,7 @@ module Elibri
|
|
882
909
|
comment 'Zawsze 02 - Downloadable file', :kind => :onix_supporting_resources
|
883
910
|
tag(:ResourceForm, Elibri::ONIX::Dict::Release_3_0::ResourceForm::DOWNLOADABLE_FILE)
|
884
911
|
url = attachment.file.url
|
885
|
-
if url.index("http://") #w sklepie zwraca mi całego linka, wygodniej mi jest to tutaj wychwycić
|
912
|
+
if url.index("http://") || url.index("https://") #w sklepie zwraca mi całego linka, wygodniej mi jest to tutaj wychwycić
|
886
913
|
tag(:ResourceLink, URI.escape(url))
|
887
914
|
else
|
888
915
|
tag(:ResourceLink, URI.escape('http://' + HOST_NAME + url))
|
@@ -901,11 +928,19 @@ module Elibri
|
|
901
928
|
# Oprócz nazwy serii może zostać również podany numer wewnątrz serii, jeśli seria jest numerowana.
|
902
929
|
# Książka może należeć do kilku serii, wtedy tag <strong><Collection></strong> występuje kilkukrotnie.
|
903
930
|
def export_series_memberships!(product)
|
904
|
-
if product.series_membership_kind.user_given?
|
905
|
-
product.series_memberships.each_with_index do |series_membership, idx|
|
931
|
+
if product.respond_to?(:series_membership_kind) && (product.series_membership_kind.user_given? || product.collection_with_issn)
|
932
|
+
(product.series_memberships + [product.collection_with_issn]).compact.each_with_index do |series_membership, idx|
|
906
933
|
tag(:Collection) do
|
907
934
|
comment "Używamy tylko #{Elibri::ONIX::Dict::Release_3_0::CollectionType::PUBLISHER_COLLECTION} - seria wydawnictwa", :kind => :onix_series_memberships
|
908
935
|
tag(:CollectionType, Elibri::ONIX::Dict::Release_3_0::CollectionType::PUBLISHER_COLLECTION) #lista 148
|
936
|
+
|
937
|
+
if series_membership.respond_to?(:issn) && series_membership.issn.present?
|
938
|
+
comment "W przypadku prasy serializowany jest numer ISSN"
|
939
|
+
tag(:CollectionIdentifier) do
|
940
|
+
tag(:CollectionIDType, "02") #issn - lista 13
|
941
|
+
tag(:IDValue, series_membership.issn)
|
942
|
+
end
|
943
|
+
end
|
909
944
|
comment "Teraz następuje podobna struktura, jak w przypadku tytułu", :kind => :onix_series_memberships
|
910
945
|
tag(:TitleDetail) do
|
911
946
|
comment "Używamy tylko #{Elibri::ONIX::Dict::Release_3_0::TitleType::DISTINCTIVE_TITLE}", :kind => :onix_series_memberships
|
@@ -938,8 +973,8 @@ module Elibri
|
|
938
973
|
tag(:ProductIDType, Elibri::ONIX::Dict::Release_3_0::ProductIDType::PROPRIETARY)
|
939
974
|
tag(:IDTypeName, "elibri")
|
940
975
|
tag(:IDValue, facsimile.record_reference)
|
941
|
-
end
|
942
|
-
end
|
976
|
+
end
|
977
|
+
end
|
943
978
|
end
|
944
979
|
end
|
945
980
|
end
|
@@ -953,7 +988,7 @@ module Elibri
|
|
953
988
|
# identyfikatorów produktu. Poza podstawowym <strong><ProductIdentifier></strong>, znajdują się także identyfikatory
|
954
989
|
# poszczególnych dostawców. Tag <strong><IDTypeName></strong> zawiera nazwę dostawcy.
|
955
990
|
def export_supply_details!(product)
|
956
|
-
return if product.respond_to?(:skip_ProductSupply) && product.skip_ProductSupply
|
991
|
+
return if product.respond_to?(:skip_ProductSupply) && product.skip_ProductSupply || !product.respond_to?(:product_availabilities)
|
957
992
|
unless product.product_availabilities.empty?
|
958
993
|
tag(:ProductSupply) do
|
959
994
|
product.product_availabilities.each do |pa|
|
@@ -1043,6 +1078,7 @@ module Elibri
|
|
1043
1078
|
comment 'Vat w procentach'
|
1044
1079
|
tag("elibri:Vat", product.vat) if product.vat.present?
|
1045
1080
|
tag("elibri:PKWiU", product.pkwiu) if product.pkwiu.present?
|
1081
|
+
tag("elibri:PDWExclusiveness", product.pdw_exclusiveness) if product.pdw_exclusiveness.present?
|
1046
1082
|
tag("elibri:preview_exists", product.preview_exists?.to_s)
|
1047
1083
|
if product.digital?
|
1048
1084
|
if product.epub_sale_not_restricted? || product.epub_sale_restricted_to.nil?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elibri_onix_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Urbański
|
@@ -9,20 +9,20 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
description: XML Generator used by Elibri gems
|
@@ -33,7 +33,7 @@ executables: []
|
|
33
33
|
extensions: []
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
|
-
- .gitignore
|
36
|
+
- ".gitignore"
|
37
37
|
- Gemfile
|
38
38
|
- README
|
39
39
|
- Rakefile
|
@@ -50,19 +50,18 @@ require_paths:
|
|
50
50
|
- lib
|
51
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
62
|
rubyforge_project: elibri_onix_generator
|
63
|
-
rubygems_version: 2.
|
63
|
+
rubygems_version: 2.4.8
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: XML Generator used by Elibri gems
|
67
67
|
test_files: []
|
68
|
-
has_rdoc:
|