plist 3.3.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6419e8cb1fbfdc4d07ec54cf7ca8e2baf6ed33af
4
- data.tar.gz: a4c8aa0a95cc0ad9bf25b724963ca8493543a015
2
+ SHA256:
3
+ metadata.gz: 34fa4fc386b9fb97f4e27a345e5a15fcae275edba2e2c92285ef04ffb25ee2b8
4
+ data.tar.gz: a0a416e828b8232c07fe1b817929b55697c2234856d2a2801123e3df9cc6bb17
5
5
  SHA512:
6
- metadata.gz: 973b6bed1abafcffd88e4e51bfa8c304ce38b37a60f9d1424e68360ccdb7b749368f13c645fe5827ca63c11396aa45b6f980b8ff2dac56123a86202ad50c00bf
7
- data.tar.gz: 623bd3fca1591131ca3cd8d0dc6a683b444f63ed9aec50a3dc257408de93c3686b45ef4484b34fa43d04d9ca118799b0d7af84734e4cc8fa751abd1ca8de24bb
6
+ metadata.gz: e0742f71c11f859b4b104b0e3f2bf8896b736397fbfe54eef20b72439a582448af160649c205507b66aa87c506d216745f794b73fe8aa77c3e7f576289b68c88
7
+ data.tar.gz: c413bc34bdfb8edd54377bb7fb9210ccfa81992b98acb131499582785aec7b7764c1463eacfdb6768bfe3d70d1bde213045b08182a6ed60b8f44b2ee18ef9974
@@ -6,210 +6,168 @@
6
6
  # Distributed under the MIT License
7
7
  #
8
8
 
9
- module Plist; end
10
-
11
- # === Create a plist
12
- # You can dump an object to a plist in one of two ways:
13
- #
14
- # * <tt>Plist::Emit.dump(obj)</tt>
15
- # * <tt>obj.to_plist</tt>
16
- # * This requires that you mixin the <tt>Plist::Emit</tt> module, which is already done for +Array+ and +Hash+.
17
- #
18
- # The following Ruby classes are converted into native plist types:
19
- # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
20
- # * +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the <array> and <dict> containers (respectively).
21
- # * +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a <data> element.
22
- # * 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.
23
- #
24
- # For detailed usage instructions, refer to USAGE[link:files/docs/USAGE.html] and the methods documented below.
25
- module Plist::Emit
26
- # Helper method for injecting into classes. Calls <tt>Plist::Emit.dump</tt> with +self+.
27
- def to_plist(envelope = true)
28
- return Plist::Emit.dump(self, envelope)
29
- end
30
-
31
- # Helper method for injecting into classes. Calls <tt>Plist::Emit.save_plist</tt> with +self+.
32
- def save_plist(filename)
33
- Plist::Emit.save_plist(self, filename)
34
- end
35
-
36
- # The following Ruby classes are converted into native plist types:
37
- # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time
9
+ module Plist
10
+ # === Create a plist
11
+ # You can dump an object to a plist in one of two ways:
38
12
  #
39
- # Write us (via RubyForge) if you think another class can be coerced safely into one of the expected plist classes.
13
+ # * <tt>Plist::Emit.dump(obj)</tt>
14
+ # * <tt>obj.to_plist</tt>
15
+ # * This requires that you mixin the <tt>Plist::Emit</tt> module, which is already done for +Array+ and +Hash+.
40
16
  #
41
- # +IO+ and +StringIO+ objects are encoded and placed in <data> elements; other objects are <tt>Marshal.dump</tt>'ed unless they implement +to_plist_node+.
17
+ # The following Ruby classes are converted into native plist types:
18
+ # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
19
+ # * +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the <array> and <dict> containers (respectively).
20
+ # * +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a <data> element.
21
+ # * 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.
42
22
  #
43
- # 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.
44
- def self.dump(obj, envelope = true)
45
- output = plist_node(obj)
23
+ # For detailed usage instructions, refer to USAGE[link:files/docs/USAGE.html] and the methods documented below.
24
+ module Emit
25
+ DEFAULT_INDENT = "\t"
46
26
 
47
- output = wrap(output) if envelope
27
+ # Helper method for injecting into classes. Calls <tt>Plist::Emit.dump</tt> with +self+.
28
+ def to_plist(envelope = true, options = {})
29
+ Plist::Emit.dump(self, envelope, options)
30
+ end
48
31
 
49
- return output
50
- end
32
+ # Helper method for injecting into classes. Calls <tt>Plist::Emit.save_plist</tt> with +self+.
33
+ def save_plist(filename, options = {})
34
+ Plist::Emit.save_plist(self, filename, options)
35
+ end
51
36
 
