elibri_onix 0.5.19 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/lib/elibri_onix/external_timestamp.rb +2 -2
  3. data/lib/elibri_onix/onix_3_0/audience_range.rb +4 -17
  4. data/lib/elibri_onix/onix_3_0/collection.rb +0 -0
  5. data/lib/elibri_onix/onix_3_0/contributor.rb +15 -38
  6. data/lib/elibri_onix/onix_3_0/excerpt_info.rb +8 -21
  7. data/lib/elibri_onix/onix_3_0/extent.rb +9 -24
  8. data/lib/elibri_onix/onix_3_0/file_info.rb +2 -13
  9. data/lib/elibri_onix/onix_3_0/header.rb +7 -17
  10. data/lib/elibri_onix/onix_3_0/imprint.rb +2 -18
  11. data/lib/elibri_onix/onix_3_0/language.rb +5 -22
  12. data/lib/elibri_onix/onix_3_0/measure.rb +4 -18
  13. data/lib/elibri_onix/onix_3_0/onix_message.rb +2 -17
  14. data/lib/elibri_onix/onix_3_0/price.rb +14 -25
  15. data/lib/elibri_onix/onix_3_0/price_constraint_limit.rb +22 -0
  16. data/lib/elibri_onix/onix_3_0/price_identifier.rb +18 -0
  17. data/lib/elibri_onix/onix_3_0/product.rb +62 -127
  18. data/lib/elibri_onix/onix_3_0/product_identifier.rb +6 -22
  19. data/lib/elibri_onix/onix_3_0/publisher.rb +4 -21
  20. data/lib/elibri_onix/onix_3_0/publisher_subject.rb +3 -13
  21. data/lib/elibri_onix/onix_3_0/publishing_date.rb +3 -21
  22. data/lib/elibri_onix/onix_3_0/related_product.rb +5 -24
  23. data/lib/elibri_onix/onix_3_0/sales_restriction.rb +5 -22
  24. data/lib/elibri_onix/onix_3_0/sender.rb +0 -12
  25. data/lib/elibri_onix/onix_3_0/stock_quantity_coded.rb +4 -19
  26. data/lib/elibri_onix/onix_3_0/supplier.rb +7 -25
  27. data/lib/elibri_onix/onix_3_0/supplier_identifier.rb +4 -23
  28. data/lib/elibri_onix/onix_3_0/supply_detail.rb +9 -26
  29. data/lib/elibri_onix/onix_3_0/supporting_resource.rb +7 -20
  30. data/lib/elibri_onix/onix_3_0/text_content.rb +9 -24
  31. data/lib/elibri_onix/onix_3_0/thema_subject.rb +2 -15
  32. data/lib/elibri_onix/onix_3_0/title_detail.rb +9 -28
  33. data/lib/elibri_onix/onix_3_0/title_element.rb +10 -35
  34. data/lib/elibri_onix/releases.rb +2 -2
  35. data/lib/elibri_onix/timestamp_parser.rb +12 -0
  36. data/lib/elibri_onix/version.rb +1 -1
  37. data/lib/elibri_onix.rb +4 -8
  38. data/test/elibri_audiobook_test.rb +1 -1
  39. data/test/elibri_contributors_test.rb +3 -3
  40. data/test/elibri_ebook_files_test.rb +2 -2
  41. data/test/elibri_extensions_test.rb +0 -12
  42. data/test/elibri_group_contributor_test.rb +1 -1
  43. data/test/elibri_onix_release_3_0_onix_message_test.rb +1 -6
  44. data/test/elibri_record_identifiers_test.rb +2 -2
  45. data/test/elibri_supporting_resources_test.rb +2 -2
  46. data/test/elibri_texts_test.rb +5 -5
  47. data/test/fixtures/all_possible_tags.xml +1 -18
  48. data/test/fixtures/lending_example.xml +419 -0
  49. data/test/fixtures/onix_announced_product_example.xml +1 -3
  50. data/test/fixtures/onix_audience_range_example.xml +1 -3
  51. data/test/fixtures/onix_audiobook_extent_example.xml +1 -3
  52. data/test/fixtures/onix_collective_work_example.xml +1 -3
  53. data/test/fixtures/onix_contributors_example.xml +1 -3
  54. data/test/fixtures/onix_ebook_extent_example.xml +1 -4
  55. data/test/fixtures/onix_edition_example.xml +1 -3
  56. data/test/fixtures/onix_epub_details_example.xml +5 -4
  57. data/test/fixtures/onix_languages_example.xml +1 -3
  58. data/test/fixtures/onix_measurement_example.xml +1 -3
  59. data/test/fixtures/onix_no_contributors_example.xml +1 -3
  60. data/test/fixtures/onix_out_of_print_product_example.xml +1 -3
  61. data/test/fixtures/onix_preorder_product_example.xml +1 -3
  62. data/test/fixtures/onix_product_form_example.xml +1 -4
  63. data/test/fixtures/onix_published_group_product_example.xml +1 -3
  64. data/test/fixtures/onix_published_product_example.xml +1 -3
  65. data/test/fixtures/onix_publisher_info_example.xml +1 -3
  66. data/test/fixtures/onix_record_identifiers_example.xml +1 -4
  67. data/test/fixtures/onix_related_products_example.xml +1 -3
  68. data/test/fixtures/onix_removed_elibri_extensions.xml +0 -1
  69. data/test/fixtures/onix_sale_restrictions_example.xml +1 -3
  70. data/test/fixtures/onix_series_memberships_example.xml +1 -3
  71. data/test/fixtures/onix_supporting_resources_example.xml +1 -2
  72. data/test/fixtures/onix_territorial_rights_example.xml +1 -4
  73. data/test/fixtures/onix_texts_example.xml +1 -3
  74. data/test/fixtures/onix_title_with_collection_example.xml +1 -3
  75. data/test/fixtures/onix_titles_example.xml +1 -3
  76. data/test/fixtures/onix_unlimited_book_sample_example.xml +1 -4
  77. data/test/lending_licence_test.rb +43 -0
  78. metadata +9 -20
  79. data/lib/elibri_onix/hash_id.rb +0 -37
  80. data/test/fixtures/old_dialect.xml +0 -29
  81. data/test/fixtures/onix_elibri_extensions_example.xml +0 -57
