elibri_onix_generator 0.4.3 → 0.4.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c05a34a89b8b767c29e2944702fa2f586141b4c
|
4
|
+
data.tar.gz: 57210eef6751fccbf7182f4d90c695151f7c2ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 908de32a9a946c7b44492c7a4875e546d8d45880c6ab626e6c9cdf64f870ab5d37817436c6f950728a28d2770b00279caf11877ae85d9b9dbb7183e740ec5dea
|
7
|
+
data.tar.gz: 158d5f989653fef2247d5907a0af63fae295c216cd00462f7c045bfd306fe4ad691c2a40f7e7a0328f274e8a8f1f7add294e7cb5dbb446a004c8472be39ec2ce
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
3
|
require "elibri_onix_generator/version"
|
4
|
+
require "elibri_onix_generator/model/product"
|
5
|
+
require "elibri_onix_generator/model/contributor"
|
4
6
|
|
5
7
|
Gem::Specification.new do |s|
|
6
8
|
s.name = "elibri_onix_generator"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Elibri
|
2
|
+
module ONIX
|
3
|
+
module Model
|
4
|
+
|
5
|
+
class Contributor
|
6
|
+
|
7
|
+
attr_accessor :role_onix_code, :name, :last_name, :language_onix_code, :full_name
|
8
|
+
|
9
|
+
def initialize(attributes = {})
|
10
|
+
attributes.each do |key, value|
|
11
|
+
self.send("#{key}=", value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def generated_full_name
|
16
|
+
full_name || "#{name} #{last_name}".strip
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'elibri_onix_generator'
|
2
|
+
|
3
|
+
module Elibri
|
4
|
+
module ONIX
|
5
|
+
module Model
|
6
|
+
|
7
|
+
class Product
|
8
|
+
|
9
|
+
class OnixGenerator
|
10
|
+
include Elibri::ONIX::Generator
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
attr_accessor :product_form_onix_code, :publisher_name, :record_reference, :isbn_value,
|
15
|
+
:authorship_kind, :edition_statement, :thema_codes, :publishing_status_onix_code,
|
16
|
+
:publication_day, :publication_month, :publication_year, :cover_url, :notification_type_onix_code,
|
17
|
+
:collection_name, :collection_part, :title, :subtitle, :title_part, :original_title, :trade_title,
|
18
|
+
:description, :contributors, :height, :width, :thickness, :weight, :number_of_illustrations, :number_of_pages,
|
19
|
+
:cover_type_name, :price_amount, :series_name, :vat, :pkwiu
|
20
|
+
|
21
|
+
def to_xml
|
22
|
+
OnixGenerator.new(self, {}).to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def kind_of_book?
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def series_membership_kind
|
31
|
+
if series_name && series_name.size > 0
|
32
|
+
"user_given"
|
33
|
+
else
|
34
|
+
"no_series"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def series_memberships
|
39
|
+
if series_name && series_name.size > 0
|
40
|
+
[OpenStruct.new(series_name: series_name)]
|
41
|
+
else
|
42
|
+
[]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def collection_with_issn
|
47
|
+
end
|
48
|
+
|
49
|
+
def cover_type
|
50
|
+
if cover_type_name && cover_type_name.size > 0
|
51
|
+
OpenStruct.new(name: cover_type_name)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def kind_of_measurable?
|
56
|
+
width || height
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def title_parts
|
61
|
+
res = []
|
62
|
+
product_code = Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT #01
|
63
|
+
collection_code = Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::COLLECTION #02
|
64
|
+
res << OpenStruct.new(:level => collection_code, :title => collection_name, :part => self.collection_part) if collection_name && collection_name.size > 0
|
65
|
+
res << OpenStruct.new(:level => product_code, :title => self.title, :subtitle => self.subtitle, :part => self.title_part) if self.title && self.title.size > 0
|
66
|
+
return res
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def other_texts
|
71
|
+
if self.description && self.description.size > 0
|
72
|
+
[OpenStruct.new({ :text => description,
|
73
|
+
:type_onix_code => "03",
|
74
|
+
:exportable? => true})]
|
75
|
+
else
|
76
|
+
[]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def attachments
|
81
|
+
if cover_url
|
82
|
+
[OpenStruct.new({"onix_resource_mode" => "03", "attachment_type_code" => "01",
|
83
|
+
"file" => OpenStruct.new({ "url" => cover_url })})]
|
84
|
+
else
|
85
|
+
[]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def notification_type
|
91
|
+
OpenStruct.new({"onix_code" => notification_type_onix_code}) if notification_type_onix_code
|
92
|
+
end
|
93
|
+
|
94
|
+
def publication_date_with_onix_format_code
|
95
|
+
publication_year_str = self.publication_year ? "%04d"% self.publication_year : nil
|
96
|
+
publication_month_str = self.publication_month ? "%02d"% self.publication_month : nil
|
97
|
+
publication_day_str = self.publication_day ? "%02d"% self.publication_day : nil
|
98
|
+
|
99
|
+
publication_date = [publication_year_str, publication_month_str, publication_day_str].compact.join('')
|
100
|
+
|
101
|
+
if self.publication_year && self.publication_month && self.publication_day
|
102
|
+
[publication_year_str + publication_month_str + publication_day_str, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDD]
|
103
|
+
elsif self.publication_year && self.publication_month
|
104
|
+
[publication_year_str + publication_month_str, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMM]
|
105
|
+
elsif self.publication_year
|
106
|
+
[publication_year_str, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYY]
|
107
|
+
else
|
108
|
+
[nil, nil]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def public?
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
def publisher_name_for_onix
|
117
|
+
publisher_name
|
118
|
+
end
|
119
|
+
|
120
|
+
def thema_codes_for_onix
|
121
|
+
thema_codes
|
122
|
+
end
|
123
|
+
|
124
|
+
def initialize(attributes = {})
|
125
|
+
attributes.each do |key, value|
|
126
|
+
self.send("#{key}=", value)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -644,8 +644,7 @@ module Elibri
|
|
644
644
|
end
|
645
645
|
end
|
646
646
|
|
647
|
-
if
|
648
|
-
(product.kind_of_book? or product.kind_of_ebook?) && product.number_of_pages #number_of_pages to int
|
647
|
+
if field_exists?(product, :number_of_pages)
|
649
648
|
tag(:Extent) do
|
650
649
|
comment 'Liczba stron - tylko dla produktów typu książka', :kind => :onix_extent
|
651
650
|
tag(:ExtentType, Elibri::ONIX::Dict::Release_3_0::ExtentType::PAGE_COUNT)
|
@@ -653,8 +652,7 @@ module Elibri
|
|
653
652
|
tag(:ExtentUnit, Elibri::ONIX::Dict::Release_3_0::ExtentUnit::PAGES)
|
654
653
|
end
|
655
654
|
end
|
656
|
-
if
|
657
|
-
(product.kind_of_book? or product.kind_of_ebook?) and product.number_of_illustrations
|
655
|
+
if field_exists?(product, :number_of_illustrations)
|
658
656
|
comment 'Liczba ilustracji - tylko dla produktów typu książka', :kind => :onix_extent
|
659
657
|
tag(:NumberOfIllustrations, product.number_of_illustrations)
|
660
658
|
end
|
@@ -953,7 +951,7 @@ module Elibri
|
|
953
951
|
# Oprócz nazwy serii może zostać również podany numer wewnątrz serii, jeśli seria jest numerowana.
|
954
952
|
# Książka może należeć do kilku serii, wtedy tag <strong><Collection></strong> występuje kilkukrotnie.
|
955
953
|
def export_series_memberships!(product)
|
956
|
-
if product.respond_to?(:series_membership_kind) && (product.series_membership_kind
|
954
|
+
if product.respond_to?(:series_membership_kind) && (product.series_membership_kind == "user_given" || product.collection_with_issn)
|
957
955
|
(product.series_memberships + [product.collection_with_issn]).compact.each_with_index do |series_membership, idx|
|
958
956
|
tag(:Collection) do
|
959
957
|
comment "Używamy tylko #{Elibri::ONIX::Dict::Release_3_0::CollectionType::PUBLISHER_COLLECTION} - seria wydawnictwa", :kind => :onix_series_memberships
|
@@ -1094,7 +1092,10 @@ module Elibri
|
|
1094
1092
|
if @elibri_onix_dialect >= '3.0.1'
|
1095
1093
|
|
1096
1094
|
if field_exists?(product, :cover_type)
|
1097
|
-
|
1095
|
+
begin
|
1096
|
+
comment_dictionary "Format okładki", Product::CoverType.all.map(&:name), :indent => 10
|
1097
|
+
rescue NameError
|
1098
|
+
end
|
1098
1099
|
tag("elibri:CoverType", product.cover_type.name)
|
1099
1100
|
end
|
1100
1101
|
|
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.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Urbański
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-09-
|
12
|
+
date: 2018-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -53,6 +53,8 @@ files:
|
|
53
53
|
- Rakefile
|
54
54
|
- elibri_onix_generator.gemspec
|
55
55
|
- lib/elibri_onix_generator.rb
|
56
|
+
- lib/elibri_onix_generator/model/contributor.rb
|
57
|
+
- lib/elibri_onix_generator/model/product.rb
|
56
58
|
- lib/elibri_onix_generator/version.rb
|
57
59
|
homepage: ''
|
58
60
|
licenses: []
|