elibri_onix 0.5.18 → 0.6.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/external_timestamp.rb +2 -2
- data/lib/elibri_onix/onix_3_0/audience_range.rb +4 -17
- data/lib/elibri_onix/onix_3_0/collection.rb +0 -0
- data/lib/elibri_onix/onix_3_0/contributor.rb +15 -38
- data/lib/elibri_onix/onix_3_0/excerpt_info.rb +8 -21
- data/lib/elibri_onix/onix_3_0/extent.rb +9 -24
- data/lib/elibri_onix/onix_3_0/file_info.rb +2 -13
- data/lib/elibri_onix/onix_3_0/header.rb +7 -17
- data/lib/elibri_onix/onix_3_0/imprint.rb +2 -18
- data/lib/elibri_onix/onix_3_0/language.rb +5 -22
- data/lib/elibri_onix/onix_3_0/measure.rb +4 -18
- data/lib/elibri_onix/onix_3_0/onix_message.rb +2 -17
- data/lib/elibri_onix/onix_3_0/price.rb +14 -25
- data/lib/elibri_onix/onix_3_0/price_constraint_limit.rb +22 -0
- data/lib/elibri_onix/onix_3_0/price_identifier.rb +18 -0
- data/lib/elibri_onix/onix_3_0/product.rb +63 -131
- data/lib/elibri_onix/onix_3_0/product_identifier.rb +6 -22
- data/lib/elibri_onix/onix_3_0/publisher.rb +4 -21
- data/lib/elibri_onix/onix_3_0/publisher_subject.rb +3 -13
- data/lib/elibri_onix/onix_3_0/publishing_date.rb +3 -21
- data/lib/elibri_onix/onix_3_0/related_product.rb +5 -24
- data/lib/elibri_onix/onix_3_0/sales_restriction.rb +5 -22
- data/lib/elibri_onix/onix_3_0/sender.rb +0 -12
- data/lib/elibri_onix/onix_3_0/stock_quantity_coded.rb +4 -19
- data/lib/elibri_onix/onix_3_0/supplier.rb +7 -25
- data/lib/elibri_onix/onix_3_0/supplier_identifier.rb +4 -23
- data/lib/elibri_onix/onix_3_0/supply_detail.rb +9 -26
- data/lib/elibri_onix/onix_3_0/supporting_resource.rb +7 -20
- data/lib/elibri_onix/onix_3_0/text_content.rb +9 -24
- data/lib/elibri_onix/onix_3_0/thema_subject.rb +2 -15
- data/lib/elibri_onix/onix_3_0/title_detail.rb +9 -28
- data/lib/elibri_onix/onix_3_0/title_element.rb +10 -35
- data/lib/elibri_onix/releases.rb +2 -2
- data/lib/elibri_onix/timestamp_parser.rb +12 -0
- data/lib/elibri_onix/version.rb +1 -1
- data/lib/elibri_onix.rb +4 -8
- data/test/elibri_audiobook_test.rb +1 -1
- data/test/elibri_contributors_test.rb +3 -3
- data/test/elibri_ebook_files_test.rb +2 -2
- data/test/elibri_extensions_test.rb +0 -12
- data/test/elibri_group_contributor_test.rb +1 -1
- data/test/elibri_onix_release_3_0_onix_message_test.rb +1 -6
- data/test/elibri_record_identifiers_test.rb +2 -2
- data/test/elibri_sale_restrictions_test.rb +1 -1
- data/test/elibri_supporting_resources_test.rb +2 -2
- data/test/elibri_texts_test.rb +5 -5
- data/test/fixtures/all_possible_tags.xml +1 -18
- data/test/fixtures/lending_example.xml +419 -0
- data/test/fixtures/onix_announced_product_example.xml +1 -3
- data/test/fixtures/onix_audience_range_example.xml +1 -3
- data/test/fixtures/onix_audiobook_extent_example.xml +1 -3
- data/test/fixtures/onix_collective_work_example.xml +1 -3
- data/test/fixtures/onix_contributors_example.xml +1 -3
- data/test/fixtures/onix_ebook_extent_example.xml +1 -4
- data/test/fixtures/onix_edition_example.xml +1 -3
- data/test/fixtures/onix_epub_details_example.xml +5 -4
- data/test/fixtures/onix_languages_example.xml +1 -3
- data/test/fixtures/onix_measurement_example.xml +1 -3
- data/test/fixtures/onix_no_contributors_example.xml +1 -3
- data/test/fixtures/onix_out_of_print_product_example.xml +1 -3
- data/test/fixtures/onix_preorder_product_example.xml +1 -3
- data/test/fixtures/onix_product_form_example.xml +1 -4
- data/test/fixtures/onix_published_group_product_example.xml +1 -3
- data/test/fixtures/onix_published_product_example.xml +1 -3
- data/test/fixtures/onix_publisher_info_example.xml +1 -3
- data/test/fixtures/onix_record_identifiers_example.xml +1 -4
- data/test/fixtures/onix_related_products_example.xml +1 -3
- data/test/fixtures/onix_removed_elibri_extensions.xml +0 -1
- data/test/fixtures/onix_sale_restrictions_example.xml +1 -3
- data/test/fixtures/onix_series_memberships_example.xml +1 -3
- data/test/fixtures/onix_supporting_resources_example.xml +1 -2
- data/test/fixtures/onix_territorial_rights_example.xml +1 -4
- data/test/fixtures/onix_texts_example.xml +1 -3
- data/test/fixtures/onix_title_with_collection_example.xml +1 -3
- data/test/fixtures/onix_titles_example.xml +1 -3
- data/test/fixtures/onix_unlimited_book_sample_example.xml +1 -4
- data/test/lending_licence_test.rb +43 -0
- metadata +9 -20
- data/lib/elibri_onix/hash_id.rb +0 -37
- data/test/fixtures/old_dialect.xml +0 -29
- data/test/fixtures/onix_elibri_extensions_example.xml +0 -57
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Elibri
|
3
2
|
module ONIX
|
4
3
|
module Release_3_0
|
@@ -8,41 +7,11 @@ module Elibri
|
|
8
7
|
|
9
8
|
include Inspector
|
10
9
|
|
11
|
-
#:nodoc:
|
12
|
-
ATTRIBUTES =
|
13
|
-
[
|
14
|
-
:height, :width, :thickness, :weight, :ean, :isbn13, :number_of_pages, :duration,
|
15
|
-
:file_size, :publisher_name, :publisher_id, :imprint_name, :current_state, :reading_age_from, :reading_age_to,
|
16
|
-
:table_of_contents, :description, :reviews, :excerpts, :series, :title, :subtitle, :collection_title,
|
17
|
-
:collection_part, :full_title, :original_title, :trade_title, :parsed_publishing_date, :record_reference,
|
18
|
-
:deletion_text, :cover_type, :cover_price, :vat, :pkwiu, :additional_info, :product_composition,
|
19
|
-
:publisher, :product_form, :no_contributor, :edition_statement, :edition_type_onix_code, :number_of_illustrations, :publishing_status,
|
20
|
-
:publishing_date, :premiere, :front_cover, :series_names, :city_of_publication,
|
21
|
-
:preview_exists, :short_description, :sale_restricted_to_poland,
|
22
|
-
:technical_protection_onix_code, :unlimited_licence, :hyphenated_isbn, :preorder_embargo_date, :additional_trade_information,
|
23
|
-
:number_of_pieces, :players_number_from, :players_number_to, :playing_time_from, :playing_time_to
|
24
|
-
|
25
|
-
]
|
26
|
-
|
27
|
-
#:nodoc:
|
28
|
-
RELATIONS =
|
29
|
-
[
|
30
|
-
:contributors, #IMPORTANT
|
31
|
-
:related_products, :languages, :measures, :supply_details, :measures, :title_details,
|
32
|
-
:collections, :extents, :thema_subjects, :publisher_subjects, :audience_ranges,
|
33
|
-
:text_contents, #IMPORTANT
|
34
|
-
:supporting_resources, #for example: cover
|
35
|
-
:sales_restrictions, :authors,
|
36
|
-
:ghostwriters, :scenarists, :originators, :illustrators, :photographers, :author_of_prefaces, :drawers,
|
37
|
-
:cover_designers, :inked_or_colored_bys, :editors, :revisors, :translators, :editor_in_chiefs, :read_bys
|
38
|
-
]
|
39
|
-
|
40
10
|
def inspect_include_fields
|
41
11
|
[:record_reference, :full_title, :front_cover, :publisher, :isbn13, :ean, :premiere, :contributors, :languages, :description, :product_form_name,
|
42
12
|
:technical_protection, :digital_formats]
|
43
13
|
end
|
44
14
|
|
45
|
-
|
46
15
|
#:doc:
|
47
16
|
#wysokość w milimetrach
|
48
17
|
attr_reader :height
|
@@ -264,20 +233,11 @@ module Elibri
|
|
264
233
|
##publishing_details
|
265
234
|
@sales_restrictions = []
|
266
235
|
@excerpt_infos = []
|
267
|
-
@cover_type = nil
|
268
236
|
#moving to parsing attributes
|
269
237
|
|
270
|
-
@record_reference = data.at_css('RecordReference')
|
271
|
-
@notification_type = data.at_css('NotificationType')
|
272
|
-
@deletion_text = data.at_css('DeletionText')
|
273
|
-
|
274
|
-
if data.namespaces.values.any? { |uri| uri =~ /elibri/ }
|
275
|
-
@cover_type = data.at_xpath('elibri:CoverType').try(:text)
|
276
|
-
@pkwiu = data.at_xpath('elibri:PKWiU').try(:text)
|
277
|
-
@hyphenated_isbn = data.at_xpath('elibri:HyphenatedISBN').try(:text)
|
278
|
-
@pdw_exclusiveness = data.at_xpath('elibri:PDWExclusiveness').try(:text)
|
279
|
-
@additional_info = data.at_xpath('elibri:AdditionalInfo').try(:text)
|
280
|
-
end
|
238
|
+
@record_reference = data.at_css('RecordReference')&.text
|
239
|
+
@notification_type = data.at_css('NotificationType')&.text
|
240
|
+
@deletion_text = data.at_css('DeletionText')&.text
|
281
241
|
|
282
242
|
@identifiers = data.children.find_all { |node| node.name == 'ProductIdentifier' }.map { |ident_data| ProductIdentifier.new(ident_data) }
|
283
243
|
begin
|
@@ -285,71 +245,49 @@ module Elibri
|
|
285
245
|
rescue
|
286
246
|
@related_products = []
|
287
247
|
end
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
@
|
296
|
-
@vat = data.at_xpath('elibri:Vat').try(:text).try(:to_i)
|
297
|
-
else
|
298
|
-
#00 - Supplier role - Unspecified
|
299
|
-
price_sd = @supply_details.find { |sd| sd.supplier && ["00", Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_TO_RET].include?(sd.supplier.role) }
|
300
|
-
if price_sd && price_sd.price && price_sd.price && price_sd.price.type == Elibri::ONIX::Dict::Release_3_0::PriceTypeCode::RRP_WITH_TAX
|
301
|
-
@vat = price_sd.price.tax_rate_percent.to_i
|
302
|
-
@cover_price = price_sd.price.amount
|
303
|
-
@additional_trade_information = price_sd.additional_trade_information
|
304
|
-
end
|
248
|
+
@supply_details = data.css('SupplyDetail').map { |supply_data| SupplyDetail.new(supply_data) }
|
249
|
+
|
250
|
+
#00 - Supplier role - Unspecified
|
251
|
+
price_sd = @supply_details.find { |sd| sd.supplier && ["00", Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_TO_RET].include?(sd.supplier.role) }
|
252
|
+
if price_sd && price_sd.prices[0] && price_sd.prices[0].type == Elibri::ONIX::Dict::Release_3_0::PriceTypeCode::RRP_WITH_TAX
|
253
|
+
@vat = price_sd.prices[0].tax_rate_percent.to_i
|
254
|
+
@cover_price = price_sd.prices[0].amount
|
255
|
+
@additional_trade_information = price_sd.additional_trade_information
|
305
256
|
end
|
306
257
|
|
307
258
|
descriptive_details_setup(data.at_css('DescriptiveDetail')) if data.at_css('DescriptiveDetail')
|
308
259
|
collateral_details_setup(data.at_css('CollateralDetail')) if data.at_css('CollateralDetail')
|
309
260
|
|
310
|
-
|
311
|
-
@preview_exists = (data.at_xpath('elibri:preview_exists').text == "true")
|
312
|
-
else
|
313
|
-
@preview_exists = @supporting_resources.find { |sr| sr.content_type_name == "widget" && sr.link =~ /p.elibri.com.pl/ }.present?
|
314
|
-
end
|
261
|
+
@preview_exists = !!@supporting_resources.find { |sr| sr.content_type_name == "widget" && sr.link =~ /p.elibri.com.pl/ }
|
315
262
|
|
316
263
|
product_form_features_setup(data.css("ProductFormFeature"))
|
317
264
|
|
318
265
|
publishing_details_setup(data.at_css('PublishingDetail')) if data.at_css('PublishingDetail')
|
319
266
|
licence_information_setup(data)
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
demo = @supporting_resources.find { |sr| sr.content_type_name == "sample_content" }
|
324
|
-
if demo
|
325
|
-
@excerpt_infos = demo.data.css("ResourceVersion").map { |node| ExcerptInfo.new(node) }
|
326
|
-
end
|
327
|
-
|
267
|
+
demo = @supporting_resources.find { |sr| sr.content_type_name == "sample_content" }
|
268
|
+
if demo
|
269
|
+
@excerpt_infos = demo.data.css("ResourceVersion").map { |node| ExcerptInfo.new(node) }
|
328
270
|
end
|
271
|
+
|
329
272
|
@file_infos = data.css("BodyResource").map { |node| FileInfo.new(node) }
|
330
273
|
after_parse
|
331
274
|
end
|
332
275
|
|
276
|
+
def cover_type
|
277
|
+
if @product_form && @product_form =~ /^B/ &&
|
278
|
+
Elibri::ONIX::Dict::CoverType.determine_cover_type(@product_form, data.at_css('ProductFormDetail')&.text)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
333
282
|
def licence_information_setup(data)
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
@licence_limited_to = _parse_date(date)
|
341
|
-
end
|
283
|
+
daten = data.css('PublishingDate').find { |d| d.at_css("PublishingDateRole") && d.at_css("PublishingDateRole").text == Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::OUT_OF_PRINT_DATE }
|
284
|
+
if daten
|
285
|
+
date = daten.at_css('Date').text
|
286
|
+
@licence_limited_to_before_type_cast = date
|
287
|
+
@licence_limited_to = _parse_date(date)
|
288
|
+
@unlimited_licence = false
|
342
289
|
else
|
343
|
-
|
344
|
-
if daten
|
345
|
-
date = daten.at_css('Date').text
|
346
|
-
@licence_limited_to_before_type_cast = date
|
347
|
-
@licence_limited_to = _parse_date(date)
|
348
|
-
@unlimited_licence = false
|
349
|
-
else
|
350
|
-
@unlimited_licence = true
|
351
|
-
end
|
352
|
-
|
290
|
+
@unlimited_licence = true
|
353
291
|
end
|
354
292
|
end
|
355
293
|
|
@@ -371,23 +309,20 @@ module Elibri
|
|
371
309
|
end
|
372
310
|
|
373
311
|
def descriptive_details_setup(data)
|
374
|
-
@country_of_manufacture = data.at_css("CountryOfManufacture")
|
312
|
+
@country_of_manufacture = data.at_css("CountryOfManufacture")&.text
|
375
313
|
|
376
|
-
@product_composition = data.at_css('ProductComposition')
|
377
|
-
@product_form = data.at_css('ProductForm')
|
314
|
+
@product_composition = data.at_css('ProductComposition')&.text
|
315
|
+
@product_form = data.at_css('ProductForm')&.text
|
378
316
|
if @product_form
|
379
|
-
if @product_form.starts_with?("B") && !@cover_type
|
380
|
-
@cover_type = Elibri::ONIX::Dict::CoverType.determine_cover_type(@product_form, data.at_css('ProductFormDetail').try(:text))
|
381
|
-
end
|
382
317
|
if Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(@product_form)
|
383
318
|
@product_form_name = Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(@product_form).name(:en).downcase
|
384
319
|
end
|
385
320
|
|
386
|
-
simplified_product_form = @product_form
|
387
|
-
if Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(simplified_product_form)
|
321
|
+
simplified_product_form = @product_form =~ /^B/ ? "BA" : @product_form
|
322
|
+
if Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(simplified_product_form)&.digital?
|
388
323
|
@digital_formats = []
|
389
324
|
data.css("ProductFormDetail").each do |format|
|
390
|
-
format_name = Elibri::ONIX::Dict::Release_3_0::ProductFormDetail::find_by_onix_code(format.text)
|
325
|
+
format_name = Elibri::ONIX::Dict::Release_3_0::ProductFormDetail::find_by_onix_code(format.text)&.name
|
391
326
|
@digital_formats << format_name.upcase.gsub("MOBIPOCKET", "MOBI") if format_name
|
392
327
|
end
|
393
328
|
end
|
@@ -411,23 +346,23 @@ module Elibri
|
|
411
346
|
@extents = data.css('Extent').map { |extent_data| Extent.new(extent_data) }
|
412
347
|
|
413
348
|
@publisher_subjects = data.css('Subject').find_all { |sd|
|
414
|
-
%w{24}.include?(sd.at_css('SubjectSchemeIdentifier')
|
349
|
+
%w{24}.include?(sd.at_css('SubjectSchemeIdentifier')&.text) }.map { |sd| PublisherSubject.new(sd) }
|
415
350
|
@thema_subjects = data.css('Subject').find_all { |sd|
|
416
|
-
%w{93 94 95 96 97 98 99}.include?(sd.at_css('SubjectSchemeIdentifier')
|
351
|
+
%w{93 94 95 96 97 98 99}.include?(sd.at_css('SubjectSchemeIdentifier')&.text) }.map { |sd| ThemaSubject.new(sd) }
|
417
352
|
@audience_ranges = data.css('AudienceRange').map { |audience_data| AudienceRange.new(audience_data) }
|
418
353
|
|
419
354
|
#zabezpiecznie pliku
|
420
|
-
if protection = data.at_css("EpubTechnicalProtection")
|
421
|
-
@technical_protection = Elibri::ONIX::Dict::Release_3_0::EpubTechnicalProtection::find_by_onix_code(protection)
|
355
|
+
if protection = data.at_css("EpubTechnicalProtection")&.text
|
356
|
+
@technical_protection = Elibri::ONIX::Dict::Release_3_0::EpubTechnicalProtection::find_by_onix_code(protection)&.name
|
422
357
|
@technical_protection_onix_code = protection
|
423
358
|
end
|
424
359
|
|
425
|
-
@edition_statement = data.at_css('EditionStatement')
|
426
|
-
if Elibri::ONIX::Dict::Release_3_0::EditionType.find_by_onix_code(data.at_css('EditionType')
|
427
|
-
@edition_type_onix_code = data.at_css('EditionType')
|
360
|
+
@edition_statement = data.at_css('EditionStatement')&.text
|
361
|
+
if Elibri::ONIX::Dict::Release_3_0::EditionType.find_by_onix_code(data.at_css('EditionType')&.text)
|
362
|
+
@edition_type_onix_code = data.at_css('EditionType')&.text
|
428
363
|
end
|
429
364
|
|
430
|
-
@number_of_illustrations = data.at_css('NumberOfIllustrations')
|
365
|
+
@number_of_illustrations = data.at_css('NumberOfIllustrations')&.text&.to_i
|
431
366
|
end
|
432
367
|
|
433
368
|
def collateral_details_setup(data)
|
@@ -438,8 +373,8 @@ module Elibri
|
|
438
373
|
def publishing_details_setup(data)
|
439
374
|
@imprint = Imprint.new(data.at_css('Imprint')) if data.at_css('Imprint')
|
440
375
|
@publisher = Publisher.new(data.at_css('Publisher')) if data.at_css('Publisher')
|
441
|
-
@publishing_status = data.at_css('PublishingStatus')
|
442
|
-
@city_of_publication = data.at_css("CityOfPublication")
|
376
|
+
@publishing_status = data.at_css('PublishingStatus')&.text
|
377
|
+
@city_of_publication = data.at_css("CityOfPublication")&.text
|
443
378
|
publication_dates = data.css('PublishingDate').map do |node|
|
444
379
|
PublishingDate.new(node)
|
445
380
|
end
|
@@ -449,7 +384,7 @@ module Elibri
|
|
449
384
|
|
450
385
|
@sales_restrictions = data.css('SalesRestriction').map { |restriction_data| SalesRestriction.new(restriction_data) }
|
451
386
|
#ograniczenia terytorialne
|
452
|
-
if data.at_css("CountriesIncluded")
|
387
|
+
if data.at_css("CountriesIncluded")&.text == "PL"
|
453
388
|
@sale_restricted_to_poland = true
|
454
389
|
else
|
455
390
|
@sale_restricted_to_poland = false
|
@@ -483,7 +418,7 @@ module Elibri
|
|
483
418
|
|
484
419
|
#flaga, czy książka to praca zbiorowa?
|
485
420
|
def unnamed_persons?
|
486
|
-
@contributors.size == 1 && contributors[0].unnamed_persons
|
421
|
+
@contributors.size == 1 && contributors[0].unnamed_persons
|
487
422
|
end
|
488
423
|
|
489
424
|
#flaga, czy istnieje podgląd produktu
|
@@ -537,10 +472,7 @@ module Elibri
|
|
537
472
|
#data premiery w postaci listy [rok, miesiąc, dzień], [rok, miesiąc], [rok], lub pustej listy - jeśli data premiery nie jest znana
|
538
473
|
#(data premiery może nie być znana w przypadku backlisty)
|
539
474
|
def parsed_publishing_date
|
540
|
-
if
|
541
|
-
date = sales_restrictions[0].end_date
|
542
|
-
[date.year, date.month, date.day]
|
543
|
-
elsif publishing_date
|
475
|
+
if publishing_date
|
544
476
|
publishing_date.parsed
|
545
477
|
else
|
546
478
|
[]
|
@@ -556,21 +488,21 @@ module Elibri
|
|
556
488
|
|
557
489
|
def after_parse
|
558
490
|
%w{height width thickness weight}.each do |mn|
|
559
|
-
instance_variable_set("@#{mn}", measures.find { |m| m.type_name == mn }
|
491
|
+
instance_variable_set("@#{mn}", measures.find { |m| m.type_name == mn }&.measurement)
|
560
492
|
end
|
561
493
|
|
562
|
-
@ean = @identifiers.find { |identifier| identifier.identifier_type == "ean" }
|
494
|
+
@ean = @identifiers.find { |identifier| identifier.identifier_type == "ean" }&.value
|
563
495
|
|
564
|
-
@number_of_pages = @extents.find {|extent| extent.type_name == "page_count" }
|
565
|
-
@duration = @extents.find {|extent| extent.type_name == "duration" }
|
566
|
-
@file_size = @extents.find {|extent| extent.type_name == "file_size" }
|
496
|
+
@number_of_pages = @extents.find {|extent| extent.type_name == "page_count" }&.value
|
497
|
+
@duration = @extents.find {|extent| extent.type_name == "duration" }&.value
|
498
|
+
@file_size = @extents.find {|extent| extent.type_name == "file_size" }&.value
|
567
499
|
@publisher_name = @publisher.name if publisher
|
568
500
|
@publisher_id = @publisher.eid if publisher
|
569
501
|
@imprint_name = @imprint.name if imprint
|
570
|
-
@isbn13 = @identifiers.find { |identifier| identifier.identifier_type == "isbn13" }
|
502
|
+
@isbn13 = @identifiers.find { |identifier| identifier.identifier_type == "isbn13" }&.value
|
571
503
|
@hyphenated_isbn ||= @isbn13
|
572
|
-
@reading_age_from = @audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "03")}
|
573
|
-
@reading_age_to = @audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "04")}
|
504
|
+
@reading_age_from = @audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "03")}&.value&.to_i
|
505
|
+
@reading_age_to = @audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "04")}&.value&.to_i
|
574
506
|
@table_of_contents = @text_contents.find { |t| t.type_name == "table_of_contents" }
|
575
507
|
@description = @text_contents.find { |t| t.type_name == "main_description" }
|
576
508
|
@short_description = @text_contents.find { |t| t.type_name == "short_description" }
|
@@ -579,14 +511,14 @@ module Elibri
|
|
579
511
|
@series = @collections.map { |c| [c.title_detail.elements[0].title, c.title_detail.elements[0].part_number] }
|
580
512
|
distinctive_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::DISTINCTIVE_TITLE)
|
581
513
|
if distinctive_title
|
582
|
-
@title = distinctive_title.product_level
|
583
|
-
@subtitle = distinctive_title.product_level
|
584
|
-
@collection_title = distinctive_title.collection_level
|
585
|
-
@collection_part = distinctive_title.collection_level
|
514
|
+
@title = distinctive_title.product_level&.title
|
515
|
+
@subtitle = distinctive_title.product_level&.subtitle
|
516
|
+
@collection_title = distinctive_title.collection_level&.title
|
517
|
+
@collection_part = distinctive_title.collection_level&.part_number
|
586
518
|
end
|
587
|
-
@full_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::DISTINCTIVE_TITLE)
|
588
|
-
@original_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::ORIGINAL_TITLE)
|
589
|
-
@trade_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::DISTRIBUTORS_TITLE)
|
519
|
+
@full_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::DISTINCTIVE_TITLE)&.full_title
|
520
|
+
@original_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::ORIGINAL_TITLE)&.full_title
|
521
|
+
@trade_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::DISTRIBUTORS_TITLE)&.full_title
|
590
522
|
|
591
523
|
compute_state!
|
592
524
|
end
|
@@ -1,45 +1,30 @@
|
|
1
|
-
|
2
1
|
module Elibri
|
3
2
|
module ONIX
|
4
3
|
module Release_3_0
|
5
|
-
|
6
|
-
#product identifier, for example isbn
|
7
4
|
class ProductIdentifier
|
8
|
-
|
9
|
-
include HashId
|
10
5
|
|
11
6
|
#onix code of type (see elibri_onix_dict, Elibri::ONIX::Dict::Release_3_0::ProductIDType)
|
12
7
|
attr_accessor :type
|
13
8
|
|
14
9
|
#if type is prioprietery (01) - then the name of type
|
15
10
|
attr_accessor :type_name
|
16
|
-
|
11
|
+
|
17
12
|
#identifier value
|
18
13
|
attr_accessor :value
|
19
14
|
|
20
15
|
#xml representation of identifier
|
21
16
|
attr_accessor :to_xml
|
22
|
-
|
23
|
-
#:nodoc:
|
24
|
-
ATTRIBUTES = [
|
25
|
-
:type, :type_name, :value, :identifier_type
|
26
|
-
]
|
27
|
-
|
28
|
-
#:nodoc:
|
29
|
-
RELATIONS = [
|
30
|
-
:inspect_include_fields
|
31
|
-
]
|
32
|
-
|
17
|
+
|
33
18
|
def initialize(data)
|
34
19
|
@to_xml = data.to_s
|
35
|
-
@type = data.at_css('ProductIDType')
|
36
|
-
@type_name = data.at_css('IDTypeName')
|
37
|
-
@value = data.at_css('IDValue')
|
20
|
+
@type = data.at_css('ProductIDType')&.text
|
21
|
+
@type_name = data.at_css('IDTypeName')&.text
|
22
|
+
@value = data.at_css('IDValue')&.text
|
38
23
|
end
|
39
24
|
|
40
25
|
#returs the string name of value type
|
41
26
|
def identifier_type
|
42
|
-
Elibri::ONIX::Dict::Release_3_0::ProductIDType.find_by_onix_code(@type)
|
27
|
+
Elibri::ONIX::Dict::Release_3_0::ProductIDType.find_by_onix_code(@type)&.const_name&.downcase
|
43
28
|
end
|
44
29
|
|
45
30
|
#:nodoc:
|
@@ -47,7 +32,6 @@ module Elibri
|
|
47
32
|
[:identifier_type]
|
48
33
|
end
|
49
34
|
end
|
50
|
-
|
51
35
|
end
|
52
36
|
end
|
53
37
|
end
|
@@ -1,36 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
1
|
module Elibri
|
5
2
|
module ONIX
|
6
3
|
module Release_3_0
|
7
|
-
|
8
4
|
class Publisher
|
9
|
-
|
10
|
-
#from ONIX documentation:
|
11
|
-
#A repeatable group of data elements which together identify an entity which is associated with the publishing of a product.
|
12
|
-
#The composite allows additional publishing roles to be introduced without adding new fields.
|
13
|
-
#Each occurrence of the composite must carry a publishing role code and either a name identifier code or a name or both.
|
14
|
-
|
15
|
-
|
16
5
|
include Inspector
|
17
6
|
|
18
|
-
ATTRIBUTES = [
|
19
|
-
:role, :name, :eid
|
20
|
-
]
|
21
|
-
|
22
|
-
RELATIONS = []
|
23
|
-
|
24
7
|
#role występuje w tej chwili tylko 01 - główny wydawca
|
25
8
|
|
26
9
|
attr_accessor :role, :name, :eid, :to_xml
|
27
|
-
|
10
|
+
|
28
11
|
def initialize(data)
|
29
12
|
@to_xml = data.to_s
|
30
|
-
@role = data.at_css('PublishingRole')
|
31
|
-
@name = data.at_css('PublisherName')
|
13
|
+
@role = data.at_css('PublishingRole')&.text
|
14
|
+
@name = data.at_css('PublisherName')&.text
|
32
15
|
if data.at_css('PublisherIdentifier')
|
33
|
-
@eid = data.at_css('PublisherIdentifier').at_css('IDValue')
|
16
|
+
@eid = data.at_css('PublisherIdentifier').at_css('IDValue')&.text&.to_i
|
34
17
|
end
|
35
18
|
end
|
36
19
|
|
@@ -1,31 +1,21 @@
|
|
1
|
-
|
2
1
|
module Elibri
|
3
2
|
module ONIX
|
4
3
|
module Release_3_0
|
5
4
|
|
6
5
|
class PublisherSubject
|
7
6
|
|
8
|
-
include HashId
|
9
|
-
|
10
|
-
ATTRIBUTES = [
|
11
|
-
:code, :heading_text
|
12
|
-
]
|
13
|
-
|
14
|
-
RELATIONS = [
|
15
|
-
:inspect_include_fields
|
16
|
-
]
|
17
|
-
|
18
7
|
attr_accessor :code, :heading_text, :to_xml
|
19
8
|
|
20
9
|
def initialize(data)
|
21
10
|
@to_xml = data.to_s
|
22
|
-
@code = data.at_css('SubjectCode')
|
23
|
-
@heading_text = data.at_css('SubjectHeadingText')
|
11
|
+
@code = data.at_css('SubjectCode')&.text
|
12
|
+
@heading_text = data.at_css('SubjectHeadingText')&.text
|
24
13
|
end
|
25
14
|
|
26
15
|
def inspect_include_fields
|
27
16
|
[:code]
|
28
17
|
end
|
18
|
+
|
29
19
|
end
|
30
20
|
end
|
31
21
|
end
|
@@ -1,32 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
1
|
module Elibri
|
5
2
|
module ONIX
|
6
3
|
module Release_3_0
|
7
|
-
|
8
4
|
class PublishingDate
|
9
5
|
|
10
|
-
#from ONIX documentation:
|
11
|
-
#A repeatable group of data elements which together specify a date associated with the publishing of the product.
|
12
|
-
#Optional, but a date of publication must be specified either or in <MarketPublishingDetail> (P.25).
|
13
|
-
#Other dates related to the publishing of a product can be sent in further repeats.
|
14
|
-
|
15
|
-
include HashId
|
16
|
-
|
17
|
-
ATTRIBUTES = [
|
18
|
-
:role, :format, :date, :parsed
|
19
|
-
]
|
20
|
-
|
21
|
-
RELATIONS = []
|
22
|
-
|
23
6
|
attr_accessor :role, :format, :date, :to_xml
|
24
7
|
|
25
8
|
def initialize(data)
|
26
9
|
@to_xml = data.to_s
|
27
|
-
@role = data.at_css('PublishingDateRole')
|
28
|
-
@format = data.at_css('DateFormat')
|
29
|
-
@date = data.at_css('Date')
|
10
|
+
@role = data.at_css('PublishingDateRole')&.text
|
11
|
+
@format = data.at_css('DateFormat')&.text || data.at_css('Date')['dateformat'] || '00'
|
12
|
+
@date = data.at_css('Date')&.text
|
30
13
|
end
|
31
14
|
|
32
15
|
def parsed
|
@@ -38,7 +21,6 @@ module Elibri
|
|
38
21
|
end
|
39
22
|
|
40
23
|
end
|
41
|
-
|
42
24
|
end
|
43
25
|
end
|
44
26
|
end
|
@@ -1,39 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
module Elibri
|
4
2
|
module ONIX
|
5
3
|
module Release_3_0
|
6
|
-
|
7
4
|
class RelatedProduct
|
8
|
-
|
9
|
-
#from ONIX documentation:
|
10
|
-
#An optional and repeatable group of data elements which together describe a product which has a specified relationship
|
11
|
-
#to the product described in the ONIX record.
|
12
|
-
include HashId
|
13
|
-
|
14
|
-
#:nodoc:
|
15
|
-
ATTRIBUTES = [
|
16
|
-
:relation_code, :proprietary_identifiers, :record_reference
|
17
|
-
]
|
18
|
-
|
19
|
-
#:nodoc:
|
20
|
-
RELATIONS = [
|
21
|
-
:identifiers
|
22
|
-
]
|
23
|
-
|
5
|
+
|
24
6
|
attr_reader :relation_code
|
25
7
|
attr_reader :identifiers
|
26
8
|
attr_reader :to_xml
|
27
|
-
|
9
|
+
|
28
10
|
def initialize(data)
|
29
11
|
@to_xml = data.to_s
|
30
|
-
@relation_code = data.at_css('ProductRelationCode')
|
12
|
+
@relation_code = data.at_css('ProductRelationCode')&.text
|
31
13
|
@identifiers = data.css('ProductIdentifier').map { |identifier_data| ProductIdentifier.new(identifier_data) }
|
32
14
|
end
|
33
15
|
|
34
|
-
|
16
|
+
|
35
17
|
def record_reference
|
36
|
-
@identifiers.find {|identifier| identifier.type == '01' && identifier.type_name == 'elibri' }
|
18
|
+
@identifiers.find {|identifier| identifier.type == '01' && identifier.type_name == 'elibri' }&.value
|
37
19
|
end
|
38
20
|
|
39
21
|
|
@@ -46,7 +28,6 @@ module Elibri
|
|
46
28
|
end
|
47
29
|
|
48
30
|
end
|
49
|
-
|
50
31
|
end
|
51
32
|
end
|
52
33
|
end
|
@@ -1,41 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
1
|
module Elibri
|
5
2
|
module ONIX
|
6
3
|
module Release_3_0
|
7
|
-
|
8
4
|
class SalesRestriction
|
9
5
|
|
10
|
-
#from ONIX documentation:
|
11
|
-
#A group of data elements which together identify a non-territorial sales restriction which a publisher applies to a product.
|
12
|
-
#Optional and repeatable.
|
13
|
-
|
14
|
-
include HashId
|
15
|
-
|
16
|
-
ATTRIBUTES = [
|
17
|
-
:type, :outlet_name, :end_date
|
18
|
-
]
|
19
|
-
|
20
|
-
RELATIONS = []
|
21
|
-
|
22
6
|
attr_accessor :type, :outlet_name, :outlet_code, :end_date, :to_xml
|
23
7
|
|
24
8
|
def initialize(data)
|
25
9
|
@to_xml = data.to_s
|
26
|
-
@type = data.at_css('SalesRestrictionType')
|
10
|
+
@type = data.at_css('SalesRestrictionType')&.text&.to_i
|
27
11
|
if data.at_css('SalesOutlet')
|
28
|
-
@outlet_name = data.at_css('SalesOutlet').at_css('SalesOutletName')
|
12
|
+
@outlet_name = data.at_css('SalesOutlet').at_css('SalesOutletName')&.text
|
29
13
|
outlet_id_struct = data.at_css('SalesOutlet').at_css('SalesOutletIdentifier')
|
30
|
-
if outlet_id_struct && outlet_id_struct.at_css("SalesOutletIDType")
|
31
|
-
@outlet_code = outlet_id_struct.at_css("IDValue")
|
14
|
+
if outlet_id_struct && outlet_id_struct.at_css("SalesOutletIDType")&.text == "03"
|
15
|
+
@outlet_code = outlet_id_struct.at_css("IDValue")&.text
|
32
16
|
end
|
33
17
|
end
|
34
|
-
@end_date = Date.parse(data.at_css('EndDate')
|
18
|
+
@end_date = Date.parse(data.at_css('EndDate')&.text) if data.at_css('EndDate')
|
35
19
|
end
|
36
20
|
|
37
21
|
end
|
38
|
-
|
39
22
|
end
|
40
23
|
end
|
41
24
|
end
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
1
|
module Elibri
|
3
2
|
module ONIX
|
4
3
|
module Release_3_0
|
5
|
-
|
6
|
-
#Sender of the message
|
7
4
|
class Sender
|
8
5
|
include Inspector
|
9
6
|
|
@@ -13,14 +10,6 @@ module Elibri
|
|
13
10
|
#xml representation of sender
|
14
11
|
attr_accessor :to_xml
|
15
12
|
|
16
|
-
#:nodoc:
|
17
|
-
ATTRIBUTES = [
|
18
|
-
:sender_name, :contact_name, :email_address
|
19
|
-
]
|
20
|
-
|
21
|
-
#:nodoc:
|
22
|
-
RELATIONS = []
|
23
|
-
|
24
13
|
#:nodoc:
|
25
14
|
def inspect_include_fields
|
26
15
|
[:sender_name]
|
@@ -32,7 +21,6 @@ module Elibri
|
|
32
21
|
end
|
33
22
|
|
34
23
|
end
|
35
|
-
|
36
24
|
end
|
37
25
|
end
|
38
26
|
end
|