feedtools 0.2.18 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ require 'test/unit'
2
+ require 'feed_tools'
3
+ require 'feed_tools/helpers/feed_tools_helper'
4
+
5
+ class InterfaceTest < Test::Unit::TestCase
6
+ def setup
7
+ FeedTools.reset_configurations
8
+ FeedTools.configurations[:tidy_enabled] = false
9
+ FeedTools.configurations[:feed_cache] = "FeedTools::DatabaseFeedCache"
10
+ FeedTools::FeedToolsHelper.default_local_path =
11
+ File.expand_path(
12
+ File.expand_path(File.dirname(__FILE__)) + '/../feeds')
13
+ end
14
+
15
+ def test_feed_interface
16
+ # These will throw an exception if missing, obviously
17
+ feed = FeedTools::Feed.new
18
+ feed.title
19
+ feed.subtitle
20
+ feed.description
21
+ feed.link
22
+ feed.entries
23
+ feed.items
24
+ end
25
+
26
+ def test_feed_item_interface
27
+ # These will throw an exception if missing, obviously
28
+ feed_item = FeedTools::FeedItem.new
29
+ feed_item.title
30
+ feed_item.content
31
+ feed_item.description
32
+ feed_item.link
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ require 'test/unit'
2
+ require 'feed_tools'
3
+ require 'feed_tools/helpers/feed_tools_helper'
4
+
5
+ class ItunesTest < Test::Unit::TestCase
6
+ include FeedTools::FeedToolsHelper
7
+
8
+ def setup
9
+ FeedTools.reset_configurations
10
+ FeedTools.configurations[:tidy_enabled] = false
11
+ FeedTools.configurations[:feed_cache] = "FeedTools::DatabaseFeedCache"
12
+ FeedTools::FeedToolsHelper.default_local_path =
13
+ File.expand_path(
14
+ File.expand_path(File.dirname(__FILE__)) + '/../feeds')
15
+ end
16
+
17
+ def test_nothing_yet
18
+ end
19
+ end
@@ -3,16 +3,32 @@ require 'feed_tools'
3
3
  require 'feed_tools/helpers/feed_tools_helper'
4
4
 
5
5
  class NonStandardTest < Test::Unit::TestCase
6
- include FeedToolsHelper
6
+ include FeedTools::FeedToolsHelper
7
7
 
8
8
  def setup
9
- FeedTools.tidy_enabled = false
10
- FeedTools.feed_cache = FeedTools::DatabaseFeedCache
11
- FeedToolsHelper.default_local_path =
9
+ FeedTools.reset_configurations
10
+ FeedTools.configurations[:tidy_enabled] = false
11
+ FeedTools.configurations[:feed_cache] = "FeedTools::DatabaseFeedCache"
12
+ FeedTools::FeedToolsHelper.default_local_path =
12
13
  File.expand_path(
13
14
  File.expand_path(File.dirname(__FILE__)) + '/../feeds')
14
15
  end
15
16
 
17
+ def test_rss_feed_id
18
+ with_feed(:from_data => <<-FEED
19
+ <rss version="2.0">
20
+ <channel>
21
+ <guid isPermaLink="false">
22
+ 95148ACD-C1A3-45C3-A927-15C836892DCC
23
+ </guid>
24
+ </channel>
25
+ </rss>
26
+ FEED
27
+ ) { |feed|
28
+ assert_equal("95148ACD-C1A3-45C3-A927-15C836892DCC", feed.id)
29
+ }
30
+ end
31
+
16
32
  def test_xss_strict
