muck-feedbag 0.6.0 → 0.7.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/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ * 0.6 - Fri Mar 5 20:10:33 EST 2010
2
+ - Added bin/feedbag.
3
+ - Removed the args[:narrow] option, not really needed.
4
+ - Handle case where feed URLs contain GET parameters; add tests
5
+ by Patrick Reagan <patrick.reagan@viget.com>.
6
+
1
7
  * 0.5.99 - Tue May 12 12:52:22 EDT 2009
2
8
  - Added rails/init.rb to load easily on a Rails app.
3
9
 
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+
6
+ begin
7
+ require 'rcov/rcovtask'
8
+ Rcov::RcovTask.new do |t|
9
+ t.libs << 'lib'
10
+ t.pattern = 'test/*_test.rb'
11
+ t.verbose = true
12
+ t.output_dir = 'coverage'
13
+ t.rcov_opts << '--exclude "gems/*"'
14
+ end
15
+ rescue LoadError
16
+ task :rcov do
17
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
18
+ end
19
+ end
20
+
21
+ desc 'Test muck-feedbag.'
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'test'
24
+ t.test_files = FileList["test/feedbag_test.rb"]
25
+ t.verbose = true
26
+ end
27
+
28
+ task :test => :check_dependencies
29
+ task :default => :test
30
+
31
+ begin
32
+ require 'jeweler'
33
+ Jeweler::Tasks.new do |gem|
34
+ gem.name = "muck-feedbag"
35
+ gem.summary = "Fork of the feedbag gem."
36
+ gem.description = "This gem will return title and url for each feed discovered at a given url"
37
+ gem.email = "justin@tatemae.com"
38
+ gem.homepage = "http://github.com/tatemae/muck-feedbag"
39
+ gem.authors = ["Axiombox", "David Moreno", "Joel Duffin", "Justin Ball", "Fabien Penso"]
40
+ gem.add_development_dependency "shoulda"
41
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
42
+ end
43
+ Jeweler::GemcutterTasks.new
44
+ rescue LoadError
45
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
46
+ end
47
+
48
+ Rake::RDocTask.new do |rdoc|
49
+ if File.exist?('VERSION')
50
+ version = File.read('VERSION')
51
+ else
52
+ version = ""
53
+ end
54
+
55
+ rdoc.rdoc_dir = 'rdoc'
56
+ rdoc.title = "muck-feedbag #{version}"
57
+ rdoc.rdoc_files.include('README*')
58
+ rdoc.rdoc_files.include('lib/**/*.rb')
59
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.1
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "feedbag"
5
+
6
+ def usage
7
+ %Q{
8
+ #{$0} <url 1> [<url 2> <url 3> ... <url n>]
9
+ }
10
+ end
11
+
12
+ if ARGV.empty?
13
+ puts usage
14
+ exit 1
15
+ end
16
+
17
+ ARGV.each do |url|
18
+ puts "== #{url}:"
19
+ feeds = Feedbag.find url
20
+ if feeds.empty?
21
+ puts " no feeds found!"
22
+ else
23
+ feeds.each do |f|
24
+ puts " - #{f}"
25
+ end
26
+ end
27
+ end
28
+
@@ -2,19 +2,22 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{feedbag}
5
- s.version = "0.5.103"
6
- s.homepage = "http://axiombox.com/feedbag"
7
- #s.rubyforge_project = "feedbag"
5
+ s.version = "0.6"
6
+ s.homepage = "http://axiombox.com/feedbag"
7
+ s.rubyforge_project = "feedbag"
8
8
 
9
9
  s.authors = ["Axiombox", "David Moreno"]
