Permalink
Browse files

* WWW::Favicon#find_from_html takes url as string

  • Loading branch information...
1 parent 9adecd1 commit f04d8f05fb779b5e5e01a37d9dd489ae538998f3 @youpy committed Jul 3, 2008
Showing with 12 additions and 7 deletions.
  1. +5 −6 lib/www/favicon.rb
  2. +6 −0 spec/www-favicon_spec.rb
  3. +1 −1 www-favicon.gemspec
View
@@ -5,16 +5,15 @@
module WWW
class Favicon
- VERSION = '0.0.2'
+ VERSION = '0.0.3'
def find(url)
- uri = URI(url)
- html = request(uri).body
-
- find_from_html(html, uri)
+ html = request(URI(url)).body
+ find_from_html(html, url)
end
- def find_from_html(html, uri)
+ def find_from_html(html, url)
+ uri = URI(url)
find_from_link(html, uri) || try_default_path(uri)
end
View
@@ -32,11 +32,17 @@
it "should find from default path" do
@favicon.stub!(:request).and_return(expect(:body => '<html></html>'), expect(:code => '200'))
@favicon.find('http://www.example.com/').should == 'http://www.example.com/favicon.ico'
+
+ @favicon.stub!(:request).and_return(expect(:code => '200'))
+ @favicon.find_from_html('<html></html>', 'http://www.example.com/').should == 'http://www.example.com/favicon.ico'
end
it "should not find from default path" do
@favicon.stub!(:request).and_return(expect(:body => '<html></html>'), expect(:code => '404'))
@favicon.find('http://example.com/').should be_nil
+
+ @favicon.stub!(:request).and_return(expect(:code => '404'))
+ @favicon.find_from_html('<html></html>', 'http://www.example.com/').should be_nil
end
end
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = %q{www-favicon}
- s.version = "0.0.2"
+ s.version = "0.0.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["youpy"]

0 comments on commit f04d8f0

Please sign in to comment.