plist2 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3d1e3e8776e61658ce9a4df4a82bde92b902a278
4
+ data.tar.gz: 5b9a8d2852df6ee94c425659a25330392da1267e
5
+ SHA512:
6
+ metadata.gz: 85850638265697ae615cfdb0461f0f8cd7b881a6be12175fc628eaff9cabeaec85120d22fa0ac9dc41603d5ba2bb1397875820236e8cc1515af3b47ecd51fe9a
7
+ data.tar.gz: 1b369977559917f562c66ecb111f6263301c8ce8048325c5599dc662493380ecf9d5f28f97588746e41ed8953404b1d683cf2156631ae5017974b22c0bd109e7
@@ -0,0 +1,103 @@
1
+ = plist - All-purpose Property List manipulation library
2
+
3
+ === Release version 3.0.0!
4
+
5
+ 2010-02-23:
6
+ * Ruby 1.9.x compatibility!
7
+
8
+ 2010-02-16:
9
+ * excise a bunch of unnecessary @@ variables
10
+ * fix up some tests for cross-version compatibility
11
+
12
+ 2010-02-14:
13
+ * generalized cleanup:
14
+ * fix old file headers
15
+ * modernize rakefile
16
+ * clean up rdoc
17
+
18
+ 2010-01-08:
19
+ * move from RubyForge Subversion to GitHub
20
+
21
+ 2007-02-22 (r81):
22
+ * 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.
23
+
24
+ 2006-09-20 (r80):
25
+ * tweak a comment in generator.rb to make it clear that we're not using Base64.b64encode because it's broken.
26
+
27
+ === Release version 3.0.0!
28
+
29
+ 2006-09-20 (r77 - r79):
30
+ * move IndentedString inside Plist::Emit and :nodoc: it
31
+ * Tag 3.0.0! (from rev 78)
32
+
33
+ 2006-09-19 (r73 - r75):
34
+ * Really fix the rakefile this time (apparently I deleted some code that I needed...)
35
+ * alter the fix_whitespace rake task to ignore the assets directory
36
+ * cleanup whitespace
37
+
38
+ 2006-09-18 (r70 - r72):
39
+ * Update this file ;)
40
+ * Fix Rakefile
41
+ * gem install -t now works correctly
42
+ * Remove super-sekr1t rdoc staging area from rdoc publishing task
43
+
44
+ 2006-09-15 (r64 - r69):
45
+ * Change behavior of empty collection elements to match What Apple Does
46
+ * Fix some gem packaging infrastructure
47
+
48
+ 2006-09-13 (r61 - r63):
49
+ * Merge generator injection removal branch into trunk!
50
+
51
+ 2006-09-13 (r52 - r60):
52
+ * Fix indentation/newlines in generator (finally!)
53
+ * Refix indentation to be more faithful to the way Apple emits their plists
54
+ * Remove horrific regex and replace it with proper comment parsing
55
+ * Empty plists return nil when parsed
56
+ * Sort hash keys before emitting (now we can test multi-element hashes!)
57
+ * Inject #<=> into Symbol so that sorting Symbol-keyed hashes won't freak out
58
+
59
+ 2006-09-12 (r47 - r51):
60
+ * More test rejiggering
61
+ * New tests to expose some bugs
62
+
63
+ 2006-09-10 (r33 - r46):
64
+ * Update tests for new generator code
65
+ * Rejigger some tests
66
+ * 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
67
+ * Marshal.dump unrecognized objects into <data> elements
68
+ * Make the parser strip out comments and Marshal.load <data> elements if possible
69
+ * Update some rdoc
70
+
71
+ === Release version 2.1.1!
72
+
73
+ 2006-09-10 (r31 - r32):
74
+ * Added encoding / decoding for entities (&amp; etc)
75
+ * Changed parsing of <data> elements to return StringIO objects
76
+ * Fixed bug with empty <key> tags
77
+
78
+ 2006-08-24 (r25 - r30):
79
+ * Invert ownership of methods in the generator, allowing us to remove the self.extend(self)
80
+ * New branch to remove method inject from parser
81
+
82
+ 2006-08-23 (r22 - r24):
83
+ * Add rcov task to Rakefile
84
+ * Add some tests
85
+
86
+ 2006-08-20 (r9 - r21):
87
+ * Add a bunch of rdoc and rdoc infrastructure
88
+ * Add rake task to clean up errant whitespace
89
+ * Spin off a branch to remove a bunch of method injection in the generator code
90
+ * Rename some tests for clarity's sake
91
+ * Replace NARF generation code with Ben's generation code
92
+ * Update tests
93
+ * This broke indentation (will be fixed later)
94
+ * Add Plist::Emit.dump, so you can dump objects which don't include Plist::Emit, update tests to match
95
+ * Fix a bug with the method that wraps output in the plist header/footer
96
+
97
+ 2006-08-19 (r1 - r8):
98
+ * The beginnings of merging the plist project into the NARF plist library (under the plist project's name)
99
+ * fancier project infrastructure (more tests, Rakefile, the like)
100
+ * Add/update copyright notices in the source files
101
+ * Move a bunch of documentation out to README
102
+ * Split library into chunks
103
+ * Properly delete files when cleaning up from tests
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006-2010, Ben Bleything and Patrick May
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included
12
+ in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
15
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
16
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,158 @@
1
+ = All-purpose Property List manipulation library
2
+
3
+ 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.
4
+
5
+ == Usage
6
+
7
+ === Parsing
8
+
9
+ result = Plist::parse_xml('path/to/example.plist')
10
+
11
+ result.class
12
+ => Hash
13
+
14
+ "#{result['FirstName']} #{result['LastName']}"
15
+ => "John Public"
16
+
17
+ result['ZipPostal']
18
+ => "12345"
19
+
20
+ ==== Example Property List
21
+
22
+ <?xml version="1.0" encoding="UTF-8"?>
23
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
24
+ <plist version="1.0">
25
+ <dict>
26
+ <key>FirstName</key>
27
+ <string>John</string>
28
+
29
+ <key>LastName</key>
30
+ <string>Public</string>
31
+
32
+ <key>StreetAddr1</key>
33
+ <string>123 Anywhere St.</string>
34
+
35
+ <key>StateProv</key>
36
+ <string>CA</string>
37
+
38
+ <key>City</key>
39
+ <string>Some Town</string>
40
+
41
+ <key>CountryName</key>
42
+ <string>United States</string>
43
+
44
+ <key>AreaCode</key>
45
+ <string>555</string>
46
+
47
+ <key>LocalPhoneNumber</key>
48
+ <string>5551212</string>
49
+
50
+ <key>ZipPostal</key>
51
+ <string>12345</string>
52
+ </dict>
53
+ </plist>
54
+
55
+ === Generation
56
+
57
+ plist also provides the ability to generate plists from Ruby objects. The following Ruby classes are converted into native plist types:
58
+ Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
59
+
60
+ * +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the <array> and <dict> containers (respectively).
61
+ * +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a <data> element.
62
+ * User classes may implement +to_plist_node+ to dictate how they should be serialized; otherwise the object will be passed to <tt>Marshal.dump</tt> and the result placed in a <data> element. See below for more details.
63
+
64
+ ==== Creating a plist
65
+
66
+ There are two ways to generate complete plists. Given an object:
67
+
68
+ obj = [1, :two, {'c' => 0xd}]
69
+
70
+ If you've mixed in <tt>Plist::Emit</tt> (which is already done for +Array+ and +Hash+), you can simply call +to_plist+:
71
+
72
+ obj.to_plist
73
+
74
+ This is equivalent to calling <tt>Plist::Emit.dump(obj)</tt>. Either one will yield:
75
+
76
+ <?xml version="1.0" encoding="UTF-8"?>
77
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
78
+ <plist version="1.0">
79
+ <array>
80
+ <integer>1</integer>
81
+ <string>two</string>
82
+ <dict>
83
+ <key>c</key>
84
+ <integer>13</integer>
85
+ </dict>
86
+ </array>
87
+ </plist>
88
+
89
+ You can also dump plist fragments by passing +false+ as the second parameter:
90
+
91
+ Plist::Emit.dump('holy cow!', false)
92
+ => "<string>holy cow!</string>"
93
+
94
+ ==== Custom serialization
95
+
96
+ 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.
97
+
98
+ An example:
99
+
100
+ class MyFancyString
101
+ ...
102
+
103
+ def to_plist_node
104
+ return "<string>#{self.defancify}</string>"
105
+ end
106
+ end
107
+
108
+ 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.
109
+
110
+ If for whatever reason you can't add this method, your object will be serialized with <tt>Marshal.dump</tt> instead.
111
+
112
+ == Links
113
+
114
+ [Project Page] http://plist.rubyforge.org
115
+ [GitHub] http://github.com/bleything/plist
116
+ [RDoc] http://plist.rubyforge.org
117
+
118
+ == Credits
119
+
120
+ plist is maintained by Ben Bleything <mailto:ben@bleything.net> and Patrick May <mailto:patrick@hexane.org>. Patrick wrote most of the code; Ben is a recent addition to the project, having merged in his plist generation library.
121
+
122
+ Other folks who have helped along the way:
123
+
124
+ [<b>Martin Dittus</b>] who pointed out that +Time+ wasn't enough for plist <tt>Dates</tt>, especially those in <tt>~/Library/Cookies/Cookies.plist</tt>
125
+ [<b>Chuck Remes</b>] who pushed Patrick towards implementing <tt>#to_plist</tt>
126
+ [<b>Mat Schaffer</b>] who supplied code and test cases for <tt><data></tt> elements
127
+ [<b>Michael Granger</b>] for encouragement and help
128
+ [<b>Carsten Bormann, Chris Hoffman, Dana Contreras, Hongli Lai, Johan Sørensen</b>] for contributing Ruby 1.9.x compatibility fixes
129
+
130
+ == License and Copyright
131
+
132
+ plist is released under the MIT License.
133
+
134
+ 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.
135
+
136
+ === MIT License
137
+
138
+ Copyright (c) 2006-2010, Ben Bleything <ben@bleything.net> and Patrick May <patrick@hexane.org>
139
+
140
+ Permission is hereby granted, free of charge, to any person obtaining
141
+ a copy of this software and associated documentation files (the
142
+ "Software"), to deal in the Software without restriction, including
143
+ without limitation the rights to use, copy, modify, merge, publish,
144
+ distribute, sublicense, and/or sell copies of the Software, and to
145
+ permit persons to whom the Software is furnished to do so, subject to
146
+ the following conditions:
147
+
148
+ The above copyright notice and this permission notice shall be included
149
+ in all copies or substantial portions of the Software.
150
+
151
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
152
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
153
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
154
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
155
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
156
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
157
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
158
+
@@ -0,0 +1,152 @@
1
+ #
2
+ # Plist Rakefile
3
+ #
4
+ # Based heavily on Geoffrey Grosenbach's Rakefile for gruff.
5
+ # Includes whitespace-fixing task based on code from Typo.
6
+ #
7
+ # Copyright 2006-2010 Ben Bleything and Patrick May
8
+ # Distributed under the MIT License
9
+ #
10
+
11
+ require 'fileutils'
12
+ require 'rubygems'
13
+ require 'rubygems/package_task'
14
+ require 'rake'
15
+ require 'rake/testtask'
16
+ require 'rake/contrib/rubyforgepublisher'
17
+
18
+ $:.unshift(File.dirname(__FILE__) + "/lib")
19
+ require 'plist'
20
+
21
+ PKG_NAME = 'plist2'
22
+ PKG_VERSION = Plist::VERSION
23
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
24
+
25
+ RELEASE_NAME = "REL #{PKG_VERSION}"
26
+
27
+ RUBYFORGE_PROJECT = "plist"
28
+ RUBYFORGE_USER = ENV['RUBYFORGE_USER']
29
+
30
+ TEST_FILES = Dir.glob('test/test_*')
31
+ TEST_ASSETS = Dir.glob('test/assets/*')
32
+ LIB_FILES = Dir.glob('lib/**/*')
33
+ RELEASE_FILES = [ "Rakefile", "README.rdoc", "CHANGELOG", "LICENSE" ] + LIB_FILES + TEST_FILES + TEST_ASSETS
34
+
35
+ task :default => [ :test ]
36
+ # Run the unit tests
37
+ Rake::TestTask.new { |t|
38
+ t.libs << "test"
39
+ t.test_files = TEST_FILES
40
+ t.verbose = true
41
+ }
42
+
43
+ desc "Clean pkg, coverage, and rdoc; remove .bak files"
44
+ task :clean => [ :clobber_rdoc, :clobber_package, :clobber_coverage ] do
45
+ puts cmd = "find . -type f -name *.bak -delete"
46
+ `#{cmd}`
47
+ end
48
+
49
+ task :clobber_coverage do
50
+ puts cmd = "rm -rf coverage"
51
+ `#{cmd}`
52
+ end
53
+
54
+ desc "Generate coverage analysis with rcov (requires rcov to be installed)"
55
+ task :rcov => [ :clobber_coverage ] do
56
+ puts cmd = "rcov -Ilib --xrefs -T test/*.rb"
57
+ puts `#{cmd}`
58
+ end
59
+
60
+ desc "Strip trailing whitespace and fix newlines for all release files"
61
+ task :fix_whitespace => [ :clean ] do
62
+ RELEASE_FILES.reject {|i| i =~ /assets/}.each do |filename|
63
+ next if File.directory? filename
64
+
65
+ File.open(filename) do |file|
66
+ newfile = ''
67
+ needs_love = false
68
+
69
+ file.readlines.each_with_index do |line, lineno|
70
+ if line =~ /[ \t]+$/
71
+ needs_love = true
72
+ puts "#{filename}: trailing whitespace on line #{lineno}"
73
+ line.gsub!(/[ \t]*$/, '')
74
+ end
75
+
76
+ if line.chomp == line
77
+ needs_love = true
78
+ puts "#{filename}: no newline on line #{lineno}"
79
+ line << "\n"
80
+ end
81
+
82
+ newfile << line
83
+ end
84
+
85
+ if needs_love
86
+ tempname = "#{filename}.new"
87
+
88
+ File.open(tempname, 'w').write(newfile)
89
+ File.chmod(File.stat(filename).mode, tempname)
90
+
91
+ FileUtils.ln filename, "#{filename}.bak"
92
+ FileUtils.ln tempname, filename, :force => true
93
+ File.unlink(tempname)
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ desc "Copy documentation to rubyforge"
100
+ task :update_rdoc => [ :rdoc ] do
101
+ Rake::SshDirPublisher.new("#{RUBYFORGE_USER}@rubyforge.org", "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}", "rdoc").upload
102
+ end
103
+
104
+ begin
105
+ require 'rdoc/task'
106
+
107
+ # Generate the RDoc documentation
108
+ RDoc::Task.new do |rdoc|
109
+ rdoc.title = "All-purpose Property List manipulation library"
110
+ rdoc.main = "README.rdoc"
111
+
112
+ rdoc.rdoc_dir = 'rdoc'
113
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG')
114
+ rdoc.rdoc_files.include('lib/**')
115
+
116
+ rdoc.options = [
117
+ '-H', # show hash marks on method names in comments
118
+ '-N', # show line numbers
119
+ ]
120
+ end
121
+ rescue LoadError
122
+ $stderr.puts "Could not load rdoc tasks"
123
+ end
124
+
125
+ # Create compressed packages
126
+ spec = Gem::Specification.new do |s|
127
+ s.name = PKG_NAME
128
+ s.version = PKG_VERSION
129
+
130
+ s.summary = "All-purpose Property List manipulation library. Fork from the original until some stuff is merged."
131
+ s.description = <<-EOD
132
+ 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.
133
+ EOD
134
+
135
+ s.authors = "Ben Bleything and Patrick May"
136
+ s.homepage = "http://plist.rubyforge.org"
137
+
138
+ s.rubyforge_project = RUBYFORGE_PROJECT
139
+
140
+ s.has_rdoc = true
141
+
142
+ s.files = RELEASE_FILES
143
+ s.test_files = TEST_FILES
144
+
145
+ s.autorequire = 'plist'
146
+ end
147
+
148
+ Gem::PackageTask.new(spec) do |p|
149
+ p.gem_spec = spec
150
+ p.need_tar = true
151
+ p.need_zip = true
152
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # = plist
4
+ #
5
+ # This is the main file for plist. Everything interesting happens in
6
+ # Plist and Plist::Emit.
7
+ #
8
+ # Copyright 2006-2010 Ben Bleything and Patrick May
9
+ # Distributed under the MIT License
10
+ #
11
+
12
+ require 'base64'
13
+ require 'cgi'
14
+ require 'stringio'
15
+
16
+ require 'plist/generator'
17
+ require 'plist/parser'
18
+
19
+ module Plist
20
+ VERSION = '3.1.0'
21
+ end