elibri_onix 0.1.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.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/elibri_onix.gemspec +104 -0
- data/lib/elibri_onix.rb +16 -0
- data/lib/elibri_onix/onix_3_0/audience_range.rb +20 -0
- data/lib/elibri_onix/onix_3_0/collection.rb +23 -0
- data/lib/elibri_onix/onix_3_0/contributor.rb +27 -0
- data/lib/elibri_onix/onix_3_0/extent.rb +18 -0
- data/lib/elibri_onix/onix_3_0/header.rb +18 -0
- data/lib/elibri_onix/onix_3_0/imprint.rb +18 -0
- data/lib/elibri_onix/onix_3_0/language.rb +19 -0
- data/lib/elibri_onix/onix_3_0/measure.rb +18 -0
- data/lib/elibri_onix/onix_3_0/onix_message.rb +18 -0
- data/lib/elibri_onix/onix_3_0/price.rb +40 -0
- data/lib/elibri_onix/onix_3_0/product.rb +144 -0
- data/lib/elibri_onix/onix_3_0/product_identifier.rb +17 -0
- data/lib/elibri_onix/onix_3_0/publisher.rb +20 -0
- data/lib/elibri_onix/onix_3_0/publishing_date.rb +21 -0
- data/lib/elibri_onix/onix_3_0/related_product.rb +35 -0
- data/lib/elibri_onix/onix_3_0/sales_restriction.rb +21 -0
- data/lib/elibri_onix/onix_3_0/sender.rb +17 -0
- data/lib/elibri_onix/onix_3_0/stock_quantity_coded.rb +21 -0
- data/lib/elibri_onix/onix_3_0/subject.rb +28 -0
- data/lib/elibri_onix/onix_3_0/supplier.rb +29 -0
- data/lib/elibri_onix/onix_3_0/supplier_identifier.rb +22 -0
- data/lib/elibri_onix/onix_3_0/supply_detail.rb +34 -0
- data/lib/elibri_onix/onix_3_0/supporting_resource.rb +25 -0
- data/lib/elibri_onix/onix_3_0/text_content.rb +21 -0
- data/lib/elibri_onix/onix_3_0/title_detail.rb +42 -0
- data/lib/elibri_onix/onix_3_0/title_element.rb +28 -0
- data/lib/elibri_onix/releases.rb +10 -0
- data/lib/elibri_onix/version.rb +13 -0
- data/test/elibri_onix_release_3_0_onix_message_test.rb +178 -0
- data/test/elibri_onix_test.rb +10 -0
- data/test/fixtures/all_possible_tags.xml +442 -0
- data/test/helper.rb +20 -0
- metadata +241 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Elibri
|
4
|
+
module ONIX
|
5
|
+
module Release_3_0
|
6
|
+
|
7
|
+
class Measure
|
8
|
+
include ROXML
|
9
|
+
|
10
|
+
xml_name 'Measure'
|
11
|
+
xml_accessor :type, :from => 'MeasureType', :as => Fixnum
|
12
|
+
xml_accessor :measurement, :from => 'Measurement', :as => BigDecimal
|
13
|
+
xml_accessor :unit, :from => 'MeasureUnitCode'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
module Elibri
|
3
|
+
module ONIX
|
4
|
+
module Release_3_0
|
5
|
+
|
6
|
+
class ONIXMessage
|
7
|
+
include ROXML
|
8
|
+
|
9
|
+
xml_name 'ONIXMessage'
|
10
|
+
xml_accessor :release, :from => "@release"
|
11
|
+
|
12
|
+
xml_accessor :products, :as => [Product]
|
13
|
+
xml_accessor :header, :as => Header
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
module Elibri
|
6
|
+
module ONIX
|
7
|
+
module Release_3_0
|
8
|
+
|
9
|
+
class Price
|
10
|
+
include ROXML
|
11
|
+
|
12
|
+
xml_name 'Price'
|
13
|
+
|
14
|
+
xml_accessor :type, :from => 'PriceType', :as => Fixnum
|
15
|
+
xml_accessor :minimum_order_quantity, :from => 'MinimumOrderQuantity', :as => Fixnum
|
16
|
+
xml_accessor :amount, :from => 'PriceAmount', :as => BigDecimal
|
17
|
+
xml_accessor :currency_code, :from => 'CurrencyCode'
|
18
|
+
xml_accessor :printed_on_product, :from => 'PrintedOnProduct', :as => Fixnum
|
19
|
+
xml_accessor :position_on_product, :from => 'PositionOnProduct', :as => Fixnum
|
20
|
+
|
21
|
+
with_options :in => 'Tax' do |tax|
|
22
|
+
tax.xml_accessor :tax_type, :from => 'TaxType', :as => Fixnum
|
23
|
+
tax.xml_accessor :tax_rate_percent, :from => 'TaxRatePercent', :as => BigDecimal
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def printed_on_product?
|
28
|
+
printed_on_product == 2
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def vat
|
33
|
+
tax_type == 1 ? tax_rate_percent : nil
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
|
2
|
+
module Elibri
|
3
|
+
module ONIX
|
4
|
+
module Release_3_0
|
5
|
+
|
6
|
+
class Product
|
7
|
+
include ROXML
|
8
|
+
|
9
|
+
xml_name 'Product'
|
10
|
+
xml_accessor :record_reference, :from => 'RecordReference'
|
11
|
+
xml_accessor :notification_type, :from => 'NotificationType', :as => Fixnum
|
12
|
+
xml_accessor :deletion_text, :from => 'DeletionText'
|
13
|
+
|
14
|
+
xml_accessor :cover_type, :from => 'elibri:CoverType'
|
15
|
+
xml_accessor :cover_price, :from => 'elibri:CoverPrice', :as => BigDecimal
|
16
|
+
xml_accessor :vat, :from => 'elibri:Vat', :as => Fixnum
|
17
|
+
xml_accessor :pkwiu, :from => 'elibri:PKWiU'
|
18
|
+
|
19
|
+
xml_accessor :identifiers, :as => [ProductIdentifier]
|
20
|
+
xml_accessor :related_products, :as => [RelatedProduct], :in => 'RelatedMaterial'
|
21
|
+
xml_accessor :supply_details, :as => [SupplyDetail], :in => 'ProductSupply'
|
22
|
+
|
23
|
+
with_options :in => 'DescriptiveDetail' do |descriptive_detail|
|
24
|
+
descriptive_detail.xml_accessor :product_composition, :from => 'ProductComposition', :as => Fixnum
|
25
|
+
descriptive_detail.xml_accessor :product_form, :from => 'ProductForm'
|
26
|
+
descriptive_detail.xml_accessor :measures, :as => [Measure]
|
27
|
+
descriptive_detail.xml_accessor :title_details, :as => [TitleDetail]
|
28
|
+
descriptive_detail.xml_accessor :collections, :as => [Collection]
|
29
|
+
descriptive_detail.xml_accessor :contributors, :as => [Contributor]
|
30
|
+
descriptive_detail.xml_accessor :languages, :as => [Language]
|
31
|
+
descriptive_detail.xml_accessor :extents, :as => [Extent]
|
32
|
+
descriptive_detail.xml_accessor :subjects, :as => [Subject]
|
33
|
+
descriptive_detail.xml_accessor :audience_ranges, :as => [AudienceRange]
|
34
|
+
descriptive_detail.xml_accessor :edition_statement, :from => 'EditionStatement'
|
35
|
+
descriptive_detail.xml_accessor :number_of_illustrations, :from => 'NumberOfIllustrations', :as => Fixnum
|
36
|
+
end
|
37
|
+
|
38
|
+
with_options :in => 'CollateralDetail' do |collateral_detail|
|
39
|
+
collateral_detail.xml_accessor :text_contents, :as => [TextContent]
|
40
|
+
collateral_detail.xml_accessor :supporting_resources, :as => [SupportingResource]
|
41
|
+
end
|
42
|
+
|
43
|
+
with_options :in => 'PublishingDetail' do |publishing_detail|
|
44
|
+
publishing_detail.xml_accessor :imprint, :as => Imprint
|
45
|
+
publishing_detail.xml_accessor :publisher, :as => Publisher
|
46
|
+
publishing_detail.xml_accessor :publishing_status, :from => 'PublishingStatus', :as => Fixnum
|
47
|
+
publishing_detail.xml_accessor :publishing_date, :as => PublishingDate
|
48
|
+
publishing_detail.xml_accessor :sales_restrictions, :as => [SalesRestriction]
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def isbn13
|
53
|
+
identifiers.find {|identifier| identifier.type == 15}.try(:value)
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def ean13
|
58
|
+
identifiers.find {|identifier| identifier.type == 3}.try(:value)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
%w{height width thickness weight}.each do |method_name|
|
63
|
+
define_method(method_name) do
|
64
|
+
send(method_name + '_measure').try(:measurement)
|
65
|
+
end
|
66
|
+
|
67
|
+
define_method(method_name + '_unit') do
|
68
|
+
send(method_name + '_measure').try(:unit)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def proprietary_identifiers
|
74
|
+
Hash.new.tap do |hash|
|
75
|
+
identifiers.each do |identifier|
|
76
|
+
hash[identifier.type_name] = identifier.value if identifier.type == 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def full_title
|
83
|
+
title_details.find {|title_detail| title_detail.type == 1}.try(:full_title)
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def original_title
|
88
|
+
title_details.find {|title_detail| title_detail.type == 3}.try(:full_title)
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
def trade_title
|
93
|
+
title_details.find {|title_detail| title_detail.type == 10}.try(:full_title)
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def number_of_pages
|
98
|
+
extents.find {|extent| extent.type == 0}.try(:value)
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
def reading_age_from
|
103
|
+
age_from = audience_ranges.find {|audience_range| (audience_range.qualifier == 18) && (audience_range.precision == 3)}.try(:value)
|
104
|
+
age_from.present? ? age_from.to_i : nil
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def reading_age_to
|
109
|
+
age_to = audience_ranges.find {|audience_range| (audience_range.qualifier == 18) && (audience_range.precision == 4)}.try(:value)
|
110
|
+
age_to.present? ? age_to.to_i : nil
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
def imprint_name
|
115
|
+
imprint.try(:name)
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def height_measure
|
122
|
+
measures.find {|measure| measure.type == 1}
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def width_measure
|
127
|
+
measures.find {|measure| measure.type == 2}
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
def thickness_measure
|
132
|
+
measures.find {|measure| measure.type == 3}
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
def weight_measure
|
137
|
+
measures.find {|measure| measure.type == 8}
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
module Elibri
|
3
|
+
module ONIX
|
4
|
+
module Release_3_0
|
5
|
+
|
6
|
+
class ProductIdentifier
|
7
|
+
include ROXML
|
8
|
+
|
9
|
+
xml_name 'ProductIdentifier'
|
10
|
+
xml_accessor :type, :as => Fixnum, :from => 'ProductIDType'
|
11
|
+
xml_accessor :type_name, :from => 'IDTypeName'
|
12
|
+
xml_accessor :value, :from => 'IDValue'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Elibri
|
5
|
+
module ONIX
|
6
|
+
module Release_3_0
|
7
|
+
|
8
|
+
class Publisher
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name 'Publisher'
|
12
|
+
|
13
|
+
xml_accessor :role, :from => 'PublishingRole', :as => Fixnum
|
14
|
+
xml_accessor :name, :from => 'PublisherName'
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Elibri
|
5
|
+
module ONIX
|
6
|
+
module Release_3_0
|
7
|
+
|
8
|
+
class PublishingDate
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name 'PublishingDate'
|
12
|
+
|
13
|
+
xml_accessor :role, :from => 'PublishingDateRole', :as => Fixnum
|
14
|
+
xml_accessor :format, :from => 'DateFormat', :as => Fixnum
|
15
|
+
xml_accessor :date, :from => 'Date'
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
module Elibri
|
6
|
+
module ONIX
|
7
|
+
module Release_3_0
|
8
|
+
|
9
|
+
class RelatedProduct
|
10
|
+
include ROXML
|
11
|
+
|
12
|
+
xml_name 'RelatedProduct'
|
13
|
+
|
14
|
+
xml_accessor :relation_code, :from => 'ProductRelationCode', :as => Fixnum
|
15
|
+
xml_accessor :identifiers, :as => [ProductIdentifier]
|
16
|
+
|
17
|
+
|
18
|
+
def isbn13
|
19
|
+
identifiers.find {|identifier| identifier.type == 15}.try(:value)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def proprietary_identifiers
|
24
|
+
Hash.new.tap do |hash|
|
25
|
+
identifiers.each do |identifier|
|
26
|
+
hash[identifier.type_name] = identifier.value if identifier.type == 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Elibri
|
5
|
+
module ONIX
|
6
|
+
module Release_3_0
|
7
|
+
|
8
|
+
class SalesRestriction
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name 'SalesRestriction'
|
12
|
+
|
13
|
+
xml_accessor :type, :from => 'SalesRestrictionType', :as => Fixnum
|
14
|
+
xml_accessor :outlet_name, :from => 'SalesOutletName', :in => 'SalesOutlet'
|
15
|
+
xml_accessor :end_date, :from => 'EndDate', :as => Date
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
module Elibri
|
3
|
+
module ONIX
|
4
|
+
module Release_3_0
|
5
|
+
|
6
|
+
class Sender
|
7
|
+
include ROXML
|
8
|
+
xml_name 'Sender'
|
9
|
+
|
10
|
+
xml_accessor :sender_name, :from => 'SenderName'
|
11
|
+
xml_accessor :contact_name, :from => 'ContactName'
|
12
|
+
xml_accessor :email_address, :from => 'EmailAddress'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
module Elibri
|
6
|
+
module ONIX
|
7
|
+
module Release_3_0
|
8
|
+
|
9
|
+
class StockQuantityCoded
|
10
|
+
include ROXML
|
11
|
+
|
12
|
+
xml_name 'StockQuantityCoded'
|
13
|
+
|
14
|
+
xml_accessor :code_type, :from => 'StockQuantityCodeType', :as => Fixnum
|
15
|
+
xml_accessor :code, :from => 'StockQuantityCode'
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Elibri
|
4
|
+
module ONIX
|
5
|
+
module Release_3_0
|
6
|
+
|
7
|
+
class Subject
|
8
|
+
include ROXML
|
9
|
+
|
10
|
+
xml_name 'Subject'
|
11
|
+
xml_accessor :scheme_identifier, :from => 'SubjectSchemeIdentifier', :as => Fixnum
|
12
|
+
xml_accessor :scheme_name, :from => 'SubjectSchemeName'
|
13
|
+
xml_accessor :scheme_version, :from => 'SubjectSchemeVersion'
|
14
|
+
xml_accessor :code, :from => 'SubjectCode'
|
15
|
+
xml_accessor :heading_text, :from => 'SubjectHeadingText'
|
16
|
+
|
17
|
+
xml_accessor :main_subject, :from => 'MainSubject'
|
18
|
+
|
19
|
+
|
20
|
+
def main_subject?
|
21
|
+
main_subject == ''
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Elibri
|
5
|
+
module ONIX
|
6
|
+
module Release_3_0
|
7
|
+
|
8
|
+
class Supplier
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name 'Supplier'
|
12
|
+
|
13
|
+
xml_accessor :role, :from => 'SupplierRole', :as => Fixnum
|
14
|
+
xml_accessor :identifiers, :as => [SupplierIdentifier]
|
15
|
+
xml_accessor :name, :from => 'SupplierName'
|
16
|
+
xml_accessor :telephone_number, :from => 'TelephoneNumber'
|
17
|
+
xml_accessor :email_address, :from => 'EmailAddress'
|
18
|
+
xml_accessor :website, :from => 'WebsiteLink', :in => 'Website'
|
19
|
+
|
20
|
+
|
21
|
+
def nip
|
22
|
+
identifiers.find {|identifier| (identifier.type == 2) && (identifier.type_name == 'NIP')}.try(:value)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|