CFPropertyList 2.2.7 → 2.2.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.
- checksums.yaml +4 -4
- data/README +0 -0
- data/lib/cfpropertylist/rbBinaryCFPropertyList.rb +33 -4
- data/lib/cfpropertylist/rbCFPropertyList.rb +2 -1
- data/lib/cfpropertylist/rbCFTypes.rb +18 -0
- data/lib/cfpropertylist/rbLibXMLParser.rb +5 -1
- data/lib/cfpropertylist/rbNokogiriParser.rb +5 -1
- data/lib/cfpropertylist/rbREXMLParser.rb +5 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2c18e8671e6aa61b76ef1b99fff2850b2746c4d
|
4
|
+
data.tar.gz: 153b07e4656885b5cd155af83555dad763a17e1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75f4be2ff85f13c0309b7c7fe390b721a5ee98d454aa45a010ba03288381a0f9c6e90539f7c34921685c5ef92e8803ab7469ce826059bfa777a98d001974d3fe
|
7
|
+
data.tar.gz: b7842bee8b9cb899b432880b16e675c78e4cb87ed64c473efb988c2dd4313266844b1f341f8b659e0baeaca9ad0bf7fa81fbc74f763ea53c8ecedafd149d59a3
|
data/README
CHANGED
File without changes
|
@@ -295,11 +295,11 @@ module CFPropertyList
|
|
295
295
|
# first: read keys
|
296
296
|
if(length != 0) then
|
297
297
|
buff = fd.read(length * @object_ref_size)
|
298
|
-
keys = unpack_with_size(@object_ref_size, buff)
|
298
|
+
keys = unpack_with_size(@object_ref_size, buff)
|
299
299
|
|
300
300
|
# second: read object refs
|
301
301
|
buff = fd.read(length * @object_ref_size)
|
302
|
-
objects = unpack_with_size(@object_ref_size, buff)
|
302
|
+
objects = unpack_with_size(@object_ref_size, buff)
|
303
303
|
|
304
304
|
# read real keys and objects
|
305
305
|
0.upto(length-1) do |i|
|
@@ -313,13 +313,14 @@ module CFPropertyList
|
|
313
313
|
end
|
314
314
|
protected :read_binary_dict
|
315
315
|
|
316
|
-
# Read an object type byte, decode it and delegate to the correct
|
316
|
+
# Read an object type byte, decode it and delegate to the correct
|
317
|
+
# reader function
|
317
318
|
def read_binary_object(fname,fd)
|
318
319
|
# first: read the marker byte
|
319
320
|
buff = fd.read(1)
|
320
321
|
|
321
322
|
object_length = buff.unpack("C*")
|
322
|
-
object_length = object_length[0]
|
323
|
+
object_length = object_length[0] & 0xF
|
323
324
|
|
324
325
|
buff = buff.unpack("H*")
|
325
326
|
object_type = buff[0][0].chr
|
@@ -344,6 +345,8 @@ module CFPropertyList
|
|
344
345
|
read_binary_string(fname,fd,object_length)
|
345
346
|
when '6' # unicode string (utf16be)
|
346
347
|
read_binary_unicode_string(fname,fd,object_length)
|
348
|
+
when '8'
|
349
|
+
CFUid.new(read_binary_int(fname, fd, object_length).value)
|
347
350
|
when 'a' # array
|
348
351
|
read_binary_array(fname,fd,object_length)
|
349
352
|
when 'd' # dictionary
|
@@ -511,6 +514,32 @@ module CFPropertyList
|
|
511
514
|
@written_object_count - 1
|
512
515
|
end
|
513
516
|
|
517
|
+
def uid_to_binary(value)
|
518
|
+
nbytes = 0
|
519
|
+
nbytes = 1 if value > 0xFF # 1 byte integer
|
520
|
+
nbytes += 1 if value > 0xFFFF # 4 byte integer
|
521
|
+
nbytes += 1 if value > 0xFFFFFFFF # 8 byte integer
|
522
|
+
nbytes = 3 if value < 0 # 8 byte integer, since signed
|
523
|
+
|
524
|
+
@object_table[@written_object_count] = Binary.type_bytes(0b1000, nbytes) <<
|
525
|
+
if nbytes < 3
|
526
|
+
[value].pack(
|
527
|
+
if nbytes == 0 then "C"
|
528
|
+
elsif nbytes == 1 then "n"
|
529
|
+
else "N"
|
530
|
+
end
|
531
|
+
)
|
532
|
+
else
|
533
|
+
# 64 bit signed integer; we need the higher and the lower 32 bit of the value
|
534
|
+
high_word = value >> 32
|
535
|
+
low_word = value & 0xFFFFFFFF
|
536
|
+
[high_word,low_word].pack("NN")
|
537
|
+
end
|
538
|
+
|
539
|
+
@written_object_count += 1
|
540
|
+
@written_object_count - 1
|
541
|
+
end
|
542
|
+
|
514
543
|
# Convert date value (apple format) to binary and adds it to the object table
|
515
544
|
def date_to_binary(val)
|
516
545
|
val = val.getutc.to_f - CFDate::DATE_DIFF_APPLE_UNIX # CFDate is a real, number of seconds since 01/01/2001 00:00:00 GMT
|
@@ -129,6 +129,7 @@ module CFPropertyList
|
|
129
129
|
def guess(object, options = {})
|
130
130
|
case object
|
131
131
|
when Fixnum, Integer then CFInteger.new(object)
|
132
|
+
when UidFixnum then CFUid.new(object)
|
132
133
|
when Float then CFReal.new(object)
|
133
134
|
when TrueClass, FalseClass then CFBoolean.new(object)
|
134
135
|
|
@@ -183,7 +184,7 @@ module CFPropertyList
|
|
183
184
|
def native_types(object,keys_as_symbols=false)
|
184
185
|
return if object.nil?
|
185
186
|
|
186
|
-
if(object.is_a?(CFDate) || object.is_a?(CFString) || object.is_a?(CFInteger) || object.is_a?(CFReal) || object.is_a?(CFBoolean)) then
|
187
|
+
if(object.is_a?(CFDate) || object.is_a?(CFString) || object.is_a?(CFInteger) || object.is_a?(CFReal) || object.is_a?(CFBoolean)) || object.is_a?(CFUid) then
|
187
188
|
return object.value
|
188
189
|
elsif(object.is_a?(CFData)) then
|
189
190
|
return CFPropertyList::Blob.new(object.decoded_value)
|
@@ -17,6 +17,13 @@ module CFPropertyList
|
|
17
17
|
class Blob < String
|
18
18
|
end
|
19
19
|
|
20
|
+
##
|
21
|
+
# UidFixnum is intended to distinguish between a Ruby Fixnum
|
22
|
+
# instance that should be converted to a CFInteger/CFReal type and a
|
23
|
+
# Ruby Fixnum instance that should be converted to a CFUid type.
|
24
|
+
class UidFixnum < Fixnum
|
25
|
+
end
|
26
|
+
|
20
27
|
# This class defines the base class for all CFType classes
|
21
28
|
#
|
22
29
|
class CFType
|
@@ -243,6 +250,17 @@ module CFPropertyList
|
|
243
250
|
bplist.dict_to_binary(self)
|
244
251
|
end
|
245
252
|
end
|
253
|
+
|
254
|
+
class CFUid < CFType
|
255
|
+
def to_xml(parser)
|
256
|
+
CFDictionary.new({'CF$UID' => CFInteger.new(@value)}).to_xml(parser)
|
257
|
+
end
|
258
|
+
|
259
|
+
# convert to binary
|
260
|
+
def to_binary(bplist)
|
261
|
+
bplist.uid_to_binary(@value)
|
262
|
+
end
|
263
|
+
end
|
246
264
|
end
|
247
265
|
|
248
266
|
# eof
|
@@ -104,7 +104,11 @@ module CFPropertyList
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
|
107
|
+
if hsh['CF$UID'] and hsh.keys.length == 1
|
108
|
+
ret = CFUid.new(hsh['CF$UID'].value)
|
109
|
+
else
|
110
|
+
ret = CFDictionary.new(hsh)
|
111
|
+
end
|
108
112
|
|
109
113
|
when 'array'
|
110
114
|
ary = Array.new
|
@@ -107,7 +107,11 @@ module CFPropertyList
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
|
110
|
+
if hsh['CF$UID'] and hsh.keys.length == 1
|
111
|
+
ret = CFUid.new(hsh['CF$UID'].value)
|
112
|
+
else
|
113
|
+
ret = CFDictionary.new(hsh)
|
114
|
+
end
|
111
115
|
|
112
116
|
when 'array'
|
113
117
|
ary = Array.new
|
@@ -53,7 +53,6 @@ module CFPropertyList
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def new_node(name)
|
56
|
-
#LibXML::XML::Node.new(name)
|
57
56
|
REXML::Element.new(name)
|
58
57
|
end
|
59
58
|
|
@@ -105,7 +104,11 @@ module CFPropertyList
|
|
105
104
|
end
|
106
105
|
end
|
107
106
|
|
108
|
-
|
107
|
+
if hsh['CF$UID'] and hsh.keys.length == 1
|
108
|
+
ret = CFUid.new(hsh['CF$UID'].value)
|
109
|
+
else
|
110
|
+
ret = CFDictionary.new(hsh)
|
111
|
+
end
|
109
112
|
|
110
113
|
when 'array'
|
111
114
|
ary = Array.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CFPropertyList
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Kruse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|