elibri_onix 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "http://rubygems.org"
3
3
  gem 'activesupport', '>= 2.3.5'
4
4
  gem 'roxml', '= 3.1.3'
5
5
  gem 'i18n'
6
- gem 'elibri_onix_dict', '0.0.5'
6
+ gem 'elibri_onix_dict', '>= 0.0.5'
7
7
 
8
8
  group :development do
9
9
  gem "pry"
data/Gemfile.lock CHANGED
@@ -38,7 +38,7 @@ PLATFORMS
38
38
  DEPENDENCIES
39
39
  activesupport (>= 2.3.5)
40
40
  bundler (>= 1.0.0)
41
- elibri_onix_dict (= 0.0.5)
41
+ elibri_onix_dict (>= 0.0.5)
42
42
  i18n
43
43
  jeweler (~> 1.6.2)
44
44
  minitest
data/elibri_onix.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{elibri_onix}
8
- s.version = "0.1.9"
8
+ s.version = "0.1.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcin Urbanski"]
@@ -26,6 +26,8 @@ Gem::Specification.new do |s|
26
26
  "VERSION",
27
27
  "elibri_onix.gemspec",
28
28
  "lib/elibri_onix.rb",
29
+ "lib/elibri_onix/external_id.rb",
30
+ "lib/elibri_onix/external_timestamp.rb",
29
31
  "lib/elibri_onix/inspector.rb",
30
32
  "lib/elibri_onix/onix_3_0/audience_range.rb",
31
33
  "lib/elibri_onix/onix_3_0/collection.rb",
@@ -113,7 +115,7 @@ Gem::Specification.new do |s|
113
115
  s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
114
116
  s.add_runtime_dependency(%q<roxml>, ["= 3.1.3"])
115
117
  s.add_runtime_dependency(%q<i18n>, [">= 0"])
116
- s.add_runtime_dependency(%q<elibri_onix_dict>, ["= 0.0.5"])
118
+ s.add_runtime_dependency(%q<elibri_onix_dict>, [">= 0.0.5"])
117
119
  s.add_development_dependency(%q<pry>, [">= 0"])
118
120
  s.add_development_dependency(%q<mocha>, [">= 0"])
119
121
  s.add_development_dependency(%q<minitest>, [">= 0"])
@@ -124,7 +126,7 @@ Gem::Specification.new do |s|
124
126
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
125
127
  s.add_dependency(%q<roxml>, ["= 3.1.3"])
126
128
  s.add_dependency(%q<i18n>, [">= 0"])
127
- s.add_dependency(%q<elibri_onix_dict>, ["= 0.0.5"])
129
+ s.add_dependency(%q<elibri_onix_dict>, [">= 0.0.5"])
128
130
  s.add_dependency(%q<pry>, [">= 0"])
129
131
  s.add_dependency(%q<mocha>, [">= 0"])
130
132
  s.add_dependency(%q<minitest>, [">= 0"])
@@ -136,7 +138,7 @@ Gem::Specification.new do |s|
136
138
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
137
139
  s.add_dependency(%q<roxml>, ["= 3.1.3"])
138
140
  s.add_dependency(%q<i18n>, [">= 0"])
139
- s.add_dependency(%q<elibri_onix_dict>, ["= 0.0.5"])
141
+ s.add_dependency(%q<elibri_onix_dict>, [">= 0.0.5"])
140
142
  s.add_dependency(%q<pry>, [">= 0"])
141
143
  s.add_dependency(%q<mocha>, [">= 0"])
142
144
  s.add_dependency(%q<minitest>, [">= 0"])
