plist4r 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/.gitignore +4 -0
  2. data/.yardopts +11 -0
  3. data/LICENSE +3 -1
  4. data/README.rdoc +25 -122
  5. data/Rakefile +14 -0
  6. data/VERSION +1 -1
  7. data/bin/plist4r +2 -0
  8. data/ext/osx_plist/Makefile +157 -0
  9. data/ext/osx_plist/extconf.rb +9 -0
  10. data/ext/osx_plist/plist.c +606 -0
  11. data/ext/osx_plist/plist.o +0 -0
  12. data/lib/plist4r.rb +6 -3
  13. data/lib/plist4r/application.rb +1 -2
  14. data/lib/plist4r/backend.rb +102 -34
  15. data/lib/plist4r/backend/c_f_property_list.rb +65 -0
  16. data/lib/plist4r/backend/c_f_property_list/LICENSE +19 -0
  17. data/lib/plist4r/backend/c_f_property_list/README +34 -0
  18. data/lib/plist4r/backend/c_f_property_list/cfpropertylist.rb +6 -0
  19. data/lib/plist4r/backend/c_f_property_list/rbBinaryCFPropertyList.rb +663 -0
  20. data/lib/plist4r/backend/c_f_property_list/rbCFPlistError.rb +26 -0
  21. data/lib/plist4r/backend/c_f_property_list/rbCFPropertyList.rb +348 -0
  22. data/lib/plist4r/backend/c_f_property_list/rbCFTypes.rb +241 -0
  23. data/lib/plist4r/backend/c_f_property_list/rbXMLCFPropertyList.rb +116 -0
  24. data/lib/plist4r/backend/example.rb +37 -52
  25. data/lib/plist4r/backend/haml.rb +47 -36
  26. data/lib/plist4r/backend/libxml4r.rb +24 -20
  27. data/lib/plist4r/backend/osx_plist.rb +82 -0
  28. data/lib/plist4r/backend/ruby_cocoa.rb +172 -54
  29. data/lib/plist4r/backend/test/data_types.rb +163 -0
  30. data/lib/plist4r/backend/test/harness.rb +255 -0
  31. data/lib/plist4r/backend/test/output.rb +47 -0
  32. data/lib/plist4r/backend_base.rb +4 -2
  33. data/lib/plist4r/{options.rb → cli.rb} +2 -1
  34. data/lib/plist4r/commands.rb +13 -8
  35. data/lib/plist4r/config.rb +36 -9
  36. data/lib/plist4r/docs/Backends.html +59 -0
  37. data/lib/plist4r/docs/DeveloperGuide.rdoc +53 -0
  38. data/lib/plist4r/docs/EditingPlistFiles.rdoc +88 -0
  39. data/lib/plist4r/docs/InfoPlistExample.rdoc +33 -0
  40. data/lib/plist4r/docs/LaunchdPlistExample.rdoc +33 -0
  41. data/lib/plist4r/docs/PlistKeyNames.rdoc +47 -0
  42. data/lib/plist4r/mixin/array_dict.rb +61 -0
  43. data/lib/plist4r/mixin/data_methods.rb +178 -54
  44. data/lib/plist4r/mixin/haml4r.rb +4 -0
  45. data/lib/plist4r/mixin/haml4r/css_attributes.rb +19 -0
  46. data/lib/plist4r/mixin/haml4r/examples.rb +261 -0
  47. data/lib/plist4r/mixin/haml4r/haml_table_example.rb +79 -0
  48. data/lib/plist4r/mixin/haml4r/table.rb +157 -0
  49. data/lib/plist4r/mixin/haml4r/table_cell.rb +160 -0
  50. data/lib/plist4r/mixin/haml4r/table_cells.rb +485 -0
  51. data/lib/plist4r/mixin/haml4r/table_section.rb +101 -0
  52. data/lib/plist4r/mixin/ordered_hash.rb +9 -1
  53. data/lib/plist4r/mixin/popen4.rb +1 -1
  54. data/lib/plist4r/mixin/ruby_stdlib.rb +154 -1
  55. data/lib/plist4r/mixin/script.rb +133 -0
  56. data/lib/plist4r/mixin/table.rb +435 -0
  57. data/lib/plist4r/plist.rb +272 -94
  58. data/lib/plist4r/plist_cache.rb +42 -43
  59. data/lib/plist4r/plist_type.rb +31 -74
  60. data/lib/plist4r/plist_type/info.rb +157 -3
  61. data/lib/plist4r/plist_type/launchd.rb +54 -48
  62. data/lib/plist4r/plist_type/plist.rb +1 -3
  63. data/plist4r.gemspec +74 -14
  64. data/spec/{examples.rb → launchd_examples.rb} +131 -139
  65. data/spec/plist4r/application_spec.rb +37 -0
  66. data/spec/plist4r/backend_spec.rb +256 -0
  67. data/spec/plist4r/cli_spec.rb +25 -0
  68. data/spec/plist4r/commands_spec.rb +20 -0
  69. data/spec/plist4r/config_spec.rb +38 -0
  70. data/spec/plist4r/mixin/array_dict_spec.rb +120 -0
  71. data/spec/plist4r/mixin/data_methods_spec.rb +96 -0
  72. data/spec/plist4r/mixin/haml4r/examples.rb +261 -0
  73. data/spec/plist4r/mixin/ruby_stdlib_spec.rb +228 -0
  74. data/spec/plist4r/plist_cache_spec.rb +261 -0
  75. data/spec/plist4r/plist_spec.rb +841 -23
  76. data/spec/plist4r/plist_type_spec.rb +126 -0
  77. data/spec/plist4r_spec.rb +53 -27
  78. data/spec/scratchpad.rb +226 -0
  79. data/spec/spec_helper.rb +5 -1
  80. metadata +109 -23
  81. data/lib/plist4r/backend/plutil.rb +0 -25
  82. data/lib/plist4r/mixin.rb +0 -7
  83. data/plists/array_mini.xml +0 -14
  84. data/plists/example_big_binary.plist +0 -0
  85. data/plists/example_medium_binary_launchd.plist +0 -0
  86. data/plists/example_medium_launchd.xml +0 -53
  87. data/plists/mini.xml +0 -12
  88. data/test.rb +0 -40
@@ -3,8 +3,6 @@ require 'plist4r/plist_type'
3
3
 
4
4
  module Plist4r
5
5
  class PlistType::Plist < PlistType
6
- def self.valid_keys
7
- {}
8
- end
6
+ ValidKeys = {}
9
7
  end
10
8
  end
data/plist4r.gemspec CHANGED
@@ -5,15 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{plist4r}
8
- s.version = "0.2.2"
8
+ s.version = "1.0.0"
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-04-18}
12
+ s.date = %q{2010-07-20}
13
13
  s.default_executable = %q{plist4r}
14
14
  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}
15
15
  s.email = %q{dreamcat4@gmail.com}
16
16
  s.executables = ["plist4r"]
17
+ s.extensions = ["ext/osx_plist/extconf.rb"]
17
18
  s.extra_rdoc_files = [
18
19
  "LICENSE",
19
20
  "README.rdoc"
@@ -28,28 +29,60 @@ Gem::Specification.new do |s|
28
29
  "Rakefile",
29
30
  "VERSION",
30
31
  "bin/plist4r",
32
+ "ext/osx_plist/Makefile",
33
+ "ext/osx_plist/extconf.rb",
34
+ "ext/osx_plist/plist.c",
35
+ "ext/osx_plist/plist.o",
31
36
  "features/plist4r.feature",
32
37
  "features/step_definitions/plist4r_steps.rb",
33
38
  "features/support/env.rb",
34
39
  "lib/plist4r.rb",
35
40
  "lib/plist4r/application.rb",
36
41
  "lib/plist4r/backend.rb",
42
+ "lib/plist4r/backend/c_f_property_list.rb",
43
+ "lib/plist4r/backend/c_f_property_list/LICENSE",
44
+ "lib/plist4r/backend/c_f_property_list/README",
45
+ "lib/plist4r/backend/c_f_property_list/cfpropertylist.rb",
46
+ "lib/plist4r/backend/c_f_property_list/rbBinaryCFPropertyList.rb",
47
+ "lib/plist4r/backend/c_f_property_list/rbCFPlistError.rb",
48
+ "lib/plist4r/backend/c_f_property_list/rbCFPropertyList.rb",
49
+ "lib/plist4r/backend/c_f_property_list/rbCFTypes.rb",
50
+ "lib/plist4r/backend/c_f_property_list/rbXMLCFPropertyList.rb",
37
51
  "lib/plist4r/backend/example.rb",
38
52
  "lib/plist4r/backend/haml.rb",
39
53
  "lib/plist4r/backend/libxml4r.rb",
40
- "lib/plist4r/backend/plutil.rb",
54
+ "lib/plist4r/backend/osx_plist.rb",
41
55
  "lib/plist4r/backend/ruby_cocoa.rb",
56
+ "lib/plist4r/backend/test/data_types.rb",
57
+ "lib/plist4r/backend/test/harness.rb",
58
+ "lib/plist4r/backend/test/output.rb",
42
59
  "lib/plist4r/backend_base.rb",
60
+ "lib/plist4r/cli.rb",
43
61
  "lib/plist4r/commands.rb",
44
62
  "lib/plist4r/config.rb",
45
- "lib/plist4r/mixin.rb",
63
+ "lib/plist4r/docs/Backends.html",
64
+ "lib/plist4r/docs/DeveloperGuide.rdoc",
65
+ "lib/plist4r/docs/EditingPlistFiles.rdoc",
66
+ "lib/plist4r/docs/InfoPlistExample.rdoc",
67
+ "lib/plist4r/docs/LaunchdPlistExample.rdoc",
68
+ "lib/plist4r/docs/PlistKeyNames.rdoc",
69
+ "lib/plist4r/mixin/array_dict.rb",
46
70
  "lib/plist4r/mixin/data_methods.rb",
71
+ "lib/plist4r/mixin/haml4r.rb",
72
+ "lib/plist4r/mixin/haml4r/css_attributes.rb",
73
+ "lib/plist4r/mixin/haml4r/examples.rb",
74
+ "lib/plist4r/mixin/haml4r/haml_table_example.rb",
75
+ "lib/plist4r/mixin/haml4r/table.rb",
76
+ "lib/plist4r/mixin/haml4r/table_cell.rb",
77
+ "lib/plist4r/mixin/haml4r/table_cells.rb",
78
+ "lib/plist4r/mixin/haml4r/table_section.rb",
47
79
  "lib/plist4r/mixin/mixlib_cli.rb",
48
80
  "lib/plist4r/mixin/mixlib_config.rb",
49
81
  "lib/plist4r/mixin/ordered_hash.rb",
50
82
  "lib/plist4r/mixin/popen4.rb",
51
83
  "lib/plist4r/mixin/ruby_stdlib.rb",
52
- "lib/plist4r/options.rb",
84
+ "lib/plist4r/mixin/script.rb",
85
+ "lib/plist4r/mixin/table.rb",
53
86
  "lib/plist4r/plist.rb",
54
87
  "lib/plist4r/plist_cache.rb",
55
88
  "lib/plist4r/plist_type.rb",
@@ -57,17 +90,23 @@ Gem::Specification.new do |s|
57
90
  "lib/plist4r/plist_type/launchd.rb",
58
91
  "lib/plist4r/plist_type/plist.rb",
59
92
  "plist4r.gemspec",
60
- "plists/array_mini.xml",
61
- "plists/example_big_binary.plist",
62
- "plists/example_medium_binary_launchd.plist",
63
- "plists/example_medium_launchd.xml",
64
- "plists/mini.xml",
65
- "spec/examples.rb",
93
+ "spec/launchd_examples.rb",
94
+ "spec/plist4r/application_spec.rb",
95
+ "spec/plist4r/backend_spec.rb",
96
+ "spec/plist4r/cli_spec.rb",
97
+ "spec/plist4r/commands_spec.rb",
98
+ "spec/plist4r/config_spec.rb",
99
+ "spec/plist4r/mixin/array_dict_spec.rb",
100
+ "spec/plist4r/mixin/data_methods_spec.rb",
101
+ "spec/plist4r/mixin/haml4r/examples.rb",
102
+ "spec/plist4r/mixin/ruby_stdlib_spec.rb",
103
+ "spec/plist4r/plist_cache_spec.rb",
66
104
  "spec/plist4r/plist_spec.rb",
105
+ "spec/plist4r/plist_type_spec.rb",
67
106
  "spec/plist4r_spec.rb",
107
+ "spec/scratchpad.rb",
68
108
  "spec/spec.opts",
69
- "spec/spec_helper.rb",
70
- "test.rb"
109
+ "spec/spec_helper.rb"
71
110
  ]
