CFPropertyList 2.2.1 → 2.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0365c5873a771aa9b3f29a9c40ff915c23839a25
4
- data.tar.gz: 4cc982239b806c7857b844deebbcca016deea87d
3
+ metadata.gz: 2583d99467cd5b72787e594784a01cc38235fb35
4
+ data.tar.gz: a99215eb410bc4c0bf30954f80799da7714eb689
5
5
  SHA512:
6
- metadata.gz: a4ec6d399c5823c687ac7800ec9b72d9b0e69f1eb9774cf9467f84d3d1555e903c53d6dc23312e0cfeed9349a5fb044406b2d0750ed3799bdb4ef40ce855dd7d
7
- data.tar.gz: d1043959eac257f061eef8279cebdcfe1de2fe0f1ecacdab816805f95e8a105446b40089c477b66ff2f5f2994163569bc41292feb5e01c9a38f597178c8822ed
6
+ metadata.gz: 078d45dd78c76dd52767adc09b8ec74dcb77fe58aece7749604340b7421d372775bd109b9cb878ffb996171852f83a720a5e2d83e559941d07780a5e567cd872
7
+ data.tar.gz: 260de5c1c07b134b1e164992f10292d109dcb33551d02aca1f91ebecf596b1fb76397e9220881736f6f3718d55ef90e61e5e60408f678cc156b38567eba38fe3
@@ -1,5 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ require 'stringio'
4
+
3
5
  module CFPropertyList
4
6
  # Binary PList parser class
5
7
  class Binary
@@ -162,7 +162,12 @@ module CFPropertyList
162
162
  when Object.const_defined?('BigDecimal') && object.is_a?(BigDecimal)
163
163
  CFReal.new(object)
164
164
  when object.respond_to?(:read)
165
- CFData.new(object.read(), CFData::DATA_RAW)
165
+ raw_data = object.read
166
+ # treat the data as a bytestring (ASCII-8BIT) if Ruby supports it. Do this by forcing
167
+ # the encoding, on the assumption that the bytes were read correctly, and just tagged with
168
+ # an inappropriate encoding, rather than transcoding.
169
+ raw_data.force_encoding(Encoding::ASCII_8BIT) if raw_data.respond_to?(:force_encoding)
170
+ CFData.new(raw_data, CFData::DATA_RAW)
166
171
  when options[:converter_method] && object.respond_to?(options[:converter_method])
167
172
  if options[:converter_with_opts]
168
173
  CFPropertyList.guess(object.send(options[:converter_method],options),options)
@@ -380,8 +385,13 @@ module CFPropertyList
380
385
  # format = List::FORMAT_BINARY:: The format to save the plist
381
386
  # opts={}:: Pass parser options
382
387
  def to_str(format=List::FORMAT_BINARY,opts={})
388
+ raise CFFormatError.new("Format #{format} not supported, use List::FORMAT_BINARY or List::FORMAT_XML") if format != FORMAT_BINARY && format != FORMAT_XML
389
+
383
390
  prsr = @@parsers[format-1].new
391
+
384
392
  opts[:root] = @value
393
+ opts[:formatted] = @formatted unless opts.has_key?(:formatted)
394
+
385
395
  return prsr.to_str(opts)
386
396
  end
387
397
  end
@@ -395,7 +405,7 @@ class Array
395
405
 
396
406
  plist = CFPropertyList::List.new
397
407
  plist.value = CFPropertyList.guess(self, options)
398
- plist.to_str(options[:plist_format])
408
+ plist.to_str(options[:plist_format], options)
399
409
  end
400
410
  end
401
411
 
@@ -406,7 +416,7 @@ class Enumerator
406
416
 
407
417
  plist = CFPropertyList::List.new
408
418
  plist.value = CFPropertyList.guess(self, options)
409
- plist.to_str(options[:plist_format])
419
+ plist.to_str(options[:plist_format], options)
410
420
  end
411
421
  end
412
422
 
@@ -417,7 +427,7 @@ class Hash
417
427
 
418
428
  plist = CFPropertyList::List.new
419
429
  plist.value = CFPropertyList.guess(self, options)
420
- plist.to_str(options[:plist_format])
430
+ plist.to_str(options[:plist_format], options)
421
431
  end
422
432
  end
423
433
 
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.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kruse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-16 00:00:00.000000000 Z
11
+ date: 2013-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake