CFPropertyList 2.0.13.1 → 2.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -222,16 +222,24 @@ module CFPropertyList
222
222
 
223
223
  # Count characters considering character set
224
224
  def Binary.charset_strlen(str,charset="UTF-8")
225
- return str.length if str.respond_to?("encode")
226
-
227
- utf8_str = Iconv.conv("UTF-8",charset,str)
228
- size = utf8_str.scan(/./mu).size
229
-
225
+ if str.respond_to?(:encode)
226
+ size = str.length
227
+ else
228
+ utf8_str = Iconv.conv("UTF-8",charset,str)
229
+ size = utf8_str.scan(/./mu).size
230
+ end
231
+
230
232
  # UTF-16 code units in the range D800-DBFF are the beginning of
231
233
  # a surrogate pair, and count as one additional character for
232
234
  # length calculation.
233
- str.split('').each_slice(2) { |pair| size += 1 if ("\xd8".."\xdb").include?(pair[0]) } if charset =~ /^UTF-16/
234
-
235
+ if charset =~ /^UTF-16/
236
+ if str.respond_to?(:encode)
237
+ str.bytes.to_a.each_slice(2) { |pair| size += 1 if (0xd8..0xdb).include?(pair[0]) }
238
+ else
239
+ str.split('').each_slice(2) { |pair| size += 1 if ("\xd8".."\xdb").include?(pair[0]) }
240
+ end
241
+ end
242
+
235
243
  return size
236
244
  end
237
245
 
@@ -434,7 +442,11 @@ module CFPropertyList
434
442
  end
435
443
 
436
444
  def Binary.ascii_string?(str)
437
- return str.scan(/[\x80-\xFF]/m).size == 0
445
+ if str.respond_to?(:ascii_only?)
446
+ return str.ascii_only?
447
+ else
448
+ return str.scan(/[\x80-\xFF]/mn).size == 0
449
+ end
438
450
  end
439
451
 
440
452
  # Uniques and transforms a string value to binary format and adds it to the object table
@@ -572,10 +584,9 @@ module CFPropertyList
572
584
  saved_object_count = @written_object_count
573
585
  @written_object_count += 1
574
586
 
575
- keys_and_values = val.value.collect do |k, v|
576
- [ CFString.new(k).to_binary(self), v.to_binary(self) ]
577
- end.flatten
578
-
587
+ keys_and_values = val.value.keys.collect { |k| CFString.new(k).to_binary(self) }
588
+ keys_and_values += val.value.keys.collect { |k| val.value[k].to_binary(self) }
589
+
579
590
  bdata = Binary.type_bytes(0b1101,val.value.size) +
580
591
  Binary.pack_int_array_with_size(@object_ref_size, keys_and_values)
581
592
 
@@ -43,6 +43,7 @@ module CFPropertyList
43
43
  first = true
44
44
  end
45
45
 
46
+ str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding)
46
47
  return str1
47
48
  end
48
49
 
@@ -50,8 +51,14 @@ module CFPropertyList
50
51
 
51
52
  # get the value of a DOM node
52
53
  def get_value(n)
53
- return n.first.content if n.children?
54
- return n.content
54
+ content = if n.children?
55
+ n.first.content
56
+ else
57
+ n.content
58
+ end
59
+
60
+ content.force_encoding('UTF-8') if content.respond_to?(:force_encoding)
61
+ content
55
62
  end
56
63
 
57
64
  # import the XML values
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CFPropertyList
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 2
7
- - 0
8
- - 13
9
- - 1
10
- version: 2.0.13.1
4
+ version: 2.0.14
11
5
  platform: ruby
12
6
  authors:
13
7
  - Christian Kruse
@@ -15,39 +9,29 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2010-09-17 00:00:00 +02:00
12
+ date: 2010-09-27 00:00:00 +02:00
19
13
  default_executable:
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: libxml-ruby
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- segments:
30
- - 1
31
- - 1
32
- - 0
33
23
  version: 1.1.0
34
- type: :runtime
35
- version_requirements: *id001
24
+ version:
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: rake
38
- prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
41
30
  requirements:
42
31
  - - ">="
43
32
  - !ruby/object:Gem::Version
44
- segments:
45
- - 0
46
- - 7
47
- - 0
48
33
  version: 0.7.0
49
- type: :runtime
50
- version_requirements: *id002
34
+ version:
51
35
  description: This is a module to read, write and manipulate both binary and XML property lists as defined by apple.
52
36
  email: cjk@wwwtech.de
53
37
  executables: []
@@ -74,25 +58,21 @@ rdoc_options: []
74
58
  require_paths:
75
59
  - lib
76
60
  required_ruby_version: !ruby/object:Gem::Requirement
77
- none: false
78
61
  requirements:
79
62
  - - ">="
80
63
  - !ruby/object:Gem::Version
81
- segments:
82
- - 0
83
64
  version: "0"
65
+ version:
84
66
  required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
67
  requirements:
87
68
  - - ">="
88
69
  - !ruby/object:Gem::Version
89
- segments:
90
- - 0
91
70
  version: "0"
71
+ version:
92
72
  requirements: []
93
73
 
94
74
  rubyforge_project: cfpropertylist
95
- rubygems_version: 1.3.7
75
+ rubygems_version: 1.3.5
96
76
  signing_key:
97
77
  specification_version: 3
98
78
  summary: Read, write and manipulate both binary and XML property lists as defined by apple