plist 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/plist.rb +19 -5
  2. data/test_plist.rb +7 -1
  3. metadata +2 -2
data/plist.rb CHANGED
@@ -3,10 +3,15 @@
3
3
 
4
4
  # Plist parses Mac OS X xml property list files into ruby data structures.
5
5
  #
6
- # Note: Date and Data elements are not yet implemented. Plist::parse_xml
7
- # should blow up if when it encounters such elements. If you encounter
8
- # such an error, please send your plist file to patrick@hexane.org,
9
- # so that I can implement the proper support.
6
+ # Note that I don't use these two elements much:
7
+ #
8
+ # + Date elements are returned as Time objects.
9
+ # + Data elements are not yet implemented.
10
+ #
11
+ # Plist::parse_xml will blow up if it encounters a data element.
12
+ # If you encounter such an error, or if you have a Date element which
13
+ # can't be parsed into a Time object, please send your plist file to
14
+ # patrick@hexane.org so that I can implement the proper support.
10
15
  #
11
16
  # The main point of this api is one method: Plist::parse_xml( filename )
12
17
  class Plist
@@ -20,6 +25,8 @@ class Plist
20
25
  end
21
26
 
22
27
  class Listener
28
+ #include REXML::StreamListener
29
+
23
30
  attr_accessor :result, :open
24
31
 
25
32
  def initialize
@@ -27,7 +34,6 @@ class Plist
27
34
  @open = Array.new
28
35
  end
29
36
 
30
- #include REXML::StreamListener
31
37
 
32
38
  def tag_start(name, attributes)
33
39
  @open.push PTag::mappings[name].new
@@ -175,4 +181,12 @@ class Plist
175
181
  text.to_f
176
182
  end
177
183
  end
184
+
185
+ require 'time'
186
+ class PDate < PTag
187
+ def to_ruby
188
+ Time.parse(text)
189
+ end
190
+ end
191
+
178
192
  end
data/test_plist.rb CHANGED
@@ -48,9 +48,15 @@ class TestPlist < Test::Unit::TestCase
48
48
  end
49
49
 
50
50
  #def test_load_something_big
51
- # plist = Plist::parse_xml( "/Users/patsplat/Pictures/iPhoto Library/AlbumData.xml" )
51
+ # plist = Plist::parse_xml( "~/Pictures/iPhoto Library/AlbumData.xml" )
52
52
  #end
53
53
 
54
+ def test_date_fields
55
+ result = Plist::parse_xml("Cookies.plist")
56
+ assert_kind_of( Time, result.first['Expires'] )
57
+ assert_equal( "Thu Oct 25 12:36:35 UTC 2007", result.first['Expires'].to_s )
58
+ end
59
+
54
60
  end
55
61
 
56
62
  __END__
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11.3
3
3
  specification_version: 1
4
4
  name: plist
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2006-01-08 00:00:00 -05:00
6
+ version: 1.1.0
7
+ date: 2006-04-27 00:00:00 -04:00
8
8
  summary: plist parses Mac OS X plist files into ruby data types.
9
9
  require_paths:
10
10
  - "."