Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
phanle committed Feb 24, 2012
1 parent f47e229 commit cb79a3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
17 changes: 1 addition & 16 deletions feed_parser.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
require 'rubygems'
require 'nokogiri'

class FeedParser
attr_reader :file
def initialize(file)
@file = file
end

def parse
f = File.open(file)
doc = Nokogiri::XML(f)
f.close
root = doc.css('channel')
return NewSource.new(root.css("title").first.text, root.css("link").first.text)
end

end

class NewSource
attr_reader :name, :root_url
def initialize(name, root_url)
@name = name
@root_url = root_url
end

end
5 changes: 3 additions & 2 deletions feed_parser_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'rubygems'
require 'awesome_print'
require File.join(File.dirname(__FILE__), 'feed_parser')

describe FeedParser do
Expand All @@ -16,4 +14,7 @@
subject.root_url.should == 'http://quechoa.info'
end

it "has multiple news items" do
subject.should have(3).items
end
end

0 comments on commit cb79a3a

Please sign in to comment.