summaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2005-03-31 22:08:32 +0000
committerlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2005-03-31 22:08:32 +0000
commit16ec9aba7e94e628f22bcaeb3ecdd7916f3a3df5 (patch)
treefcee2e08574f55e141eeea3cb2747a4a80c04d89 /devtools
parent94c2f3339fbe18700fcc057367784d04bb2a76d9 (diff)
downloadfeed2imap-16ec9aba7e94e628f22bcaeb3ecdd7916f3a3df5.tar.gz
feed2imap-16ec9aba7e94e628f22bcaeb3ecdd7916f3a3df5.tar.bz2
feed2imap-16ec9aba7e94e628f22bcaeb3ecdd7916f3a3df5.zip
first import
git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@5 f70e237a-67f3-0310-a06c-d2b8a7116972
Diffstat (limited to '')
-rwxr-xr-xdevtools/testparser.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/devtools/testparser.rb b/devtools/testparser.rb
new file mode 100755
index 0000000..2b29544
--- /dev/null
+++ b/devtools/testparser.rb
@@ -0,0 +1,73 @@
+#!/usr/bin/ruby -w
+
+# This script takes a lot of .xml files, parse them, and ensure that each of them has at least
+# channel : a title, a link
+# each item : a title, a link, a content
+
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+require 'channel'
+
+XMLDIR = '../opml/output/'
+DETAILED = true
+def do_dir(dir)
+ Dir.foreach(dir) do |f|
+ next if f !~ /.xml$/
+ do_file(XMLDIR + f)
+ end
+end
+
+def do_file(file)
+ print "#{file} : "
+ str = File::read(file)
+ if str.length == 0
+ puts "EMPTY"
+ return
+ end
+ begin
+ chan = Channel::new(str)
+ rescue UnknownFeedTypeException
+ puts "UNKNOWNFEEDTYPE"
+ return
+ rescue Exception
+ puts "EXCEPTION"
+ puts $!
+ return
+ end
+ ok = true
+ if chan.title.nil?
+ ok = false
+ puts "Channel Title Empty" if DETAILED
+ end
+ if chan.link.nil?
+ ok = false
+ puts "Channel Link Empty" if DETAILED
+ end
+ if chan.items.length == 0
+ ok = false
+ puts "Channel Items Empty" if DETAILED
+ end
+ chan.items.each do |i|
+ if i.title.nil?
+ ok = false
+ puts "Item Title Empty" if DETAILED
+ end
+ if i.link.nil?
+ ok = false
+ puts "Item Link Empty" if DETAILED
+ end
+ if i.content.nil?
+ ok = false
+ puts "Item Content Empty" if DETAILED
+ end
+ end
+ if ok
+ puts "OK"
+ else
+ puts "ERROR"
+ end
+end
+
+STDOUT.sync = true
+#do_file('../opml/output/112.xml')
+do_dir(XMLDIR)
+