10
- s.date = %q{2009-02-10}
10
+ s.date = %q{2010-03-05}
11
11
  s.description = %q{Ruby's favorite feed auto-discoverty tool}
12
12
  s.email = %q{david@axiombox.com}
13
13
  s.extra_rdoc_files = ["README.markdown", "COPYING"]
14
- s.files = ["lib/feedbag.rb", "benchmark/rfeedfinder_benchmark.rb"]
14
+ s.files = ["lib/feedbag.rb", "benchmark/rfeedfinder_benchmark.rb", "bin/feedbag"]
15
15
  s.has_rdoc = true
16
16
  s.rdoc_options = ["--main", "README.markdown"]
17
17
  s.summary = %q{Ruby's favorite feed auto-discovery tool}
18
18
  s.add_dependency("hpricot", '>= 0.6')
19
+ s.bindir = 'bin'
20
+ s.default_executable = %q{feedbag}
21
+ s.executables = ["feedbag"]
19
22
  end
20
23
 
@@ -21,9 +21,10 @@ require "hpricot"
21
21
  require "open-uri"
22
22
  require "net/http"
23
23
  require 'timeout'
24
+ require 'iconv'
24
25
 
25
26
  module Feedbag
26
- Feed = Struct.new(:url, :title)
27
+ Feed = Struct.new(:url, :title, :human_url)
27
28
 
28
29
  @content_types = [
29
30
  'application/x.atom+xml',
@@ -41,6 +42,8 @@ module Feedbag
41
42
  # use LWR::Simple.normalize some time
42
43
  url_uri = URI.parse(url)
43
44
  url = "#{url_uri.scheme or 'http'}://#{url_uri.host}#{url_uri.path}"
45
+ url << "?#{url_uri.query}" if url_uri.query
46
+
44
47
  # hack:
45
48
  url.sub!(/^feed:\/\//, 'http://')
46
49
 
@@ -69,31 +72,34 @@ module Feedbag
69
72
  return self.add_feed(url, nil) if looks_like_feed? url
70
73
 
71
74
  # check if feed_valid is avail
72
- unless args[:narrow]
73
- begin
74
- require "feed_validator"
75
- v = W3C::FeedValidator.new
76
- v.validate_url(url)
77
- return self.add_feed(url, nil) if v.valid?
78
- rescue LoadError
79
- # scoo
80
- rescue REXML::ParseException
81
- # usually indicates timeout
82
- # TODO: actually find out timeout. use Terminator?
83
- $stderr.puts "Feed looked like feed but might not have passed validation or timed out"
84
- rescue => ex
85
- $stderr.puts "#{ex.class} error ocurred with: `#{url}': #{ex.message}"
86
- end
87
- end
75
+ begin
76
+ require "feed_validator"
77
+ v = W3C::FeedValidator.new
78
+ v.validate_url(url)
79
+ return self.add_feed(url, nil) if v.valid?
80
+ rescue LoadError
81
+ # scoo
82
+ rescue REXML::ParseException
83
+ # usually indicates timeout
84
+ # TODO: actually find out timeout. use Terminator?
85
+ # $stderr.puts "Feed looked like feed but might not have passed validation or timed out"
86
+ rescue => ex
87
+ $stderr.puts "#{ex.class} error ocurred with: `#{url}': #{ex.message}"
88
+ end
88
89
 
89
90
  begin
90
91
  Timeout::timeout(10) do
91
92
  open(url) do |f|
92
- if @content_types.include?(f.content_type.downcase)
93
- return self.add_feed(url, nil)
94
- end
95
-
96
- doc = Hpricot(f.read)
93
+ content_type = f.content_type.downcase
94
+ if content_type == "application/octet-stream" # open failed
95
+ content_type = f.meta["content-type"].gsub(/;.*$/, '')
96
+ end
97
+ if @content_types.include?(content_type)
98
+ return self.add_feed(url, nil)
99
+ end
100
+
101
+ ic = Iconv.new('UTF-8//IGNORE', f.charset)
102
+ doc = Hpricot(ic.iconv(f.read))
97
103
 
98
104
  if doc.at("base") and doc.at("base")["href"]
99
105
  $base_uri = doc.at("base")["href"]
@@ -109,14 +115,20 @@ module Feedbag
109
115
  end
110
116
  end
111
117
 
112
- unless args[:narrow]
113
- (doc/"a").each do |a|
114
- next unless a["href"]
115
- if self.looks_like_feed?(a["href"])
116
- self.add_feed(a["href"], url, $base_uri, a["title"] || a.inner_html || a['alt']) # multiple fallbacks, first title, then the tag content, then the alt tag (in case of image)
117
- end
118
+ (doc/"a").each do |a|
119
+ next unless a["href"]
120
+ if self.looks_like_feed?(a["href"]) and (a["href"] =~ /\// or a["href"] =~ /#{url_uri.host}/)
121
+ self.add_feed(a["href"], url, $base_uri, a["title"] || a.inner_html || a['alt'])
122
+ end
123
+ end
124
+
125
+ (doc/"a").each do |a|
126
+ next unless a["href"]
127
+ if self.looks_like_feed?(a["href"])
128
+ self.add_feed(a["href"], url, $base_uri, a["title"] || a.inner_html || a['alt'])
118
129
  end
119
130
  end
131
+
120
132
  end
121
133
  end
122
134
  rescue Timeout::Error => err
@@ -161,7 +173,7 @@ module Feedbag
161
173
  end
162
174
 
163
175
  # verify url is really valid
164
- $feeds.push(Feed.new(url, title)) unless $feeds.any? { |f| f.url == url }# if self._is_http_valid(URI.parse(url), orig_url)
176
+ $feeds.push(Feed.new(url, title, orig_url)) unless $feeds.any? { |f| f.url == url }# if self._is_http_valid(URI.parse(url), orig_url)
165
177
  end
166
178
 
167
179
  # not used. yet.
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{muck-feedbag}
8
+ s.version = "0.7.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Axiombox", "David Moreno", "Joel Duffin", "Justin Ball", "Fabien Penso"]
12
+ s.date = %q{2011-01-31}
13
+ s.default_executable = %q{feedbag}
14
+ s.description = %q{This gem will return title and url for each feed discovered at a given url}
15
+ s.email = %q{justin@tatemae.com}
16
+ s.executables = ["feedbag"]
17
+ s.extra_rdoc_files = [
18
+ "ChangeLog",
19
+ "README.markdown",
20
+ "TODO"
21
+ ]
22
+ s.files = [
23
+ "COPYING",
24
+ "ChangeLog",
25
+ "README.markdown",
26
+ "Rakefile",
27
+ "TODO",
28
+ "VERSION",
29
+ "benchmark/rfeedfinder_benchmark.rb",
30
+ "bin/feedbag",
31
+ "feedbag.gemspec",
32
+ "index.html",
33
+ "lib/feedbag.rb",
34
+ "muck-feedbag.gemspec",
35
+ "test/atom_autodiscovery_test.rb",
36
+ "test/feedbag_test.rb",
37
+ "test/test_helper.rb"
38
+ ]
39
+ s.homepage = %q{http://github.com/tatemae/muck-feedbag}
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.7}
42
+ s.summary = %q{Fork of the feedbag gem.}
43
+ s.test_files = [
44
+ "test/atom_autodiscovery_test.rb",
45
+ "test/feedbag_test.rb",
46
+ "test/test_helper.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<shoulda>, [">= 0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<shoulda>, [">= 0"])
60
+ end
61
+ end
62
+
@@ -1,10 +1,4 @@
1
- #!/usr/bin/ruby
2
-
3
- require "#{File.dirname(__FILE__)}/../feedbag"
4
- require "test/unit"
5
- require "open-uri"
6
- require "hpricot"
7
- require "pp"
1
+ require File.dirname(__FILE__) + '/test_helper'
8
2
 
9
3
  class AtomAutoDiscoveryTest < Test::Unit::TestCase
10
4
  def test_autodisc
@@ -20,14 +14,14 @@ class AtomAutoDiscoveryTest < Test::Unit::TestCase
20
14
  f = Feedbag.find url
21
15
 
22
16
  assert_instance_of Array, f
23
- assert f.size == 1, "Feedbag didn't find a feed on #{url} or found more than one"
17
+ f.size.should == 1, "Feedbag didn't find a feed on #{url} or found more than one"
24
18
 
25
19
  puts " found #{f[0]}"
26
20
  feed = Hpricot(open(f[0]))
27
21
 
28
22
  (feed/"link").each do |l|
29
23
  next unless l["rel"] == "alternate"
30
- assert_equal l["href"], url
24
+ url.should == l["href"]
31
25
  end
32
26
 
33
27
  # ahora me voy al siguiente
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class FeedbagTest < ActiveSupport::TestCase
4
+
5
+ test "Feedbag.feed? should know that an RSS url is a feed" do
6
+ rss_url = 'http://example.com/rss/'
7
+ Feedbag.stubs(:find).with(rss_url).returns([rss_url])
8
+
9
+ assert Feedbag.feed?(rss_url)
10
+ end
11
+
12
+ test "Feedbag.feed? should know that an RSS url with parameters is a feed" do
13
+ rss_url = "http://example.com/data?format=rss"
14
+ Feedbag.stubs(:find).with(rss_url).returns([rss_url])
15
+
16
+ assert Feedbag.feed?(rss_url)
17
+ end
18
+
19
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+
3
+ require 'test/unit'
4
+
5
+
6
+ require 'active_support'
7
+ require 'active_support/test_case'
8
+
9
+ require 'mocha'
10
+
11
+ require File.dirname(__FILE__) + '/../lib/feedbag'
metadata CHANGED
@@ -1,77 +1,102 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-feedbag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ hash: 1
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 1
10
+ version: 0.7.1
5
11
  platform: ruby
6
12
  authors:
13
+ - Axiombox
14
+ - David Moreno
7
15
  - Joel Duffin
8
16
  - Justin Ball
17
+ - Fabien Penso
9
18
  autorequire:
10
19
  bindir: bin
11
20
  cert_chain: []
12
21
 
13
- date: 2009-11-10 00:00:00 -07:00
14
- default_executable:
22
+ date: 2011-01-31 00:00:00 -07:00
23
+ default_executable: feedbag
15
24
  dependencies:
16
25
  - !ruby/object:Gem::Dependency
17
26
  name: shoulda
18
- type: :development
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
27
+ prerelease: false
28
+ requirement: &id001 !ruby/object:Gem::Requirement
29
+ none: false
21
30
  requirements:
22
31
  - - ">="
23
32
  - !ruby/object:Gem::Version
33
+ hash: 3
34
+ segments:
35
+ - 0
24
36
  version: "0"
25
- version:
37
+ type: :development
38
+ version_requirements: *id001
26
39
  description: This gem will return title and url for each feed discovered at a given url
27
40
  email: justin@tatemae.com
28
- executables: []
29
-
41
+ executables:
42
+ - feedbag
30
43
  extensions: []
31
44
 
32
45
  extra_rdoc_files:
33
46
  - ChangeLog
34
47
  - README.markdown
48
+ - TODO
35
49
  files:
36
- - .gitignore
37
50
  - COPYING
38
51
  - ChangeLog
39
52
  - README.markdown
53
+ - Rakefile
40
54
  - TODO
41
55
  - VERSION
42
56
  - benchmark/rfeedfinder_benchmark.rb
57
+ - bin/feedbag
43
58
  - feedbag.gemspec
44
59
  - index.html
45
60
  - lib/feedbag.rb
46
- - rails/init.rb
61
+ - muck-feedbag.gemspec
47
62
  - test/atom_autodiscovery_test.rb
63
+ - test/feedbag_test.rb
64
+ - test/test_helper.rb
48
65
  has_rdoc: true
49
66
  homepage: http://github.com/tatemae/muck-feedbag
50
67
  licenses: []
51
68
 
52
69
  post_install_message:
53
- rdoc_options:
54
- - --charset=UTF-8
70
+ rdoc_options: []
71
+
55
72
  require_paths:
56
73
  - lib
57
74
  required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
58
76
  requirements:
59
77
  - - ">="
60
78
  - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
61
82
  version: "0"
62
- version:
63
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
64
85
  requirements:
65
86
  - - ">="
66
87
  - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
67
91
  version: "0"
68
- version:
69
92
  requirements: []
70
93
 
71
94
  rubyforge_project:
72
- rubygems_version: 1.3.5
95
+ rubygems_version: 1.3.7
73
96
  signing_key:
74
97
  specification_version: 3
75
98
  summary: Fork of the feedbag gem.
76
99
  test_files:
77
100
  - test/atom_autodiscovery_test.rb
101
+ - test/feedbag_test.rb
102
+ - test/test_helper.rb
data/.gitignore DELETED
@@ -1,30 +0,0 @@
1
- *.swp
2
- **/*.pid
3
- log/*.log
4
- log/*.pid
5
- tmp
6
- .DS_Store
7
- public/cache/**/*
8
- public/system/**/*
9
- doc/**/*
10
- db/*.sqlite3
11
- .project
12
- .loadpath
13
- nbproject/
14
- .idea
15
- testjour.log
16
- *.so
17
- *.o
18
- Makefile
19
- mkmf.log
20
- *.bundle
21
- conftest
22
- content/
23
- .idea
24
- *.sw?
25
- .DS_Store
26
- coverage
27
- rdoc
28
- pkg
29
- pkg/*
30
- log/*
@@ -1 +0,0 @@
1
- require File.join File.dirname(__FILE__), "..", "lib", "feedbag"