52
- # Writes the serialized object's plist to the specified filename.
53
- def self.save_plist(obj, filename)
54
- File.open(filename, 'wb') do |f|
55
- f.write(obj.to_plist)
37
+ # The following Ruby classes are converted into native plist types:
38
+ # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time
39
+ #
40
+ # Write us (via RubyForge) if you think another class can be coerced safely into one of the expected plist classes.
41
+ #
42
+ # +IO+ and +StringIO+ objects are encoded and placed in <data> elements; other objects are <tt>Marshal.dump</tt>'ed unless they implement +to_plist_node+.
43
+ #
44
+ # 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.
45
+ def self.dump(obj, envelope = true, options = {})
46
+ options = { :indent => DEFAULT_INDENT }.merge(options)
47
+
48
+ output = PlistBuilder.new(options[:indent]).build(obj)
49
+ output = wrap(output) if envelope
50
+
51
+ output
52
+ end
53
+
54
+ # Writes the serialized object's plist to the specified filename.
55
+ def self.save_plist(obj, filename, options = {})
56
+ File.open(filename, 'wb') do |f|
57
+ f.write(obj.to_plist(true, options))
58
+ end
56
59
  end
57
- end
58
60
 
59
- private
60
- def self.plist_node(element)
61
- output = ''
62
-
63
- if element.respond_to? :to_plist_node
64
- output << element.to_plist_node
65
- else
66
- case element
67
- when Array
68
- if element.empty?
69
- output << "<array/>\n"
61
+ private
62
+
63
+ class PlistBuilder
64
+ def initialize(indent_str)
65
+ @indent_str = indent_str.to_s
66
+ end
67
+
68
+ def build(element, level=0)
69
+ if element.respond_to? :to_plist_node
70
+ element.to_plist_node
70
71
  else
71
- output << tag('array') {
72
- element.collect {|e| plist_node(e)}
73
- }
72
+ case element
73
+ when Array
74
+ if element.empty?
75
+ tag('array', nil, level)
76
+ else
77
+ tag('array', nil, level) {
78
+ element.collect {|e| build(e, level + 1) }.join
79
+ }
80
+ end
81
+ when Hash
82
+ if element.empty?
83
+ tag('dict', nil, level)
84
+ else
85
+ tag('dict', '', level) do
86
+ element.sort_by{|k,v| k.to_s }.collect do |k,v|
87
+ tag('key', CGI.escapeHTML(k.to_s), level + 1) +
88
+ build(v, level + 1)
89
+ end.join
90
+ end
91
+ end
92
+ when true, false
93
+ tag(element, nil, level)
94
+ when Time
95
+ tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ'), level)
96
+ when Date # also catches DateTime
97
+ tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ'), level)
98
+ when String, Symbol, Integer, Float
99
+ tag(element_type(element), CGI.escapeHTML(element.to_s), level)
100
+ when IO, StringIO
101
+ data = element.tap(&:rewind).read
102
+ data_tag(data, level)
103
+ else
104
+ data = Marshal.dump(element)
105
+ comment_tag('The <data> element below contains a Ruby object which has been serialized with Marshal.dump.') +
106
+ data_tag(data, level)
107
+ end
74
108
  end
75
- when Hash
76
- if element.empty?
77
- output << "<dict/>\n"
78
- else
79
- inner_tags = []
109
+ end
80
110
 
81
- element.keys.sort_by{|k| k.to_s }.each do |k|
82
- v = element[k]
83
- inner_tags << tag('key', CGI::escapeHTML(k.to_s))
84
- inner_tags << plist_node(v)
85
- end
111
+ private
86
112
 
87
- output << tag('dict') {
88
- inner_tags
89
- }
113
+ def tag(type, contents, level, &block)
114
+ if block_given?
115
+ indent("<#{type}>\n", level) +
116
+ block.call +
117
+ indent("</#{type}>\n", level)
118
+ elsif contents.to_s.empty?
119
+ indent("<#{type}/>\n", level)
120
+ else
121
+ indent("<#{type}>#{contents.to_s}</#{type}>\n", level)
90
122
  end
91
- when true, false
92
- output << "<#{element}/>\n"
93
- when Time
94
- output << tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ'))
95
- when Date # also catches DateTime
96
- output << tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ'))
97
- when String, Symbol, Integer, Float
98
- output << tag(element_type(element), CGI::escapeHTML(element.to_s))
99
- when IO, StringIO
100
- element.rewind
101
- contents = element.read
123
+ end
124
+
125
+ def data_tag(data, level)
102
126
  # note that apple plists are wrapped at a different length then