@@ -1,45 +1,27 @@
1
-
2
-
3
-
4
1
  module Elibri
5
2
  module ONIX
6
3
  module Release_3_0
7
-
8
4
  class Supplier
9
-
10
- #from ONIX documentation:
11
- #A group of data elements which together define a supplier. Mandatory in each occurrence of the <SupplyDetail> composite, and not repeatable.
12
5
 
13
- ATTRIBUTES = [
14
- :role, :name, :telephone_number, :email_address, :website, :nip
15
- ]
16
-
17
- RELATIONS = [
18
- :identifiers
19
- ]
20
-
21
- include HashId
22
-
23
6
  attr_accessor :role, :identifiers, :name, :telephone_number, :email_address, :website, :to_xml
24
-
7
+
25
8
  def initialize(data)
26
9
  @to_xml = data.to_s
27
- @role = data.at_css('SupplierRole').try(:text)
10
+ @role = data.at_css('SupplierRole')&.text
28
11
  @identifiers = data.css('SupplierIdentifier').map { |identifier_data| SupplierIdentifier.new(identifier_data) }
29
- @name = data.at_css('SupplierName').try(:text)
30
- @telephone_number = data.at_css('TelephoneNumber').try(:text)
31
- @email_address = data.at_css('EmailAddress').try(:text)
12
+ @name = data.at_css('SupplierName')&.text
13
+ @telephone_number = data.at_css('TelephoneNumber')&.text
14
+ @email_address = data.at_css('EmailAddress')&.text
32
15
  if data.at_css('Website')
33
- @website = data.at_css('Website').at_css('WebsiteLink').try(:text)
16
+ @website = data.at_css('Website').at_css('WebsiteLink')&.text
34
17
  end
35
18
  end
36
19
 
37
20
  def nip
