Class: Plist4r::Config

Inherits:
Object show all
Extended by:
Mixlib::Config
Defined in:
lib/plist4r/config.rb

Overview

The special configuration object, which holds all runtime defaults for individual plist instances. When we create a new Plist object, it will inherit these defaults. # Reverse the priority order of backends Plist4r::Config.reverse!

# Set the default folder from which to load / save plist files Plist4r::Config = “/path/to/my/plist/files”

# Save new plist files as binary plists (when format not known) Plist4r::Config = :binary

# Add custom / application specific Plist Type. You’ll also need to subclass PlistType Expects class Plist4r::PlistType::MyPlistType to be defined require ‘my_plist_type.rb’ Plist4r::Config << “my_plist_type”

# Raise an exception plist keys which dont belong to the selected Plist type Plist4r::Config = true

Constant Summary collapse

CoreFoundationFramework =
"/System/Library/Frameworks/CoreFoundation.framework"
RubycocoaFramework =
"/System/Library/Frameworks/RubyCocoa.framework"
DefaultBackendsAny =
["c_f_property_list","haml","libxml4r"]
DefaultBackendsOsx =
["osx_plist","c_f_property_list","haml","libxml4r"]

Class Method Summary collapse

Methods included from Mixlib::Config

[], []=, config_attr_writer, configure, from_file, has_key?, hash_dup, keys, merge!, method_missing

Class Method Details

.default_backends(sym = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/plist4r/config.rb', line 37

def self.default_backends sym=nil
  case sym
  when :brew
    ["ruby_cocoa"]
  else
    if File.exists? CoreFoundationFramework
      if File.exists? RubycocoaFramework
        DefaultBackendsOsx + ["ruby_cocoa"]
      else
        DefaultBackendsOsx
      end
    else
      DefaultBackendsAny
    end
  end
end