103
127
  # what ruby's base64 wraps by default.
104
128
  # I used #encode64 instead of #b64encode (which allows a length arg)
105
129
  # because b64encode is b0rked and ignores the length arg.
106
- data = "\n"
107
- Base64::encode64(contents).gsub(/\s+/, '').scan(/.{1,68}/o) { data << $& << "\n" }
108
- output << tag('data', data)
109
- else
110
- output << comment( 'The <data> element below contains a Ruby object which has been serialized with Marshal.dump.' )
111
- data = "\n"
112
- Base64::encode64(Marshal.dump(element)).gsub(/\s+/, '').scan(/.{1,68}/o) { data << $& << "\n" }
113
- output << tag('data', data )
130
+ tag('data', nil, level) do
131
+ Base64.encode64(data)
132
+ .gsub(/\s+/, '')
133
+ .scan(/.{1,68}/o)
134
+ .collect { |line| indent(line, level) }
135
+ .join("\n")
136
+ .concat("\n")
137
+ end
114
138
  end
115
- end
116
-
117
- return output
118
- end
119
-
120
- def self.comment(content)
121
- return "<!-- #{content} -->\n"
122
- end
123
139
 
124
- def self.tag(type, contents = '', &block)
125
- out = nil
126
-
127
- if block_given?
128
- out = IndentedString.new
129
- out << "<#{type}>"
130
- out.raise_indent
131
-
132
- out << block.call
133
-
134
- out.lower_indent
135
- out << "</#{type}>"
136
- else
137
- out = "<#{type}>#{contents.to_s}</#{type}>\n"
138
- end
139
-
140
- return out.to_s
141
- end
142
-
143
- def self.wrap(contents)
144
- output = ''
145
-
146
- output << '<?xml version="1.0" encoding="UTF-8"?>' + "\n"
147
- output << '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' + "\n"
148
- output << '<plist version="1.0">' + "\n"
149
-
150
- output << contents
151
-
152
- output << '</plist>' + "\n"
153
-
154
- return output
155
- end
156
-
157
- def self.element_type(item)
158
- case item
159
- when String, Symbol
160
- 'string'
161
-
162
- when Integer
163
- 'integer'
164
-
165
- when Float
166
- 'real'
167
-
168
- else
169
- raise "Don't know about this data type... something must be wrong!"
170
- end
171
- end
172
- private
173
- class IndentedString #:nodoc:
174
- attr_accessor :indent_string
175
-
176
- def initialize(str = "\t")
177
- @indent_string = str
178
- @contents = ''
179
- @indent_level = 0
180
- end
181
-
182
- def to_s
183
- return @contents
184
- end
185
-
186
- def raise_indent
187
- @indent_level += 1
188
- end
189
-
190
- def lower_indent
191
- @indent_level -= 1 if @indent_level > 0
192
- end
193
-
194
- def <<(val)
195
- if val.is_a? Array
196
- val.each do |f|
197
- self << f
198
- end
199
- else
200
- # if it's already indented, don't bother indenting further
201
- unless val =~ /\A#{@indent_string}/
202
- indent = @indent_string * @indent_level
140
+ def indent(str, level)
141
+ @indent_str.to_s * level + str
142
+ end
203
143
 
204
- @contents << val.gsub(/^/, indent)
144
+ def element_type(item)
145
+ case item
146
+ when String, Symbol
147
+ 'string'
148
+ when Integer
149
+ 'integer'
150
+ when Float
151
+ 'real'
205
152
  else
206
- @contents << val
153
+ raise "Don't know about this data type... something must be wrong!"
207
154
  end
155
+ end
208
156
 
209
- # it already has a newline, don't add another
210
- @contents << "\n" unless val =~ /\n$/
157
+ def comment_tag(content)
158
+ return "<!-- #{content} -->\n"
211
159
  end
212
160
  end
161
+
162
+ def self.wrap(contents)
163
+ output = '<?xml version="1.0" encoding="UTF-8"?>' + "\n"
164
+ output << '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' + "\n"
165
+ output << '<plist version="1.0">' + "\n"
166
+ output << contents
167
+ output << '</plist>' + "\n"
168
+
169
+ output
170
+ end
213
171
  end
214
172
  end
215
173
 
data/lib/plist/parser.rb CHANGED
@@ -11,42 +11,54 @@
11
11
  # === Load a plist file
12
12
  # This is the main point of the library:
