summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bleything <ben@bleything.net>2006-08-20 18:16:45 +0000
committerBen Bleything <ben@bleything.net>2006-08-20 18:16:45 +0000
commit7990c721d88baf4dde0ca5933b438a44460c0b0e (patch)
treedab86319af74a902431adb4485d08bc47d65f126
parent146efd1ac86ee6052762d6c4e075936b0295e423 (diff)
downloadplist-7990c721d88baf4dde0ca5933b438a44460c0b0e.tar.gz
whitespace cleanup
-rw-r--r--Rakefile4
-rw-r--r--lib/plist.rb4
-rw-r--r--lib/plist/generator.rb10
-rw-r--r--lib/plist/parser.rb20
-rw-r--r--test/test_narf_plist.rb6
5 files changed, 22 insertions, 22 deletions
diff --git a/Rakefile b/Rakefile
index 0eb8541..510d423 100644
--- a/Rakefile
+++ b/Rakefile
@@ -113,7 +113,7 @@ EOD
s.authors = "Ben Bleything and Patrick May"
s.homepage = "http://plist.rubyforge.org"
-
+
s.rubyforge_project = RUBYFORGE_PROJECT
s.has_rdoc = true
@@ -128,4 +128,4 @@ Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
p.need_tar = true
p.need_zip = true
-end \ No newline at end of file
+end
diff --git a/lib/plist.rb b/lib/plist.rb
index d8d33b9..814bf0a 100644
--- a/lib/plist.rb
+++ b/lib/plist.rb
@@ -10,9 +10,9 @@
#
# This is the main file for plist. Everything interesting happens in Plist and Plist::Emit.
-require 'plist/generator'
+require 'plist/generator'
require 'plist/parser'
module Plist
VERSION = '3.0.0'
-end \ No newline at end of file
+end
diff --git a/lib/plist/generator.rb b/lib/plist/generator.rb
index 57fb179..c44c979 100644
--- a/lib/plist/generator.rb
+++ b/lib/plist/generator.rb
@@ -28,7 +28,7 @@
# Hash
#
# Notes:
-#
+#
# + Array and Hash are recursive -- the elements of an Array and the values of a Hash
# must convert to a plist.
# + The keys of the Hash must be strings.
@@ -36,7 +36,7 @@
# + Data elements can be set with to an open IO or a StringIO
#
# If you have suggestions for mapping other Ruby types to the plist types, send a note to:
-#
+#
# mailto:plist@hexane.org
#
# I'll take a look and probably add it, I'm just reticent to create too many
@@ -158,12 +158,12 @@ require 'stringio'
def to_plist_fragment
self.rewind
data = self.read
-
+
output = "<data>\n"
Base64::encode64(data).gsub(/\s+/, '').scan(/.{1,68}/o) { output << $& << "\n" }
output << "</data>"
-
+
output
end
end
-end \ No newline at end of file
+end
diff --git a/lib/plist/parser.rb b/lib/plist/parser.rb
index 3d08a68..a92b997 100644
--- a/lib/plist/parser.rb
+++ b/lib/plist/parser.rb
@@ -44,7 +44,7 @@ XML
class Listener
#include REXML::StreamListener
-
+
attr_accessor :result, :open
def initialize
@@ -52,11 +52,11 @@ XML
@open = Array.new
end
-
+
def tag_start(name, attributes)
@open.push PTag::mappings[name].new
end
-
+
def text( contents )
@open.last.text = contents if @open.last
end
@@ -76,17 +76,17 @@ XML
@filename_or_xml = filename_or_xml
@listener = listener
end
-
+
TEXT = /([^<]+)/
XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/um
DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/um
-
+
def parse
plist_tags = PTag::mappings.keys.join('|')
start_tag = /<(#{plist_tags})([^>]*)>/i
end_tag = /<\/(#{plist_tags})[^>]*>/i
-
+
require 'strscan'
@scanner = StringScanner.new( if (File.exists? @filename_or_xml)
File.open(@filename_or_xml, "r") {|f| f.read}
@@ -102,7 +102,7 @@ XML
@listener.tag_end(@scanner[1])
end
elsif @scanner.scan(TEXT)
- @listener.text(@scanner[1])
+ @listener.text(@scanner[1])
elsif @scanner.scan(end_tag)
@listener.tag_end(@scanner[1])
else
@@ -146,7 +146,7 @@ XML
def to_ruby
dict = Hash.new
key = nil
-
+
children.each do |c|
if key.nil?
key = c.to_ruby
@@ -159,13 +159,13 @@ XML
dict
end
end
-
+
class PKey < PTag
def to_ruby
text
end
end
-
+
class PString < PTag
def to_ruby
text || ''
diff --git a/test/test_narf_plist.rb b/test/test_narf_plist.rb
index ccef63b..2e94a1c 100644
--- a/test/test_narf_plist.rb
+++ b/test/test_narf_plist.rb
@@ -35,7 +35,7 @@ class TestPlist < Test::Unit::TestCase
"AlbumName"=>"Roll 1",
"AlbumId"=>6}],
result["List of Rolls"] )
-
+
# string
assert_kind_of( String, result["Application Version"] )
assert_equal( "5.0.4 (263)", result["Application Version"] )
@@ -59,7 +59,7 @@ class TestPlist < Test::Unit::TestCase
#end
- # date fields are credited to
+ # date fields are credited to
def test_date_fields
result = Plist::parse_xml("test/assets/Cookies.plist")
assert_kind_of( DateTime, result.first['Expires'] )
@@ -83,7 +83,7 @@ class TestPlist < Test::Unit::TestCase
source = File.open("test/assets/AlbumData.xml") { |f| f.read }
result = Plist::parse_xml(source)
-
+
assert_equal( result, Plist::parse_xml(result.to_plist) )
File.delete('hello.plist') if File.exists?('hello.plist')