@@ -0,0 +1,11 @@
1
+ module ExternalId
2
+
3
+ def self.included(base)
4
+ base.xml_accessor :id_before_type_cast, :from => "@sourcename"
5
+ end
6
+
7
+ def id
8
+ id_before_type_cast.split(":")[1].to_i
9
+ end
10
+
11
+ end
@@ -0,0 +1,17 @@
1
+ module ExternalTimestamp
2
+
3
+ def self.included(base)
4
+ base.xml_accessor :datestamp_before_type_cast, :from => "@datestamp"
5
+ end
6
+
7
+ def datestamp
8
+ year = datestamp_before_type_cast[0...4].to_i
9
+ month = datestamp_before_type_cast[4...6].to_i
10
+ day = datestamp_before_type_cast[6...8].to_i
11
+ h = datestamp_before_type_cast[9...11].to_i
12
+ m = datestamp_before_type_cast[11...13].to_i
13
+
14
+ Date.new(year, month, day) + h.hours + m.minutes
15
+ end
16
+
17
+ end
@@ -6,6 +6,8 @@ module Elibri
6
6
  class Contributor
7
7
  include ROXML
8
8
  include Inspector
9
+ include ExternalId
10
+ include ExternalTimestamp
9
11
 
10
12
  xml_name 'Contributor'
11
13
 
@@ -96,7 +96,7 @@ module Elibri
96
96
 
97
97
 
98
98
  def front_cover
99
- supporting_resources.find { |resource| resource.content_type_name == "front_cover" }.try(:link)
99
+ supporting_resources.find { |resource| resource.content_type_name == "front_cover" }
100
100
  end
101
101
 
102
102
  def series_names
@@ -170,10 +170,10 @@ module Elibri
170
170
 
171
171
  @reading_age_from = audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "03")}.try(:value)
172
172
  @reading_age_to = audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "04")}.try(:value)
173
- @table_of_contents = text_contents.find { |t| t.type_name == "table_of_contents" }.try(:text)
174
- @description = text_contents.find { |t| t.type_name == "main_description" }.try(:text)
175
- @reviews = text_contents.find_all { |t| t.type_name == "review" }.map { |t| [t.text, t.author] }
176
- @excerpts = text_contents.find_all { |t| t.type_name == "excerpt" }.map { |t| t.text }
173
+ @table_of_contents = text_contents.find { |t| t.type_name == "table_of_contents" }
174
+ @description = text_contents.find { |t| t.type_name == "main_description" }
175
+ @reviews = text_contents.find_all { |t| t.type_name == "review" }
176
+ @excerpts = text_contents.find_all { |t| t.type_name == "excerpt" }
177
177
  @series = collections.map { |c| [c.title_detail.elements[0].title, c.title_detail.elements[0].part_number] }
178
178
  distinctive_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::DISTINCTIVE_TITLE)
179
179
  if distinctive_title
@@ -7,6 +7,9 @@ module Elibri
7
7
  class SupportingResource
8
8
  include ROXML
9
9
  include Inspector
10
+ include ExternalId
11
+ include ExternalTimestamp
12
+
10
13
 
11
14
  xml_name 'SupportingResource'
12
15
 
@@ -6,6 +6,8 @@ module Elibri
6
6
  class TextContent
7
7
  include ROXML
8
8
  include Inspector
9
+ include ExternalId
10
+ include ExternalTimestamp
9
11
 
10
12
  xml_name 'TextContent'
11
13
 
@@ -4,7 +4,7 @@ module Elibri
4
4
  module Version
5
5
  MAJOR = 0
6
6
  MINOR = 1
7
- PATCH = 9
7
+ PATCH = 10
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
10
10
  end
data/lib/elibri_onix.rb CHANGED
@@ -7,7 +7,10 @@ require 'active_support/core_ext'
7
7
  require 'roxml'
8
8
  require 'elibri_onix/version'
9
9
  require 'elibri_onix/inspector'
10
+ require 'elibri_onix/external_id'
11
+ require 'elibri_onix/external_timestamp'
10
12
  require 'elibri_onix/releases'
13
+
11
14
  require 'elibri_onix_dict'
12
15
 
13
16
  $KCODE = "UTF-8"
@@ -11,6 +11,11 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
11
11
  cont1 = product.contributors[0]