13
13
  #
14
- # r = Plist::parse_xml( filename_or_xml )
14
+ # r = Plist.parse_xml(filename_or_xml)
15
15
  module Plist
16
- # Note that I don't use these two elements much:
17
- #
18
- # + Date elements are returned as DateTime objects.
19
- # + Data elements are implemented as Tempfiles
20
- #
21
- # Plist::parse_xml will blow up if it encounters a Date element.
22
- # If you encounter such an error, or if you have a Date element which
23
- # can't be parsed into a Time object, please send your plist file to
24
- # plist@hexane.org so that I can implement the proper support.
25
- def Plist::parse_xml( filename_or_xml )
26
- listener = Listener.new
27
- #parser = REXML::Parsers::StreamParser.new(File.new(filename), listener)
16
+ # Raised when an element is not implemented
17
+ class UnimplementedElementError < RuntimeError; end
18
+
19
+ # Note that I don't use these two elements much:
20
+ #
21
+ # + Date elements are returned as DateTime objects.
22
+ # + Data elements are implemented as Tempfiles
23
+ #
24
+ # Plist.parse_xml will blow up if it encounters a Date element.
25
+ # If you encounter such an error, or if you have a Date element which
26
+ # can't be parsed into a Time object, please create an issue
27
+ # attaching your plist file at https://github.com/patsplat/plist/issues
28
+ # so folks can implement the proper support.
29
+ #
30
+ # By default, <data> will be assumed to be a marshaled Ruby object and
31
+ # interpreted with <tt>Marshal.load</tt>. Pass <tt>marshal: false</tt>
32
+ # to disable this behavior and return the raw binary data as an IO
33
+ # object instead.
34
+ def self.parse_xml(filename_or_xml, options={})
35
+ listener = Listener.new(options)
36
+ # parser = REXML::Parsers::StreamParser.new(File.new(filename), listener)
28
37
  parser = StreamParser.new(filename_or_xml, listener)
29
38
  parser.parse
30
39
  listener.result
31
40
  end
32
41
 
33
42
  class Listener
34
- #include REXML::StreamListener
43
+ # include REXML::StreamListener
35
44
 
36
45
  attr_accessor :result, :open
37
46
 
38
- def initialize
47
+ def initialize(options={})
39
48
  @result = nil
40
- @open = Array.new
49
+ @open = []
50
+ @options = { :marshal => true }.merge(options).freeze
41
51
  end
42
52
 
43
-
44
53
  def tag_start(name, attributes)
45
- @open.push PTag::mappings[name].new
54
+ @open.push PTag.mappings[name].new(@options)
46
55
  end
47
56
 
48
- def text( contents )
49
- @open.last.text = contents if @open.last
57
+ def text(contents)
58
+ if @open.last
59
+ @open.last.text ||= ''
60
+ @open.last.text.concat(contents)
61
+ end
50
62
  end
51
63
 
52
64
  def tag_end(name)
@@ -60,11 +72,11 @@ module Plist
60
72
  end
61
73
 
62
74
  class StreamParser
63
- def initialize( plist_data_or_file, listener )
75
+ def initialize(plist_data_or_file, listener)
64
76
  if plist_data_or_file.respond_to? :read
65
77
  @xml = plist_data_or_file.read
66
78
  elsif File.exist? plist_data_or_file
67
- @xml = File.read( plist_data_or_file )
79
+ @xml = File.read(plist_data_or_file)
68
80
  else
69
81
  @xml = plist_data_or_file
70
82
  end
@@ -72,21 +84,23 @@ module Plist
72
84
  @listener = listener
73
85
  end
74
86
 
75
- TEXT = /([^<]+)/
87
+ TEXT = /([^<]+)/
88
+ CDATA = /<!\[CDATA\[(.*?)\]\]>/
76
89
  XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/m
77
90
  DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/m
78
91
  COMMENT_START = /\A<!--/
79
92
  COMMENT_END = /.*?-->/m
80
-
93
+ UNIMPLEMENTED_ERROR = 'Unimplemented element. ' \
94
+ 'Consider reporting via https://github.com/patsplat/plist/issues'
81
95
 
82
96
  def parse
