feed_detector 0.0.2 → 0.0.3

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/feed_detector.rb CHANGED
@@ -62,7 +62,13 @@ module FeedDetector
62
62
  # converts relative urls to absolute urls
63
63
  def self.to_absolute_url(page_url,feed_url)
64
64
  return feed_url if feed_url =~ /^http:\/\// # already absolute
65
- File.join(page_url, feed_url)
65
+
66
+ if feed_url =~ /^\// # relative to the host root ## '/some_dir_from_root/feed.xml'
67
+ "http://#{URI.parse(page_url).host.to_s + feed_url}"
68
+ else # relative to the page path ## 'feed.xml'
69
+ feed_path = page_url.scan(/^(http:\/\/[^\/]+)((?:\/[^\/]+)+(?=\/))?\/?(?:[^\/]+)?$/i).to_s
70
+ feed_path +'/'+ feed_url
71
+ end
66
72
  end
67
73
 
68
74
 
@@ -1,3 +1,3 @@
1
1
  module FeedDetector
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -87,6 +87,10 @@ class FeedDetectorTest < Test::Unit::TestCase
87
87
  assert_equal(result, feed_paths)
88
88
  feed_paths = FeedDetector.fetch_feed_urls(@wordpress_single_feed_page_url, :rss)
89
89
  assert_equal([], feed_paths)
90
+
91
+ url = "http://showmaniac.org/259"
92
+ result = ["http://showmaniac.org/feed/259"]
93
+ assert_equal result, FeedDetector.fetch_feed_urls(url)
90
94
 
91
95
  # page containing several feed pointers
92
96
  result = [@wordpress_atom_url, "http://bettysteger.com/comments/feed/"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feed_detector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-27 00:00:00.000000000 Z
12
+ date: 2012-04-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'A ruby gem based on code from Dominiek''s post (http://synaptify.com/?p=93)
15
15
  on detecting feeds. '