plist 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b76cafca96f807c09a6ab294cfbbdb7382d037e3
4
- data.tar.gz: 6934d855210d3a9962b3810139061075eec5ef23
3
+ metadata.gz: 6419e8cb1fbfdc4d07ec54cf7ca8e2baf6ed33af
4
+ data.tar.gz: a4c8aa0a95cc0ad9bf25b724963ca8493543a015
5
5
  SHA512:
6
- metadata.gz: 446131557d54d2a68e215ab21ff083a9181a6228e02a6e060b5307927e37c5f2c1fef85cf65317da12e633c59388502b83a85d7d3d5f3170067dd43ddeec72c9
7
- data.tar.gz: aa7bfd8345be6d48b86f526df32837e1890114c76c8170c9c88dd1d19042a271a1d619002659badcb7a0dfd8c0a53cacdb9ba0028aedae30c8d265ab9ea2b583
6
+ metadata.gz: 973b6bed1abafcffd88e4e51bfa8c304ce38b37a60f9d1424e68360ccdb7b749368f13c645fe5827ca63c11396aa45b6f980b8ff2dac56123a86202ad50c00bf
7
+ data.tar.gz: 623bd3fca1591131ca3cd8d0dc6a683b444f63ed9aec50a3dc257408de93c3686b45ef4484b34fa43d04d9ca118799b0d7af84734e4cc8fa751abd1ca8de24bb
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,16 @@
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
@@ -1,6 +1,28 @@
1
1
  = plist - All-purpose Property List manipulation library
2
2
 
3
- === Release version 3.0.0!
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)
4
26
 
5
27
  2010-02-23:
6
28
  * Ruby 1.9.x compatibility!
@@ -24,7 +46,7 @@
24
46
  2006-09-20 (r80):
25
47
  * tweak a comment in generator.rb to make it clear that we're not using Base64.b64encode because it's broken.
26
48
 
27
- === Release version 3.0.0!
49
+ === 3.0.0 (2006-09-20)
28
50
 
29
51
  2006-09-20 (r77 - r79):
30
52
  * move IndentedString inside Plist::Emit and :nodoc: it
@@ -56,6 +78,8 @@
56
78
  * Sort hash keys before emitting (now we can test multi-element hashes!)
57
79
  * Inject #<=> into Symbol so that sorting Symbol-keyed hashes won't freak out
58
80
 
81
+ === 2.1.2 (2006-09-20)
82
+
59
83
  2006-09-12 (r47 - r51):
60
84
  * More test rejiggering
61
85
  * New tests to expose some bugs
@@ -68,7 +92,7 @@
68
92
  * Make the parser strip out comments and Marshal.load <data> elements if possible
69
93
  * Update some rdoc
70
94
 
71
- === Release version 2.1.1!
95
+ === 2.1.1 (2006-09-10)
72
96
 
73
97
  2006-09-10 (r31 - r32):
74
98
  * Added encoding / decoding for entities (&amp; etc)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in plist.gemspec
4
+ gemspec
File without changes
@@ -1,5 +1,8 @@
1
1
  = All-purpose Property List manipulation library
2
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
+
3
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.
4
7
 
5
8
  == Usage
data/Rakefile CHANGED
@@ -1,154 +1,10 @@
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
- #
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
10
3
 