38
- @identifiers.find {|identifier| (identifier.type == '02') && (identifier.type_name == 'NIP')}.try(:value)
21
+ @identifiers.find {|identifier| (identifier.type == '02') && (identifier.type_name == 'NIP')}&.value
39
22
  end
40
23
 
41
24
  end
42
-
43
25
  end
44
26
  end
45
27
  end
@@ -1,34 +1,15 @@
1
-
2
-
3
-
4
-
5
1
  module Elibri
6
2
  module ONIX
7
3
  module Release_3_0
8
-
9
4
  class SupplierIdentifier
10
-
11
- #from ONIX documentation:
12
- #A repeatable group of data elements which together define the identifier of a supplier in accordance with a specified scheme,
13
- #and allowing different types of supplier identifier to be included without defining additional data elements.
14
- #Optional, but each occurrence of the <Supplier> composite must carry either at least one supplier identifier,
15
- #or a <SupplierName>, or both.
16
-
17
- include HashId
18
5
 
19
- ATTRIBUTES = [
20
- :type, :type_name, :value
21
- ]
22
-
23
- RELATIONS = []
24
-
25
6
  attr_accessor :type, :type_name, :value, :to_xml
26
-
7
+
27
8
  def initialize(data)
28
9
  @to_xml = data.to_s
29
- @type = data.at_css('SupplierIDType').try(:text)
30
- @type_name = data.at_css('IDTypeName').try(:text)
31
- @value = data.at_css('IDValue').try(:text)
10
+ @type = data.at_css('SupplierIDType')&.text
11
+ @type_name = data.at_css('IDTypeName')&.text
12
+ @value = data.at_css('IDValue')&.text
32
13
  end
33
14
 
34
15
  end
@@ -1,51 +1,34 @@
1
-
2
-
3
-
4
1
  module Elibri
5
2
  module ONIX
6
3
  module Release_3_0
7
-
8
4
  class SupplyDetail
9
-
10
- #from ONIX documentation:
11
- #A group of data elements which together give details of a supply source, and price and availability from that source.
12
- #Mandatory in each occurrence of the <ProductSupply> block and repeatable.
13
-
14
- include HashId
15
-
16
5
 
17
- ATTRIBUTES = [
18
- :relation_code, :supplier, :product_availability, :pack_quantity, :price, :on_hand, :quantity_coded, :quantity_code, :additional_trade_information
19
- ]
20
-
21
- attr_accessor :relation_code, :supplier, :product_availability, :pack_quantity, :price, :on_hand, :quantity_coded, :to_xml, :additional_trade_information
6
+ attr_accessor :relation_code, :supplier, :product_availability, :pack_quantity, :prices,
7
+ :on_hand, :quantity_coded, :to_xml, :additional_trade_information
22
8
 
23
- RELATIONS = []
24
-
25
9
  def initialize(data)
26
10
  @to_xml = data.to_s
27
- @relation_code = data.at_css('ProductRelationCode').try(:text).try(:to_i)
11
+ @relation_code = data.at_css('ProductRelationCode')&.text&.to_i
28
12
  @supplier = Supplier.new(data.at_css('Supplier')) if data.at_css('Supplier')
29
- @product_availability = data.at_css('ProductAvailability').try(:text).try(:to_i)
30
- @pack_quantity = data.at_css('PackQuantity').try(:text).try(:to_i)
31
- @price = Price.new(data.at_css('Price')) if data.at_css('Price')
13
+ @product_availability = data.at_css('ProductAvailability')&.text&.to_i
14
+ @pack_quantity = data.at_css('PackQuantity')&.text&.to_i
15
+ @prices = data.css("Price").map { |p| Price.new(p) }
32
16
  if data.at_css('Stock')
33
- @on_hand = data.at_css('Stock').at_css('OnHand').try(:text).try(:to_i)
17
+ @on_hand = data.at_css('Stock').at_css('OnHand')&.text&.to_i
34
18
  @quantity_coded = StockQuantityCoded.new(data.at_css('Stock').at_css('StockQuantityCoded')) if data.at_css('Stock').at_css('StockQuantityCoded')
35
19
  end
36
20
  if own_coding = data.at_css('SupplierOwnCoding')
