plist.utf8 3.1.1
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 +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +12 -0
- data/CHANGELOG +103 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -0
- data/LICENSE +20 -0
- data/README.rdoc +158 -0
- data/Rakefile +154 -0
- data/lib/plist/generator.rb +222 -0
- data/lib/plist/parser.rb +225 -0
- data/lib/plist/version.rb +3 -0
- data/lib/plist.rb +18 -0
- data/plist.gemspec +23 -0
- data/test/assets/AlbumData.xml +203 -0
- data/test/assets/Cookies.plist +104 -0
- data/test/assets/commented.plist +9 -0
- data/test/assets/example_data.bin +0 -0
- data/test/assets/example_data.jpg +0 -0
- data/test/assets/example_data.plist +259 -0
- data/test/assets/test_data_elements.plist +24 -0
- data/test/assets/test_empty_key.plist +13 -0
- data/test/test_data_elements.rb +124 -0
- data/test/test_generator.rb +75 -0
- data/test/test_generator_basic_types.rb +53 -0
- data/test/test_generator_collections.rb +77 -0
- data/test/test_parser.rb +97 -0
- metadata +111 -0
data/test/test_parser.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'plist'
|
5
|
+
|
6
|
+
class TestParser < Test::Unit::TestCase
|
7
|
+
def test_Plist_parse_xml
|
8
|
+
result = Plist::parse_xml("test/assets/AlbumData.xml")
|
9
|
+
|
10
|
+
# dict
|
11
|
+
assert_kind_of( Hash, result )
|
12
|
+
|
13
|
+
expected = [
|
14
|
+
"List of Albums",
|
15
|
+
"Minor Version",
|
16
|
+
"Master Image List",
|
17
|
+
"Major Version",
|
18
|
+
"List of Keywords",
|
19
|
+
"Archive Path",
|
20
|
+
"List of Rolls",
|
21
|
+
"Application Version"
|
22
|
+
]
|
23
|
+
assert_equal( expected.sort, result.keys.sort )
|
24
|
+
|
25
|
+
# array
|
26
|
+
assert_kind_of( Array, result["List of Rolls"] )
|
27
|
+
assert_equal( [ {"PhotoCount"=>1,
|
28
|
+
"KeyList"=>["7"],
|
29
|
+
"Parent"=>999000,
|
30
|
+
"Album Type"=>"Regular",
|
31
|
+
"AlbumName"=>"Roll 1",
|
32
|
+
"AlbumId"=>6}],
|
33
|
+
result["List of Rolls"] )
|
34
|
+
|
35
|
+
# string
|
36
|
+
assert_kind_of( String, result["Application Version"] )
|
37
|
+
assert_equal( "5.0.4 (263)", result["Application Version"] )
|
38
|
+
|
39
|
+
# integer
|
40
|
+
assert_kind_of( Integer, result["Major Version"] )
|
41
|
+
assert_equal( 2, result["Major Version"] )
|
42
|
+
|
43
|
+
# true
|
44
|
+
assert_kind_of( TrueClass, result["List of Albums"][0]["Master"] )
|
45
|
+
assert( result["List of Albums"][0]["Master"] )
|
46
|
+
|
47
|
+
# false
|
48
|
+
assert_kind_of( FalseClass, result["List of Albums"][1]["SlideShowUseTitles"] )
|
49
|
+
assert( ! result["List of Albums"][1]["SlideShowUseTitles"] )
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
# uncomment this test to work on speed optimization
|
54
|
+
#def test_load_something_big
|
55
|
+
# plist = Plist::parse_xml( "~/Pictures/iPhoto Library/AlbumData.xml" )
|
56
|
+
#end
|
57
|
+
|
58
|
+
# date fields are credited to
|
59
|
+
def test_date_fields
|
60
|
+
result = Plist::parse_xml("test/assets/Cookies.plist")
|
61
|
+
assert_kind_of( DateTime, result.first['Expires'] )
|
62
|
+
assert_equal DateTime.parse( "2007-10-25T12:36:35Z" ), result.first['Expires']
|
63
|
+
end
|
64
|
+
|
65
|
+
# bug fix for empty <key>
|
66
|
+
# reported by Matthias Peick <matthias@peick.de>
|
67
|
+
# reported and fixed by Frederik Seiffert <ego@frederikseiffert.de>
|
68
|
+
def test_empty_dict_key
|
69
|
+
data = Plist::parse_xml("test/assets/test_empty_key.plist");
|
70
|
+
assert_equal("2", data['key']['subkey'])
|
71
|
+
end
|
72
|
+
|
73
|
+
# bug fix for decoding entities
|
74
|
+
# reported by Matthias Peick <matthias@peick.de>
|
75
|
+
def test_decode_entities
|
76
|
+
data = Plist::parse_xml('<string>Fish & Chips</string>')
|
77
|
+
assert_equal('Fish & Chips', data)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_comment_handling_and_empty_plist
|
81
|
+
assert_nothing_raised do
|
82
|
+
assert_nil( Plist::parse_xml( File.read('test/assets/commented.plist') ) )
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_filename_or_xml_is_stringio
|
87
|
+
require 'stringio'
|
88
|
+
|
89
|
+
str = StringIO.new
|
90
|
+
data = Plist::parse_xml(str)
|
91
|
+
|
92
|
+
assert_nil data
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
__END__
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: plist.utf8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- shiren1118
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: plist
|
42
|
+
email:
|
43
|
+
- shiren1118@126.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- CHANGELOG
|
51
|
+
- Gemfile
|
52
|
+
- Gemfile.lock
|
53
|
+
- LICENSE
|
54
|
+
- README.rdoc
|
55
|
+
- Rakefile
|
56
|
+
- lib/plist.rb
|
57
|
+
- lib/plist/generator.rb
|
58
|
+
- lib/plist/parser.rb
|
59
|
+
- lib/plist/version.rb
|
60
|
+
- plist.gemspec
|
61
|
+
- test/assets/AlbumData.xml
|
62
|
+
- test/assets/Cookies.plist
|
63
|
+
- test/assets/commented.plist
|
64
|
+
- test/assets/example_data.bin
|
65
|
+
- test/assets/example_data.jpg
|
66
|
+
- test/assets/example_data.plist
|
67
|
+
- test/assets/test_data_elements.plist
|
68
|
+
- test/assets/test_empty_key.plist
|
69
|
+
- test/test_data_elements.rb
|
70
|
+
- test/test_generator.rb
|
71
|
+
- test/test_generator_basic_types.rb
|
72
|
+
- test/test_generator_collections.rb
|
73
|
+
- test/test_parser.rb
|
74
|
+
homepage: ''
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.2.0
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: plist
|
98
|
+
test_files:
|
99
|
+
- test/assets/AlbumData.xml
|
100
|
+
- test/assets/Cookies.plist
|
101
|
+
- test/assets/commented.plist
|
102
|
+
- test/assets/example_data.bin
|
103
|
+
- test/assets/example_data.jpg
|
104
|
+
- test/assets/example_data.plist
|
105
|
+
- test/assets/test_data_elements.plist
|
106
|
+
- test/assets/test_empty_key.plist
|
107
|
+
- test/test_data_elements.rb
|
108
|
+
- test/test_generator.rb
|
109
|
+
- test/test_generator_basic_types.rb
|
110
|
+
- test/test_generator_collections.rb
|
111
|
+
- test/test_parser.rb
|