Permalink
Browse files

Generalize the API, pass XML::Reader not an IO object.

  • Loading branch information...
1 parent 2034bdc commit a94951e1ee1ca12a43d9347a9c389c74dccd48b3 @AustinBlues committed Aug 15, 2011
Showing with 8 additions and 7 deletions.
  1. +2 −1 examples/opml_to_yaml.rb
  2. +1 −2 lib/opml_speed_reader.rb
  3. +1 −1 lib/opml_speed_reader/version.rb
  4. +4 −3 test/test_suite.rb
View
@@ -7,7 +7,8 @@
XML::Error.set_handler(&XML::Error::QUIET_HANDLER)
begin
- puts OpmlSpeedReader.parse(STDIN).to_yaml
+ reader = XML::Reader.io(STDIN)
+ puts OpmlSpeedReader.parse(reader).to_yaml
rescue OpmlSpeedReader::NotOPML
STDERR.puts "Not OPML"
exit 1
View
@@ -104,8 +104,7 @@ def self.parse_body(reader, stack)
# Parse OPML, reading XML from +io+, returning hash with all RSS
# feed relevant data.
- def self.parse(io)
- reader = XML::Reader.io(io)
+ def self.parse(reader)
parser_stack = []
title = OpmlSpeedReader.parse_header(reader, parser_stack)
@@ -1,3 +1,3 @@
module OpmlSpeedReader
- VERSION = "0.2.2"
+ VERSION = "0.3.0"
end
View
@@ -16,7 +16,8 @@ def setup
def test_parsing
Dir['./test/opml/*.yml'].each do |filename|
expected = YAML::load( File.open( filename ) )
- opml = OpmlSpeedReader.parse(open(filename.gsub(/\.yml\Z/, '.xml')))
+ reader = XML::Reader.io(open(filename.gsub(/\.yml\Z/, '.xml')))
+ opml = OpmlSpeedReader.parse(reader)
assert (opml == expected)
end
end
@@ -25,9 +26,9 @@ def test_parsing
# Test exception thrown for non-OPML file (it's an HTML file, a
# common user mistake.
def test_not_opml
- io = open('./test/opml/not_opml.html')
+ reader = XML::Reader.io(open('./test/opml/not_opml.html'))
assert_raise OpmlSpeedReader::NotOPML do
- OpmlSpeedReader.parse(io)
+ OpmlSpeedReader.parse(reader)
end
end
end

0 comments on commit a94951e

Please sign in to comment.