elibri_onix 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +7 -4
- data/lib/elibri_onix/onix_3_0/excerpt_info.rb +44 -0
- data/lib/elibri_onix/onix_3_0/file_info.rb +43 -0
- data/lib/elibri_onix/onix_3_0/product.rb +7 -0
- data/lib/elibri_onix/releases.rb +1 -1
- data/lib/elibri_onix/version.rb +1 -1
- data/test/elibri_ebook_files_test.rb +27 -0
- data/test/fixtures/onix_ebook_with_files_example.xml +60 -0
- metadata +8 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
elibri_onix (0.2.
|
4
|
+
elibri_onix (0.2.10)
|
5
5
|
activesupport (>= 2.3.5)
|
6
6
|
elibri_onix_dict (>= 0.0.5)
|
7
7
|
i18n
|
@@ -20,12 +20,15 @@ GEM
|
|
20
20
|
json (1.7.6-java)
|
21
21
|
metaclass (0.0.1)
|
22
22
|
method_source (0.7.1)
|
23
|
+
mini_portile (0.5.1)
|
23
24
|
minitest (3.0.1)
|
24
25
|
mocha (0.11.4)
|
25
26
|
metaclass (~> 0.0.1)
|
26
|
-
multi_json (1.7.
|
27
|
-
nokogiri (1.
|
28
|
-
|
27
|
+
multi_json (1.7.7)
|
28
|
+
nokogiri (1.6.0)
|
29
|
+
mini_portile (~> 0.5.0)
|
30
|
+
nokogiri (1.6.0-java)
|
31
|
+
mini_portile (~> 0.5.0)
|
29
32
|
pry (0.9.9.6)
|
30
33
|
coderay (~> 1.0.5)
|
31
34
|
method_source (~> 0.7.1)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Elibri
|
4
|
+
module ONIX
|
5
|
+
module Release_3_0
|
6
|
+
|
7
|
+
class ExcerptInfo
|
8
|
+
|
9
|
+
#Informacja o fragmencie publikacji (e-book)
|
10
|
+
|
11
|
+
ATTRIBUTES = [
|
12
|
+
:file_type, :file_size, :md5, :updated_at, :link
|
13
|
+
]
|
14
|
+
|
15
|
+
RELATIONS = [
|
16
|
+
:inspect_include_fields
|
17
|
+
]
|
18
|
+
|
19
|
+
attr_accessor :file_type, :file_size, :md5, :updated_at, :link, :eid, :to_xml
|
20
|
+
|
21
|
+
def initialize(data)
|
22
|
+
@to_xml = data.to_s
|
23
|
+
@file_type = data.attributes['file_type'].value
|
24
|
+
@file_size = data.attributes['file_size'].value.to_i
|
25
|
+
@md5 = data.attributes['md5'].value
|
26
|
+
@updated_at = Time.parse(data.attributes['updated_at'].value)
|
27
|
+
@link = data.text
|
28
|
+
@eid = data.attributes['id'].value.to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
def id
|
32
|
+
Kernel.warn "[DEPRECATION] `id` is deprecated. Please use `eid` instead."
|
33
|
+
eid
|
34
|
+
end
|
35
|
+
|
36
|
+
def inspect_include_fields
|
37
|
+
[:link]
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Elibri
|
4
|
+
module ONIX
|
5
|
+
module Release_3_0
|
6
|
+
|
7
|
+
class FileInfo
|
8
|
+
|
9
|
+
#Informacja o fragmencie publikacji (e-book)
|
10
|
+
|
11
|
+
ATTRIBUTES = [
|
12
|
+
:file_type, :file_size, :md5, :updated_at
|
13
|
+
]
|
14
|
+
|
15
|
+
RELATIONS = [
|
16
|
+
:inspect_include_fields
|
17
|
+
]
|
18
|
+
|
19
|
+
attr_accessor :file_type, :file_size, :md5, :updated_at, :eid, :to_xml
|
20
|
+
|
21
|
+
def initialize(data)
|
22
|
+
@to_xml = data.to_s
|
23
|
+
@file_type = data.attributes['file_type'].value
|
24
|
+
@file_size = data.attributes['file_size'].value.to_i
|
25
|
+
@md5 = data.attributes['md5'].value
|
26
|
+
@updated_at = Time.parse(data.attributes['updated_at'].value)
|
27
|
+
@eid = data.attributes['id'].value.to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
def id
|
31
|
+
Kernel.warn "[DEPRECATION] `id` is deprecated. Please use `eid` instead."
|
32
|
+
eid
|
33
|
+
end
|
34
|
+
|
35
|
+
def inspect_include_fields
|
36
|
+
[:file_type]
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -175,6 +175,11 @@ module Elibri
|
|
175
175
|
#miasto, w którym została wydana ksiażka
|
176
176
|
attr_reader :city_of_publication
|
177
177
|
|
178
|
+
#informacje o fragmentach utworów (produkty cyfrowe)
|
179
|
+
attr_reader :excerpt_infos
|
180
|
+
|
181
|
+
#informacje o plikach master (produkty cyfrowe)
|
182
|
+
attr_reader :file_infos
|
178
183
|
|
179
184
|
#:nodoc:
|
180
185
|
attr_reader :text_contents
|
@@ -251,6 +256,8 @@ module Elibri
|
|
251
256
|
collateral_details_setup(data.at_xpath('xmlns:CollateralDetail')) if data.at_xpath('xmlns:CollateralDetail')
|
252
257
|
publishing_details_setup(data.at_xpath('xmlns:PublishingDetail')) if data.at_xpath('xmlns:PublishingDetail')
|
253
258
|
licence_information_setup(data)
|
259
|
+
@excerpt_infos = data.xpath("//elibri:excerpt").map { |node| ExcerptInfo.new(node) }
|
260
|
+
@file_infos = data.xpath("//elibri:master").map { |node| FileInfo.new(node) }
|
254
261
|
after_parse
|
255
262
|
end
|
256
263
|
|
data/lib/elibri_onix/releases.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
sender header product_identifier measure title_element title_detail collection contributor subject
|
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
|
7
|
+
product onix_message excerpt_info file_info
|
8
8
|
}.each do |file_name|
|
9
9
|
require File.join(File.dirname(__FILE__), "onix_3_0", file_name)
|
10
10
|
end
|
data/lib/elibri_onix/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Elibri::ONIX::Release_3_0::ONIXMessage do
|
4
|
+
|
5
|
+
it "should be able to parse file informations" do
|
6
|
+
product = load_fixture("onix_ebook_with_files_example.xml")
|
7
|
+
|
8
|
+
assert_equal 2, product.excerpt_infos.size
|
9
|
+
e = product.excerpt_infos[0]
|
10
|
+
|
11
|
+
assert_equal 2100230, e.file_size
|
12
|
+
assert_equal "4b145ff46636b06f49225abdab70927f", e.md5
|
13
|
+
assert_equal "epub_excerpt", e.file_type
|
14
|
+
assert_equal Time.parse("2012-12-30 15:18 +00:00"), e.updated_at
|
15
|
+
assert_equal "https://www.elibri.com.pl/excerpt/767", e.link
|
16
|
+
assert_equal 767, e.eid
|
17
|
+
|
18
|
+
assert_equal 2, product.file_infos.size
|
19
|
+
f = product.file_infos[0]
|
20
|
+
assert_equal 4197382, f.file_size
|
21
|
+
assert_equal "e9353ce40eaa677f8c5d666c2f8bbb3f", f.md5
|
22
|
+
assert_equal "epub", f.file_type
|
23
|
+
assert_equal Time.parse("2012-12-30 15:18 +00:00"), f.updated_at
|
24
|
+
assert_equal 765, f.eid
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ONIXMessage release="3.0" xmlns="http://ns.editeur.org/onix/3.0/reference" xmlns:elibri="http://elibri.com.pl/ns/extensions">
|
3
|
+
<elibri:Dialect>3.0.1</elibri:Dialect>
|
4
|
+
<Header>
|
5
|
+
<Sender>
|
6
|
+
<SenderName>Elibri.com.pl</SenderName>
|
7
|
+
<ContactName>Tomasz Meka</ContactName>
|
8
|
+
<EmailAddress>kontakt@elibri.com.pl</EmailAddress>
|
9
|
+
</Sender>
|
10
|
+
<SentDateTime>20130710</SentDateTime>
|
11
|
+
</Header>
|
12
|
+
<Product>
|
13
|
+
<RecordReference>fdb8fa072be774d97a97</RecordReference>
|
14
|
+
<NotificationType>03</NotificationType>
|
15
|
+
<ProductIdentifier>
|
16
|
+
<ProductIDType>15</ProductIDType>
|
17
|
+
<IDValue>9788324799992</IDValue>
|
18
|
+
</ProductIdentifier>
|
19
|
+
<DescriptiveDetail>
|
20
|
+
<ProductComposition>00</ProductComposition>
|
21
|
+
<ProductForm>EA</ProductForm>
|
22
|
+
<TitleDetail>
|
23
|
+
<TitleType>01</TitleType>
|
24
|
+
<TitleElement>
|
25
|
+
<TitleElementLevel>01</TitleElementLevel>
|
26
|
+
<TitleText>Nielegalni</TitleText>
|
27
|
+
</TitleElement>
|
28
|
+
</TitleDetail>
|
29
|
+
</DescriptiveDetail>
|
30
|
+
<PublishingDetail>
|
31
|
+
<Publisher>
|
32
|
+
<PublishingRole>01</PublishingRole>
|
33
|
+
<PublisherIdentifier>
|
34
|
+
<PublisherIDType>01</PublisherIDType>
|
35
|
+
<IDTypeName>ElibriPublisherCode</IDTypeName>
|
36
|
+
<IDValue>11</IDValue>
|
37
|
+
</PublisherIdentifier>
|
38
|
+
<PublisherName>GREG</PublisherName>
|
39
|
+
</Publisher>
|
40
|
+
<CityOfPublication>Warszawa</CityOfPublication>
|
41
|
+
<PublishingStatus>04</PublishingStatus>
|
42
|
+
<SalesRights>
|
43
|
+
<SalesRightsType>01</SalesRightsType>
|
44
|
+
<Territory>
|
45
|
+
<RegionsIncluded>WORLD</RegionsIncluded>
|
46
|
+
</Territory>
|
47
|
+
</SalesRights>
|
48
|
+
</PublishingDetail>
|
49
|
+
<elibri:preview_exists>false</elibri:preview_exists>
|
50
|
+
<elibri:SaleNotRestricted/>
|
51
|
+
<elibri:excerpts>
|
52
|
+
<elibri:excerpt md5="4b145ff46636b06f49225abdab70927f" file_size="2100230" file_type="epub_excerpt" updated_at="2012-12-30T15:18:00+00:00" id="767">https://www.elibri.com.pl/excerpt/767</elibri:excerpt>
|
53
|
+
<elibri:excerpt md5="6f534ab6ab573845bb7ab221192aa86a" file_size="2101254" file_type="mobi_excerpt" updated_at="2012-12-30T15:16:00+00:00" id="768">https://www.elibri.com.pl/excerpt/768</elibri:excerpt>
|
54
|
+
</elibri:excerpts>
|
55
|
+
<elibri:masters>
|
56
|
+
<elibri:master id="765" md5="e9353ce40eaa677f8c5d666c2f8bbb3f" file_size="4197382" file_type="epub" updated_at="2012-12-30T15:18:00+00:00"/>
|
57
|
+
<elibri:master id="766" md5="d2c75a26973a1888f241125717b166cf" file_size="5246982" file_type="mobi" updated_at="2012-12-30T15:16:00+00:00"/>
|
58
|
+
</elibri:masters>
|
59
|
+
</Product>
|
60
|
+
</ONIXMessage>
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: elibri_onix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.11
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Marcin Urbanski
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-07-17 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -155,7 +155,9 @@ files:
|
|
155
155
|
- lib/elibri_onix/onix_3_0/audience_range.rb
|
156
156
|
- lib/elibri_onix/onix_3_0/collection.rb
|
157
157
|
- lib/elibri_onix/onix_3_0/contributor.rb
|
158
|
+
- lib/elibri_onix/onix_3_0/excerpt_info.rb
|
158
159
|
- lib/elibri_onix/onix_3_0/extent.rb
|
160
|
+
- lib/elibri_onix/onix_3_0/file_info.rb
|
159
161
|
- lib/elibri_onix/onix_3_0/header.rb
|
160
162
|
- lib/elibri_onix/onix_3_0/imprint.rb
|
161
163
|
- lib/elibri_onix/onix_3_0/language.rb
|
@@ -183,6 +185,7 @@ files:
|
|
183
185
|
- test/elibri_audience_range_test.rb
|
184
186
|
- test/elibri_categories_test.rb
|
185
187
|
- test/elibri_contributors_test.rb
|
188
|
+
- test/elibri_ebook_files_test.rb
|
186
189
|
- test/elibri_edition_test.rb
|
187
190
|
- test/elibri_extensions_test.rb
|
188
191
|
- test/elibri_extent_test.rb
|
@@ -212,6 +215,7 @@ files:
|
|
212
215
|
- test/fixtures/onix_collective_work_example.xml
|
213
216
|
- test/fixtures/onix_contributors_example.xml
|
214
217
|
- test/fixtures/onix_ebook_extent_example.xml
|
218
|
+
- test/fixtures/onix_ebook_with_files_example.xml
|
215
219
|
- test/fixtures/onix_edition_example.xml
|
216
220
|
- test/fixtures/onix_elibri_extensions_example.xml
|
217
221
|
- test/fixtures/onix_epub_details_example.xml
|
@@ -265,6 +269,7 @@ test_files:
|
|
265
269
|
- test/elibri_audience_range_test.rb
|
266
270
|
- test/elibri_categories_test.rb
|
267
271
|
- test/elibri_contributors_test.rb
|
272
|
+
- test/elibri_ebook_files_test.rb
|
268
273
|
- test/elibri_edition_test.rb
|
269
274
|
- test/elibri_extensions_test.rb
|
270
275
|
- test/elibri_extent_test.rb
|
@@ -294,6 +299,7 @@ test_files:
|
|
294
299
|
- test/fixtures/onix_collective_work_example.xml
|
295
300
|
- test/fixtures/onix_contributors_example.xml
|
296
301
|
- test/fixtures/onix_ebook_extent_example.xml
|
302
|
+
- test/fixtures/onix_ebook_with_files_example.xml
|
297
303
|
- test/fixtures/onix_edition_example.xml
|
298
304
|
- test/fixtures/onix_elibri_extensions_example.xml
|
299
305
|
- test/fixtures/onix_epub_details_example.xml
|