milkfarm-onix 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.8.8 (15 March 2011)
2
+ - Format EpubType value as 3-digit, padded number
3
+
1
4
  v0.8.7 (13 March 2011)
2
5
  - Merge yob's commits (code lists, short tags, i18n)
3
6
  - Add WorkIdentifier composite (PR.7.15, PR.7.16, PR.7.17)
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#{val}"
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.to_s
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
@@ -1,3 +1,3 @@
1
1
  module ONIX
2
- VERSION = "0.8.7"
2
+ VERSION = "0.8.8"
3
3
  end
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: 49
4
+ hash: 47
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 7
10
- version: 0.8.7
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-12 23:00:00 -08:00
19
+ date: 2011-03-15 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency