plist4r 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +120 -9
- data/VERSION +1 -1
- data/lib/plist4r.rb +54 -0
- data/lib/plist4r/backend.rb +52 -0
- data/lib/plist4r/backend/example.rb +69 -0
- data/lib/plist4r/backend/haml.rb +74 -0
- data/lib/plist4r/backend/libxml4r.rb +80 -0
- data/lib/plist4r/backend/plutil.rb +19 -0
- data/lib/plist4r/backend/ruby_cocoa.rb +191 -0
- data/lib/plist4r/config.rb +18 -0
- data/lib/plist4r/mixin.rb +7 -0
- data/lib/plist4r/mixin/class_attributes.rb +128 -0
- data/lib/plist4r/mixin/data_methods.rb +63 -0
- data/lib/plist4r/mixin/mixlib_config.rb +178 -0
- data/lib/plist4r/mixin/ordered_hash.rb +168 -0
- data/lib/plist4r/mixin/popen4.rb +193 -0
- data/lib/plist4r/mixin/ruby_stdlib.rb +24 -0
- data/lib/plist4r/plist.rb +256 -0
- data/lib/plist4r/plist_cache.rb +66 -0
- data/lib/plist4r/plist_type.rb +59 -0
- data/lib/plist4r/plist_type/info.rb +0 -0
- data/lib/plist4r/plist_type/launchd.rb +572 -0
- data/lib/plist4r/plist_type/plist.rb +0 -0
- data/plist4r.gemspec +86 -0
- data/spec/examples.rb +399 -0
- metadata +25 -2
File without changes
|
data/plist4r.gemspec
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{plist4r}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["dreamcat4"]
|
12
|
+
s.date = %q{2010-03-15}
|
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
|
+
s.email = %q{dreamcat4@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"features/plist4r.feature",
|
27
|
+
"features/step_definitions/plist4r_steps.rb",
|
28
|
+
"features/support/env.rb",
|
29
|
+
"lib/plist4r.rb",
|
30
|
+
"lib/plist4r/backend.rb",
|
31
|
+
"lib/plist4r/backend/example.rb",
|
32
|
+
"lib/plist4r/backend/haml.rb",
|
33
|
+
"lib/plist4r/backend/libxml4r.rb",
|
34
|
+
"lib/plist4r/backend/plutil.rb",
|
35
|
+
"lib/plist4r/backend/ruby_cocoa.rb",
|
36
|
+
"lib/plist4r/config.rb",
|
37
|
+
"lib/plist4r/mixin.rb",
|
38
|
+
"lib/plist4r/mixin/class_attributes.rb",
|
39
|
+
"lib/plist4r/mixin/data_methods.rb",
|
40
|
+
"lib/plist4r/mixin/mixlib_config.rb",
|
41
|
+
"lib/plist4r/mixin/ordered_hash.rb",
|
42
|
+
"lib/plist4r/mixin/popen4.rb",
|
43
|
+
"lib/plist4r/mixin/ruby_stdlib.rb",
|
44
|
+
"lib/plist4r/plist.rb",
|
45
|
+
"lib/plist4r/plist_cache.rb",
|
46
|
+
"lib/plist4r/plist_type.rb",
|
47
|
+
"lib/plist4r/plist_type/info.rb",
|
48
|
+
"lib/plist4r/plist_type/launchd.rb",
|
49
|
+
"lib/plist4r/plist_type/plist.rb",
|
50
|
+
"plist4r.gemspec",
|
51
|
+
"spec/examples.rb",
|
52
|
+
"spec/plist4r_spec.rb",
|
53
|
+
"spec/spec.opts",
|
54
|
+
"spec/spec_helper.rb"
|
55
|
+
]
|
56
|
+
s.homepage = %q{http://github.com/dreamcat4/plist4r}
|
57
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
58
|
+
s.require_paths = ["lib"]
|
59
|
+
s.rubygems_version = %q{1.3.5}
|
60
|
+
s.summary = %q{Dreamcat4's plist4r gem. For reading/writing plists in ruby}
|
61
|
+
s.test_files = [
|
62
|
+
"spec/examples.rb",
|
63
|
+
"spec/plist4r_spec.rb",
|
64
|
+
"spec/spec_helper.rb"
|
65
|
+
]
|
66
|
+
|
67
|
+
if s.respond_to? :specification_version then
|
68
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
69
|
+
s.specification_version = 3
|
70
|
+
|
71
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
72
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
73
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
74
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
75
|
+
else
|
76
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
77
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
78
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
79
|
+
end
|
80
|
+
else
|
81
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
82
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
83
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
data/spec/examples.rb
ADDED
@@ -0,0 +1,399 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# for irb
|
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
|
+
|
11
|
+
def snake_case
|
12
|
+
str = self.dup.gsub(/[A-Z]/) {|s| "_" + s}
|
13
|
+
str = str.downcase.sub(/^\_/, "")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
@launchd_plists = []
|
17
|
+
def plist name=nil, *program_args, &blk
|
18
|
+
puts self
|
19
|
+
puts self.class.inspect
|
20
|
+
puts self.class.to_s.inspect
|
21
|
+
name = "com.github.homebrew.#{self.class.to_s.snake_case}" unless name
|
22
|
+
@launchd_plists << ::LaunchdPlist.new(prefix, name, *program_args, &blk)
|
23
|
+
end
|
24
|
+
@name = "my_formula"
|
25
|
+
def name
|
26
|
+
@name
|
27
|
+
end
|
28
|
+
@prefix = `pwd`.delete("\n")
|
29
|
+
def prefix
|
30
|
+
@prefix
|
31
|
+
end
|
32
|
+
|
33
|
+
plist do
|
34
|
+
label "com.github.homebrew.myprogram"
|
35
|
+
program_arguments ["/usr/bin/myprogram"]
|
36
|
+
run_at_load true
|
37
|
+
working_directory "/var/db/myprogram"
|
38
|
+
standard_out_path "/var/log/myprogram.log"
|
39
|
+
|
40
|
+
sockets do
|
41
|
+
sock_service_name "netbios-ssn"
|
42
|
+
end
|
43
|
+
sockets do
|
44
|
+
sock_service_name "netbios"
|
45
|
+
bonjour ['smb']
|
46
|
+
end
|
47
|
+
end
|
48
|
+
@launchd_plists.first.finalize
|
49
|
+
|
50
|
+
def program_arguments array=nil
|
51
|
+
array
|
52
|
+
@program_arguments = array
|
53
|
+
else
|
54
|
+
@program_arguments
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def watch_paths array=nil
|
59
|
+
array.class == Array ? @watch_paths = array : @watch_paths
|
60
|
+
end
|
61
|
+
|
62
|
+
def label string
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
@xml_keys = {
|
67
|
+
'Label' => 'com.howbrew.haml',
|
68
|
+
'EnvironmentVariables' => {
|
69
|
+
'PATH' => '/sbin:/usr/sbin:/bin:/usr/bin',
|
70
|
+
'RUBY_LIB' => '/usr/lib/ruby/site_ruby/1.8'
|
71
|
+
},
|
72
|
+
|
73
|
+
'ProgramArguments' => [
|
74
|
+
"bash", "-l", "-c", "/usr/bin/env", "ruby", "-e", "puts RUBY_VERSION"
|
75
|
+
],
|
76
|
+
|
77
|
+
'Sockets' => {
|
78
|
+
'netbios' => {
|
79
|
+
'SockServiceName' => 'netbios-ssn',
|
80
|
+
'SockFamily' => 'IPv4'
|
81
|
+
},
|
82
|
+
|
83
|
+
'direct' => {
|
84
|
+
'SockServiceName' => 'netbios-ssn',
|
85
|
+
'SockFamily' => 'IPv4',
|
86
|
+
'Bonjour' => [
|
87
|
+
'smb'
|
88
|
+
],
|
89
|
+
}
|
90
|
+
},
|
91
|
+
|
92
|
+
'StartCalendarInterval' => {
|
93
|
+
'Hour' => 3,
|
94
|
+
'Minute' => 15,
|
95
|
+
'Weekday' => 6,
|
96
|
+
},
|
97
|
+
|
98
|
+
'WatchPaths' => [
|
99
|
+
"/Volumes/CD\ ROM",
|
100
|
+
"/var/run"
|
101
|
+
],
|
102
|
+
|
103
|
+
'RunAtLoad' => true,
|
104
|
+
'Debug' => true
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
launchd_plist "myprogram" do
|
109
|
+
env "PATH" => '/sbin:/usr/sbin:/bin:/usr/bin',
|
110
|
+
"RUBY_LIB" => '/usr/lib/ruby/site_ruby/1.8'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
launchd_plist "myprogram" do
|
116
|
+
sockets do
|
117
|
+
netbios do
|
118
|
+
name "netbios-ssn"
|
119
|
+
end
|
120
|
+
direct do
|
121
|
+
name "netbios"
|
122
|
+
bonjour ['smb']
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
launchd_plist "myprogram" do
|
128
|
+
sockets do
|
129
|
+
add "netbios" do
|
130
|
+
name "netbios-ssn"
|
131
|
+
end
|
132
|
+
direct do
|
133
|
+
name "netbios"
|
134
|
+
bonjour ['smb']
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
launchd_plist "myprogram" do
|
141
|
+
socket "netbios", :name => "netbios-ssn"
|
142
|
+
|
143
|
+
socket "direct", :name => "netbios" do
|
144
|
+
bonjour ['smb']
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
@launchd << plist "myprogram" do
|
154
|
+
start_calendar_interval do
|
155
|
+
hour 3
|
156
|
+
minute 15
|
157
|
+
weekday 6
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
@launchd << plist "com.github.homebrew.myprogram" do
|
162
|
+
label "com.github.homebrew.myprogram"
|
163
|
+
program_arguments [prefix+"bin/myprogram"]
|
164
|
+
run_at_load true
|
165
|
+
working_directory "/var/db/myprogram"
|
166
|
+
standard_out_path "/var/log/myprogram.log"
|
167
|
+
# ...
|
168
|
+
end
|
169
|
+
|
170
|
+
@launchd << plist do
|
171
|
+
label "com.github.homebrew.myprogram"
|
172
|
+
program_arguments [prefix+"bin/myprogram"]
|
173
|
+
run_at_load true
|
174
|
+
working_directory "/var/db/myprogram"
|
175
|
+
standard_out_path "/var/log/myprogram.log"
|
176
|
+
# ...
|
177
|
+
end
|
178
|
+
|
179
|
+
@launchd << plist "com.apache.couchdb"
|
180
|
+
@launchd << plist "com.sun.mysql.client", "com.sun.mysql.server"
|
181
|
+
|
182
|
+
|
183
|
+
# o = Haml::Engine.new("%p Haml code!").render
|
184
|
+
# engine = Haml::Engine.new("%p Haml code!")
|
185
|
+
|
186
|
+
# require 'rubygems'
|
187
|
+
# require 'haml'
|
188
|
+
# pwd = `pwd`.delete("\n")
|
189
|
+
# require "#{pwd}/test_plist.feature.rb"
|
190
|
+
# engine = Haml::Engine.new File.read("#{pwd}/launchd_plist.haml")
|
191
|
+
# print engine.render(self)
|
192
|
+
|
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>
|
322
|
+
|
323
|
+
# <key>StartCalendarInterval</key>
|
324
|
+
# <dict>
|
325
|
+
# <key>Hour</key>
|
326
|
+
# <integer>3</integer>
|
327
|
+
# <key>Minute</key>
|
328
|
+
# <integer>15</integer>
|
329
|
+
# <key>Weekday</key>
|
330
|
+
# <integer>6</integer>
|
331
|
+
# </dict>
|
332
|
+
#
|
333
|
+
# <key>WatchPaths</key>
|
334
|
+
# <array>
|
335
|
+
# <string>/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist</string>
|
336
|
+
# </array>
|
337
|
+
#
|
338
|
+
# <key>Sockets</key>
|
339
|
+
# <dict>
|
340
|
+
# <key>Listeners</key>
|
341
|
+
# <dict>
|
342
|
+
# <key>SockServiceName</key>
|
343
|
+
# <string>bootps</string>
|
344
|
+
# <key>SockType</key>
|
345
|
+
# <string>dgram</string>
|
346
|
+
# <key>SockFamily</key>
|
347
|
+
# <string>IPv4</string>
|
348
|
+
# </dict>
|
349
|
+
# </dict>
|
350
|
+
#
|
351
|
+
# <key>inetdCompatibility</key>
|
352
|
+
# <dict>
|
353
|
+
# <key>Wait</key>
|
354
|
+
# <true/>
|
355
|
+
# </dict>
|
356
|
+
#
|
357
|
+
# <key>WatchPaths</key>
|
358
|
+
# <array>
|
359
|
+
# <string><path to some dir></string>
|
360
|
+
# </array>
|
361
|
+
#
|
362
|
+
# <key>Sockets</key>
|
363
|
+
# <dict>
|
364
|
+
# <key>Listeners</key>
|
365
|
+
# <dict>
|
366
|
+
# <key>Bonjour</key>
|
367
|
+
# <array>
|
368
|
+
# <string>ssh</string>
|
369
|
+
# <string>sftp-ssh</string>
|
370
|
+
# </array>
|
371
|
+
# <key>SockServiceName</key>
|
372
|
+
# <string>ssh</string>
|
373
|
+
# </dict>
|
374
|
+
# </dict>
|
375
|
+
#
|
376
|
+
# <key>Sockets</key>
|
377
|
+
# <dict>
|
378
|
+
# <key>Listeners</key>
|
379
|
+
# <dict>
|
380
|
+
# <key>SockPassive</key>
|
381
|
+
# <true/>
|
382
|
+
# <key>SockServiceName</key>
|
383
|
+
# <string>ftp</string>
|
384
|
+
# <key>SockType</key>
|
385
|
+
# <string>SOCK_STREAM</string>
|
386
|
+
# </dict>
|
387
|
+
# </dict>
|
388
|
+
#
|
389
|
+
# <key>StartCalendarInterval</key>
|
390
|
+
# <dict>
|
391
|
+
# <key>Hour</key>
|
392
|
+
# <integer>3</integer>
|
393
|
+
# <key>Minute</key>
|
394
|
+
# <integer>15</integer>
|
395
|
+
# <key>Weekday</key>
|
396
|
+
# <integer>6</integer>
|
397
|
+
# </dict>
|
398
|
+
|
399
|
+
|