Class: Plist4r::Config

Extended by:
Mixlib::Config
Defined in:
lib/plist4r/config.rb

Class Methods

Methods included from Mixlib::Config

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

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.

Examples:

# Reverse the priority order of backends
Plist4r::Config[:backends].reverse!

# Set the default folder from which to load / save plist files
Plist4r::Config[:default_path] = "/path/to/my/plist/files"

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

# Add custom / application specific Plist Type. You'll also need to subclass {Plist4r::PlistType}
Expects class Plist4r::PlistType::MyPlistType to be defined
require 'my_plist_type.rb'
Plist4r::Config[:types] << "my_plist_type"

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

Constant Summary

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 Details

+ (Object) default_backends(sym = nil)



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