11
- require 'fileutils'
12
- require 'rubygems'
13
- require 'rake'
14
- require 'rake/testtask'
15
- require 'rake/packagetask'
16
- require 'rake/contrib/rubyforgepublisher'
17
- require 'rubygems/package_task'
18
-
19
- $:.unshift(File.dirname(__FILE__) + "/lib")
20
- require 'plist'
21
-
22
- PKG_NAME = 'plist'
23
- PKG_VERSION = Plist::VERSION
24
- PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
25
-
26
- RELEASE_NAME = "REL #{PKG_VERSION}"
27
-
28
- RUBYFORGE_PROJECT = "plist"
29
- RUBYFORGE_USER = ENV['RUBYFORGE_USER']
30
-
31
- TEST_FILES = Dir.glob('test/test_*')
32
- TEST_ASSETS = Dir.glob('test/assets/*')
33
- LIB_FILES = Dir.glob('lib/**/*')
34
- RELEASE_FILES = [ "Rakefile", "README.rdoc", "CHANGELOG", "LICENSE" ] + LIB_FILES + TEST_FILES + TEST_ASSETS
35
-
36
- task :default => [ :test ]
37
- # Run the unit tests
38
- Rake::TestTask.new { |t|
4
+ Rake::TestTask.new(:test) do |t|
39
5
  t.libs << "test"
40
- t.test_files = TEST_FILES
41
- t.verbose = true
42
- }
43
-
44
- desc "Clean pkg, coverage, and rdoc; remove .bak files"
45
- task :clean => [ :clobber_rdoc, :clobber_package, :clobber_coverage ] do
46
- puts cmd = "find . -type f -name *.bak -delete"
47
- `#{cmd}`
48
- end
49
-
50
- task :clobber_coverage do
51
- puts cmd = "rm -rf coverage"
52
- `#{cmd}`
53
- end
54
-
55
- desc "Generate coverage analysis with rcov (requires rcov to be installed)"
56
- task :rcov => [ :clobber_coverage ] do
57
- puts cmd = "rcov -Ilib --xrefs -T test/*.rb"
58
- puts `#{cmd}`
59
- end
60
-
61
- desc "Strip trailing whitespace and fix newlines for all release files"
62
- task :fix_whitespace => [ :clean ] do
63
- RELEASE_FILES.reject {|i| i =~ /assets/}.each do |filename|
64
- next if File.directory? filename
65
-
66
- File.open(filename) do |file|
67
- newfile = ''
68
- needs_love = false
69
-
70
- file.readlines.each_with_index do |line, lineno|
71
- if line =~ /[ \t]+$/
72
- needs_love = true
73
- puts "#{filename}: trailing whitespace on line #{lineno}"
74
- line.gsub!(/[ \t]*$/, '')
75
- end
76
-
77
- if line.chomp == line
78
- needs_love = true
79
- puts "#{filename}: no newline on line #{lineno}"
80
- line << "\n"
81
- end
82
-
83
- newfile << line
84
- end
85
-
86
- if needs_love
87
- tempname = "#{filename}.new"
88
-
89
- File.open(tempname, 'w').write(newfile)
90
- File.chmod(File.stat(filename).mode, tempname)
91
-
92
- FileUtils.ln filename, "#{filename}.bak"
93
- FileUtils.ln tempname, filename, :force => true
94
- File.unlink(tempname)
95
- end
96
- end
97
- end
98
- end
99
-
100
- desc "Copy documentation to rubyforge"
101
- task :update_rdoc => [ :rdoc ] do
102
- Rake::SshDirPublisher.new("#{RUBYFORGE_USER}@rubyforge.org", "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}", "rdoc").upload
103
- end
104
-
105
- begin
106
- require 'rdoc/task'
107
-
108
- # Generate the RDoc documentation
109
- RDoc::Task.new do |rdoc|
110
- rdoc.title = "All-purpose Property List manipulation library"
111
- rdoc.main = "README.rdoc"
112
-
113
- rdoc.rdoc_dir = 'rdoc'
114
- rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG')
115
- rdoc.rdoc_files.include('lib/**')
116
-
117
- rdoc.options = [
118
- '-H', # show hash marks on method names in comments
119
- '-N', # show line numbers
120
- ]
121
- end
122
- rescue LoadError
123
- $stderr.puts "Could not load rdoc tasks"
124
- end
125
-
126
- # Create compressed packages
127
- spec = Gem::Specification.new do |s|
128
- s.name = PKG_NAME
129
- s.version = PKG_VERSION
130
-
131
- s.summary = "All-purpose Property List manipulation library."
132
- s.description = <<-EOD
133
- 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.
134
- EOD
135
-
136
- s.authors = "Ben Bleything and Patrick Way"
137
- s.homepage = "http://plist.rubyforge.org"
138
-
139
- s.rubyforge_project = RUBYFORGE_PROJECT
140
-
141
- s.has_rdoc = true
142
-
143
- s.files = RELEASE_FILES
144
- s.test_files = TEST_FILES
145
-
146
- s.autorequire = 'plist'
147
- end
148
-
149
- Gem::PackageTask.new(spec) do |p|
150
- p.gem_spec = spec
151
- p.need_tar = true
152
- p.need_zip = true
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/test_*.rb"]
153
8
  end
154
9
 
