plist4r 0.2.0 → 0.2.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -54,8 +54,19 @@ module Plist4r::Backend::Libxml4r
54
54
  ::LibXML::XML.default_keep_blanks = false
55
55
  doc = string.to_xmldoc
56
56
  doc.strip!
57
+
57
58
  root = doc.node["/plist/dict"]
58
- ordered_hash = tree_hash root
59
+ ordered_hash = nil
60
+ if root
61
+ ordered_hash = tree_hash root
62
+ else
63
+ root = doc.node["/plist/array"]
64
+ if root
65
+ ordered_hash = ::ActiveSupport::OrderedHash.new
66
+ ordered_hash["Array"] = tree_array root
67
+ end
68
+ end
69
+ ordered_hash
59
70
  end
60
71
 
61
72
  def from_string plist, string
@@ -58,7 +58,15 @@ module Plist
58
58
 
59
59
  def open filename
60
60
  plist_dict = ::OSX::NSDictionary.dictionaryWithContentsOfFile(filename)
61
- puts "#{plist_dict.to_ruby.inspect}"
61
+ if plist_dict
62
+ puts "#{plist_dict.to_ruby.inspect}"
63
+ else
64
+ plist_array = ::OSX::NSArray.arrayWithContentsOfFile(filename) unless plist_dict
65
+ raise "Couldnt parse file: #{filename}" unless plist_array
66
+ plist_dict = ::ActiveSupport::OrderedHash.new
67
+ plist_dict["Array"] = plist_array.to_ruby
68
+ puts "#{plist_dict.inspect}"
69
+ end
62
70
  end
63
71
 
64
72
  def save hash, filename, file_format
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{plist4r}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["dreamcat4"]
12
- s.date = %q{2010-03-18}
12
+ s.date = %q{2010-03-28}
13
13
  s.description = %q{In development. Plist4R is a gem which is striving for 3 things: ease of use, speed, and reliability handling of plists. To help achieve these goals, we may plug-in or re-write this gem with one or several backends. Notably, we try to distinguish this gem by providing easy-to use DSL interface for users. For common plist type(s), such as convenience methods for Launchd Plist}
14
14
  s.email = %q{dreamcat4@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
49
49
  "lib/plist4r/plist_type/launchd.rb",
50
50
  "lib/plist4r/plist_type/plist.rb",
51
51
  "plist4r.gemspec",
52
+ "plists/array_mini.xml",
52
53
  "plists/example_big_binary.plist",
53
54
  "plists/example_medium_binary_launchd.plist",
54
55
  "plists/example_medium_launchd.xml",
@@ -63,7 +64,7 @@ Gem::Specification.new do |s|
63
64
  s.homepage = %q{http://github.com/dreamcat4/plist4r}
64
65
  s.rdoc_options = ["--charset=UTF-8"]
65
66
  s.require_paths = ["lib"]
66
- s.rubygems_version = %q{1.3.5}
67
+ s.rubygems_version = %q{1.3.6}
67
68
  s.summary = %q{Dreamcat4's plist4r gem. For reading/writing plists in ruby}
68
69
  s.test_files = [
69
70
  "spec/examples.rb",
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <array>
5
+ <dict>
6
+ <key>WebIconDatabaseDirectoryDefaultsKey</key>
7
+ <string>~/Library/Icons</string>
8
+ <key>WebKitDefaultFontSize</key>
9
+ <integer>11</integer>
10
+ <key>WebKitStandardFont</key>
11
+ <string>Lucida Grande</string>
12
+ </dict>
13
+ </array>
14
+ </plist>
data/test.rb CHANGED
@@ -5,9 +5,10 @@ require 'lib/plist4r'
5
5
  # puts "Backends = #{::Plist4r::Config[:backends].inspect}"
6
6
  # Plist4r.new
7
7
 
8
- p = Plist4r.open "plists/mini.xml"
8
+ Plist4r::Config[:backends].replace ["haml","libxml4r"]
9
+ p = Plist4r.open "plists/array_mini.xml"
9
10
 
10
- # puts p.inspect
11
+ puts p.inspect
11
12
  # puts p.to_hash.inspect
12
13
  # puts p.to_xml
13
14
 
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plist4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 1
9
+ version: 0.2.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - dreamcat4
@@ -9,39 +14,47 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-18 00:00:00 +00:00
17
+ date: 2010-03-28 00:00:00 +00:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
23
31
  version: 1.2.9
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: yard
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
33
43
  version: "0"
34
- version:
44
+ type: :development
45
+ version_requirements: *id002
35
46
  - !ruby/object:Gem::Dependency
36
47
  name: cucumber
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
40
50
  requirements:
41
51
  - - ">="
42
52
  - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
43
55
  version: "0"
44
- version:
56
+ type: :development
57
+ version_requirements: *id003
45
58
  description: "In development. Plist4R is a gem which is striving for 3 things: ease of use, speed, and reliability handling of plists. To help achieve these goals, we may plug-in or re-write this gem with one or several backends. Notably, we try to distinguish this gem by providing easy-to use DSL interface for users. For common plist type(s), such as convenience methods for Launchd Plist"
46
59
  email: dreamcat4@gmail.com
47
60
  executables: []
@@ -84,6 +97,7 @@ files:
84
97
  - lib/plist4r/plist_type/launchd.rb
85
98
  - lib/plist4r/plist_type/plist.rb
86
99
  - plist4r.gemspec
100
+ - plists/array_mini.xml
87
101
  - plists/example_big_binary.plist
88
102
  - plists/example_medium_binary_launchd.plist
89
103
  - plists/example_medium_launchd.xml
@@ -107,18 +121,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
124
+ segments:
125
+ - 0
110
126
  version: "0"
111
- version:
112
127
  required_rubygems_version: !ruby/object:Gem::Requirement
113
128
  requirements:
114
129
  - - ">="
115
130
  - !ruby/object:Gem::Version
131
+ segments:
132
+ - 0
116
133
  version: "0"
117
- version:
118
134
  requirements: []
119
135
 
120
136
  rubyforge_project:
121
- rubygems_version: 1.3.5
137
+ rubygems_version: 1.3.6
122
138
  signing_key:
123
139
  specification_version: 3
124
140
  summary: Dreamcat4's plist4r gem. For reading/writing plists in ruby