37
21
  if own_coding.at_css('SupplierCodeType').text == Elibri::ONIX::Dict::Release_3_0::SupplierOwnCodeType::SUPPLIERS_SALES_CLASSIFICATION
38
- @additional_trade_information = own_coding.at_css('SupplierCodeValue').text
22
+ @additional_trade_information = own_coding.at_css('SupplierCodeValue').text
39
23
  end
40
24
  end
41
25
  end
42
26
 
43
27
  def quantity_code
44
- @quantity_coded.try(:code)
28
+ @quantity_coded&.code
45
29
  end
46
30
 
47
31
  end
48
-
49
32
  end
50
33
  end
51
34
  end
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module Elibri
4
2
  module ONIX
5
3
  module Release_3_0
@@ -8,27 +6,16 @@ module Elibri
8
6
  include ExternalId
9
7
  include ExternalTimestamp
10
8
  include Inspector
11
-
12
- #from ONIX documentation:
13
- #An optional and repeatable group of data elements which together describe a supporting resource.
14
-
15
- ATTRIBUTES = [
16
- :content_type, :mode, :form, :link, :content_type_name, :mode_name, :form_name
17
- ]
18
-
19
- RELATIONS = [
20
- :inspect_include_fields
21
- ]
22
-
9
+
23
10
  attr_accessor :content_type, :mode, :form, :link, :to_xml, :data
24
-
11
+
25
12
  def initialize(data)
26
13
  @data = data
27
14
  @to_xml = data.to_s
28
- @content_type = data.at_css('ResourceContentType').try(:text)
29
- @mode = data.at_css('ResourceMode').try(:text)
30
- @form = data.at_css('ResourceVersion').at_css('ResourceForm').try(:text)
31
- @link = data.at_css('ResourceVersion').at_css('ResourceLink').try(:text)
15
+ @content_type = data.at_css('ResourceContentType')&.text
16
+ @mode = data.at_css('ResourceMode')&.text
17
+ @form = data.at_css('ResourceVersion').at_css('ResourceForm')&.text
18
+ @link = data.at_css('ResourceVersion').at_css('ResourceLink')&.text
32
19
  set_eid(data)
33
20
  set_datestamp(data)
34
21
  end
@@ -41,7 +28,7 @@ module Elibri
41
28
  raise ArgumentError, "Cannot find ResourceContentType for #{@content_type}"
42
29
  end
43
30
  end
44
-
31
+
45
32
  #def audience_name
46
33
  # Elibri::ONIX::Dict::Release_3_0::ContentAudience.find_by_onix_code(audience).const_name.downcase
47
34
  #end
@@ -1,46 +1,31 @@
1
-
2
1
  module Elibri
3
2
  module ONIX
4
3
  module Release_3_0
5
-
6
4
  class TextContent
7
5
  include ExternalId
8
6
  include ExternalTimestamp
9
7
  include Inspector
10
-
11
- #from ONIX documentation:
12
- #An optional and repeatable group of data elements which together carry text related to the product.
13
-
14
- #:nodoc:
15
- ATTRIBUTES = [
16
- :type, :author, :source_title, :text, :source_url, :type_name
17
- ]
18
-
19
- #:nodoc:
20
- RELATIONS = [
21
- :inspect_include_fields
22
- ]
23
-
8
+
24
9
  attr_accessor :type, :author, :source_title, :text, :source_url, :to_xml
25
-
10
+
26
11
  def initialize(data)
27
12
  @to_xml = data.to_s
28
- @type = data.at_css('TextType').try(:text)
29
- @author = data.at_css('TextAuthor').try(:text)
30
- @source_title = data.at_css('SourceTitle').try(:text)
13
+ @type = data.at_css('TextType')&.text
14
+ @author = data.at_css('TextAuthor')&.text
15
+ @source_title = data.at_css('SourceTitle')&.text
31
16
  if data.at_css('Text')
32
- @text = data.at_css('Text').children.find { |x| x.cdata? }.try(:text) #cdata => true ?
33
- @source_url = data.at_css('Text').attribute('sourcename').try(:text)
17
+ @text = data.at_css('Text').children.find { |x| x.cdata? }&.text #cdata => true ?
18
+ @source_url = data.at_css('Text').attribute('sourcename')&.text
34
19
  end
