milkfarm-onix 0.8.7 → 0.8.8
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/CHANGELOG +3 -0
- data/lib/onix.rb +11 -5
- data/lib/onix/product.rb +1 -1
- data/lib/onix/version.rb +1 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
data/lib/onix.rb
CHANGED
@@ -31,15 +31,21 @@ module ONIX
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.two_digit
|
34
|
+
padded_number(2)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.three_digit
|
38
|
+
padded_number(3)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.padded_number(n)
|
34
42
|
lambda do |val|
|
35
43
|
if val.nil?
|
36
44
|
nil
|
37
|
-
elsif val < 10
|
38
|
-
"0#{
|
39
|
-
elsif val > 99
|
40
|
-
val.to_s[-2,2]
|
45
|
+
elsif val >= 0 && val < 10**n
|
46
|
+
sprintf("%0#{n}d", val)
|
41
47
|
else
|
42
|
-
val
|
48
|
+
raise ArgumentError, "Value '#{val}' does not conform to #{n}-digit restrictions"
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
data/lib/onix/product.rb
CHANGED
@@ -11,7 +11,7 @@ module ONIX
|
|
11
11
|
xml_accessor :product_identifiers, :from => "ProductIdentifier", :as => [ONIX::ProductIdentifier]
|
12
12
|
xml_accessor :product_form, :from => "ProductForm"
|
13
13
|
xml_accessor :product_form_detail, :from => "ProductFormDetail"
|
14
|
-
xml_reader :epub_type, :from => "EpubType"
|
14
|
+
xml_reader :epub_type, :from => "EpubType", :as => Fixnum, :to_xml => ONIX::Formatters.three_digit
|
15
15
|
xml_accessor :series, :from => "Series", :as => [ONIX::Series]
|
16
16
|
xml_accessor :sets, :from => "Set", :as => [ONIX::Set]
|
17
17
|
xml_accessor :titles, :from => "Title", :as => [ONIX::Title]
|
data/lib/onix/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milkfarm-onix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 47
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 8
|
10
|
+
version: 0.8.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Healy
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-03-
|
19
|
+
date: 2011-03-15 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|