pax_global_header 0000666 0000000 0000000 00000000064 13773177205 0014526 g ustar 00root root 0000000 0000000 52 comment=ce8f9ae42a114f603ea200c955e420782bffc4ad
plist-3.6.0/ 0000775 0000000 0000000 00000000000 13773177205 0012667 5 ustar 00root root 0000000 0000000 plist-3.6.0/.gitignore 0000664 0000000 0000000 00000000127 13773177205 0014657 0 ustar 00root root 0000000 0000000 /.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
plist-3.6.0/.travis.yml 0000664 0000000 0000000 00000000462 13773177205 0015002 0 ustar 00root root 0000000 0000000 ---
language: ruby
cache: bundler
branches:
only:
- master
rvm:
- jruby-18mode
- jruby-19mode
- 1.9.3
- 2.0.0-p648 # macOS
- 2.1.10
- 2.2.10
- 2.3.8
- 2.4.5
- 2.5.3
- 2.6
- 2.7
- 3.0
- ruby-head
- jruby-head
before_install: gem install bundler -v '~> 1.14' --conservative
plist-3.6.0/CHANGELOG.rdoc 0000664 0000000 0000000 00000012364 13773177205 0015035 0 ustar 00root root 0000000 0000000 = plist - All-purpose Property List manipulation library
=== Unreleased
https://github.com/patsplat/plist/compare/v3.6.0...HEAD
* Your contribution here!
=== 3.6.0 (2020-12-30)
https://github.com/patsplat/plist/compare/v3.5.0...v3.6.0
New features and important changes:
* Do not indent multiline string values (https://github.com/patsplat/plist/pull/54)
* Add `Plist::UnimplementedElementError` (https://github.com/patsplat/plist/pull/51)
* Add support for text inside `` (https://github.com/patsplat/plist/pull/49)
Housekeeping:
* Add Ruby 2.7 and 3.0 to CI (https://github.com/patsplat/plist/pull/55)
* add docker-compose for development (https://github.com/patsplat/plist/pull/47)
* Replace `require` with `require_relative`(https://github.com/patsplat/plist/pull/52)
=== 3.5.0 (2018-12-22)
https://github.com/patsplat/plist/compare/v3.4.0...v3.5.0
* Only ship the required libs in the gem artifact (https://github.com/patsplat/plist/pull/48)
=== 3.4.0 (2017-12-08)
https://github.com/patsplat/plist/compare/v3.3.0...v3.4.0
* Support custom indent string (https://github.com/patsplat/plist/pull/44)
=== 3.3.0 (2017-04-28)
https://github.com/patsplat/plist/compare/dece870...v3.3.0
* Fix ASCII/UTF-8 error (https://github.com/patsplat/plist/pull/38).
* Fix Fixnum, Bignum deprecations in Ruby 2.4
* Fix unused variable `e` warning
=== 3.2.0 (2016-01-28)
https://github.com/patsplat/plist/compare/ea0b4e7...dece870
* Changed sort to sort_by in Plist::Emit.plist_node to allow mixed symbol and string hash keys
* Updated deprecated File.exists? to File.exist?
* Fixed defect in PData in which exception was thrown when element was read from plist
=== 3.1.0 (2010-02-23)
2010-02-23:
* Ruby 1.9.x compatibility!
2010-02-16:
* excise a bunch of unnecessary @@ variables
* fix up some tests for cross-version compatibility
2010-02-14:
* generalized cleanup:
* fix old file headers
* modernize rakefile
* clean up rdoc
2010-01-08:
* move from RubyForge Subversion to GitHub
2007-02-22 (r81):
* make the plist parser accept strings contain XML or any object that responds to #read (File and StringIO being the intended targets here). Test and idea contributed by Chuck Remes.
2006-09-20 (r80):
* tweak a comment in generator.rb to make it clear that we're not using Base64.b64encode because it's broken.
=== 3.0.0 (2006-09-20)
2006-09-20 (r77 - r79):
* move IndentedString inside Plist::Emit and :nodoc: it
* Tag 3.0.0! (from rev 78)
2006-09-19 (r73 - r75):
* Really fix the rakefile this time (apparently I deleted some code that I needed...)
* alter the fix_whitespace rake task to ignore the assets directory
* cleanup whitespace
2006-09-18 (r70 - r72):
* Update this file ;)
* Fix Rakefile
* gem install -t now works correctly
* Remove super-sekr1t rdoc staging area from rdoc publishing task
2006-09-15 (r64 - r69):
* Change behavior of empty collection elements to match What Apple Does
* Fix some gem packaging infrastructure
2006-09-13 (r61 - r63):
* Merge generator injection removal branch into trunk!
2006-09-13 (r52 - r60):
* Fix indentation/newlines in generator (finally!)
* Refix indentation to be more faithful to the way Apple emits their plists
* Remove horrific regex and replace it with proper comment parsing
* Empty plists return nil when parsed
* Sort hash keys before emitting (now we can test multi-element hashes!)
* Inject #<=> into Symbol so that sorting Symbol-keyed hashes won't freak out
=== 2.1.2 (2006-09-20)
2006-09-12 (r47 - r51):
* More test rejiggering
* New tests to expose some bugs
2006-09-10 (r33 - r46):
* Update tests for new generator code
* Rejigger some tests
* Make the generator try to call #to_plist_node on any object it tries to serialize, thus allowing class authors to define how their objects will be serialized
* Marshal.dump unrecognized objects into elements
* Make the parser strip out comments and Marshal.load elements if possible
* Update some rdoc
=== 2.1.1 (2006-09-10)
2006-09-10 (r31 - r32):
* Added encoding / decoding for entities (& etc)
* Changed parsing of elements to return StringIO objects
* Fixed bug with empty tags
2006-08-24 (r25 - r30):
* Invert ownership of methods in the generator, allowing us to remove the self.extend(self)
* New branch to remove method inject from parser
2006-08-23 (r22 - r24):
* Add rcov task to Rakefile
* Add some tests
2006-08-20 (r9 - r21):
* Add a bunch of rdoc and rdoc infrastructure
* Add rake task to clean up errant whitespace
* Spin off a branch to remove a bunch of method injection in the generator code
* Rename some tests for clarity's sake
* Replace NARF generation code with Ben's generation code
* Update tests
* This broke indentation (will be fixed later)
* Add Plist::Emit.dump, so you can dump objects which don't include Plist::Emit, update tests to match
* Fix a bug with the method that wraps output in the plist header/footer
2006-08-19 (r1 - r8):
* The beginnings of merging the plist project into the NARF plist library (under the plist project's name)
* fancier project infrastructure (more tests, Rakefile, the like)
* Add/update copyright notices in the source files
* Move a bunch of documentation out to README
* Split library into chunks
* Properly delete files when cleaning up from tests
plist-3.6.0/Dockerfile 0000664 0000000 0000000 00000000126 13773177205 0014660 0 ustar 00root root 0000000 0000000 FROM ruby:2.5.3-alpine3.8
RUN apk update && apk add git
WORKDIR /app
COPY . .
CMD sh
plist-3.6.0/Gemfile 0000664 0000000 0000000 00000000132 13773177205 0014156 0 ustar 00root root 0000000 0000000 source "https://rubygems.org"
# Specify your gem's dependencies in plist.gemspec
gemspec
plist-3.6.0/LICENSE.txt 0000664 0000000 0000000 00000002067 13773177205 0014517 0 ustar 00root root 0000000 0000000 Copyright (c) 2006-2010, Ben Bleything and Patrick May
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
plist-3.6.0/README.rdoc 0000664 0000000 0000000 00000016000 13773177205 0014472 0 ustar 00root root 0000000 0000000 = All-purpose Property List manipulation library
{
}[https://rubygems.org/gems/plist]
{
}[https://travis-ci.org/patsplat/plist]
Plist is a library to manipulate Property List files, also known as plists. It can parse plist files into native Ruby data structures as well as generating new plist files from your Ruby objects.
== Usage
=== Security considerations
Plist.parse_xml uses Marshal.load for attributes. If the attribute contains malicious data, an attacker can gain code execution.
You should never use Plist.parse_xml with untrusted plists!
=== Parsing
result = Plist.parse_xml('path/to/example.plist')
result.class
=> Hash
"#{result['FirstName']} #{result['LastName']}"
=> "John Public"
result['ZipPostal']
=> "12345"
==== Example Property List
FirstName
John
LastName
Public
StreetAddr1
123 Anywhere St.
StateProv
CA
City
Some Town
CountryName
United States
AreaCode
555
LocalPhoneNumber
5551212
ZipPostal
12345
=== Generation
plist also provides the ability to generate plists from Ruby objects. The following Ruby classes are converted into native plist types:
Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
* +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the and containers (respectively).
* +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a element.
* User classes may implement +to_plist_node+ to dictate how they should be serialized; otherwise the object will be passed to Marshal.dump and the result placed in a element. See below for more details.
==== Creating a plist
There are two ways to generate complete plists. Given an object:
obj = [1, :two, {'c' => 0xd}]
If you've mixed in Plist::Emit (which is already done for +Array+ and +Hash+), you can simply call +to_plist+:
obj.to_plist
This is equivalent to calling Plist::Emit.dump(obj). Either one will yield:
1
two
c
13
You can also dump plist fragments by passing +false+ as the second parameter:
Plist::Emit.dump('holy cow!', false)
=> "holy cow!"
==== Custom serialization
If your class can be safely coerced into a native plist datatype, you can implement +to_plist_node+. Upon encountering an object of a class it doesn't recognize, the plist library will check to see if it responds to +to_plist_node+, and if so, insert the result of that call into the plist output.
An example:
class MyFancyString
...
def to_plist_node
return "#{self.defancify}"
end
end
When you attempt to serialize a +MyFancyString+ object, the +to_plist_node+ method will be called and the object's contents will be defancified and placed in the plist.
If for whatever reason you can't add this method, your object will be serialized with Marshal.dump instead.
==== Custom indent
You can customize the default indent foramt (default format is tab) or specify the indent format on each serialization. For example, if you want to reduce size of plist output, you can set the indent to nil.
An example to change default indent format:
Plist::Emit::DEFAULT_INDENT = nil
An example to specify indent format on dump:
Plist::Emit.dump({:foo => :bar}, false)
=> "\n\tfoo\n\tbar\n\n"
Plist::Emit.dump({:foo => :bar}, false, :indent => nil)
=> "\nfoo\nbar\n\n"
== Links
[Rubygems] https://rubygems.org/gems/plist
[GitHub] https://github.com/bleything/plist
[RDoc] http://www.rubydoc.info/gems/plist
== Credits
plist was authored by Ben Bleything and Patrick May . Patrick wrote most of the code; Ben contributed his plist generation library. The project is currently maintained by @mattbrictson[https://github.com/mattbrictson].
Other folks who have helped along the way:
[Martin Dittus] who pointed out that +Time+ wasn't enough for plist Dates, especially those in ~/Library/Cookies/Cookies.plist
[Chuck Remes] who pushed Patrick towards implementing #to_plist
[Mat Schaffer] who supplied code and test cases for elements
[Michael Granger] for encouragement and help
[Carsten Bormann, Chris Hoffman, Dana Contreras, Hongli Lai, Johan Sørensen] for contributing Ruby 1.9.x compatibility fixes
And thank you to all of the other GitHub contributors[https://github.com/patsplat/plist/graphs/contributors] not mentioned here!
== License and Copyright
plist is released under the MIT License.
Portions of the code (notably the Rakefile) contain code pulled and/or adapted from other projects. These files contain a comment at the top describing what was used.
=== MIT License
Copyright (c) 2006-2010, Ben Bleything and Patrick May
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
plist-3.6.0/Rakefile 0000664 0000000 0000000 00000000306 13773177205 0014333 0 ustar 00root root 0000000 0000000 require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/test_*.rb"]
end
task :default => :test
plist-3.6.0/bin/ 0000775 0000000 0000000 00000000000 13773177205 0013437 5 ustar 00root root 0000000 0000000 plist-3.6.0/bin/console 0000775 0000000 0000000 00000000524 13773177205 0015030 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby
require "bundler/setup"
require "plist"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"
IRB.start(__FILE__)
plist-3.6.0/bin/setup 0000775 0000000 0000000 00000000203 13773177205 0014520 0 ustar 00root root 0000000 0000000 #!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx
bundle install
# Do any other automated setup that you need to do here
plist-3.6.0/docker-compose.yml 0000664 0000000 0000000 00000000107 13773177205 0016322 0 ustar 00root root 0000000 0000000 version: '3'
services:
dev:
build: .
volumes:
- .:/app
plist-3.6.0/lib/ 0000775 0000000 0000000 00000000000 13773177205 0013435 5 ustar 00root root 0000000 0000000 plist-3.6.0/lib/plist.rb 0000664 0000000 0000000 00000000561 13773177205 0015117 0 ustar 00root root 0000000 0000000 # encoding: utf-8
# = plist
#
# This is the main file for plist. Everything interesting happens in
# Plist and Plist::Emit.
#
# Copyright 2006-2010 Ben Bleything and Patrick May
# Distributed under the MIT License
#
require 'base64'
require 'cgi'
require 'stringio'
require_relative 'plist/generator'
require_relative 'plist/parser'
require_relative 'plist/version'
plist-3.6.0/lib/plist/ 0000775 0000000 0000000 00000000000 13773177205 0014570 5 ustar 00root root 0000000 0000000 plist-3.6.0/lib/plist/generator.rb 0000664 0000000 0000000 00000014054 13773177205 0017107 0 ustar 00root root 0000000 0000000 # encoding: utf-8
# = plist
#
# Copyright 2006-2010 Ben Bleything and Patrick May
# Distributed under the MIT License
#
module Plist
# === Create a plist
# You can dump an object to a plist in one of two ways:
#
# * Plist::Emit.dump(obj)
# * obj.to_plist
# * This requires that you mixin the Plist::Emit module, which is already done for +Array+ and +Hash+.
#
# The following Ruby classes are converted into native plist types:
# Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
# * +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the and containers (respectively).
# * +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a element.
# * User classes may implement +to_plist_node+ to dictate how they should be serialized; otherwise the object will be passed to Marshal.dump and the result placed in a element.
#
# For detailed usage instructions, refer to USAGE[link:files/docs/USAGE.html] and the methods documented below.
module Emit
DEFAULT_INDENT = "\t"
# Helper method for injecting into classes. Calls Plist::Emit.dump with +self+.
def to_plist(envelope = true, options = {})
Plist::Emit.dump(self, envelope, options)
end
# Helper method for injecting into classes. Calls Plist::Emit.save_plist with +self+.
def save_plist(filename, options = {})
Plist::Emit.save_plist(self, filename, options)
end
# The following Ruby classes are converted into native plist types:
# Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time
#
# Write us (via RubyForge) if you think another class can be coerced safely into one of the expected plist classes.
#
# +IO+ and +StringIO+ objects are encoded and placed in elements; other objects are Marshal.dump'ed unless they implement +to_plist_node+.
#
# The +envelope+ parameters dictates whether or not the resultant plist fragment is wrapped in the normal XML/plist header and footer. Set it to false if you only want the fragment.
def self.dump(obj, envelope = true, options = {})
options = { :indent => DEFAULT_INDENT }.merge(options)
output = PlistBuilder.new(options[:indent]).build(obj)
output = wrap(output) if envelope
output
end
# Writes the serialized object's plist to the specified filename.
def self.save_plist(obj, filename, options = {})
File.open(filename, 'wb') do |f|
f.write(obj.to_plist(true, options))
end
end
private
class PlistBuilder
def initialize(indent_str)
@indent_str = indent_str.to_s
end
def build(element, level=0)
if element.respond_to? :to_plist_node
element.to_plist_node
else
case element
when Array
if element.empty?
tag('array', nil, level)
else
tag('array', nil, level) {
element.collect {|e| build(e, level + 1) }.join
}
end
when Hash
if element.empty?
tag('dict', nil, level)
else
tag('dict', '', level) do
element.sort_by{|k,v| k.to_s }.collect do |k,v|
tag('key', CGI.escapeHTML(k.to_s), level + 1) +
build(v, level + 1)
end.join
end
end
when true, false
tag(element, nil, level)
when Time
tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ'), level)
when Date # also catches DateTime
tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ'), level)
when String, Symbol, Integer, Float
tag(element_type(element), CGI.escapeHTML(element.to_s), level)
when IO, StringIO
data = element.tap(&:rewind).read
data_tag(data, level)
else
data = Marshal.dump(element)
comment_tag('The element below contains a Ruby object which has been serialized with Marshal.dump.') +
data_tag(data, level)
end
end
end
private
def tag(type, contents, level, &block)
if block_given?
indent("<#{type}>\n", level) +
block.call +
indent("#{type}>\n", level)
elsif contents.to_s.empty?
indent("<#{type}/>\n", level)
else
indent("<#{type}>#{contents.to_s}#{type}>\n", level)
end
end
def data_tag(data, level)
# note that apple plists are wrapped at a different length then
# what ruby's base64 wraps by default.
# I used #encode64 instead of #b64encode (which allows a length arg)
# because b64encode is b0rked and ignores the length arg.
tag('data', nil, level) do
Base64.encode64(data)
.gsub(/\s+/, '')
.scan(/.{1,68}/o)
.collect { |line| indent(line, level) }
.join("\n")
.concat("\n")
end
end
def indent(str, level)
@indent_str.to_s * level + str
end
def element_type(item)
case item
when String, Symbol
'string'
when Integer
'integer'
when Float
'real'
else
raise "Don't know about this data type... something must be wrong!"
end
end
def comment_tag(content)
return "\n"
end
end
def self.wrap(contents)
output = '' + "\n"
output << '' + "\n"
output << '' + "\n"
output << contents
output << '' + "\n"
output
end
end
end
class Array #:nodoc:
include Plist::Emit
end
class Hash #:nodoc:
include Plist::Emit
end
plist-3.6.0/lib/plist/parser.rb 0000775 0000000 0000000 00000013147 13773177205 0016422 0 ustar 00root root 0000000 0000000 # encoding: utf-8
# = plist
#
# Copyright 2006-2010 Ben Bleything and Patrick May
# Distributed under the MIT License
#
# Plist parses Mac OS X xml property list files into ruby data structures.
#
# === Load a plist file
# This is the main point of the library:
#
# r = Plist.parse_xml(filename_or_xml)
module Plist
# Raised when an element is not implemented
class UnimplementedElementError < RuntimeError; end
# Note that I don't use these two elements much:
#
# + Date elements are returned as DateTime objects.
# + Data elements are implemented as Tempfiles
#
# Plist.parse_xml will blow up if it encounters a Date element.
# If you encounter such an error, or if you have a Date element which
# can't be parsed into a Time object, please create an issue
# attaching your plist file at https://github.com/patsplat/plist/issues
# so folks can implement the proper support.
def self.parse_xml(filename_or_xml)
listener = Listener.new
# parser = REXML::Parsers::StreamParser.new(File.new(filename), listener)
parser = StreamParser.new(filename_or_xml, listener)
parser.parse
listener.result
end
class Listener
# include REXML::StreamListener
attr_accessor :result, :open
def initialize
@result = nil
@open = []
end
def tag_start(name, attributes)
@open.push PTag.mappings[name].new
end
def text(contents)
if @open.last
@open.last.text ||= ''
@open.last.text.concat(contents)
end
end
def tag_end(name)
last = @open.pop
if @open.empty?
@result = last.to_ruby
else
@open.last.children.push last
end
end
end
class StreamParser
def initialize(plist_data_or_file, listener)
if plist_data_or_file.respond_to? :read
@xml = plist_data_or_file.read
elsif File.exist? plist_data_or_file
@xml = File.read(plist_data_or_file)
else
@xml = plist_data_or_file
end
@listener = listener
end
TEXT = /([^<]+)/
CDATA = //
XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/m
DOCTYPE_PATTERN = /\s*)/m
COMMENT_START = /\A/m
UNIMPLEMENTED_ERROR = 'Unimplemented element. ' \
'Consider reporting via https://github.com/patsplat/plist/issues'
def parse
plist_tags = PTag.mappings.keys.join('|')
start_tag = /<(#{plist_tags})([^>]*)>/i
end_tag = /<\/(#{plist_tags})[^>]*>/i
require 'strscan'
@scanner = StringScanner.new(@xml)
until @scanner.eos?
if @scanner.scan(COMMENT_START)
@scanner.scan(COMMENT_END)
elsif @scanner.scan(XMLDECL_PATTERN)
encoding = parse_encoding_from_xml_declaration(@scanner[1])
next if encoding.nil?
# use the specified encoding for the rest of the file
next unless String.method_defined?(:force_encoding)
@scanner.string = @scanner.rest.force_encoding(encoding)
elsif @scanner.scan(DOCTYPE_PATTERN)
next
elsif @scanner.scan(start_tag)
@listener.tag_start(@scanner[1], nil)
if (@scanner[2] =~ /\/$/)
@listener.tag_end(@scanner[1])
end
elsif @scanner.scan(TEXT)
@listener.text(@scanner[1])
elsif @scanner.scan(CDATA)
@listener.text(@scanner[1])
elsif @scanner.scan(end_tag)
@listener.tag_end(@scanner[1])
else
raise UnimplementedElementError.new(UNIMPLEMENTED_ERROR)
end
end
end
private
def parse_encoding_from_xml_declaration(xml_declaration)
return unless defined?(Encoding)
xml_encoding = xml_declaration.match(/(?:\A|\s)encoding=(?:"(.*?)"|'(.*?)')(?:\s|\Z)/)
return if xml_encoding.nil?
begin
Encoding.find(xml_encoding[1])
rescue ArgumentError
nil
end
end
end
class PTag
def self.mappings
@mappings ||= {}
end
def self.inherited(sub_class)
key = sub_class.to_s.downcase
key.gsub!(/^plist::/, '')
key.gsub!(/^p/, '') unless key == "plist"
mappings[key] = sub_class
end
attr_accessor :text, :children
def initialize
@children = []
end
def to_ruby
raise "Unimplemented: " + self.class.to_s + "#to_ruby on #{self.inspect}"
end
end
class PList < PTag
def to_ruby
children.first.to_ruby if children.first
end
end
class PDict < PTag
def to_ruby
dict = {}
key = nil
children.each do |c|
if key.nil?
key = c.to_ruby
else
dict[key] = c.to_ruby
key = nil
end
end
dict
end
end
class PKey < PTag
def to_ruby
CGI.unescapeHTML(text || '')
end
end
class PString < PTag
def to_ruby
CGI.unescapeHTML(text || '')
end
end
class PArray < PTag
def to_ruby
children.collect do |c|
c.to_ruby
end
end
end
class PInteger < PTag
def to_ruby
text.to_i
end
end
class PTrue < PTag
def to_ruby
true
end
end
class PFalse < PTag
def to_ruby
false
end
end
class PReal < PTag
def to_ruby
text.to_f
end
end
require 'date'
class PDate < PTag
def to_ruby
DateTime.parse(text)
end
end
require 'base64'
class PData < PTag
def to_ruby
data = Base64.decode64(text.gsub(/\s+/, '')) unless text.nil?
begin
return Marshal.load(data)
rescue Exception
io = StringIO.new
io.write data
io.rewind
return io
end
end
end
end
plist-3.6.0/lib/plist/version.rb 0000664 0000000 0000000 00000000077 13773177205 0016606 0 ustar 00root root 0000000 0000000 # encoding: utf-8
module Plist
VERSION = '3.6.0'.freeze
end
plist-3.6.0/plist.gemspec 0000664 0000000 0000000 00000002133 13773177205 0015366 0 ustar 00root root 0000000 0000000 # encoding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "plist/version"
Gem::Specification.new do |spec|
spec.name = "plist"
spec.version = Plist::VERSION
spec.authors = ["Ben Bleything", "Patrick May"]
spec.summary = "All-purpose Property List manipulation library"
spec.description = "Plist is a library to manipulate Property List files, "\
"also known as plists. It can parse plist files into "\
"native Ruby data structures as well as generating new "\
"plist files from your Ruby objects."
spec.homepage = "https://github.com/patsplat/plist"
spec.license = "MIT"
spec.files = %w{LICENSE.txt} + Dir.glob("lib/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
spec.require_paths = ["lib"]
spec.required_ruby_version = ">= 1.9.3"
spec.add_development_dependency "bundler", ">= 1.14"
spec.add_development_dependency "rake", "~> 10.5"
spec.add_development_dependency "test-unit", "~> 1.2"
end
plist-3.6.0/test/ 0000775 0000000 0000000 00000000000 13773177205 0013646 5 ustar 00root root 0000000 0000000 plist-3.6.0/test/assets/ 0000775 0000000 0000000 00000000000 13773177205 0015150 5 ustar 00root root 0000000 0000000 plist-3.6.0/test/assets/AlbumData.xml 0000664 0000000 0000000 00000011417 13773177205 0017530 0 ustar 00root root 0000000 0000000
Application Version
5.0.4 (263)
Archive Path
/Users/username/Pictures/iPhoto Library
List of Albums
AlbumId
999000
AlbumName
Library
KeyList
7
Master
PhotoCount
1
PlayMusic
YES
RepeatSlideShow
YES
SecondsPerSlide
3
SlideShowUseTitles
SongPath
TransitionDirection
0
TransitionName
Dissolve
TransitionSpeed
1
Album Type
Special Roll
AlbumId
999001
AlbumName
Last Roll
Filter Mode
All
Filters
Count
1
Operation
In Last
Type
Roll
KeyList
7
PhotoCount
1
PlayMusic
YES
RepeatSlideShow
YES
SecondsPerSlide
3
SlideShowUseTitles
SongPath
TransitionDirection
0
TransitionName
Dissolve
TransitionSpeed
1
Album Type
Special Month
AlbumId
999002
AlbumName
Last 12 Months
Filter Mode
All
Filters
KeyList
7
PhotoCount
1
PlayMusic
YES
RepeatSlideShow
YES
SecondsPerSlide
3
SlideShowUseTitles
SongPath
TransitionDirection
0
TransitionName
Dissolve
TransitionSpeed
1
Album Type
Regular
AlbumId
9
AlbumName
An Album
KeyList
7
PhotoCount
1
PlayMusic
YES
RepeatSlideShow
YES
SecondsPerSlide
3
SlideShowUseTitles
SongPath
TransitionDirection
0
TransitionName
Dissolve
TransitionSpeed
1
List of Keywords
List of Rolls
Album Type
Regular
AlbumId
6
AlbumName
Roll 1
KeyList
7
Parent
999000
PhotoCount
1
Major Version
2
Master Image List
7
Aspect Ratio
1
Caption
fallow_keep.png.450x450.2005-12-04
Comment
a comment
DateAsTimerInterval
158341389
ImagePath
/Users/username/Pictures/iPhoto Library/2006/01/07/fallow_keep.png.450x450.2005-12-04.jpg
MediaType
Image
MetaModDateAsTimerInterval
158341439.728129
ModDateAsTimerInterval
158341389
Rating
0
Roll
6
ThumbPath
/Users/username/Pictures/iPhoto Library/2006/01/07/Thumbs/7.jpg
Minor Version
0
plist-3.6.0/test/assets/Cookies.plist 0000664 0000000 0000000 00000004773 13773177205 0017634 0 ustar 00root root 0000000 0000000
Created
151936595.697543
Domain
.cleveland.com
Expires
2007-10-25T12:36:35Z
Name
CTC
Path
/
Value
:broadband:
Created
151778895.063041
Domain
.gamefaqs.com
Expires
2006-04-21T16:47:58Z
Name
ctk
Path
/
Value
NDM1YmJlYmU0NjZiOGYxZjc1NjgxODg0YmRkMA%3D%3D
Created
183530456
Domain
arstechnica.com
Expires
2006-10-26T13:56:36Z
Name
fontFace
Path
/
Value
1
Created
183004526
Domain
.sourceforge.net
Expires
2006-10-20T02:35:26Z
Name
FRQSTR
Path
/
Value
18829595x86799:1:1440x87033:1:1440x86799:1:1440x87248:1:1440|18829595|18829595|18829595|18829595
Created
151053128.640531
Domain
.tvguide.com
Expires
2025-10-10T07:12:17Z
Name
DMSEG
Path
/
Value
1BDF3D1CC07FC70F&D04451&434EC763&4351FD51&0&
Created
151304125.760261
Domain
.code.blogspot.com
Expires
2038-01-18T00:00:00Z
Name
__utma
Path
/
Value
11680422.1172819419.1129611326.1129611326.1129611326.1
Created
599529600
Domain
.tvguide.com
Expires
2020-01-01T00:00:00Z
Name
gfm
Path
/
Value
0
plist-3.6.0/test/assets/commented.plist 0000664 0000000 0000000 00000000366 13773177205 0020205 0 ustar 00root root 0000000 0000000
plist-3.6.0/test/assets/example_data.bin 0000664 0000000 0000000 00000000144 13773177205 0020265 0 ustar 00root root 0000000 0000000 plist-3.6.0/test/assets/example_data.jpg 0000664 0000000 0000000 00000022437 13773177205 0020306 0 ustar 00root root 0000000 0000000 JFIF Photoshop 3.0 8BIM @ICC_PROFILE 0appl mntrRGB XYZ acspAPPL -applq|yS rXYZ , gXYZ @ bXYZ T wtpt h chad | ,rTRC gTRC bTRC vcgt ndin >desc , ddscm Hmmod (cprt -XYZ g <