Permalink
Browse files

Write EpubType as 3 digits

* Don't pass 'length' option to xml_accessor
  • Loading branch information...
milkfarm committed Feb 26, 2012
1 parent 5dacace commit 63829265494d072f3f3c8c7b5d52b25cbeceb7ab
Showing with 9 additions and 1 deletion.
  1. +2 −0 lib/onix/core/element.rb
  2. +1 −1 lib/onix/elements/product.rb
  3. +6 −0 spec/elements/product_spec.rb
View
@@ -115,6 +115,7 @@ def self.onix_code_from_list(name, tag_name, options = {})
end
code_opts = options.slice(:length, :enforce)
options.delete(:enforce)
+ options.delete(:length)
prep = lambda { |value|
ONIX::Code.new(list_number, value, code_opts)
}
@@ -164,6 +165,7 @@ def self.onix_codes_from_list(name, tag_name, options = {}, &blk)
end
code_opts = options.slice(:length, :enforce)
options.delete(:enforce)
+ options.delete(:length)
prep = lambda { |values|
if block_given?
values = [values].flatten.collect { |v| blk.call(v) }
@@ -30,7 +30,7 @@ class ONIX::Product < ONIX::Element
onix_composite :product_classifications, ONIX::ProductClassification
# PR.4 Epublication
- onix_code_from_list :epub_type, "EpubType", :list => 10
+ onix_code_from_list :epub_type, "EpubType", :list => 10, :length => 3
xml_accessor :epub_type_version, "EpubTypeVersion"
xml_accessor :epub_type_description, "EpubTypeDescription"
onix_code_from_list :epub_format, "EpubFormat", :list => 11
@@ -141,4 +141,10 @@
product2.title.should eql("grimm's fairy tales")
end
+ it "should write EpubType data as three digits if data is FixNum" do
+ product = ONIX::Product.new
+ product.epub_type = 1
+ product.to_xml.to_s.include?("<EpubType>001</EpubType>").should be_true
+ end
+
end

0 comments on commit 6382926

Please sign in to comment.