12
12
  cont2 = product.contributors[1]
13
13
 
14
+ assert_equal "contributorid:255", cont1.id_before_type_cast
15
+ assert_equal 255, cont1.id
16
+ assert_equal "20111104T0905", cont1.datestamp_before_type_cast
17
+ assert_equal Date.new(2011, 11, 04).to_time + 9.hours + 5.minutes, cont1.datestamp
18
+
14
19
  assert_equal "author", cont1.role_name
15
20
  assert_equal "Św. Tomasz z Akwinu", cont1.person_name
16
21
  assert_equal ["Św. Tomasz z Akwinu"], product.authors
@@ -6,7 +6,20 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
6
6
  product = load_fixture("onix_supporting_resources_example.xml")
7
7
 
8
8
  assert_equal 2, product.supporting_resources.size
9
- assert_equal "http://elibri.com.pl/sciezka/do/pliku.png", product.front_cover
9
+
10
+ assert_equal product.supporting_resources.first, product.front_cover
11
+
12
+ assert_equal "front_cover", product.supporting_resources.first.content_type_name
13
+ assert_equal "image", product.supporting_resources.first.mode_name
14
+ assert_equal "downloadable_file", product.supporting_resources.first.form_name
15
+
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
18
+ assert_equal 667, product.front_cover.id
19
+
20
+ assert_equal "sample_content", product.supporting_resources[1].content_type_name
21
+ assert_equal "text", product.supporting_resources[1].mode_name
22
+ assert_equal "downloadable_file", product.supporting_resources[1].form_name
10
23
  end
11
24
 
12
25
  end
@@ -6,11 +6,26 @@ describe Elibri::ONIX::Release_3_0::ONIXMessage do
6
6
  product = load_fixture("onix_texts_example.xml")
7
7
 
8
8
  assert_equal 4, product.text_contents.size
9
+
10
+ assert_equal "1. Wprowadzenie<br />2. Rozdział pierwszy<br />[...]", product.table_of_contents.text
11
+ assert_equal Date.new(2011, 12, 04) + 12.hours + 15.minutes, product.table_of_contents.datestamp
12
+ assert_equal 133, product.table_of_contents.id
9
13
 
10
- assert_equal "1. Wprowadzenie<br/>2. Rozdział pierwszy<br/>[...]", product.table_of_contents
11
- assert_equal [["Recenzja książki<br/>[...]", "Jan Kowalski"]], product.reviews
12
- assert_equal "Opis książki<br/>[...]", product.description
13
- assert_equal ["Fragment książki<br/>[...]"], product.excerpts
14
- end
14
+ assert_equal 1, product.reviews.size
15
+ review = product.reviews.first
16
+ assert_equal "Recenzja książki<br />[...]", review.text
17
+ assert_equal "Jan Kowalski", review.author
18
+ assert_equal Date.new(2011, 12, 4) + 12.hours + 18.minutes, review.datestamp
19
+ assert_equal 134, review.id
20
+
21
+ assert_equal "Opis książki<br />[...]", product.description.text
22
+ assert_equal Date.new(2011, 12, 4) + 12.hours + 25.minutes, product.description.datestamp
23
+ assert_equal 135, product.description.id
15
24
 
25
+ assert_equal 1, product.excerpts.size
26
+ excerpt = product.excerpts.first
27
+ assert_equal "Fragment książki<br />[...]", excerpt.text
28
+ assert_equal Date.new(2011, 12, 4) + 12.hours + 35.minutes, excerpt.datestamp
29
+ assert_equal 136, excerpt.id
30
+ end
16
31
  end
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <ONIXMessage xmlns:elibri="http://elibri.com.pl/ns/extensions" release="3.0" xmlns="http://www.editeur.org/onix/3.0/reference">
2
+ <ONIXMessage xmlns="http://www.editeur.org/onix/3.0/reference" release="3.0" xmlns:elibri="http://elibri.com.pl/ns/extensions">
3
3
  <elibri:Dialect>3.0.1</elibri:Dialect>