72
111
  s.homepage = %q{http://github.com/dreamcat4/plist4r}
73
112
  s.rdoc_options = ["--charset=UTF-8"]
@@ -75,9 +114,21 @@ Gem::Specification.new do |s|
75
114
  s.rubygems_version = %q{1.3.6}
76
115
  s.summary = %q{Dreamcat4's plist4r gem. For reading/writing plists in ruby}
77
116
  s.test_files = [
78
- "spec/examples.rb",
117
+ "spec/launchd_examples.rb",
118
+ "spec/plist4r/application_spec.rb",
119
+ "spec/plist4r/backend_spec.rb",
120
+ "spec/plist4r/cli_spec.rb",
121
+ "spec/plist4r/commands_spec.rb",
122
+ "spec/plist4r/config_spec.rb",
123
+ "spec/plist4r/mixin/array_dict_spec.rb",
124
+ "spec/plist4r/mixin/data_methods_spec.rb",
125
+ "spec/plist4r/mixin/haml4r/examples.rb",
126
+ "spec/plist4r/mixin/ruby_stdlib_spec.rb",
127
+ "spec/plist4r/plist_cache_spec.rb",
79
128
  "spec/plist4r/plist_spec.rb",
129
+ "spec/plist4r/plist_type_spec.rb",
80
130
  "spec/plist4r_spec.rb",
131
+ "spec/scratchpad.rb",
81
132
  "spec/spec_helper.rb"
82
133
  ]
83
134
 
@@ -86,15 +137,24 @@ Gem::Specification.new do |s|
86
137
  s.specification_version = 3
87
138
 
88
139
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
140
+ s.add_runtime_dependency(%q<libxml-ruby>, [">= 0"])
141
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
142
+ s.add_runtime_dependency(%q<libxml4r>, [">= 0"])
89
143
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
90
144
  s.add_development_dependency(%q<yard>, [">= 0"])
91
145
  s.add_development_dependency(%q<cucumber>, [">= 0"])
92
146
  else
147
+ s.add_dependency(%q<libxml-ruby>, [">= 0"])
148
+ s.add_dependency(%q<haml>, [">= 0"])
149
+ s.add_dependency(%q<libxml4r>, [">= 0"])
93
150
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
94
151
  s.add_dependency(%q<yard>, [">= 0"])
95
152
  s.add_dependency(%q<cucumber>, [">= 0"])
96
153
  end
97
154
  else
155
+ s.add_dependency(%q<libxml-ruby>, [">= 0"])
156
+ s.add_dependency(%q<haml>, [">= 0"])
157
+ s.add_dependency(%q<libxml4r>, [">= 0"])
98
158
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
99
159
  s.add_dependency(%q<yard>, [">= 0"])
100
160
  s.add_dependency(%q<cucumber>, [">= 0"])
@@ -2,17 +2,7 @@
2
2
 
3
3
  # for irb
4
4
  require './launchd_plist.rb'
5
- class String
6
- def camelcase
7
- str = self.dup.capitalize.gsub(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase } \
8
- .gsub('+', 'x')
9
- end
10
5
 
11
- def snake_case
12
- str = self.dup.gsub(/[A-Z]/) {|s| "_" + s}
13
- str = str.downcase.sub(/^\_/, "")
14
- end
15
- end
16
6
  @launchd_plists = []
17
7
  def plist name=nil, *program_args, &blk
18
8
  puts self
@@ -190,135 +180,137 @@ end
190
180
  # engine = Haml::Engine.new File.read("#{pwd}/launchd_plist.haml")
191
181
  # print engine.render(self)
192
182
 
193
- <key>Sockets</key>
194
- <dict>
195
- <key>Listeners</key>
196
- <dict>
197
- <key>SockFamily</key>
198
- <string>Unix</string>
199
- <key>SockPathMode</key>
200
- <integer>384</integer>
201
- <key>SockPathName</key>
202
- <string>/var/run/vpncontrol.sock</string>
203
- </dict>
204
- </dict>
205
-
206
-
207
- <key>Sockets</key>
208
- <dict>
209
- <key>Listeners</key>
210
- <array>
211
- <dict>
212
- <key>SockNodeName</key>
213
- <string>::1</string>
214
- <key>SockServiceName</key>
215
- <string>ipp</string>
216
- </dict>
217
- <dict>
218
- <key>SockNodeName</key>
219
- <string>127.0.0.1</string>
220
- <key>SockServiceName</key>
221
- <string>ipp</string>
222
- </dict>
223
- <dict>
224
- <key>SockPathMode</key>
225
- <integer>49663</integer>
226
- <key>SockPathName</key>
227
- <string>/private/var/run/cupsd</string>
228
- </dict>
229
- </array>
230
- </dict>
231
-
232
- <key>Sockets</key>
233
- <dict>
234
- <key>listener1</key>
235
- <dict>
236
- <key>SockNodeName</key>
237
- <string>::1</string>
238
- <key>SockServiceName</key>
239
- <string>ipp</string>
240
- </dict>
241
- <key>listener2</key>
242
- <dict>
243
- <key>SockNodeName</key>
244
- <string>127.0.0.1</string>
245
- <key>SockServiceName</key>
246
- <string>ipp</string>
247
- </dict>
248
- <key>listener3</key>
249
- <dict>
250
- <key>SockPathMode</key>
251
- <integer>49663</integer>
252
- <key>SockPathName</key>
253
- <string>/private/var/run/cupsd</string>
254
- </dict>
255
- </dict>
256
-
257
-
258
-
259
-
260
-
261
- <key>Sockets</key>
262
- <dict>
263
- <key>listener1</key>
264
- <array>
265
- <dict>
266
- <key>SockNodeName</key>
267
- <string>::1</string>
268
- <key>SockServiceName</key>
269
- <string>ipp</string>
270
- </dict>
271
- </array>
272
- <key>listener2</key>
273
- <array>
274
- <dict>
275
- <key>SockNodeName</key>
276
- <string>127.0.0.1</string>
277
- <key>SockServiceName</key>
278
- <string>ipp</string>
279
- </dict>
280
- </array>
281
- <key>listener3</key>
282
- <array>
283
- <dict>
284
- <key>SockPathMode</key>
285
- <integer>49663</integer>
286
- <key>SockPathName</key>
287
- <string>/private/var/run/cupsd</string>
288
- </dict>
289
- </array>
290
- </dict>
291
-
292
-
293
-
294
-
295
-
296
-
297
-
298
-
299
-
300
-
301
- <key>Sockets</key>
302
- <dict>
303
- <key>netbios</key>
304
- <dict>
305
- <key>SockServiceName</key>
306
- <string>netbios-ssn</string>
307
- <key>SockFamily</key>
308
- <string>IPv4</string>
309
- </dict>
310
- <key>direct</key>
311
- <dict>
312
- <key>SockServiceName</key>
313
- <string>microsoft-ds</string>
314
- <key>SockFamily</key>
315
- <string>IPv4</string>
316
- <key>Bonjour</key>
317
- <array>
318
- <string>smb</string>
319
- </array>
320
- </dict>
321
- </dict>
183
+
184
+
185
+ # <key>Sockets</key>
186
+ # <dict>
187
+ # <key>Listeners</key>
188
+ # <dict>
189
+ # <key>SockFamily</key>
190
+ # <string>Unix</string>
191
+ # <key>SockPathMode</key>
192
+ # <integer>384</integer>
193
+ # <key>SockPathName</key>
194
+ # <string>/var/run/vpncontrol.sock</string>
195
+ # </dict>
196
+ # </dict>
197
+
198
+
199
+ # <key>Sockets</key>
200
+ # <dict>
201
+ # <key>Listeners</key>
202
+ # <array>
203
+ # <dict>
204
+ # <key>SockNodeName</key>
205
+ # <string>::1</string>
206
+ # <key>SockServiceName</key>
207
+ # <string>ipp</string>
208
+ # </dict>
209
+ # <dict>
210
+ # <key>SockNodeName</key>
211
+ # <string>127.0.0.1</string>
212
+ # <key>SockServiceName</key>
213
+ # <string>ipp</string>
214
+ # </dict>
215
+ # <dict>
216
+ # <key>SockPathMode</key>
217
+ # <integer>49663</integer>
218
+ # <key>SockPathName</key>
219
+ # <string>/private/var/run/cupsd</string>
220
+ # </dict>
221
+ # </array>
222
+ # </dict>
223
+
224
+ # <key>Sockets</key>
225
+ # <dict>
226
+ # <key>listener1</key>
227
+ # <dict>
228
+ # <key>SockNodeName</key>
229
+ # <string>::1</string>
230
+ # <key>SockServiceName</key>
231
+ # <string>ipp</string>
232
+ # </dict>
233
+ # <key>listener2</key>
234
+ # <dict>
235
+ # <key>SockNodeName</key>
236
+ # <string>127.0.0.1</string>
237
+ # <key>SockServiceName</key>
238
+ # <string>ipp</string>
239
+ # </dict>
240
+ # <key>listener3</key>
241
+ # <dict>
242
+ # <key>SockPathMode</key>
243
+ # <integer>49663</integer>
244
+ # <key>SockPathName</key>
245
+ # <string>/private/var/run/cupsd</string>
246
+ # </dict>
247
+ # </dict>
248
+
249
+
250
+
251
+
252
+
253
+ # <key>Sockets</key>
254
+ # <dict>
255
+ # <key>listener1</key>
256
+ # <array>
257
+ # <dict>
258
+ # <key>SockNodeName</key>
259
+ # <string>::1</string>
260
+ # <key>SockServiceName</key>
261
+ # <string>ipp</string>
262
+ # </dict>
263
+ # </array>
264
+ # <key>listener2</key>
265
+ # <array>
266
+ # <dict>
267
+ # <key>SockNodeName</key>
268
+ # <string>127.0.0.1</string>
269
+ # <key>SockServiceName</key>
270
+ # <string>ipp</string>
271
+ # </dict>
272
+ # </array>
273
+ # <key>listener3</key>
274
+ # <array>
275
+ # <dict>
276
+ # <key>SockPathMode</key>
277
+ # <integer>49663</integer>
278
+ # <key>SockPathName</key>
279
+ # <string>/private/var/run/cupsd</string>
280
+ # </dict>
281
+ # </array>
282
+ # </dict>
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+ # <key>Sockets</key>
294
+ # <dict>
295
+ # <key>netbios</key>
296
+ # <dict>
297
+ # <key>SockServiceName</key>
298
+ # <string>netbios-ssn</string>
299
+ # <key>SockFamily</key>
300
+ # <string>IPv4</string>
301
+ # </dict>
302
+ # <key>direct</key>
303
+ # <dict>
304
+ # <key>SockServiceName</key>
305
+ # <string>microsoft-ds</string>
306
+ # <key>SockFamily</key>
307
+ # <string>IPv4</string>
308
+ # <key>Bonjour</key>
309
+ # <array>
310
+ # <string>smb</string>
311
+ # </array>
312
+ # </dict>
313
+ # </dict>
322
314
 
323
315
  # <key>StartCalendarInterval</key>
324
316
  # <dict>