feedme 0.8.1 → 0.8.2

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/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ === 0.8.2
2
+
3
+ * Remove VERSION variable from feedme.rb
4
+ * Don't double-escape CDATA-escaped content
5
+
6
+ === 0.8.1 / 2010-01-02
7
+
8
+ * Add new transformation :esc
9
+ * Expose parsed tags as attribute :fm_parsed
10
+
1
11
  === 0.8 / 2009-12-14
2
12
 
3
13
  * Add new virtual method _values: returns all values for a given tag.
data/Manifest.txt CHANGED
@@ -3,7 +3,9 @@ Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
5
  lib/feedme.rb
6
- lib/truncator.rb
7
- lib/util.rb
6
+ lib/feedme-util.rb
7
+ lib/hpricot-util.rb
8
+ lib/html-cleaner.rb
9
+ lib/nokogiri-util.rb
8
10
  examples/rocketboom.rb
9
11
  examples/rocketboom.rss
data/Rakefile CHANGED
@@ -9,12 +9,11 @@ tasks = Jeweler::Tasks.new do |s|
9
9
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
10
10
  s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile",
11
11
  "lib/feedme.rb", "lib/hpricot-util.rb", "lib/nokogiri-util.rb",
12
- "lib/html-cleaner.rb", "lib/util.rb", "examples/rocketboom.rb",
12
+ "lib/html-cleaner.rb", "lib/feedme-util.rb", "examples/rocketboom.rb",
13
13
  "examples/rocketboom.rss", "test/test_helper.rb"]
14
14
  s.homepage = %q{http://wiki.github.com/jdidion/feedme}
15
15
  s.rdoc_options = ["--main", "README.txt"]
16
16
  s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{feedme}
18
17
  s.summary = %q{A simple, flexible, and extensible RSS and Atom parser for Ruby}
19
18
  s.test_files = ["test/test_helper.rb"]
20
19
  end
File without changes
data/lib/feedme.rb CHANGED
@@ -1,11 +1,8 @@
1
1
  require 'cgi'
2
2
  require 'time'
3
- require 'util.rb'
3
+ require 'feedme-util'
4
4
 
5
5
  module FeedMe
6
- # The current version of FeedMe.
7
- VERSION = "0.7.2"
8
-
9
6
  # The value of Parser#fm_type for RSS feeds.
10
7
  RSS = :RSS
11
8
  # The value of Parser#fm_type for RDF (RSS 1.0) feeds.
@@ -489,6 +486,8 @@ module FeedMe
489
486
 
490
487
  def _transform(trans_array, value)
491
488
  trans_array.each do |t|
489
+ return nil if value.nil?
490
+
492
491
  if t.is_a? String
493
492
  value = _transform(fm_builder.transformations[t], value)
494
493
  else
@@ -503,8 +502,8 @@ module FeedMe
503
502
  end
504
503
 
505
504
  trans = fm_builder.transformation_fns[t_name] or
506
- raise NameError.new("No such transformation #{t_name}", t_name)
507
-
505
+ raise NoMethodError.new("No such transformation #{t_name}", t_name)
506
+
508
507
  if value.is_a? Array
509
508
  value = value.collect {|x| trans.call(x, *args) }
510
509
  else
@@ -559,9 +558,9 @@ module FeedMe
559
558
  def parse
560
559
  # RSS = everything between channel tags + everthing between </channel> and </rdf> if this is an RDF document
561
560
  if @fm_source =~ %r{<(?:.*?:)?(rss|rdf)(.*?)>.*?<(?:.*?:)?channel(.*?)>(.+)</(?:.*?:)?channel>(.*)</(?:.*?:)?(?:rss|rdf)>}mi
562
- @fm_type = $2.upcase.to_s
561
+ @fm_type = $1.upcase.to_s
563
562
  @fm_tags = fm_builder.all_rss_tags
564
- attrs = parse_attributes($1, $3)
563
+ attrs = parse_attributes($1, $2 + $3)
565
564
  attrs[:version] ||= '1.0';
566
565
  parse_content(self, attrs, $4, @fm_tags)
567
566
 
@@ -709,13 +708,17 @@ module FeedMe
709
708
  end
710
709
 
711
710
  def unescape(content)
712
- content = CGI.unescapeHTML(content)
713
-
714
- query = content.match(/^(http:.*\?)(.*)$/)
715
- content = query[1] + CGI.unescape(query[2]) if query
716
-
717
711
  cdata = content.match(%r{<!\[CDATA\[(.*)\]\]>}mi)
718
- content = cdata[1] if cdata
712
+ if cdata
713
+ # CDATA-escaped content is not encoded
714
+ content = cdata[1]
715
+ else
716
+ # unescape
717
+ content = CGI.unescapeHTML(content)
718
+ # further unescape any URL query strings
719
+ query = content.match(/^(http:.*\?)(.*)$/)
720
+ content = query[1] + CGI.unescape(query[2]) if query
721
+ end
719
722
 
720
723
  return content
721
724
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Didion
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-02 00:00:00 -05:00
12
+ date: 2010-01-14 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -31,11 +31,11 @@ files:
31
31
  - Rakefile
32
32
  - examples/rocketboom.rb
33
33
  - examples/rocketboom.rss
34
+ - lib/feedme-util.rb
34
35
  - lib/feedme.rb
35
36
  - lib/hpricot-util.rb
36
37
  - lib/html-cleaner.rb
37
38
  - lib/nokogiri-util.rb
38
- - lib/util.rb
39
39
  - test/test_helper.rb
40
40
  has_rdoc: true
41
41
  homepage: http://wiki.github.com/jdidion/feedme
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version:
62
62
  requirements: []
63
63
 
64
- rubyforge_project: feedme
64
+ rubyforge_project:
65
65
  rubygems_version: 1.3.5
66
66
  signing_key:
67
67
  specification_version: 3