35
20
  set_eid(data)
36
21
  set_datestamp(data)
37
22
  end
38
23
 
39
24
  def type_name
40
- Elibri::ONIX::Dict::Release_3_0::OtherTextType.find_by_onix_code(@type).try(:const_name).try(:downcase)
25
+ Elibri::ONIX::Dict::Release_3_0::OtherTextType.find_by_onix_code(@type)&.const_name&.downcase
41
26
  end
42
27
 
43
-
28
+
44
29
  def inspect_include_fields
45
30
  [:type_name, :text]
46
31
  end
@@ -1,27 +1,14 @@
1
-
2
1
  module Elibri
3
2
  module ONIX
4
3
  module Release_3_0
5
-
6
- #Kategoria Themy
7
4
  class ThemaSubject
8
5
 
9
- include HashId
10
-
11
- ATTRIBUTES = [
12
- :code, :heading_text
13
- ]
14
-
15
- RELATIONS = [
16
- :inspect_include_fields
17
- ]
18
-
19
6
  attr_accessor :code, :heading_text, :to_xml
20
7
 
21
8
  def initialize(data)
22
9
  @to_xml = data.to_s
23
- @code = data.at_css('SubjectCode').try(:text)
24
- @heading_text = data.at_css('SubjectHeadingText').try(:text)
10
+ @code = data.at_css('SubjectCode')&.text
11
+ @heading_text = data.at_css('SubjectHeadingText')&.text
25
12
  end
26
13
 
27
14
  def inspect_include_fields
@@ -1,32 +1,13 @@
1
-
2
-
3
1
  module Elibri
4
2
  module ONIX
5
3
  module Release_3_0
6
-
7
4
  class TitleDetail
8
-
9
- #from ONIX documentation:
10
- #A repeatable group of data elements which together give the text of a collection title and specify its type.
11
- #Optional, but the composite is required unless the collection title is carried in full, and word-for- word,
12
- #as an integral part of the product title in P.6, in which case it should not be repeated in P.5.
13
-
14
- include HashId
15
-
16
- ATTRIBUTES = [
17
- :type, :type_name, :full_title, :product_level_title, :product_level, :collection_level_title,
18
- :collection_level
19
- ]
20
-
21
- RELATIONS = [
22
- :elements, :inspect_include_fields
23
- ]
24
-
5
+
25
6
  attr_accessor :type, :elements, :to_xml
26
-
7
+
27
8
  def initialize(data)
28
9
  @to_xml = data.to_s
29
- @type = data.at_css('TitleType').try(:text)
10
+ @type = data.at_css('TitleType')&.text
30
11
  @elements = data.css('TitleElement').map { |element_data| TitleElement.new(element_data) }
31
12
  end
32
13
 
@@ -40,16 +21,16 @@ module Elibri
40
21
 
41
22
  def full_title
42
23
  String.new.tap do |_full_title|
43
- _full_title << collection_level_title if collection_level_title.present?
44
- if product_level_title.present?
45
- _full_title << ". " if _full_title.present?
46
- _full_title << product_level_title
24
+ _full_title << collection_level_title if collection_level_title && collection_level_title.size > 0
25
+ if product_level_title && product_level_title.size > 0
26
+ _full_title << ". " if _full_title && _full_title.size > 0
27
+ _full_title << product_level_title
47
28
  end
48
29
  end
49
30
  end
50
31
 
51
32
  def product_level_title
52
- product_level.try(:full_title)
33
+ product_level&.full_title
53
34
  end
54
35
 
55
36
  def product_level
@@ -57,7 +38,7 @@ module Elibri
57
38
  end
58
39
 
59
40
  def collection_level_title
60
- collection_level.try(:full_title)
41
+ collection_level&.full_title
61
42
  end
62
43
 
63
44
  def collection_level
@@ -1,60 +1,35 @@
1
-
2
1
  module Elibri
3
2
  module ONIX
4
3
  module Release_3_0
5
-
6
4
  class TitleElement
