rbook-onix 0.5 → 0.5.1
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/Rakefile +1 -1
- data/lib/rbook/onix/message.rb +2 -2
- data/lib/rbook/onix/xchar.rb +3 -3
- data/specs/message_with_data_spec.rb +13 -0
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/rbook/onix/message.rb
CHANGED
@@ -77,7 +77,7 @@ module RBook
|
|
77
77
|
def to_s
|
78
78
|
doc = to_xml
|
79
79
|
output = ''
|
80
|
-
doc.write(output,
|
80
|
+
doc.write(output, 2)
|
81
81
|
return output
|
82
82
|
end
|
83
83
|
|
@@ -103,7 +103,7 @@ module RBook
|
|
103
103
|
raise 'There must be at least 1 product to burn' if @products.size < 1
|
104
104
|
|
105
105
|
doc = REXML::Document.new
|
106
|
-
doc << REXML::XMLDecl.new
|
106
|
+
doc << REXML::XMLDecl.new("1.0", "UTF-8")
|
107
107
|
doc << REXML::DocType.new('ONIXMessage', "SYSTEM \"#{ONIX_DTD_URL}\"")
|
108
108
|
msg = doc.add_element('ONIXMessage')
|
109
109
|
msg.add_element(header)
|
data/lib/rbook/onix/xchar.rb
CHANGED
@@ -45,9 +45,9 @@ end
|
|
45
45
|
class Fixnum
|
46
46
|
# xml escaped version of chr
|
47
47
|
def xchr
|
48
|
-
n = XChar::CP1252[self] || self
|
49
|
-
n = 42 unless XChar::VALID.find {|range| range.include? n}
|
50
|
-
XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};")
|
48
|
+
n = ::XChar::CP1252[self] || self
|
49
|
+
n = 42 unless ::XChar::VALID.find {|range| range.include? n}
|
50
|
+
::XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};")
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -78,4 +78,17 @@ context "A message object with valid data" do
|
|
78
78
|
n.should_not be_nil
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
specify "should include an encoding declaration in the output string" do
|
83
|
+
msg = RBook::Onix::Message.new
|
84
|
+
msg.from_person = "James Healy"
|
85
|
+
msg.from_company = "Healy Inc."
|
86
|
+
msg.to_person = "RSpec"
|
87
|
+
|
88
|
+
product = RBook::Onix::Product.new
|
89
|
+
product.product_identifier = '0977616606'
|
90
|
+
msg.add_product(product)
|
91
|
+
|
92
|
+
msg.to_s[0,128].include?("encoding='UTF-8'").should be_true
|
93
|
+
end
|
81
94
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rbook-onix
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
7
|
-
date: 2007-
|
6
|
+
version: 0.5.1
|
7
|
+
date: 2007-10-19 00:00:00 +10:00
|
8
8
|
summary: A library for manipulating ONIX files
|
9
9
|
require_paths:
|
10
10
|
- lib
|