damog-feedbag 0.5.12 → 0.5.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/feedbag.rb +32 -28
- metadata +1 -1
    
        data/lib/feedbag.rb
    CHANGED
    
    | @@ -50,7 +50,7 @@ module Feedbag | |
| 50 50 | 
             
            		end
         | 
| 51 51 | 
             
            	end
         | 
| 52 52 |  | 
| 53 | 
            -
            	def self.find(url)
         | 
| 53 | 
            +
            	def self.find(url, args = {})
         | 
| 54 54 | 
             
            		$feeds = []
         | 
| 55 55 |  | 
| 56 56 | 
             
            		url_uri = URI.parse(url)
         | 
| @@ -65,20 +65,22 @@ module Feedbag | |
| 65 65 | 
             
            		#url = "#{url_uri.scheme or 'http'}://#{url_uri.host}#{url_uri.path}"
         | 
| 66 66 |  | 
| 67 67 | 
             
            		# check if feed_valid is avail
         | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 68 | 
            +
                unless args[:narrow]
         | 
| 69 | 
            +
                  begin
         | 
| 70 | 
            +
            	  		require "feed_validator"
         | 
| 71 | 
            +
            		  	v = W3C::FeedValidator.new
         | 
| 72 | 
            +
            			  v.validate_url(url)
         | 
| 73 | 
            +
              			return self.add_feed(url, nil) if v.valid?
         | 
| 74 | 
            +
            	  	rescue LoadError
         | 
| 75 | 
            +
            		  	# scoo
         | 
| 76 | 
            +
              		rescue REXML::ParseException
         | 
| 77 | 
            +
            	  	  # usually indicates timeout
         | 
| 78 | 
            +
            		    # TODO: actually find out timeout. use Terminator?
         | 
| 79 | 
            +
            		    $stderr.puts "Feed looked like feed but might not have passed validation or timed out"
         | 
| 80 | 
            +
                  rescue => ex
         | 
| 81 | 
            +
            	  		$stderr.puts "#{ex.class} error ocurred with: `#{url}': #{ex.message}"
         | 
| 82 | 
            +
            		  end
         | 
| 83 | 
            +
                end
         | 
| 82 84 |  | 
| 83 85 | 
             
            		begin
         | 
| 84 86 | 
             
            			html = open(url) do |f|
         | 
| @@ -102,19 +104,21 @@ module Feedbag | |
| 102 104 | 
             
            					end
         | 
| 103 105 | 
             
            				end
         | 
| 104 106 |  | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 107 | 
            +
                    unless args[:narrow]
         | 
| 108 | 
            +
              				(doc/"a").each do |a|
         | 
| 109 | 
            +
            	  				next unless a["href"]
         | 
| 110 | 
            +
            		  			if self.looks_like_feed?(a["href"]) and (a["href"] =~ /\// or a["href"] =~ /#{url_uri.host}/)
         | 
| 111 | 
            +
            			  			self.add_feed(a["href"], url, $base_uri)
         | 
| 112 | 
            +
            				  	end
         | 
| 113 | 
            +
              				end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            	  			(doc/"a").each do |a|
         | 
| 116 | 
            +
            		  			next unless a["href"]
         | 
| 117 | 
            +
            			  		if self.looks_like_feed?(a["href"])
         | 
| 118 | 
            +
            				  		self.add_feed(a["href"], url, $base_uri)
         | 
| 119 | 
            +
            					  end
         | 
| 120 | 
            +
              				end
         | 
| 121 | 
            +
                    end
         | 
| 118 122 |  | 
| 119 123 | 
             
            			end
         | 
| 120 124 | 
             
            		rescue Timeout::Error => err
         |