feedtools 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +4 -0
  2. data/lib/feed_tools.rb +52 -9
  3. data/rakefile +1 -1
  4. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == FeedTools 0.2.8
2
+ * fixed bug with http headers being loaded from invalid YAML
3
+ * fixed uninitialized constant bug (you shouldn't have RUBYOPT set)
4
+ * cleaned up inspect methods
1
5
  == FeedTools 0.2.7
2
6
  * added support for Atom 1.0 output
3
7
  * improved support for Atom parsing and handling
@@ -21,18 +21,20 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
+ if Object.const_defined?(:FEED_TOOLS_ENV)
25
+ raise "Double-require attempted, aborting. This may be caused " +
26
+ "by the presence of the RUBYOPT environment variable."
27
+ end
28
+
24
29
  FEED_TOOLS_ENV = ENV['FEED_TOOLS_ENV'] ||
25
30
  ENV['RAILS_ENV'] ||
26
31
  'production' # :nodoc:
27
32
 
28
- FEED_TOOLS_VERSION = "0.2.7"
33
+ FEED_TOOLS_VERSION = "0.2.8"
29
34
 
30
35
  $:.unshift(File.dirname(__FILE__))
31
- $:.unshift(File.dirname(__FILE__) + "/../../activerecord/lib")
32
36
  $:.unshift(File.dirname(__FILE__) + "/feed_tools/vendor")
33
-
34
- require 'rubygems'
35
- require 'active_record'
37
+ $:.unshift(File.dirname(__FILE__) + "/../../activerecord/lib")
36
38
 
37
39
  begin
38
40
  require 'builder'
@@ -62,6 +64,9 @@ require 'cgi'
62
64
  require 'pp'
63
65
  require 'yaml'
64
66
 
67
+ require 'rubygems'
68
+ require_gem('activerecord', '>= 1.10.1')
69
+
65
70
  #= feed_tools.rb
66
71
  #
67
72
  # FeedTools was designed to be a simple XML feed parser, generator, and translator with a built-in
@@ -569,6 +574,9 @@ module FeedTools
569
574
  raise ArgumentError, "Expected Time, got #{date.class.name}"
570
575
  end
571
576
  tag_uri = normalize_url(url)
577
+ unless FeedTools.is_uri?(tag_uri)
578
+ raise ArgumentError, "Must supply a valid URL."
579
+ end
572
580
  host = URI.parse(tag_uri).host
573
581
  tag_uri.gsub!(/^(http|ftp|file):\/*/, "")
574
582
  tag_uri.gsub!(/#/, "/")
@@ -576,6 +584,20 @@ module FeedTools
576
584
  "#{tag_uri[(tag_uri.index(host) + host.size)..-1]}"
577
585
  return tag_uri
578
586
  end
587
+
588
+ # Converts a url into a urn:uuid: uri
589
+ # def FeedTools.build_urn_uri(url)
590
+ # unless url.kind_of? String
591
+ # raise ArgumentError, "Expected String, got #{url.class.name}"
592
+ # end
593
+ # normalized_url = normalize_url(url)
594
+ # unless FeedTools.is_uri?(normalized_url)
595
+ # raise ArgumentError, "Must supply a valid URL."
596
+ # end
597
+ # require 'uuidtools'
598
+ # tag_uri = UUID.sha1_create(normalized_url).to_uri_string
599
+ # return tag_uri
600
+ # end
579
601
 
580
602
  # Returns true if the parameter appears to be a valid uri
581
603
  def FeedTools.is_uri?(url)
@@ -865,13 +887,14 @@ module FeedTools
865
887
  feed.update!
866
888
  return feed
867
889
  end
868
-
890
+
869
891
  # Loads the feed from the remote url if the feed has expired from the cache or cannot be
870
892
  # retrieved from the cache for some reason.
871
893
  def update!
872
894
  if self.http_headers.nil? && !(self.cache_object.nil?) &&
873
895
  !(self.cache_object.http_headers.nil?)
874
896
  @http_headers = YAML.load(self.cache_object.http_headers)
897
+ @http_headers = {} unless @http_headers.kind_of? Hash
875
898
  end
876
899
  if expired? && !FeedTools.cache_only?
877
900
  load_remote_feed!
@@ -2622,11 +2645,18 @@ module FeedTools
2622
2645
  end
2623
2646
  xml_builder.generator("FeedTools - " +
2624
2647
  "http://www.sporkmonger.com/projects/feedtools")
2625
- unless self.id.nil?
2648
+ if self.id != nil
2626
2649
  unless FeedTools.is_uri? self.id
2627
- raise "The unique id must be a URI."
2650
+ # if self.link != nil
2651
+ # xml_builder.id(FeedTools.build_urn_uri(self.link))
2652
+ # else
2653
+ raise "The unique id must be a valid URI."
2654
+ # end
2655
+ else
2656
+ xml_builder.id(self.id)
2628
2657
  end
2629
- xml_builder.id(self.id)
2658
+ # elsif self.link != nil
2659
+ # xml_builder.id(FeedTools.build_urn_uri(self.link))
2630
2660
  else
2631
2661
  raise "Cannot build feed, missing feed unique id."
2632
2662
  end
@@ -2696,6 +2726,11 @@ module FeedTools
2696
2726
  end
2697
2727
  return result
2698
2728
  end
2729
+
2730
+ # Returns a simple representation of the feed object's state.
2731
+ def inspect
2732
+ return "#<FeedTools::Feed:0x#{self.object_id.to_s(16)} URL:#{self.url}>"
2733
+ end
2699
2734
  end
2700
2735
 
2701
2736
  class FeedItem
@@ -4272,6 +4307,8 @@ module FeedTools
4272
4307
  unless FeedTools.is_uri? self.id
4273
4308
  if self.time != nil && self.link != nil
4274
4309
  xml_builder.id(FeedTools.build_tag_uri(self.link, self.time))
4310
+ elsif self.link != nil
4311
+ xml_builder.id(FeedTools.build_urn_uuid_uri(self.link))
4275
4312
  else
4276
4313
  raise "The unique id must be a URI. " +
4277
4314
  "(Attempted to generate id, but failed.)"
@@ -4308,6 +4345,12 @@ module FeedTools
4308
4345
  alias_method :guid=, :id=
4309
4346
  alias_method :published, :issued
4310
4347
  alias_method :published=, :issued=
4348
+
4349
+ # Returns a simple representation of the feed item object's state.
4350
+ def inspect
4351
+ return "#<FeedTools::FeedItem:0x#{self.object_id.to_s(16)} " +
4352
+ "LINK:#{self.link}>"
4353
+ end
4311
4354
  end
4312
4355
  end
4313
4356
 
data/rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/gempackagetask'
7
7
  require 'rake/contrib/rubyforgepublisher'
8
8
 
9
9
  PKG_NAME = 'feedtools'
10
- PKG_VERSION = '0.2.7'
10
+ PKG_VERSION = '0.2.8'
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
 
13
13
  RELEASE_NAME = "REL #{PKG_VERSION}"
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.7
7
- date: 2005-09-02 00:00:00 -04:00
6
+ version: 0.2.8
7
+ date: 2005-09-13 00:00:00 -04:00
8
8
  summary: "Parsing, generation, and caching system for xml news feeds."
9
9
  require_paths:
10
10
  - lib