7
-
8
- #from ONIX documentation:
9
- #A repeatable group of data elements which together represent an element of a collection title.
10
- #At least one title element is mandatory in each occurrence of the <TitleDetail> composite.
11
- #An instance of the <TitleElement> composite must include at least one of: <PartNumber>; <YearOfAnnual>; <TitleText>, or <TitlePrefix> together
12
- #with <TitleWithoutPrefix>. In other words it must carry either the text of a title element or a part or year designation; and it may carry both.
13
- #A title element must be designated as belonging to product level, collection level, or subcollection level
14
- #(the first of these may not occur in a title element representing a collective identity, and the last-named may only occur
15
- #in the case of a multi-level collection).
16
- #In the simplest case, title detail sent in a <Collection> composite will consist of a single title element, at collection level.
17
- #However, the composite structure in ONIX 3.0 allows more complex combinations of titles and part designations in multi-level
18
- #collections to be correctly represented.
19
-
20
-
21
- include HashId
22
5
 
23
- ATTRIBUTES = [
24
- :level, :part_number, :title, :subtitle, :full_title
25
- ]
26
-
27
- RELATIONS = []
28
-
29
6
  attr_accessor :level, :part_number, :title, :subtitle, :to_xml
30
-
7
+
31
8
  def initialize(data)
32
9
  @to_xml = data.to_s
33
- @level = data.at_css('TitleElementLevel').try(:text)
34
- @part_number = data.at_css('PartNumber').try(:text)
35
- @title = data.at_css('TitleText').try(:text)
36
- @subtitle = data.at_css('Subtitle').try(:text)
10
+ @level = data.at_css('TitleElementLevel')&.text
11
+ @part_number = data.at_css('PartNumber')&.text
12
+ @title = data.at_css('TitleText')&.text
13
+ @subtitle = data.at_css('Subtitle')&.text
37
14
  end
38
15
 
39
16
  def full_title
40
17
  String.new(self.title.to_s.strip).tap do |_full_title|
41
18
  if _full_title =~ /[\.!\?]$/ #czy kończy się ?!.
42
- _full_title << " " + self.subtitle if self.subtitle.present?
19
+ _full_title << " " + self.subtitle if self.subtitle && self.subtitle.size > 0
43
20
  else
44
- _full_title << ". " + self.subtitle if self.subtitle.present?
21
+ _full_title << ". " + self.subtitle if self.subtitle && self.subtitle.size > 0
45
22
  end
46
- if self.part_number.present?
23
+ if self.part_number && self.part_number.size > 0
47
24
  if self.part_number.to_i.to_s == self.part_number
48
- _full_title << " (##{self.part_number})"
25
+ _full_title << " (##{self.part_number})"
49
26
  else
50
27
  _full_title << " (#{self.part_number})"
51
- end
28
+ end
52
29
  end
53
30
  end
54
31
  end
55
-
56
32
  end
57
-
58
33
  end
59
34
  end
60
35
  end
@@ -4,7 +4,7 @@
4
4
  sender header product_identifier measure title_element title_detail collection contributor
5
5
  language extent audience_range text_content supporting_resource imprint publisher publishing_date
6
6
  sales_restriction related_product supplier_identifier stock_quantity_coded price supplier supply_detail
7
- product onix_message excerpt_info file_info thema_subject publisher_subject
7
+ product onix_message excerpt_info file_info thema_subject publisher_subject price_identifier price_constraint_limit
8
8
  }.each do |file_name|
9
9
  require File.join(File.dirname(__FILE__), "onix_3_0", file_name)
10
- end
10
+ end
@@ -0,0 +1,12 @@
1
+ module TimestampParser
2
+
3
+ def parse_timestamp(value)
4
+ year = value[0...4].to_i
5
+ month = value[4...6].to_i
6
+ day = value[6...8].to_i
7
+ h = value[9...11].to_i
8
+ m = value[11...13].to_i
9
+ Time.new(year, month, day, h, m)
10
+ end
11
+ end
12
+
@@ -2,7 +2,7 @@ module Elibri
2
2
  module ONIX
3
3
  z = $VERBOSE
4
4
  $VERBOSE = nil
