plist4r 1.1.2 → 1.1.3

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
- 1.1.2
1
+ 1.1.3
@@ -11,19 +11,19 @@ In this example, we edit an Apple Info.plist, to modify a couple of the keys and
11
11
  # block method
12
12
  info_plist = Plist4r.open "/Applications/MyApp.app/Contents/Info.plist" do
13
13
 
14
- # plist attributes
14
+ # plist file attributes
15
15
  filename # => "/Applications/MyApp.app/Contents/Info.plist"
16
16
  file_format # => :xml
17
17
  plist_type # => :info
18
18
 
19
- # read
19
+ # read plist keys
20
20
  c_f_bundle_executable # => "MyApp"
21
21
  c_f_bundle_icon_file # => "Icon"
22
22
  c_f_bundle_identifier # => "com.mydomain.MyApp"
23
23
  c_f_bundle_name # => "MyApp"
24
24
  c_f_bundle_signature # => "????"
25
25
 
26
- # write
26
+ # write plist keys
27
27
  c_f_bundle_signature "MYAP"
28
28
  store "LSUIElement" true
29
29
 
@@ -11,19 +11,19 @@ In this example, we edit an Apple Launchd plist, to modify a couple of the keys
11
11
  # block method
12
12
  launchd_plist = Plist4r.open "/Library/LaunchDaemons/com.mydomain.MyApp.plist" do
13
13
 
14
- # plist attributes
14
+ # plist file attributes
15
15
  filename # => "/Library/LaunchDaemons/com.mydomain.MyApp.plist"
16
16
  file_format # => :xml
17
17
  plist_type # => :launchd
18
18
 
19
- # read
19
+ # read plist keys
20
20
  label # => "com.mydomain.Myapp"
21
21
  program_arguments # => ["/Applications/MyApp.app/Contents/MacOS/MyApp"]
22
22
  queue_directories # => ["/dir/to/watch/1","/dir/to/watch/2","etc..."]
23
23
  run_at_load # => false
24
24
  start_on_mount # => false
25
25
 
26
- # write
26
+ # write plist keys
27
27
  run_at_load true
28
28
  store "StartOnMount" true
29
29
 
@@ -26,6 +26,11 @@ module Plist4r
26
26
  SoftResourceLimits, HardResourceLimits MachServices Socket ]
27
27
  }
28
28
 
29
+
30
+ class InetdCompatibility < ArrayDict
31
+ ValidKeys = { :bool => %w[Wait] }
32
+ end
33
+
29
34
  # Set or return the plist key +inetdCompatibility+
30
35
  # @param [Hash <true,false>] value the
31
36
  # The presence of this key specifies that the daemon expects to be run as if it were launched from inetd.
@@ -41,20 +46,21 @@ module Plist4r
41
46
  # # return inetdCompatibility
42
47
  # launchd_plist.inetd_compatibility => hash or nil
43
48
  #
44
- def inetd_compatibility value=nil
49
+ def inetd_compatibility value=nil, &blk
45
50
  key = "inetdCompatibility"
46
51
  case value
47
- when Hash
48
- if value[:wait]
49
- @hash[key] = value[:wait]
52
+ when nil
53
+ if block_given?
54
+ @hash[key] = ::Plist4r::OrderedHash.new
55
+ @hash[key] = InetdCompatibility.new(@hash[key],&blk).to_hash
50
56
  else
51
- raise "Invalid value: #{method_name} #{value.inspect}. Should be: #{method_name} :wait => true|false"
57
+ @hash[key]
52
58
  end
53
- when nil
54
- @hash[key]
55
59
  else
56
- raise "Invalid value: #{method_name} #{value.inspect}. Should be: #{method_name} :wait => true|false"
60
+ raise "Invalid value: #{method_name} #{value.inspect}. Should be: #{method_name} { wait true|false }"
57
61
  end
62
+
63
+
58
64
  end
59
65
 
60
66
  class KeepAlive < ArrayDict
@@ -119,7 +125,6 @@ module Plist4r
119
125
  @hash[key] = value
120
126
  when nil
121
127
  if block_given?
122
- puts KeepAlive.new(@hash[key],&blk).to_hash
123
128
  @hash[key] = ::Plist4r::OrderedHash.new
124
129
  @hash[key] = KeepAlive.new(@hash[key],&blk).to_hash
125
130
  else
@@ -296,7 +301,7 @@ module Plist4r
296
301
  def soft_resource_limits value=nil, &blk
297
302
  key = "SoftResourceLimits"
298
303
  if blk
299
- @hash[key] ||= ::Plist4r::OrderedHash.new
304
+ @hash[key] = ::Plist4r::OrderedHash.new
300
305
  @hash[key] = ResourceLimits.new(@hash[key],&blk).to_hash
301
306
  else
302
307
  @hash[key]
@@ -361,7 +366,7 @@ module Plist4r
361
366
  def hard_resource_limits value=nil, &blk
362
367
  key = "HardResourceLimits"
363
368
  if blk
364
- @hash[key] ||= ::Plist4r::OrderedHash.new
369
+ @hash[key] = ::Plist4r::OrderedHash.new
365
370
  @hash[key] = ResourceLimits.new(@hash[key],&blk).to_hash
366
371
  else
367
372
  @hash[key]
@@ -428,7 +433,7 @@ module Plist4r
428
433
  def mach_services value=nil, &blk
429
434
  key = "MachServices"
430
435
  if blk
431
- @hash[key] ||= ::Plist4r::OrderedHash.new
436
+ @hash[key] = ::Plist4r::OrderedHash.new
432
437
  @hash[key] = MachServices.new(@hash[key],&blk).to_hash
433
438
  else
434
439
  @hash[key]
@@ -661,8 +666,8 @@ module Plist4r
661
666
  def socket index_or_key=nil, index=nil, &blk
662
667
  key = "Sockets"
663
668
  if blk
664
- @hash[key] ||= ::Plist4r::OrderedHash.new
665
- sockets = Sockets.new(@hash[key]).to_hash
669
+ @hash[key] = ::Plist4r::OrderedHash.new
670
+ sockets = Sockets.new(@hash[key])
666
671
 
667
672
  case index_or_key
668
673
  when nil
@@ -680,7 +685,7 @@ module Plist4r
680
685
  else
681
686
  raise "Invalid socket key: #{method_name} #{index_or_key.inspect}. Should be: #{method_name} <socket_key> &blk"
682
687
  end
683
- @hash[key] = sockets
688
+ @hash[key] = sockets.to_hash
684
689
  else
685
690
  @hash[key]
686
691
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{plist4r}
8
- s.version = "1.1.2"
8
+ s.version = "1.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["dreamcat4"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 2
9
- version: 1.1.2
8
+ - 3
9
+ version: 1.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - dreamcat4