10
+ task :default => :test
@@ -0,0 +1,14 @@
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__)
@@ -0,0 +1,8 @@
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
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
- #
1
+ # encoding: utf-8
2
+
3
3
  # = plist
4
4
  #
5
5
  # This is the main file for plist. Everything interesting happens in
@@ -15,7 +15,7 @@ require 'stringio'
15
15
 
16
16
  require 'plist/generator'
17
17
  require 'plist/parser'
18
+ require 'plist/version'
18
19
 
19
20
  module Plist
20
- VERSION = '3.2.0'
21
21
  end
@@ -1,12 +1,12 @@
1
- #!/usr/bin/env ruby
2
- #
1
+ # encoding: utf-8
2
+
3
3
  # = plist
4
4
  #
5
5
  # Copyright 2006-2010 Ben Bleything and Patrick May
6
6
  # Distributed under the MIT License
7
7
  #
8
8
 
9
- module Plist ; end
9
+ module Plist; end
10
10
 
11
11
  # === Create a plist
12
12
  # You can dump an object to a plist in one of two ways:
@@ -94,7 +94,7 @@ module Plist::Emit
94
94
  output << tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ'))
95
95
  when Date # also catches DateTime
96
96
  output << tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ'))
97
- when String, Symbol, Fixnum, Bignum, Integer, Float
97
+ when String, Symbol, Integer, Float
98
98
  output << tag(element_type(element), CGI::escapeHTML(element.to_s))
99
99
  when IO, StringIO
100
100
  element.rewind
@@ -159,7 +159,7 @@ module Plist::Emit
159
159
  when String, Symbol
160
160
  'string'
161
161
 
162
- when Fixnum, Bignum, Integer
162
+ when Integer
163
163
  'integer'
164
164
 
165
165
  when Float
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
- #
1
+ # encoding: utf-8
2
+
3
3
  # = plist
4
4
  #
5
5
  # Copyright 2006-2010 Ben Bleything and Patrick May
@@ -73,10 +73,10 @@ module Plist
73
73
  end
74
74
 
75
75
  TEXT = /([^<]+)/
76
- XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/um
77
- DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/um
78
- COMMENT_START = /\A<!--/u
79
- COMMENT_END = /.*?-->/um
76
+ XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/m
77
+ DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/m
78
+ COMMENT_START = /\A<!--/
79
+ COMMENT_END = /.*?-->/m
80
80
 
81
81
 
82
82
  def parse
@@ -91,7 +91,14 @@ module Plist
91
91
  if @scanner.scan(COMMENT_START)
92
92
  @scanner.scan(COMMENT_END)
93
93
  elsif @scanner.scan(XMLDECL_PATTERN)
94
+ encoding = parse_encoding_from_xml_declaration(@scanner[1])
95
+ next if encoding.nil?
96
+
97
+ # use the specified encoding for the rest of the file
98
+ next unless String.method_defined?(:force_encoding)
99
+ @scanner.string = @scanner.rest.force_encoding(encoding)
94
100
  elsif @scanner.scan(DOCTYPE_PATTERN)
101
+ next
95
102
  elsif @scanner.scan(start_tag)
96
103
  @listener.tag_start(@scanner[1], nil)
97
104
  if (@scanner[2] =~ /\/$/)
@@ -106,6 +113,22 @@ module Plist
106
113
  end
107
114
  end
108
115
  end
116
+
117
+ private
118
+
119
+ def parse_encoding_from_xml_declaration(xml_declaration)
120
+ return unless defined?(Encoding)
121
+
122
+ xml_encoding = xml_declaration.match(/(?:\A|\s)encoding=(?:"(.*?)"|'(.*?)')(?:\s|\Z)/)
123
+
124
+ return if xml_encoding.nil?
125
+
126
+ begin
127
+ Encoding.find(xml_encoding[1])
128
+ rescue ArgumentError
129
+ nil
130
+ end
131
+ end
109
132
  end
110
133
 
111
134
  class PTag
@@ -213,7 +236,7 @@ module Plist
213
236
  data = Base64.decode64(text.gsub(/\s+/, '')) unless text.nil?
214
237
  begin
215
238
  return Marshal.load(data)
216
- rescue Exception => e
239
+ rescue Exception
217
240
  io = StringIO.new
218
241
  io.write data
219
242
  io.rewind
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module Plist
4
+ VERSION = '3.3.0'.freeze
5
+ end
@@ -0,0 +1,30 @@
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