5
- VERSION = "0.5.19"
5
+ VERSION = "0.6.0"
6
6
  Version = VERSION
7
7
  $VERBOSE = z
8
8
  end
data/lib/elibri_onix.rb CHANGED
@@ -1,16 +1,12 @@
1
-
2
- require 'bigdecimal'
1
+ require 'i18n'
3
2
  require 'date'
4
- # Old ActiveSupport needs 'thread' to see Mutex:
5
- require 'thread'
6
- require 'active_support'
7
- require 'active_support/core_ext'
3
+ require 'bigdecimal'
8
4
  require 'nokogiri'
9
5
  require 'elibri_onix/version'
10
6
  require 'elibri_onix/inspector'
11
7
  require 'elibri_onix/external_id'
12
- require 'elibri_onix/hash_id'
13
8
  require 'elibri_onix/external_timestamp'
9
+ require 'elibri_onix/timestamp_parser'
14
10
  require 'elibri_onix/releases'
15
11
  require 'elibri_onix_dict'
16
12
 
@@ -18,7 +14,7 @@ require 'elibri_onix_dict'
18
14
  module Elibri
19
15
  module ONIX
20
16
  module Release_3_0; end
21
-
17
+
22
18
  end
23
19
  end
24
20
 
@@ -12,7 +12,7 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
12
12
  assert_equal 2589928, e.file_size
13
13
  assert_equal "0bf20c528f323dd2a6d91627ccddf52e", e.md5
14
14
  assert_equal "mp3_excerpt", e.file_type
15
- assert_equal Time.parse("20190712T2158Z"), e.updated_at
15
+ assert_equal Time.new(2019, 7, 12, 21, 58), e.updated_at
16
16
  assert_equal "https://www.elibri.com.pl/excerpt/109048/0bf20c528f323dd2a6d91627ccddf52e/kwiaty-dla-algernona-fragment.mp3", e.link
17
17
  assert_equal 109048, e.eid
18
18
 
@@ -15,17 +15,17 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
15
15
  assert_equal "contributorid:255", cont1.id_before_type_cast
16
16
  assert_equal 255, cont1.eid
17
17
  assert_equal "20111104T0905", cont1.datestamp_before_type_cast
18
- assert_equal Date.new(2011, 11, 04).to_time + 9.hours + 5.minutes, cont1.datestamp
18
+ assert_equal Time.new(2011, 11, 04, 9, 5), cont1.datestamp
19
19
 
20
20
  assert_equal "author", cont1.role_name
21
21
  assert_equal "Św. Tomasz z Akwinu", cont1.person_name
22
22
  assert_equal ["Św. Tomasz z Akwinu"], product.authors
23
- assert cont1.biographical_note.present?
23
+ assert cont1.biographical_note && cont1.biographical_note.size > 0
24
24
 
25
25
  assert_equal "translator", cont2.role_name
26
26
  assert_equal "prof. ks. Henryk von Hausswolff OP", cont2.person_name
27
27
  assert_equal ["prof. ks. Henryk von Hausswolff OP"], product.translators
28
-
28
+
29
29
  product = load_fixture("onix_no_contributors_example.xml")
30
30
  assert product.no_contributor?
31
31
  assert !product.unnamed_persons?
@@ -11,7 +11,7 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
11
11
  assert_equal 2100230, e.file_size
12
12
  assert_equal "4b145ff46636b06f49225abdab70927f", e.md5
13
13
  assert_equal "epub_excerpt", e.file_type
14
- assert_equal Time.parse("2012-12-30 15:18 +00:00"), e.updated_at
14
+ assert_equal Time.new(2012, 12, 30, 15, 18), e.updated_at
15
15
  assert_equal "https://www.elibri.com.pl/excerpt/767/4b145ff46636b06f49225abdab70927f/fragment.epub", e.link
16
16
  assert_equal 767, e.eid
17
17
 
@@ -20,7 +20,7 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
20
20
  assert_equal 4197382, f.file_size
21
21
  assert_equal "e9353ce40eaa677f8c5d666c2f8bbb3f", f.md5
22
22
  assert_equal "epub", f.file_type