83
- plist_tags = PTag::mappings.keys.join('|')
97
+ plist_tags = PTag.mappings.keys.join('|')
84
98
  start_tag = /<(#{plist_tags})([^>]*)>/i
85
99
  end_tag = /<\/(#{plist_tags})[^>]*>/i
86
100
 
87
101
  require 'strscan'
88
102
 
89
- @scanner = StringScanner.new( @xml )
103
+ @scanner = StringScanner.new(@xml)
90
104
  until @scanner.eos?
91
105
  if @scanner.scan(COMMENT_START)
92
106
  @scanner.scan(COMMENT_END)
@@ -106,10 +120,12 @@ module Plist
106
120
  end
107
121
  elsif @scanner.scan(TEXT)
108
122
  @listener.text(@scanner[1])
123
+ elsif @scanner.scan(CDATA)
124
+ @listener.text(@scanner[1])
109
125
  elsif @scanner.scan(end_tag)
110
126
  @listener.tag_end(@scanner[1])
111
127
  else
112
- raise "Unimplemented element"
128
+ raise UnimplementedElementError.new(UNIMPLEMENTED_ERROR)
113
129
  end
114
130
  end
115
131
  end
@@ -132,22 +148,22 @@ module Plist
132
148
  end
133
149
 
134
150
  class PTag
135
- @@mappings = { }
136
- def PTag::mappings
137
- @@mappings
151
+ def self.mappings
152
+ @mappings ||= {}
138
153
  end
139
154
 
140
- def PTag::inherited( sub_class )
155
+ def self.inherited(sub_class)
141
156
  key = sub_class.to_s.downcase
142
- key.gsub!(/^plist::/, '' )
157
+ key.gsub!(/^plist::/, '')
143
158
  key.gsub!(/^p/, '') unless key == "plist"
144
159
 
145
- @@mappings[key] = sub_class
160
+ mappings[key] = sub_class
146
161
  end
147
162
 
148
- attr_accessor :text, :children
149
- def initialize
150
- @children = Array.new
163
+ attr_accessor :text, :children, :options
164
+ def initialize(options)
165
+ @children = []
166
+ @options = options
151
167
  end
152
168
 
153
169
  def to_ruby
@@ -163,7 +179,7 @@ module Plist
163
179
 
164
180
  class PDict < PTag
165
181
  def to_ruby
166
- dict = Hash.new
182
+ dict = {}
167
183
  key = nil
168
184
 
169
185
  children.each do |c|
@@ -181,13 +197,13 @@ module Plist
181
197
 
182
198
  class PKey < PTag
183
199
  def to_ruby
184
- CGI::unescapeHTML(text || '')
200
+ CGI.unescapeHTML(text || '')
185
201
  end
186
202
  end
187
203
 
188
204
  class PString < PTag
189
205
  def to_ruby
190
- CGI::unescapeHTML(text || '')
206
+ CGI.unescapeHTML(text || '')
191
207
  end
192
208
  end
193
209
 
@@ -235,13 +251,13 @@ module Plist
235
251
  def to_ruby
236
252
  data = Base64.decode64(text.gsub(/\s+/, '')) unless text.nil?
237
253
  begin
238
- return Marshal.load(data)
254
+ return Marshal.load(data) if options[:marshal]
239
255
  rescue Exception
240
- io = StringIO.new
241
- io.write data
242
- io.rewind
243
- return io
244
256
  end
257
+ io = StringIO.new
258
+ io.write data
259
+ io.rewind
260
+ io
245
261
  end
246
262
  end
247
263
  end
data/lib/plist/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Plist
4
- VERSION = '3.3.0'.freeze
4
+ VERSION = '3.7.0'.freeze
5
5
  end
data/lib/plist.rb CHANGED
@@ -13,9 +13,6 @@ require 'base64'
13
13
  require 'cgi'
14
14
  require 'stringio'
15
15
 
16
- require 'plist/generator'
17
- require 'plist/parser'
18
- require 'plist/version'
19
-
20
- module Plist
21
- end
16
+ require_relative 'plist/generator'
17
+ require_relative 'plist/parser'
18
+ require_relative 'plist/version'
metadata CHANGED
@@ -1,85 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plist
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Bleything
8
8
  - Patrick May
9
- autorequire:
10
- bindir: exe
9
+ autorequire:
10
+ bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-28 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: bundler
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '1.14'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '1.14'
28
- - !ruby/object:Gem::Dependency
29
- name: rake
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '10.5'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '10.5'
42
- - !ruby/object:Gem::Dependency
43
- name: test-unit
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '1.2'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '1.2'
12
+ date: 2023-02-21 00:00:00.000000000 Z
13
+ dependencies: []
56
14
  description: Plist is a library to manipulate Property List files, also known as plists.
57
15
  It can parse plist files into native Ruby data structures as well as generating
58
16
  new plist files from your Ruby objects.
59
- email:
17
+ email:
60
18
  executables: []
61
19
  extensions: []
62
20
  extra_rdoc_files: []
63
21
  files:
64
- - ".gitignore"
65
- - ".travis.yml"
66
- - CHANGELOG.rdoc
67
- - Gemfile
68
22
  - LICENSE.txt
69
- - README.rdoc
70
- - Rakefile
71
- - bin/console
72
- - bin/setup
73
23
  - lib/plist.rb
74
24
  - lib/plist/generator.rb
75
25
  - lib/plist/parser.rb
76
26
  - lib/plist/version.rb
77
- - plist.gemspec
78
27
  homepage: https://github.com/patsplat/plist
79
28
  licenses:
80
29
  - MIT
81
30
  metadata: {}
82
- post_install_message:
31
+ post_install_message:
83
32
  rdoc_options: []
84
33
  require_paths:
85
34
  - lib
@@ -87,16 +36,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
36
  requirements:
88
37
  - - ">="
89
38
  - !ruby/object:Gem::Version
90
- version: '0'
39
+ version: 1.9.3
91
40
  required_rubygems_version: !ruby/object:Gem::Requirement
92
41
  requirements:
93
42
  - - ">="
94
43
  - !ruby/object:Gem::Version
95
44
  version: '0'
96
45
  requirements: []
97
- rubyforge_project:
98
- rubygems_version: 2.6.11
99
- signing_key:
46
+ rubygems_version: 3.4.7
47
+ signing_key:
100
48
  specification_version: 4
101
49
  summary: All-purpose Property List manipulation library
102
50
  test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - ree
5
- - jruby-18mode
6
- - 1.8.7
7
- - jruby-19mode
8
- - 1.9.3
9
- - 2.0.0-p648 # macOS
10
- - 2.1.10
11
- - 2.2.7
12
- - 2.3.4
13
- - 2.4.1
14
- - ruby-head
15
- - jruby-head
16
- before_install: gem install bundler -v '~> 1.14' --conservative
data/CHANGELOG.rdoc DELETED
@@ -1,127 +0,0 @@
1
- = plist - All-purpose Property List manipulation library
2
-
3
- === Unreleased
4
-
5
- https://github.com/patsplat/plist/compare/v3.3.0...HEAD
6
-
7
- * Your contribution here!
8
-
9
- === 3.3.0 (2017-04-28)
10
-
11
- https://github.com/patsplat/plist/compare/dece870...v3.3.0
12
-
13
- * Fix ASCII/UTF-8 error (https://github.com/patsplat/plist/pull/38).
14
- * Fix Fixnum, Bignum deprecations in Ruby 2.4
15
- * Fix unused variable `e` warning
16
-
17
- === 3.2.0 (2016-01-28)
18
-
19
- https://github.com/patsplat/plist/compare/ea0b4e7...dece870
20
-
21
- * Changed sort to sort_by in Plist::Emit.plist_node to allow mixed symbol and string hash keys
22
- * Updated deprecated File.exists? to File.exist?
23
- * Fixed defect in PData in which exception was thrown when <data/> element was read from plist
24
-
25
- === 3.1.0 (2010-02-23)
26
-
27
- 2010-02-23:
28
- * Ruby 1.9.x compatibility!
29
-
30
- 2010-02-16:
31
- * excise a bunch of unnecessary @@ variables
32
- * fix up some tests for cross-version compatibility
33
-
34
- 2010-02-14:
35
- * generalized cleanup:
36
- * fix old file headers
37
- * modernize rakefile
38
- * clean up rdoc
39
-
40
- 2010-01-08:
41
- * move from RubyForge Subversion to GitHub
42
-
43
- 2007-02-22 (r81):
44
- * 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.
45
-
46
- 2006-09-20 (r80):
47
- * tweak a comment in generator.rb to make it clear that we're not using Base64.b64encode because it's broken.
48
-
49
- === 3.0.0 (2006-09-20)
50
-
51
- 2006-09-20 (r77 - r79):
52
- * move IndentedString inside Plist::Emit and :nodoc: it
53
- * Tag 3.0.0! (from rev 78)
54
-
55
- 2006-09-19 (r73 - r75):
56
- * Really fix the rakefile this time (apparently I deleted some code that I needed...)
57
- * alter the fix_whitespace rake task to ignore the assets directory
58
- * cleanup whitespace
59
-
60
- 2006-09-18 (r70 - r72):
61
- * Update this file ;)
62
- * Fix Rakefile
63
- * gem install -t now works correctly
64
- * Remove super-sekr1t rdoc staging area from rdoc publishing task
65
-
66
- 2006-09-15 (r64 - r69):
67
- * Change behavior of empty collection elements to match What Apple Does
68
- * Fix some gem packaging infrastructure
69
-
70
- 2006-09-13 (r61 - r63):
71
- * Merge generator injection removal branch into trunk!
72
-
73
- 2006-09-13 (r52 - r60):
74
- * Fix indentation/newlines in generator (finally!)
75
- * Refix indentation to be more faithful to the way Apple emits their plists
76
- * Remove horrific regex and replace it with proper comment parsing
77
- * Empty plists return nil when parsed
78
- * Sort hash keys before emitting (now we can test multi-element hashes!)
79
- * Inject #<=> into Symbol so that sorting Symbol-keyed hashes won't freak out
80
-
81
- === 2.1.2 (2006-09-20)
82
-
83
- 2006-09-12 (r47 - r51):
84
- * More test rejiggering
85
- * New tests to expose some bugs
86
-
87
- 2006-09-10 (r33 - r46):
88
- * Update tests for new generator code
89
- * Rejigger some tests
90
- * 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
91
- * Marshal.dump unrecognized objects into <data> elements
92
- * Make the parser strip out comments and Marshal.load <data> elements if possible
93
- * Update some rdoc
94
-
95
- === 2.1.1 (2006-09-10)
96
-
97
- 2006-09-10 (r31 - r32):
98
- * Added encoding / decoding for entities (&amp; etc)
99
- * Changed parsing of <data> elements to return StringIO objects
100
- * Fixed bug with empty <key> tags
101
-
102
- 2006-08-24 (r25 - r30):
103
- * Invert ownership of methods in the generator, allowing us to remove the self.extend(self)
104
- * New branch to remove method inject from parser
105
-
106
- 2006-08-23 (r22 - r24):
107
- * Add rcov task to Rakefile
108
- * Add some tests
109
-
110
- 2006-08-20 (r9 - r21):
111
- * Add a bunch of rdoc and rdoc infrastructure
112
- * Add rake task to clean up errant whitespace
113
- * Spin off a branch to remove a bunch of method injection in the generator code
114
- * Rename some tests for clarity's sake
115
- * Replace NARF generation code with Ben's generation code
116
- * Update tests
117
- * This broke indentation (will be fixed later)
118
- * Add Plist::Emit.dump, so you can dump objects which don't include Plist::Emit, update tests to match
119
- * Fix a bug with the method that wraps output in the plist header/footer
120
-
121
- 2006-08-19 (r1 - r8):
122
- * The beginnings of merging the plist project into the NARF plist library (under the plist project's name)
123
- * fancier project infrastructure (more tests, Rakefile, the like)
124
- * Add/update copyright notices in the source files
125
- * Move a bunch of documentation out to README
126
- * Split library into chunks
127
- * Properly delete files when cleaning up from tests
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in plist.gemspec
4
- gemspec
data/README.rdoc DELETED
@@ -1,161 +0,0 @@
1
- = All-purpose Property List manipulation library
2
-
3
- {<img src="https://badge.fury.io/rb/plist.svg" alt="Gem Version" />}[https://rubygems.org/gems/plist]
4
- {<img src="https://travis-ci.org/patsplat/plist.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/patsplat/plist]
5
-
6
- 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.
7
-
8
- == Usage
9
-
10
- === Parsing
11
-
12
- result = Plist::parse_xml('path/to/example.plist')
13
-
14
- result.class
15
- => Hash
16
-
17
- "#{result['FirstName']} #{result['LastName']}"
18
- => "John Public"
19
-
20
- result['ZipPostal']
21
- => "12345"
22
-
23
- ==== Example Property List
24
-
25
- <?xml version="1.0" encoding="UTF-8"?>
26
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
27
- <plist version="1.0">
28
- <dict>
29
- <key>FirstName</key>
30
- <string>John</string>
31
-
32
- <key>LastName</key>
33
- <string>Public</string>
34
-
35
- <key>StreetAddr1</key>
36
- <string>123 Anywhere St.</string>
37
-
38
- <key>StateProv</key>
39
- <string>CA</string>
40
-
41
- <key>City</key>
42
- <string>Some Town</string>
43
-
44
- <key>CountryName</key>
45
- <string>United States</string>
46
-
47
- <key>AreaCode</key>
48
- <string>555</string>
49
-
50
- <key>LocalPhoneNumber</key>
51
- <string>5551212</string>
52
-
53
- <key>ZipPostal</key>
54
- <string>12345</string>
55
- </dict>
56
- </plist>
57
-
58
- === Generation
59
-
60
- plist also provides the ability to generate plists from Ruby objects. The following Ruby classes are converted into native plist types:
61
- Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
62
-
63
- * +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the <array> and <dict> containers (respectively).
64
- * +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a <data> element.
65
- * 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.
66
-
67
- ==== Creating a plist
68
-
69
- There are two ways to generate complete plists. Given an object:
70
-
71
- obj = [1, :two, {'c' => 0xd}]
72
-
73
- If you've mixed in <tt>Plist::Emit</tt> (which is already done for +Array+ and +Hash+), you can simply call +to_plist+:
74
-
75
- obj.to_plist
76
-
77
- This is equivalent to calling <tt>Plist::Emit.dump(obj)</tt>. Either one will yield:
78
-
79
- <?xml version="1.0" encoding="UTF-8"?>
80
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
81
- <plist version="1.0">
82
- <array>
83
- <integer>1</integer>
84
- <string>two</string>
85
- <dict>
86
- <key>c</key>
87
- <integer>13</integer>
88
- </dict>
89
- </array>
90
- </plist>
91
-
92
- You can also dump plist fragments by passing +false+ as the second parameter:
93
-
94
- Plist::Emit.dump('holy cow!', false)
95
- => "<string>holy cow!</string>"
96
-
97
- ==== Custom serialization
98
-
99
- 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.
100
-
101
- An example:
102
-
103
- class MyFancyString
104
- ...
105
-
106
- def to_plist_node
107
- return "<string>#{self.defancify}</string>"
108
- end
109
- end
110
-
111
- 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.
112
-
113
- If for whatever reason you can't add this method, your object will be serialized with <tt>Marshal.dump</tt> instead.
114
-
115
- == Links
116
-
117
- [Project Page] http://plist.rubyforge.org
118
- [GitHub] http://github.com/bleything/plist
119
- [RDoc] http://plist.rubyforge.org
120
-
121
- == Credits
122
-
123
- 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.
124
-
125
- Other folks who have helped along the way:
126
-
127
- [<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>
128
- [<b>Chuck Remes</b>] who pushed Patrick towards implementing <tt>#to_plist</tt>
129
- [<b>Mat Schaffer</b>] who supplied code and test cases for <tt><data></tt> elements
130
- [<b>Michael Granger</b>] for encouragement and help
131
- [<b>Carsten Bormann, Chris Hoffman, Dana Contreras, Hongli Lai, Johan Sørensen</b>] for contributing Ruby 1.9.x compatibility fixes
132
-
133
- == License and Copyright
134
-
135
- plist is released under the MIT License.
136
-
137
- 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.
138
-
139
- === MIT License
140
-
141
- Copyright (c) 2006-2010, Ben Bleything <ben@bleything.net> and Patrick May <patrick@hexane.org>
142
-
143
- Permission is hereby granted, free of charge, to any person obtaining
144
- a copy of this software and associated documentation files (the
145
- "Software"), to deal in the Software without restriction, including
146
- without limitation the rights to use, copy, modify, merge, publish,
147
- distribute, sublicense, and/or sell copies of the Software, and to
148
- permit persons to whom the Software is furnished to do so, subject to
149
- the following conditions:
150
-
151
- The above copyright notice and this permission notice shall be included
152
- in all copies or substantial portions of the Software.
153
-
154
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
155
- KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
156
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
157
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
158
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
159
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
160
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
161
-
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/test_*.rb"]
8
- end
9
-
10
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "plist"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/plist.gemspec DELETED
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
-
3
- lib = File.expand_path("../lib", __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "plist/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "plist"
9
- spec.version = Plist::VERSION
10
- spec.authors = ["Ben Bleything", "Patrick May"]
11
-
12
- spec.summary = "All-purpose Property List manipulation library"
13
- spec.description = "Plist is a library to manipulate Property List files, "\
14
- "also known as plists. It can parse plist files into "\
15
- "native Ruby data structures as well as generating new "\
16
- "plist files from your Ruby objects."
17
- spec.homepage = "https://github.com/patsplat/plist"
18
- spec.license = "MIT"
19
-
20
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
- f.match(%r{^(test|spec|features)/})
22
- end
23
- spec.bindir = "exe"
24
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ["lib"]
26
-
27
- spec.add_development_dependency "bundler", "~> 1.14"
28
- spec.add_development_dependency "rake", "~> 10.5"
29
- spec.add_development_dependency "test-unit", "~> 1.2"
30
- end