4
4
  <Header>
5
5
  <Sender>
@@ -7,7 +7,7 @@
7
7
  <ContactName>Tomasz Meka</ContactName>
8
8
  <EmailAddress>kontakt@elibri.com.pl</EmailAddress>
9
9
  </Sender>
10
- <SentDateTime>20111111</SentDateTime>
10
+ <SentDateTime>20111204</SentDateTime>
11
11
  </Header>
12
12
  <Product>
13
13
  <RecordReference>fdb8fa072be774d97a97</RecordReference>
@@ -26,7 +26,7 @@
26
26
  <TitleText>Taka jest nasza wiara</TitleText>
27
27
  </TitleElement>
28
28
  </TitleDetail>
29
- <Contributor>
29
+ <Contributor datestamp="20111104T0905" sourcename="contributorid:255">
30
30
  <SequenceNumber>1</SequenceNumber>
31
31
  <ContributorRole>A01</ContributorRole>
32
32
  <PersonName>Św. Tomasz z Akwinu</PersonName>
@@ -34,7 +34,7 @@
34
34
  <KeyNames>Tomasz z Akwinu</KeyNames>
35
35
  <BiographicalNote>Tomasz z Akwinu, Akwinata, łac. Thoma de Aquino (ur. 1225, zm. 7 marca 1274) – filozof scholastyczny, teolog, członek zakonu dominikanów. Był jednym z najwybitniejszych myślicieli w dziejach chrześcijaństwa. Święty Kościoła katolickiego, jeden z doktorów Kościoła, który nauczając przekazywał owoce swej kontemplacji (łac. contemplata aliis tradere).</BiographicalNote>
36
36
  </Contributor>
37
- <Contributor>
37
+ <Contributor datestamp="20111104T0905" sourcename="contributorid:256">
38
38
  <SequenceNumber>2</SequenceNumber>
39
39
  <ContributorRole>B06</ContributorRole>
40
40
  <FromLanguage>lat</FromLanguage>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <ONIXMessage xmlns:elibri="http://elibri.com.pl/ns/extensions" release="3.0" xmlns="http://www.editeur.org/onix/3.0/reference">
2
+ <ONIXMessage xmlns="http://www.editeur.org/onix/3.0/reference" release="3.0" xmlns:elibri="http://elibri.com.pl/ns/extensions">
3
3
  <elibri:Dialect>3.0.1</elibri:Dialect>
4
4
  <Header>
5
5
  <Sender>
@@ -7,7 +7,7 @@
7
7
  <ContactName>Tomasz Meka</ContactName>
8
8
  <EmailAddress>kontakt@elibri.com.pl</EmailAddress>
9
9
  </Sender>
10
- <SentDateTime>20111111</SentDateTime>
10
+ <SentDateTime>20111204</SentDateTime>
11
11
  </Header>
12
12
  <Product>
13
13
  <RecordReference>fdb8fa072be774d97a97</RecordReference>
@@ -28,7 +28,7 @@
28
28
  </TitleDetail>
29
29
  </DescriptiveDetail>
30
30
  <CollateralDetail>
31
- <SupportingResource>
31
+ <SupportingResource datestamp="20111201T1805" sourcename="resourceid:667">
32
32
  <ResourceContentType>01</ResourceContentType>
33
33
  <ContentAudience>00</ContentAudience>
34
34
  <ResourceMode>03</ResourceMode>
@@ -37,7 +37,7 @@
37
37
  <ResourceLink>http://elibri.com.pl/sciezka/do/pliku.png</ResourceLink>
38
38
  </ResourceVersion>
39
39
  </SupportingResource>
40
- <SupportingResource>
40
+ <SupportingResource datestamp="20111201T1809" sourcename="resourceid:668">
41
41
  <ResourceContentType>15</ResourceContentType>
42
42
  <ContentAudience>00</ContentAudience>