17
33
  with_feed(:from_data => <<-FEED
18
34
  <?xml version="1.0" encoding="iso-8859-1"?>
@@ -72,6 +88,7 @@ class NonStandardTest < Test::Unit::TestCase
72
88
  end
73
89
 
74
90
  def test_rss_30_lite
91
+ FeedTools.configurations[:max_ttl] = nil
75
92
  # Delusions of grandeur...
76
93
  with_feed(:from_data => <<-FEED
77
94
  <?xml version="1.0" encoding="UTF-8"?>
@@ -152,5 +169,6 @@ class NonStandardTest < Test::Unit::TestCase
152
169
  assert_equal("jonathan@rss3.org", feed.items[1].author.email)
153
170
  assert_equal("http://www.rss3.org/official_blog/?p=2", feed.items[1].guid)
154
171
  }
172
+ FeedTools.configurations[:max_ttl] = 3.days.to_s
155
173
  end
156
174
  end
@@ -0,0 +1,19 @@
1
+ require 'test/unit'
2
+ require 'feed_tools'
3
+ require 'feed_tools/helpers/feed_tools_helper'
4
+
5
+ class RdfTest < Test::Unit::TestCase
6
+ include FeedTools::FeedToolsHelper
7
+
8
+ def setup
9
+ FeedTools.reset_configurations
10
+ FeedTools.configurations[:tidy_enabled] = false
11
+ FeedTools.configurations[:feed_cache] = "FeedTools::DatabaseFeedCache"
12
+ FeedTools::FeedToolsHelper.default_local_path =
13
+ File.expand_path(
14
+ File.expand_path(File.dirname(__FILE__)) + '/../feeds')
15
+ end
16
+
17
+ def test_nothing_yet
18
+ end
19
+ end
@@ -3,12 +3,13 @@ require 'feed_tools'
3
3
  require 'feed_tools/helpers/feed_tools_helper'
4
4
 
5
5
  class RssTest < Test::Unit::TestCase
6
- include FeedToolsHelper
6
+ include FeedTools::FeedToolsHelper
7
7
 
8
8
  def setup
9
- FeedTools.tidy_enabled = false
10
- FeedTools.feed_cache = FeedTools::DatabaseFeedCache
11
- FeedToolsHelper.default_local_path =
9
+ FeedTools.reset_configurations
10
+ FeedTools.configurations[:tidy_enabled] = false
11
+ FeedTools.configurations[:feed_cache] = "FeedTools::DatabaseFeedCache"
12
+ FeedTools::FeedToolsHelper.default_local_path =
12
13
  File.expand_path(
13
14
  File.expand_path(File.dirname(__FILE__)) + '/../feeds')
14
15
  end
@@ -544,10 +545,10 @@ class RssTest < Test::Unit::TestCase
544
545
 
545
546
  def test_content_encoded
546
547
  with_feed(:from_data => <<-FEED
547
- <rss>
548
- <channel>
549
- <item>
550
- <title>Test Feed Title</title>
548
+ <rss>
549
+ <channel>
550
+ <item>
551
+ <title>Test Feed Title</title>
551
552
  <content:encoded
552
553
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
553
554
  <![CDATA[
@@ -565,21 +566,22 @@ class RssTest < Test::Unit::TestCase
565
566
  end
566
567
 
567
568
  def test_item_order
569
+ FeedTools.configurations[:timestamp_estimation_enabled] = true
568
570
  with_feed(:from_data => <<-FEED
569
- <rss>
570
- <channel>
571
- <item>
572
- <title>Item 1</title>
571
+ <rss>
572
+ <channel>
573
+ <item>
574
+ <title>Item 1</title>
573
575
  </item>
574
- <item>
575
- <title>Item 2</title>
576
+ <item>
577
+ <title>Item 2</title>
576
578
  </item>
577
- <item>
578
- <title>Item 3</title>
579
+ <item>
580
+ <title>Item 3</title>
579
581
  </item>
580
- </channel>
582
+ </channel>
581
583
  </rss>
582
- FEED
584
+ FEED
583
585
  ) { |feed|
584
586
  assert_equal("Item 1", feed.items[0].title)
585
587
  assert_equal("Item 2", feed.items[1].title)
@@ -587,48 +589,104 @@ class RssTest < Test::Unit::TestCase
587
589
  }
588
590
 
589
591
  with_feed(:from_data => <<-FEED
590
- <rss>
591
- <channel>
592
- <item>
593
- <title>Item 1</title>
594
- </item>
595
- <item>
596
- <title>Item 2</title>
597
- <pubDate>Thu, 13 Oct 2005 19:59:00 +0000</pubDate>
598
- </item>
599
- <item>
600
- <title>Item 3</title>
601
- </item>
602
- </channel>
603
- </rss>
604
- FEED
592
+ <rss>
593
+ <channel>
594
+ <item>
595
+ <title>Item 1</title>
596
+ </item>
597
+ <item>
598
+ <title>Item 2</title>
599
+ <pubDate>Thu, 13 Oct 2005 19:59:00 +0000</pubDate>
600
+ </item>
601
+ <item>
602
+ <title>Item 3</title>
603
+ </item>
604
+ </channel>
605
+ </rss>
606
+ FEED
605
607
  ) { |feed|
606
608
  assert_equal("Item 1", feed.items[0].title)
607
609
  assert_equal("Item 2", feed.items[1].title)
608
610
  assert_equal("Item 3", feed.items[2].title)
609
611
  }
612
+
613
+ FeedTools.configurations[:timestamp_estimation_enabled] = false
614
+ with_feed(:from_data => <<-FEED
615
+ <rss>
616
+ <channel>
617
+ <item>
618
+ <title>Item 1</title>
619
+ </item>
620
+ <item>
621
+ <title>Item 2</title>
622
+ <pubDate>Thu, 13 Oct 2005 19:59:00 +0000</pubDate>
623
+ </item>
624
+ <item>
625
+ <title>Item 3</title>
626
+ </item>
627
+ </channel>
628
+ </rss>
629
+ FEED
630
+ ) { |feed|
631
+ assert_equal("Item 2", feed.items[0].title)
632
+ assert_equal(nil, feed.items[1].time)
633
+ assert_equal(nil, feed.items[2].time)
634
+ }
635
+ FeedTools.configurations[:timestamp_estimation_enabled] = true
610
636
  end
611
637
 
612
638
  def test_usm
613
639
  with_feed(:from_data => <<-FEED
614
- <rss xmlns:atom="http://www.w3.org/2005/Atom">
615
- <channel>
616
- <atom:link href="http://nowhere.com/feed.xml" rel="self" />
617
- <title>Feed Title</title>
640
+ <rss xmlns:atom="http://www.w3.org/2005/Atom">
641
+ <channel>
642
+ <title>Feed Title</title>
643
+ <atom:link href="http://nowhere.com/feed.xml" rel="self" />
644
+ </channel>
645
+ </rss>
646
+ FEED
647
+ ) { |feed|
648
+ assert_equal(nil, feed.link)
649
+ assert_equal("http://nowhere.com/feed.xml", feed.url)
650
+ assert_equal("Feed Title", feed.title)
651
+ }
652
+
653
+ with_feed(:from_data => <<-FEED
654
+ <rss xmlns:atom="http://www.w3.org/2005/Atom">
655
+ <channel>
656
+ <title>Feed Title</title>
657
+ <atom:link href="http://nowhere.com/feed.xml" rel="self" />
658
+ <atom:link href="http://nowhere.com/"
659
+ type="application/xhtml+xml" />
618
660
  </channel>
619
661
  </rss>
620
662
  FEED
621
663
  ) { |feed|
664
+ assert_equal("http://nowhere.com/", feed.link)
665
+ assert_equal("http://nowhere.com/feed.xml", feed.url)
666
+ assert_equal("Feed Title", feed.title)
667
+ }
668
+
669
+ with_feed(:from_data => <<-FEED
670
+ <rss xmlns:atom="http://www.w3.org/2005/Atom">
671
+ <channel>
672
+ <title>Feed Title</title>
673
+ <atom:link href="http://nowhere.com/feed.xml" rel="self" />
674
+ <link>http://nowhere.com/</link>
675
+ </channel>
676
+ </rss>
677
+ FEED
678
+ ) { |feed|
679
+ assert_equal("http://nowhere.com/", feed.link)
622
680
  assert_equal("http://nowhere.com/feed.xml", feed.url)
623
681
  assert_equal("Feed Title", feed.title)
624
682
  }
625
683
 
626
684
  with_feed(:from_data => <<-FEED
627
685
  <rss xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
628
- xmlns:admin="http://webns.net/mvcb/">
629
- <channel>
630
- <admin:feed rdf:resource="http://nowhere.com/feed.xml" />
631
- <title>Feed Title</title>
686
+ xmlns:admin="http://webns.net/mvcb/">
687
+ <channel>
688
+ <title>Feed Title</title>
689
+ <admin:feed rdf:resource="http://nowhere.com/feed.xml" />
632
690
  </channel>
633
691
  </rss>
634
692
  FEED
@@ -640,6 +698,42 @@ class RssTest < Test::Unit::TestCase
640
698
 
641
699
  def test_http_retrieval
642
700
  # Just make sure this doesn't toss out any errors
643
- FeedTools::Feed.open('http://scobleizer.wordpress.com/feed/')
701
+ FeedTools::Feed.open('http://rss.slashdot.org/Slashdot/slashdot')
702
+ end
703
+
704
+ def test_blogger_line_breaks
705
+ with_feed(:from_data => <<-FEED
706
+ <?xml version="1.0" encoding="UTF-8"?>
707
+ <rss version="2.0">
708
+ <channel>
709
+ <convertLineBreaks xmlns="http://www.blogger.com/atom/ns#">
710
+ true
711
+ </convertLineBreaks>
712
+ <item>
713
+ <title>Test Item</title>
714
+ </item>
715
+ </channel>
716
+ </rss>
717
+ FEED
718
+ ) { |feed|
719
+ assert_equal(1, feed.items.size)
720
+ }
721
+ end
722
+
723
+ def test_atom_blog_draft
724
+ with_feed(:from_data => <<-FEED
725
+ <?xml version="1.0" encoding="UTF-8"?>
726
+ <rss version="2.0">
727
+ <channel>
728
+ <draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
729
+ <item>
730
+ <title>Test Item</title>
731
+ </item>
732
+ </channel>
733
+ </rss>
734
+ FEED
735
+ ) { |feed|
736
+ assert_equal(1, feed.items.size)
737
+ }
644
738
  end
645
- end
739
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: feedtools
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.18
7
- date: 2005-12-17 00:00:00 -05:00
6
+ version: 0.2.19
7
+ date: 2006-01-21 00:00:00 -05:00
8
8
  summary: "Parsing, generation, and caching system for xml news feeds."
9
9
  require_paths:
10
10
  - lib
@@ -40,19 +40,15 @@ files:
40
40
  - lib/feed_tools/feed_item.rb
41
41
  - lib/feed_tools/helpers
42
42
  - lib/feed_tools/vendor
43
+ - lib/feed_tools/helpers/debug_helper.rb
43
44
  - lib/feed_tools/helpers/feed_helper.rb
44
45
  - lib/feed_tools/helpers/feed_item_helper.rb
45
46
  - lib/feed_tools/helpers/feed_tools_helper.rb
46
47
  - lib/feed_tools/helpers/generic_helper.rb
47
48
  - lib/feed_tools/helpers/module_helper.rb
48
- - lib/feed_tools/vendor/builder
49
- - lib/feed_tools/vendor/builder.rb
49
+ - lib/feed_tools/helpers/retrieval_helper.rb
50
50
  - lib/feed_tools/vendor/htree
51
51
  - lib/feed_tools/vendor/htree.rb
52
- - lib/feed_tools/vendor/builder/blankslate.rb
53
- - lib/feed_tools/vendor/builder/xmlbase.rb
54
- - lib/feed_tools/vendor/builder/xmlevents.rb
55
- - lib/feed_tools/vendor/builder/xmlmarkup.rb
56
52
  - lib/feed_tools/vendor/htree/container.rb
57
53
  - lib/feed_tools/vendor/htree/context.rb
58
54
  - lib/feed_tools/vendor/htree/display.rb
@@ -2852,9 +2848,13 @@ files:
2852
2848
  - test/unit/atom_test.rb
2853
2849
  - test/unit/cache_test.rb
2854
2850
  - test/unit/cdf_test.rb
2851
+ - test/unit/encoding_test.rb
2855
2852
  - test/unit/generation_test.rb
2856
2853
  - test/unit/helper_test.rb
2854
+ - test/unit/interface_test.rb
2855
+ - test/unit/itunes_test.rb
2857
2856
  - test/unit/nonstandard_test.rb
2857
+ - test/unit/rdf_test.rb
2858
2858
  - test/unit/rss_test.rb
2859
2859
  - db/schema.mysql.sql
2860
2860
  - db/schema.postgresql.sql
@@ -2888,4 +2888,14 @@ dependencies:
2888
2888
  - ">="
2889
2889
  - !ruby/object:Gem::Version
2890
2890
  version: 0.1.2
2891
+ version:
2892
+ - !ruby/object:Gem::Dependency
2893
+ name: builder
2894
+ version_requirement:
2895
+ version_requirements: !ruby/object:Gem::Version::Requirement
2896
+ requirements:
2897
+ -
2898
+ - ">="
2899
+ - !ruby/object:Gem::Version
2900
+ version: 1.2.4
2891
2901
  version:
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #--
4
- # Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #++
11
-
12
- # :stopdoc:
13
- require 'builder/xmlmarkup'
14
- require 'builder/xmlevents'
15
- # :startdoc:
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
4
- # All rights reserved.
5
-
6
- # Permission is granted for use, copying, modification, distribution,
7
- # and distribution of modified versions of this work as long as the
8
- # above copyright notice is included.
9
- #++
10
-
11
- # :stopdoc:
12
- module Builder #:nodoc:
13
-
14
- # BlankSlate provides an abstract base class with no predefined
15
- # methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>).
16
- # BlankSlate is useful as a base class when writing classes that
17
- # depend upon <tt>method_missing</tt> (e.g. dynamic proxies).
18
- class BlankSlate #:nodoc:
19
- class << self
20
- def hide(name)
21
- undef_method name if
22
- instance_methods.include?(name.to_s) and
23
- name !~ /^(__|instance_eval)/
24
- end
25
- end
26
-
27
- instance_methods.each { |m| hide(m) }
28
- end
29
- end
30
-
31
- # Since Ruby is very dynamic, methods added to the ancestors of
32
- # BlankSlate <em>after BlankSlate is defined</em> will show up in the
33
- # list of available BlankSlate methods. We handle this by defining a hook in the Object and Kernel classes that will hide any defined
34
- module Kernel #:nodoc:
35
- class << self
36
- alias_method :blank_slate_method_added, :method_added
37
- def method_added(name)
38
- blank_slate_method_added(name)
39
- return if self != Kernel
40
- Builder::BlankSlate.hide(name)
41
- end
42
- end
43
- end
44
-
45
- class Object #:nodoc:
46
- class << self
47
- alias_method :blank_slate_method_added, :method_added
48
- def method_added(name)
49
- blank_slate_method_added(name)
50
- return if self != Object
51
- Builder::BlankSlate.hide(name)
52
- end
53
- end
54
- end
55
- # :startdoc: