CFPropertyList 2.0.17 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rbBinaryCFPropertyList.rb +2 -27
- data/lib/rbCFPropertyList.rb +43 -17
- data/lib/rbCFTypes.rb +32 -31
- data/lib/{rbXMLCFPropertyList.rb → rbLibXMLParser.rb} +17 -2
- data/lib/rbNokogiriParser.rb +140 -0
- data/lib/rbREXMLParser.rb +136 -0
- metadata +39 -71
@@ -435,6 +435,8 @@ module CFPropertyList
|
|
435
435
|
|
436
436
|
# Uniques and transforms a string value to binary format and adds it to the object table
|
437
437
|
def string_to_binary(val)
|
438
|
+
val = val.to_s
|
439
|
+
|
438
440
|
@unique_table[val] ||= begin
|
439
441
|
if !Binary.ascii_string?(val)
|
440
442
|
utf8_strlen = Binary.charset_strlen(val, "UTF-8")
|
@@ -554,33 +556,6 @@ module CFPropertyList
|
|
554
556
|
@object_table[saved_object_count] = bdata
|
555
557
|
return saved_object_count
|
556
558
|
end
|
557
|
-
|
558
|
-
=begin It is difficult to reap benefits from an Enumerator
|
559
|
-
# like an array, but we don't know length ahead of time
|
560
|
-
def enum_to_binary(val)
|
561
|
-
saved_object_count = @written_object_count
|
562
|
-
@written_object_count += 1
|
563
|
-
|
564
|
-
size = 0
|
565
|
-
# This destroys our low-memory stream.
|
566
|
-
# However, testing shows that it is faster
|
567
|
-
# Probably because packing this single Array (in pack_int_array_with_size)
|
568
|
-
# is faster than packing each individual array member separately
|
569
|
-
# i.e. to be faster it needs an Enumerator#pack
|
570
|
-
binary = val.value.map do |v|
|
571
|
-
size += 1;
|
572
|
-
v.to_binary(self)
|
573
|
-
end
|
574
|
-
@object_refs += size
|
575
|
-
|
576
|
-
bdata = Binary.type_bytes(0b1010, size) <<
|
577
|
-
Binary.pack_int_array_with_size(object_ref_size(@object_refs), binary)
|
578
|
-
|
579
|
-
@object_table[saved_object_count] = bdata
|
580
|
-
saved_object_count
|
581
|
-
end
|
582
|
-
=end
|
583
|
-
|
584
559
|
end
|
585
560
|
end
|
586
561
|
|
data/lib/rbCFPropertyList.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
require 'libxml'
|
4
3
|
require 'kconv'
|
5
4
|
require 'date'
|
6
5
|
require 'time'
|
@@ -56,6 +55,17 @@ module CFPropertyList
|
|
56
55
|
return true
|
57
56
|
end
|
58
57
|
end
|
58
|
+
|
59
|
+
class XMLParserInterface < ParserInterface
|
60
|
+
def new_node(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def new_text(val)
|
64
|
+
end
|
65
|
+
|
66
|
+
def append_node(parent, child)
|
67
|
+
end
|
68
|
+
end
|
59
69
|
end
|
60
70
|
|
61
71
|
class String
|
@@ -82,11 +92,35 @@ end
|
|
82
92
|
dirname = File.dirname(__FILE__)
|
83
93
|
require dirname + '/rbCFPlistError.rb'
|
84
94
|
require dirname + '/rbCFTypes.rb'
|
85
|
-
require dirname + '/rbXMLCFPropertyList.rb'
|
86
95
|
require dirname + '/rbBinaryCFPropertyList.rb'
|
87
96
|
|
88
97
|
require 'iconv' unless "".respond_to?("encode")
|
89
98
|
|
99
|
+
begin
|
100
|
+
Enumerable::Enumerator.new([])
|
101
|
+
rescue NameError => e
|
102
|
+
module Enumerable
|
103
|
+
class Enumerator
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
begin
|
109
|
+
require dirname + '/rbLibXMLParser.rb'
|
110
|
+
try_nokogiri = false
|
111
|
+
rescue LoadError => e
|
112
|
+
try_nokogiri = true
|
113
|
+
end
|
114
|
+
|
115
|
+
if try_nokogiri then
|
116
|
+
begin
|
117
|
+
require dirname + '/rbNokogiriParser.rb'
|
118
|
+
rescue LoadError => e
|
119
|
+
require dirname + '/rbREXMLParser.rb'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
90
124
|
module CFPropertyList
|
91
125
|
# Create CFType hierarchy by guessing the correct CFType, e.g.
|
92
126
|
#
|
@@ -99,7 +133,7 @@ module CFPropertyList
|
|
99
133
|
# +convert_unknown_to_string+:: Convert unknown objects to string calling to_str()
|
100
134
|
# +converter_method+:: Convert unknown objects to known objects calling +method_name+
|
101
135
|
#
|
102
|
-
# cftypes = CFPropertyList.guess(x,:convert_unknown_to_string => true,:converter_method => :to_hash)
|
136
|
+
# cftypes = CFPropertyList.guess(x,:convert_unknown_to_string => true,:converter_method => :to_hash, :converter_with_opts => true)
|
103
137
|
def guess(object, options = {})
|
104
138
|
case object
|
105
139
|
when Fixnum, Integer then CFInteger.new(object)
|
@@ -111,7 +145,7 @@ module CFPropertyList
|
|
111
145
|
|
112
146
|
when Time, DateTime, Date then CFDate.new(object)
|
113
147
|
|
114
|
-
when Array, Enumerator
|
148
|
+
when Array, Enumerator, Enumerable::Enumerator
|
115
149
|
ary = Array.new
|
116
150
|
object.each do |o|
|
117
151
|
ary.push CFPropertyList.guess(o, options)
|
@@ -125,18 +159,6 @@ module CFPropertyList
|
|
125
159
|
hsh[k] = CFPropertyList.guess(v, options)
|
126
160
|
end
|
127
161
|
CFDictionary.new(hsh)
|
128
|
-
|
129
|
-
=begin
|
130
|
-
when Enumerator
|
131
|
-
CFEnumerator.new(
|
132
|
-
Enumerator.new do |yielder|
|
133
|
-
object.each do |o|
|
134
|
-
yielder << CFPropertyList.guess(o, options)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
)
|
138
|
-
=end
|
139
|
-
|
140
162
|
else
|
141
163
|
case
|
142
164
|
when Object.const_defined?('BigDecimal') && object.is_a?(BigDecimal)
|
@@ -144,7 +166,11 @@ module CFPropertyList
|
|
144
166
|
when object.respond_to?(:read)
|
145
167
|
CFData.new(object.read(), CFData::DATA_RAW)
|
146
168
|
when options[:converter_method] && object.respond_to?(options[:converter_method])
|
147
|
-
|
169
|
+
if options[:converter_with_opts]
|
170
|
+
CFPropertyList.guess(object.send(options[:converter_method],options),options)
|
171
|
+
else
|
172
|
+
CFPropertyList.guess(object.send(options[:converter_method]),options)
|
173
|
+
end
|
148
174
|
when options[:convert_unknown_to_string]
|
149
175
|
CFString.new(object.to_s)
|
150
176
|
else
|
data/lib/rbCFTypes.rb
CHANGED
@@ -20,7 +20,8 @@ module CFPropertyList
|
|
20
20
|
@value = value
|
21
21
|
end
|
22
22
|
|
23
|
-
def to_xml
|
23
|
+
def to_xml(parser)
|
24
|
+
end
|
24
25
|
|
25
26
|
def to_binary(bplist) end
|
26
27
|
end
|
@@ -29,9 +30,9 @@ module CFPropertyList
|
|
29
30
|
# It will convert the value to UTF-16BE if necessary (i.e. if non-ascii char contained)
|
30
31
|
class CFString < CFType
|
31
32
|
# convert to XML
|
32
|
-
def to_xml
|
33
|
-
n =
|
34
|
-
n
|
33
|
+
def to_xml(parser)
|
34
|
+
n = parser.new_node('string')
|
35
|
+
n = parser.append_node(n, parser.new_text(@value)) unless @value.nil?
|
35
36
|
n
|
36
37
|
end
|
37
38
|
|
@@ -44,8 +45,10 @@ module CFPropertyList
|
|
44
45
|
# This class holds integer/fixnum values
|
45
46
|
class CFInteger < CFType
|
46
47
|
# convert to XML
|
47
|
-
def to_xml
|
48
|
-
|
48
|
+
def to_xml(parser)
|
49
|
+
n = parser.new_node('integer')
|
50
|
+
n = parser.append_node(n, parser.new_text(@value.to_s))
|
51
|
+
n
|
49
52
|
end
|
50
53
|
|
51
54
|
# convert to binary
|
@@ -57,8 +60,10 @@ module CFPropertyList
|
|
57
60
|
# This class holds float values
|
58
61
|
class CFReal < CFType
|
59
62
|
# convert to XML
|
60
|
-
def to_xml
|
61
|
-
|
63
|
+
def to_xml(parser)
|
64
|
+
n = parser.new_node('real')
|
65
|
+
n = parser.append_node(n, parser.new_text(@value.to_s))
|
66
|
+
n
|
62
67
|
end
|
63
68
|
|
64
69
|
# convert to binary
|
@@ -122,8 +127,10 @@ module CFPropertyList
|
|
122
127
|
end
|
123
128
|
|
124
129
|
# convert to XML
|
125
|
-
def to_xml
|
126
|
-
|
130
|
+
def to_xml(parser)
|
131
|
+
n = parser.new_node('date')
|
132
|
+
n = parser.append_node(n, parser.new_text(CFDate::date_string(@value)))
|
133
|
+
n
|
127
134
|
end
|
128
135
|
|
129
136
|
# convert to binary
|
@@ -135,8 +142,8 @@ module CFPropertyList
|
|
135
142
|
# This class contains a boolean value
|
136
143
|
class CFBoolean < CFType
|
137
144
|
# convert to XML
|
138
|
-
def to_xml
|
139
|
-
|
145
|
+
def to_xml(parser)
|
146
|
+
parser.new_node(@value ? 'true' : 'false')
|
140
147
|
end
|
141
148
|
|
142
149
|
# convert to binary
|
@@ -175,8 +182,10 @@ module CFPropertyList
|
|
175
182
|
end
|
176
183
|
|
177
184
|
# convert to XML
|
178
|
-
def to_xml
|
179
|
-
|
185
|
+
def to_xml(parser)
|
186
|
+
n = parser.new_node('data')
|
187
|
+
n = parser.append_node(n, parser.new_text(encoded_value()))
|
188
|
+
n
|
180
189
|
end
|
181
190
|
|
182
191
|
# convert to binary
|
@@ -193,10 +202,10 @@ module CFPropertyList
|
|
193
202
|
end
|
194
203
|
|
195
204
|
# convert to XML
|
196
|
-
def to_xml
|
197
|
-
n =
|
205
|
+
def to_xml(parser)
|
206
|
+
n = parser.new_node('array')
|
198
207
|
@value.each do |v|
|
199
|
-
n
|
208
|
+
n = parser.append_node(n, v.to_xml(parser))
|
200
209
|
end
|
201
210
|
n
|
202
211
|
end
|
@@ -207,14 +216,6 @@ module CFPropertyList
|
|
207
216
|
end
|
208
217
|
end
|
209
218
|
|
210
|
-
=begin
|
211
|
-
class CFEnumerator < CFArray
|
212
|
-
def to_binary(bplist)
|
213
|
-
bplist.enum_to_binary(self)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
=end
|
217
|
-
|
218
219
|
# this class contains a hash of values
|
219
220
|
class CFDictionary < CFType
|
220
221
|
# Create new CFDictonary type.
|
@@ -223,12 +224,12 @@ module CFPropertyList
|
|
223
224
|
end
|
224
225
|
|
225
226
|
# convert to XML
|
226
|
-
def to_xml
|
227
|
-
n =
|
228
|
-
@value.each_pair do |key,value|
|
229
|
-
k =
|
230
|
-
n
|
231
|
-
n
|
227
|
+
def to_xml(parser)
|
228
|
+
n = parser.new_node('dict')
|
229
|
+
@value.each_pair do |key, value|
|
230
|
+
k = parser.append_node(parser.new_node('key'), parser.new_text(key.to_s))
|
231
|
+
n = parser.append_node(n, k)
|
232
|
+
n = parser.append_node(n, value.to_xml(parser))
|
232
233
|
end
|
233
234
|
n
|
234
235
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
require 'libxml'
|
4
|
+
|
3
5
|
module CFPropertyList
|
4
6
|
# XML parser
|
5
|
-
class XML <
|
7
|
+
class XML < XMLParserInterface
|
6
8
|
# read a XML file
|
7
9
|
# opts::
|
8
10
|
# * :file - The filename of the file to load
|
@@ -27,7 +29,7 @@ module CFPropertyList
|
|
27
29
|
doc.encoding = LibXML::XML::Encoding::UTF_8
|
28
30
|
|
29
31
|
doc.root['version'] = '1.0'
|
30
|
-
doc.root << opts[:root].to_xml()
|
32
|
+
doc.root << opts[:root].to_xml(self)
|
31
33
|
|
32
34
|
# ugly hack, but there's no other possibility I know
|
33
35
|
str = doc.to_s(:indent => opts[:formatted])
|
@@ -46,6 +48,18 @@ module CFPropertyList
|
|
46
48
|
return str1
|
47
49
|
end
|
48
50
|
|
51
|
+
def new_node(name)
|
52
|
+
LibXML::XML::Node.new(name)
|
53
|
+
end
|
54
|
+
|
55
|
+
def new_text(val)
|
56
|
+
LibXML::XML::Node.new_text(val)
|
57
|
+
end
|
58
|
+
|
59
|
+
def append_node(parent, child)
|
60
|
+
parent << child
|
61
|
+
end
|
62
|
+
|
49
63
|
protected
|
50
64
|
|
51
65
|
# get the value of a DOM node
|
@@ -72,6 +86,7 @@ module CFPropertyList
|
|
72
86
|
if node.children? then
|
73
87
|
node.children.each do |n|
|
74
88
|
next if n.text? # avoid a bug of libxml
|
89
|
+
next if n.comment?
|
75
90
|
|
76
91
|
if n.name == "key" then
|
77
92
|
key = get_value(n)
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
module CFPropertyList
|
6
|
+
# XML parser
|
7
|
+
class XML < ParserInterface
|
8
|
+
# read a XML file
|
9
|
+
# opts::
|
10
|
+
# * :file - The filename of the file to load
|
11
|
+
# * :data - The data to parse
|
12
|
+
def load(opts)
|
13
|
+
if(opts.has_key?(:file)) then
|
14
|
+
File.open(opts[:file], "rb") { |fd| doc = Nokogiri::XML::Document.parse(fd, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS|Nokogiri::XML::ParseOptions::NOENT) }
|
15
|
+
else
|
16
|
+
doc = Nokogiri::XML::Document.parse(opts[:data], nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS|Nokogiri::XML::ParseOptions::NOENT)
|
17
|
+
end
|
18
|
+
|
19
|
+
root = doc.root.children.first
|
20
|
+
return import_xml(root)
|
21
|
+
end
|
22
|
+
|
23
|
+
# serialize CFPropertyList object to XML
|
24
|
+
# opts = {}:: Specify options: :formatted - Use indention and line breaks
|
25
|
+
def to_str(opts={})
|
26
|
+
doc = Nokogiri::XML::Document.new
|
27
|
+
@doc = doc
|
28
|
+
|
29
|
+
doc.root = doc.create_element 'plist', :version => '1.0'
|
30
|
+
doc.encoding = 'UTF-8'
|
31
|
+
|
32
|
+
doc.root << opts[:root].to_xml(self)
|
33
|
+
|
34
|
+
# ugly hack, but there's no other possibility I know
|
35
|
+
s_opts = Nokogiri::XML::Node::SaveOptions::AS_XML
|
36
|
+
s_opts |= Nokogiri::XML::Node::SaveOptions::FORMAT if opts[:formatted]
|
37
|
+
|
38
|
+
str = doc.serialize(:save_with => s_opts)
|
39
|
+
str1 = String.new
|
40
|
+
first = false
|
41
|
+
str.each_line do |line|
|
42
|
+
str1 << line
|
43
|
+
unless(first) then
|
44
|
+
str1 << "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" if line =~ /^\s*<\?xml/
|
45
|
+
end
|
46
|
+
|
47
|
+
first = true
|
48
|
+
end
|
49
|
+
|
50
|
+
str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding)
|
51
|
+
return str1
|
52
|
+
end
|
53
|
+
|
54
|
+
def new_node(name)
|
55
|
+
@doc.create_element name
|
56
|
+
end
|
57
|
+
|
58
|
+
def new_text(val)
|
59
|
+
@doc.create_text_node val
|
60
|
+
end
|
61
|
+
|
62
|
+
def append_node(parent, child)
|
63
|
+
parent << child
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
|
68
|
+
# get the value of a DOM node
|
69
|
+
def get_value(n)
|
70
|
+
content = if n.children.empty?
|
71
|
+
n.content
|
72
|
+
else
|
73
|
+
n.children.first.content
|
74
|
+
end
|
75
|
+
|
76
|
+
content.force_encoding('UTF-8') if content.respond_to?(:force_encoding)
|
77
|
+
content
|
78
|
+
end
|
79
|
+
|
80
|
+
# import the XML values
|
81
|
+
def import_xml(node)
|
82
|
+
ret = nil
|
83
|
+
|
84
|
+
case node.name
|
85
|
+
when 'dict'
|
86
|
+
hsh = Hash.new
|
87
|
+
key = nil
|
88
|
+
children = node.children
|
89
|
+
|
90
|
+
unless children.empty? then
|
91
|
+
children.each do |n|
|
92
|
+
next if n.text? # avoid a bug of libxml
|
93
|
+
next if n.comment?
|
94
|
+
|
95
|
+
if n.name == "key" then
|
96
|
+
key = get_value(n)
|
97
|
+
else
|
98
|
+
raise CFFormatError.new("Format error!") if key.nil?
|
99
|
+
hsh[key] = import_xml(n)
|
100
|
+
key = nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
ret = CFDictionary.new(hsh)
|
106
|
+
|
107
|
+
when 'array'
|
108
|
+
ary = Array.new
|
109
|
+
children = node.children
|
110
|
+
|
111
|
+
unless children.empty? then
|
112
|
+
children.each do |n|
|
113
|
+
ary.push import_xml(n)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
ret = CFArray.new(ary)
|
118
|
+
|
119
|
+
when 'true'
|
120
|
+
ret = CFBoolean.new(true)
|
121
|
+
when 'false'
|
122
|
+
ret = CFBoolean.new(false)
|
123
|
+
when 'real'
|
124
|
+
ret = CFReal.new(get_value(node).to_f)
|
125
|
+
when 'integer'
|
126
|
+
ret = CFInteger.new(get_value(node).to_i)
|
127
|
+
when 'string'
|
128
|
+
ret = CFString.new(get_value(node))
|
129
|
+
when 'data'
|
130
|
+
ret = CFData.new(get_value(node))
|
131
|
+
when 'date'
|
132
|
+
ret = CFDate.new(CFDate.parse_date(get_value(node)))
|
133
|
+
end
|
134
|
+
|
135
|
+
return ret
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# eof
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rexml/document'
|
4
|
+
|
5
|
+
module CFPropertyList
|
6
|
+
# XML parser
|
7
|
+
class XML < ParserInterface
|
8
|
+
# read a XML file
|
9
|
+
# opts::
|
10
|
+
# * :file - The filename of the file to load
|
11
|
+
# * :data - The data to parse
|
12
|
+
def load(opts)
|
13
|
+
if(opts.has_key?(:file)) then
|
14
|
+
File.open(opts[:file], "rb") { |fd| doc = REXML::Document.new(fd) }
|
15
|
+
else
|
16
|
+
doc = REXML::Document.new(opts[:data])
|
17
|
+
end
|
18
|
+
|
19
|
+
root = doc.root.elements[1]
|
20
|
+
return import_xml(root)
|
21
|
+
end
|
22
|
+
|
23
|
+
# serialize CFPropertyList object to XML
|
24
|
+
# opts = {}:: Specify options: :formatted - Use indention and line breaks
|
25
|
+
def to_str(opts={})
|
26
|
+
doc = REXML::Document.new
|
27
|
+
@doc = doc
|
28
|
+
|
29
|
+
doc.context[:attribute_quote] = :quote
|
30
|
+
|
31
|
+
doc.add_element 'plist', {'version' => '1.0'}
|
32
|
+
doc.root << opts[:root].to_xml(self)
|
33
|
+
|
34
|
+
formatter = if opts[:formatted] then
|
35
|
+
f = REXML::Formatters::Pretty.new(2)
|
36
|
+
f.compact = true
|
37
|
+
f
|
38
|
+
else
|
39
|
+
REXML::Formatters::Default.new
|
40
|
+
end
|
41
|
+
|
42
|
+
str = formatter.write(doc.root, "")
|
43
|
+
str1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" + str + "\n"
|
44
|
+
str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding)
|
45
|
+
|
46
|
+
return str1
|
47
|
+
end
|
48
|
+
|
49
|
+
def new_node(name)
|
50
|
+
#LibXML::XML::Node.new(name)
|
51
|
+
REXML::Element.new(name)
|
52
|
+
end
|
53
|
+
|
54
|
+
def new_text(val)
|
55
|
+
val
|
56
|
+
end
|
57
|
+
|
58
|
+
def append_node(parent, child)
|
59
|
+
if child.is_a?(String) then
|
60
|
+
parent.add_text child
|
61
|
+
else
|
62
|
+
parent.elements << child
|
63
|
+
end
|
64
|
+
parent
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
# get the value of a DOM node
|
70
|
+
def get_value(n)
|
71
|
+
content = n.text
|
72
|
+
|
73
|
+
content.force_encoding('UTF-8') if content.respond_to?(:force_encoding)
|
74
|
+
content
|
75
|
+
end
|
76
|
+
|
77
|
+
# import the XML values
|
78
|
+
def import_xml(node)
|
79
|
+
ret = nil
|
80
|
+
|
81
|
+
case node.name
|
82
|
+
when 'dict'
|
83
|
+
hsh = Hash.new
|
84
|
+
key = nil
|
85
|
+
|
86
|
+
if node.has_elements? then
|
87
|
+
node.elements.each do |n|
|
88
|
+
#print n.name + "\n"
|
89
|
+
next if n.name == '#text' # avoid a bug of libxml
|
90
|
+
next if n.name == '#comment'
|
91
|
+
|
92
|
+
if n.name == "key" then
|
93
|
+
key = get_value(n)
|
94
|
+
else
|
95
|
+
raise CFFormatError.new("Format error!") if key.nil?
|
96
|
+
hsh[key] = import_xml(n)
|
97
|
+
key = nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
ret = CFDictionary.new(hsh)
|
103
|
+
|
104
|
+
when 'array'
|
105
|
+
ary = Array.new
|
106
|
+
|
107
|
+
if node.has_elements? then
|
108
|
+
node.elements.each do |n|
|
109
|
+
ary.push import_xml(n)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
ret = CFArray.new(ary)
|
114
|
+
|
115
|
+
when 'true'
|
116
|
+
ret = CFBoolean.new(true)
|
117
|
+
when 'false'
|
118
|
+
ret = CFBoolean.new(false)
|
119
|
+
when 'real'
|
120
|
+
ret = CFReal.new(get_value(node).to_f)
|
121
|
+
when 'integer'
|
122
|
+
ret = CFInteger.new(get_value(node).to_i)
|
123
|
+
when 'string'
|
124
|
+
ret = CFString.new(get_value(node))
|
125
|
+
when 'data'
|
126
|
+
ret = CFData.new(get_value(node))
|
127
|
+
when 'date'
|
128
|
+
ret = CFDate.new(CFDate.parse_date(get_value(node)))
|
129
|
+
end
|
130
|
+
|
131
|
+
return ret
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# eof
|
metadata
CHANGED
@@ -1,99 +1,67 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: CFPropertyList
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 2
|
7
|
-
- 0
|
8
|
-
- 17
|
9
|
-
version: 2.0.17
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '2.1'
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Christian Kruse
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
name: libxml-ruby
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 1
|
31
|
-
- 0
|
32
|
-
version: 1.1.0
|
33
|
-
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
36
15
|
name: rake
|
37
|
-
|
38
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &7342600 !ruby/object:Gem::Requirement
|
39
17
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
- 7
|
46
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
47
21
|
version: 0.7.0
|
48
|
-
type: :
|
49
|
-
|
50
|
-
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *7342600
|
25
|
+
description: This is a module to read, write and manipulate both binary and XML property
|
26
|
+
lists as defined by apple.
|
51
27
|
email: cjk@wwwtech.de
|
52
28
|
executables: []
|
53
|
-
|
54
29
|
extensions: []
|
55
|
-
|
56
|
-
extra_rdoc_files:
|
30
|
+
extra_rdoc_files:
|
57
31
|
- README
|
58
|
-
files:
|
59
|
-
- lib/cfpropertylist.rb
|
60
|
-
- lib/rbCFTypes.rb
|
61
|
-
- lib/rbXMLCFPropertyList.rb
|
32
|
+
files:
|
62
33
|
- lib/rbBinaryCFPropertyList.rb
|
34
|
+
- lib/rbREXMLParser.rb
|
63
35
|
- lib/rbCFPlistError.rb
|
36
|
+
- lib/rbLibXMLParser.rb
|
37
|
+
- lib/rbCFTypes.rb
|
38
|
+
- lib/rbNokogiriParser.rb
|
64
39
|
- lib/rbCFPropertyList.rb
|
40
|
+
- lib/cfpropertylist.rb
|
65
41
|
- README
|
66
|
-
has_rdoc: true
|
67
42
|
homepage: http://github.com/ckruse/CFPropertyList
|
68
43
|
licenses: []
|
69
|
-
|
70
44
|
post_install_message:
|
71
45
|
rdoc_options: []
|
72
|
-
|
73
|
-
require_paths:
|
46
|
+
require_paths:
|
74
47
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
49
|
none: false
|
77
|
-
requirements:
|
78
|
-
- -
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
|
82
|
-
version: "0"
|
83
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
55
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
- 0
|
90
|
-
version: "0"
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
91
60
|
requirements: []
|
92
|
-
|
93
|
-
|
94
|
-
rubygems_version: 1.3.7
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.8.15
|
95
63
|
signing_key:
|
96
64
|
specification_version: 3
|
97
|
-
summary: Read, write and manipulate both binary and XML property lists as defined
|
65
|
+
summary: Read, write and manipulate both binary and XML property lists as defined
|
66
|
+
by apple
|
98
67
|
test_files: []
|
99
|
-
|