43
43
  <ResourceMode>04</ResourceMode>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <ONIXMessage release="3.0" xmlns:elibri="http://elibri.com.pl/ns/extensions" xmlns="http://www.editeur.org/onix/3.0/reference">
2
+ <ONIXMessage xmlns="http://www.editeur.org/onix/3.0/reference" release="3.0" xmlns:elibri="http://elibri.com.pl/ns/extensions">
3
3
  <elibri:Dialect>3.0.1</elibri:Dialect>
4
4
  <Header>
5
5
  <Sender>
@@ -7,7 +7,7 @@
7
7
  <ContactName>Tomasz Meka</ContactName>
8
8
  <EmailAddress>kontakt@elibri.com.pl</EmailAddress>
9
9
  </Sender>
10
- <SentDateTime>20111112</SentDateTime>
10
+ <SentDateTime>20111204</SentDateTime>
11
11
  </Header>
12
12
  <Product>
13
13
  <RecordReference>fdb8fa072be774d97a97</RecordReference>
@@ -28,33 +28,33 @@
28
28
  </TitleDetail>
29
29
  </DescriptiveDetail>
30
30
  <CollateralDetail>
31
- <TextContent>
31
+ <TextContent datestamp="20111204T1215" sourcename="textid:133">
32
32
  <TextType>04</TextType>
33
33
  <ContentAudience>00</ContentAudience>
34
34
  <Text>
35
- <![CDATA[1. Wprowadzenie<br/>2. Rozdział pierwszy<br/>[...]]]>
35
+ <![CDATA[1. Wprowadzenie<br />2. Rozdział pierwszy<br />[...]]]>
36
36
  </Text>
37
37
  </TextContent>
38
- <TextContent>
38
+ <TextContent datestamp="20111204T1218" sourcename="textid:134">
39
39
  <TextType>07</TextType>
40
40
  <ContentAudience>00</ContentAudience>
41
41
  <Text>
42
- <![CDATA[Recenzja książki<br/>[...]]]>
42
+ <![CDATA[Recenzja książki<br />[...]]]>
43
43
  </Text>
44
44
  <TextAuthor>Jan Kowalski</TextAuthor>
45
45
  </TextContent>
46
- <TextContent>
46
+ <TextContent datestamp="20111204T1225" sourcename="textid:135">
47
47
  <TextType>03</TextType>
48
48
  <ContentAudience>00</ContentAudience>
49
49
  <Text>
50
- <![CDATA[Opis książki<br/>[...]]]>
50
+ <![CDATA[Opis książki<br />[...]]]>
51
51
  </Text>
52
52
  </TextContent>
53
- <TextContent>
53
+ <TextContent datestamp="20111204T1235" sourcename="textid:136">
54
54
  <TextType>14</TextType>
55
55
  <ContentAudience>00</ContentAudience>
56
56
  <Text>
57
- <![CDATA[Fragment książki<br/>[...]]]>
57
+ <![CDATA[Fragment książki<br />[...]]]>
58
58
  </Text>
59
59
  </TextContent>
60
60
  </CollateralDetail>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elibri_onix
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 9
10
- version: 0.1.9
9
+ - 10
10
+ version: 0.1.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcin Urbanski
@@ -69,7 +69,7 @@ dependencies:
69
69
  version_requirements: &id004 !ruby/object:Gem::Requirement
70
70
  none: false
71
71
  requirements:
72
- - - "="
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  hash: 21
75
75
  segments:
@@ -187,6 +187,8 @@ files:
187
187
  - VERSION
188
188
  - elibri_onix.gemspec
189
189
  - lib/elibri_onix.rb
190
+ - lib/elibri_onix/external_id.rb
191
+ - lib/elibri_onix/external_timestamp.rb
190
192
  - lib/elibri_onix/inspector.rb
191
193
  - lib/elibri_onix/onix_3_0/audience_range.rb
192
194
  - lib/elibri_onix/onix_3_0/collection.rb