23
- assert_equal Time.parse("2012-12-30 15:18 +00:00"), f.updated_at
23
+ assert_equal Time.new(2012, 12, 30, 15, 18), f.updated_at
24
24
  assert_equal 765, f.eid
25
25
  end
26
26
 
@@ -3,18 +3,6 @@ require 'helper'
3
3
 
4
4
  describe Elibri::ONIX::Release_3_0::ONIXMessage do
5
5
 
6
- it "should be able to parse elibri extensions" do
7
- product = load_fixture("onix_elibri_extensions_example.xml")
8
-
9
- assert_equal "miękka", product.cover_type
10
- assert_equal 12.99, product.cover_price
11
- assert_equal 5, product.vat
12
- assert_equal "58.11.1", product.pkwiu
13
- assert_equal "VIC", product.pdw_exclusiveness
14
- assert product.preview_exists?
15
- assert_equal "PROMOCJA!", product.additional_info
16
- end
17
-
18
6
  it "should be able to parse the info without the propertiary extensions" do
19
7
  product = load_fixture("onix_removed_elibri_extensions.xml")
20
8
  assert_equal 12.99, product.cover_price
@@ -18,7 +18,7 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
18
18
  assert_equal "author", cont1.role_name
19
19
  assert_nil cont1.person_name
20
20
  assert_equal ["praca zbiorowa"], product.authors
21
- assert !cont1.biographical_note.present?
21
+ assert_nil cont1.biographical_note
22
22
 
23
23
  end
24
24
 
@@ -16,11 +16,6 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
16
16
 
17
17
  product = onix.products.first
18
18
 
19
- assert_equal 'miękka', product.cover_type
20
- assert_equal 12.99, product.cover_price
21
- assert_equal 5, product.vat
22
- assert_equal '58.11.1', product.pkwiu
23
-
24
19
  assert_equal 'fdb8fa072be774d97a97', product.record_reference
25
20
  assert_equal '03', product.notification_type
26
21
  assert_equal "Record had many errors", product.deletion_text
@@ -134,7 +129,7 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
134
129
  assert_equal 1000, supply_detail.on_hand
135
130
  assert_equal 7, supply_detail.pack_quantity
136
131
 
137
- supply_detail.price.tap do |price|
132
+ supply_detail.prices[0].tap do |price|
138
133
  assert_equal "02", price.type
139
134
  assert_equal 20, price.minimum_order_quantity
140
135
  assert_equal 12.99, price.amount
@@ -4,11 +4,11 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
4
4
 
5
5
  it "should be able to parse record identifiers" do
6
6
  product = load_fixture("onix_record_identifiers_example.xml")
7
-
7
+
8
8
  assert_equal "fdb8fa072be774d97a97", product.record_reference
9
9
  assert_equal '9788324799992', product.isbn13
10
10
  assert_equal '9788324788882', product.ean
11
- assert_equal '978-83-2478-888-2', product.hyphenated_isbn
11
+ assert_equal '9788324799992', product.hyphenated_isbn
12
12
 
13
13
  assert_equal({"Olesiejuk" => "355006"}, product.proprietary_identifiers)
14
14
 
@@ -4,7 +4,7 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
4
4
 
5
5
  it "should be able to parse attachment informations" do
6
6
  product = load_fixture("onix_supporting_resources_example.xml")
7
-
7
+
8
8
  assert_equal 2, product.supporting_resources.size
9
9
 
10
10
  assert_equal product.supporting_resources.first, product.front_cover
@@ -14,7 +14,7 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
14
14
  assert_equal "downloadable_file", product.supporting_resources.first.form_name
15
15
 
16
16
  assert_equal "http://elibri.com.pl/sciezka/do/pliku.png", product.front_cover.link
17
- assert_equal Date.new(2011, 12, 1) + 18.hours + 5.minutes, product.front_cover.datestamp
17
+ assert_equal Time.new(2011, 12, 1, 18, 5), product.front_cover.datestamp
18
18
  assert_equal 667, product.front_cover.eid
19
19
 
20
20
  assert_equal "widget", product.supporting_resources[1].content_type_name