Module: Plist4r
- Defined in:
- lib/plist4r.rb,
lib/plist4r/cli.rb,
lib/plist4r/plist.rb,
lib/plist4r/config.rb,
lib/plist4r/backend.rb,
lib/plist4r/commands.rb,
lib/plist4r/plist_type.rb,
lib/plist4r/application.rb,
lib/plist4r/mixin/table.rb,
lib/plist4r/plist_cache.rb,
lib/plist4r/backend_base.rb,
lib/plist4r/mixin/popen4.rb,
lib/plist4r/mixin/script.rb,
lib/plist4r/plist_type/info.rb,
lib/plist4r/mixin/array_dict.rb,
lib/plist4r/mixin/mixlib_cli.rb,
lib/plist4r/plist_type/plist.rb,
lib/plist4r/backend/ruby_cocoa.rb,
lib/plist4r/mixin/data_methods.rb,
lib/plist4r/mixin/ordered_hash.rb,
lib/plist4r/mixin/ordered_hash.rb,
lib/plist4r/plist_type/launchd.rb,
lib/plist4r/backend/test/output.rb,
lib/plist4r/mixin/mixlib_config.rb,
lib/plist4r/backend/test/harness.rb,
lib/plist4r/backend/test/data_types.rb
Overview
require ‘plist4r/backend’
Defined Under Namespace
Modules: ActiveSupport, DataMethods, Mixlib, Popen4 Classes: Application, ArrayDict, Backend, CLI, Commands, Config, OrderedHash, Plist, PlistCache, PlistType, Script, Table
Class Method Summary collapse
-
.file_detect_format(filename) ⇒ Symbol
Given a Plist filename, peek the first few bytes and detect the file format.
-
.new(*args, &blk) ⇒ Plist4r::Plist
Calls Plist4r::Plist.new with the supplied arguments and block.
-
.open(filename, *args, &blk) ⇒ Plist4r::Plist
Opens a plist file.
-
.string_detect_format(string) ⇒ Symbol
Given an string of Plist data, peek the first few bytes and detect the file format.
Class Method Details
.file_detect_format(filename) ⇒ Symbol
Given a Plist filename, peek the first few bytes and detect the file format
77 78 79 |
# File 'lib/plist4r.rb', line 77 def file_detect_format filename string_detect_format File.read(filename) end |
.new(*args, &blk) ⇒ Plist4r::Plist
Calls Plist4r::Plist.new with the supplied arguments and block
Plist4r.new => #<Plist4r::Plist:0x111546c @file_format=nil, …>
19 20 21 |
# File 'lib/plist4r.rb', line 19 def new *args, &blk return Plist.new *args, &blk end |
.open(filename, *args, &blk) ⇒ Plist4r::Plist
Opens a plist file
Plist4r.open(“example.plist”) => #<Plist4r::Plist:0x1152d1c @file_format=“xml”, …>
32 33 34 35 |
# File 'lib/plist4r.rb', line 32 def open filename, *args, &blk p = Plist.new filename, *args, &blk p.open end |
.string_detect_format(string) ⇒ Symbol
Given an string of Plist data, peek the first few bytes and detect the file format
Plist4r.string_detect_format(“{ "key1" = "value1"; "key2" = "value2"; }”) => :gnustep
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/plist4r.rb', line 44 def string_detect_format string if RUBY_VERSION >= '1.9' string = string.force_encoding(Encoding::ASCII_8BIT) end string.strip! if string[0,1] =~ /\s/ case string[0,1] when "{","(" :gnustep when "b" if string =~ /^bplist/ :binary else nil end when "<" if string =~ /^\<\?xml/ && string =~ /\<\!DOCTYPE plist/ :xml else nil end else nil end end |