rss-client 2.0.9 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007, 2008 Stoyan Zhekov
1
+ Copyright (c) 2010 Stoyan Zhekov
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -18,4 +18,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
@@ -1,19 +1,19 @@
1
- = RSSClient: Fetching and parsing RSS feeds with easy
1
+ = rss-client: Fetching and parsing RSS feeds with easy
2
2
 
3
3
  == Download
4
4
 
5
- The latest version of rake can be found at
5
+ The latest version of rss-client can be found at
6
6
 
7
- * http://rubyforge.org/project/...
7
+ * http://github.com/zh/rssclient/
8
8
 
9
9
 
10
10
  == Installation
11
11
 
12
12
  === Normal Installation
13
13
 
14
- You can install rake with the following command.
14
+ You can install rss-client with the following command.
15
15
 
16
- % ruby install.rb
16
+ % rake install
17
17
 
18
18
  from its distribution directory.
19
19
 
@@ -63,17 +63,20 @@ Download and install rss-client with the following.
63
63
  [<b>Todd Werth</b>] For the ruby command-line application skeleton
64
64
 
65
65
 
66
- == License
66
+ == Note on Patches/Pull Requests
67
+
68
+ * Fork the project.
69
+ * Make your feature addition or bug fix.
70
+ * Add tests for it. This is important so I don't break it in a
71
+ future version unintentionally.
72
+ * Commit, do not mess with rakefile, version, or history.
73
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
74
+ * Send me a pull request. Bonus points for topic branches.
67
75
 
68
- rss-client is available under an MIT-style license.
76
+ == Copyright
69
77
 
70
- :include: MIT-LICENSE
71
-
72
-
73
- == Other stuff
74
-
75
- Author:: Stoyan Zhekov <stoyan@gmail.com>
78
+ Author:: Stoyan Zhekov <zh@zhware.net>
76
79
  Requires:: Ruby 1.8.0 or later
77
- License:: Copyright (c) 2007, 2008 Stoyan Zhekov
78
- Released under an MIT-style license. See the MIT-LICENSE file
79
- included in the distribution.
80
+ License:: Copyright (c) 2010 Stoyan Zhekov.
81
+ Released under an MIT-style license.
82
+ See LICENSE for details.
data/Rakefile CHANGED
@@ -1,83 +1,79 @@
1
1
  require 'rubygems'
2
- Gem::manage_gems
3
-
4
2
  require 'rake'
5
- require 'rake/clean'
6
- require 'rake/packagetask'
7
- require 'rake/gempackagetask'
8
- require 'rake/rdoctask'
9
- require 'fileutils'
10
- include FileUtils
11
-
12
- $:.unshift File.join(File.dirname(__FILE__), "lib")
13
3
 
14
- NAME = "rss-client"
15
-
16
- RDOC_FILES = %w[
4
+ begin
5
+ require 'jeweler'
6
+ project_name = "rss-client"
7
+ rdoc_files = %w[
17
8
  lib
18
- README
19
- MIT-LICENSE
20
- ]
21
-
22
- RDOC_OPTS = %w[
9
+ README.rdoc
10
+ LICENSE
11
+ ]
12
+ rdoc_opts = %w[
23
13
  --line-numbers
24
14
  --inline-source
25
15
  --all
26
16
  --quiet
27
- --title RSSClient:\ Fetching\ and\ parsing\ RSS\ feeds\ with\ easy
28
- --main README
17
+ --title rss-client:\ Fetching\ and\ parsing\ RSS\ feeds\ with\ easy
18
+ --main README.rdoc
29
19
  --exclude "^(_darcs|.hg|.svn|spec|bin|pkg)/"
30
- ]
31
-
32
- load 'rake_tasks/annotations.rake'
20
+ ]
33
21
 
34
- spec = Gem::Specification.new do |s|
35
- s.name = NAME
36
- s.version = "2.0.9"
37
- s.author = "Stoyan Zhekov"
38
- s.email = "stoyan@gmail.com"
39
- s.rubyforge_project = NAME
40
- s.homepage = "http://www.assembla.com/wiki/show/#{NAME}"
41
- s.platform = Gem::Platform::RUBY
42
- s.summary = "Fetching and parsing RSS feeds with easy"
43
- s.files = (RDOC_FILES + %w[install.rb] + %w[Rakefile] + Dir["{bin,lib,rake_tasks,spec}/**/*"]).uniq
44
- s.test_files = Dir['spec/spec_*.rb']
45
- s.require_path = "lib"
46
- s.bindir = "bin"
47
- s.executables = ['rssclient']
48
- s.default_executable = 'rssclient'
49
- s.has_rdoc = true
50
- s.extra_rdoc_files = RDOC_FILES
51
- s.rdoc_options = RDOC_OPTS
52
- s.add_dependency("feed-normalizer", ">= 1.4.0")
22
+ Jeweler::Tasks.new do |gem|
23
+ gem.name = project_name
24
+ gem.summary = %Q{Fetching and parsing RSS feeds with easy}
25
+ gem.description = %Q{Ruby library for fetching (http-access2) and parsing (feed-normalizer) RSS (and Atom) feeds.}
26
+ gem.email = "zh@zhware.net"
27
+ gem.homepage = "http://github.com/zh/#{project_name}"
28
+ gem.authors = ["Stoyan Zhekov"]
29
+ gem.rubyforge_project = project_name
30
+ gem.platform = Gem::Platform::RUBY
31
+ gem.files = (rdoc_files + %w[Rakefile] + Dir["{bin,lib,rake_tasks,spec}/**/*"]).uniq
32
+ gem.test_files = Dir['spec/spec_*.rb']
33
+ gem.require_path = "lib"
34
+ gem.bindir = "bin"
35
+ gem.executables = ['rssclient']
36
+ gem.default_executable = 'rssclient'
37
+ gem.has_rdoc = true
38
+ gem.extra_rdoc_files = rdoc_files
39
+ gem.rdoc_options = rdoc_opts
40
+ gem.add_dependency('feed-normalizer', '>= 1.4.0')
41
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
42
+ end
43
+ rescue LoadError
44
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
53
45
  end
54
46
 
55
- Rake::GemPackageTask.new(spec) do |pkg|
56
- pkg.need_tar = true
57
- end
47
+ task :default => :spec
48
+ require 'spec/rake/spectask'
49
+ Spec::Rake::SpecTask.new {|t| t.spec_opts = ['--color']}
58
50
 
59
- desc "package and the gem"
60
- task :install do
61
- name = "#{spec.name}-#{spec.version}.gem"
62
- sh %{rake package}
63
- sh %{sudo gem install pkg/#{spec.name}-#{spec.version}.gem}
64
- end
51
+ task :test => :check_dependencies
65
52
 
66
- desc "uninstall the gem"
67
- task :uninstall => [:clean] do
68
- sh %{sudo gem uninstall #{spec.name}}
53
+ begin
54
+ require 'rcov/rcovtask'
55
+ Rcov::RcovTask.new do |test|
56
+ test.libs << 'spec'
57
+ test.pattern = 'spec/**/*_spec.rb'
58
+ test.verbose = true
59
+ test.rcov_opts = %w{--exclude rdoc\/,pkg\/,spec\/}
60
+ end
61
+ rescue LoadError
62
+ task :rcov do
63
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
64
+ end
69
65
  end
70
66
 
71
- desc "generate rdoc"
72
- task :rdoc => [:clean] do
73
- sh "rdoc #{(RDOC_OPTS + RDOC_FILES).join(' ')}"
74
- end
67
+ require 'rake/rdoctask'
68
+ Rake::RDocTask.new do |rdoc|
69
+ if File.exist?('VERSION')
70
+ version = File.read('VERSION')
71
+ else
72
+ version = ""
73
+ end
75
74
 
76
- desc "Run all the tests"
77
- task :test do
78
- sh "specrb -Ilib:spec -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
79
- end
80
-
81
- task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
82
- puts "generated latest version"
75
+ rdoc.rdoc_dir = 'rdoc'
76
+ rdoc.title = "rss-client #{version}"
77
+ rdoc.rdoc_files.include('README*')
78
+ rdoc.rdoc_files.include('lib/**/*.rb')
83
79
  end
@@ -26,10 +26,10 @@
26
26
  # -s, --since Only changes from {since} seconds ago
27
27
  #
28
28
  # == Author
29
- # Stoyan Zhekov <stoyan@gmail.com>
29
+ # Stoyan Zhekov <zh@zhware.net>
30
30
  #
31
31
  # == Copyright
32
- # Copyright (c) 2007 Stoyan Zhekov <stoyan@gmail.com>. Licensed under the MIT License:
32
+ # Copyright (c) 2010 Stoyan Zhekov <zh@zhware.net>. Licensed under the MIT License:
33
33
  # http://www.opensource.org/licenses/mit-license.php
34
34
 
35
35
  begin
@@ -43,7 +43,7 @@ require 'optparse'
43
43
  require 'rdoc/usage'
44
44
 
45
45
  class App
46
- VERSION = '2.0.9'
46
+ VERSION = '2.0.10'
47
47
 
48
48
  attr_reader :options
49
49
 
@@ -53,25 +53,35 @@ protected
53
53
  return nil unless @rssc_raw
54
54
 
55
55
  case @rssc_raw.status
56
- when 200
57
- # good
58
- when 301, 302
59
- @rssc_raw = get_url(@rssc_raw.header["Location"], opts)
60
- return nil unless @rssc_raw
61
-
62
- when 304
63
- # Not modified - nothing to do
64
- return nil
65
-
66
- when 401
67
- raise RuntimeError, "access denied, " + @rssc_raw.header['WWW-Authenticate'].to_s
68
- when 404
69
- raise RuntimeError, "feed [ #{url} ] not found"
70
- else
71
- raise RuntimeError, "can't fetch feed (unknown response code: #{@rssc_raw.status})"
56
+ when 200 # good
57
+ when 301, 302 # follow redirect ...
58
+ @rssc_raw = get_url(@rssc_raw.header["Location"], opts)
59
+ return nil unless @rssc_raw
60
+
61
+ when 304 # Not modified - nothing to do
62
+ return nil
63
+
64
+ # errors
65
+ when 401
66
+ raise RuntimeError, "access denied, " + @rssc_raw.header['WWW-Authenticate'].to_s
67
+ when 404
68
+ raise RuntimeError, "feed [ #{url} ] not found"
69
+ else
70
+ raise RuntimeError, "can't fetch feed (unknown response code: #{@rssc_raw.status})"
72
71
  end
72
+
73
+ return nil unless @rssc_raw.content
74
+
73
75
  # Parse the raw RSS
74
- return @rssc_raw.content ? FeedNormalizer::FeedNormalizer.parse(@rssc_raw.content) : nil
76
+ begin
77
+ FeedNormalizer::FeedNormalizer.parse(@rssc_raw.content, :try_others => true)
78
+ rescue NoMethodError
79
+ # undefined method `channel' for #<RSS::Atom::Feed:0x9f03b70>
80
+ # try a simpler parser ...
81
+ FeedNormalizer::FeedNormalizer.parse(@rssc_raw.content,
82
+ :try_others => true, :force_parser => FeedNormalizer::SimpleRssParser
83
+ )
84
+ end
75
85
  rescue RuntimeError => error
76
86
  @rssc_error = error
77
87
  return nil
@@ -1,10 +1,3 @@
1
- begin
2
- require 'bacon'
3
- rescue LoadError
4
- require 'rubygems'
5
- require 'bacon'
6
- end
7
-
8
- rssclient_dir = File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
9
- $LOAD_PATH.unshift(rssclient_dir)
10
- require 'rss-client'
1
+ $LOAD_PATH.unshift 'lib'
2
+ require 'rubygems'
3
+ require 'rss-client'
@@ -7,7 +7,7 @@ describe 'http-access2' do
7
7
  end
8
8
 
9
9
  it 'should have an object identity' do
10
- @client.should.not.be.same_as HTTPAccess2::Client.new
10
+ @client.should_not == HTTPAccess2::Client.new
11
11
  end
12
12
 
13
13
  end
@@ -0,0 +1,40 @@
1
+ require 'spec/helper'
2
+
3
+ class RSSFeed
4
+ include RSSClient
5
+
6
+ def self.fetch(*args)
7
+ self.new.fetch(*args)
8
+ end
9
+
10
+ def fetch(url)
11
+ get_feed url, OpenStruct.new
12
+ end
13
+ end
14
+
15
+ describe RSSClient do
16
+ describe 'basics' do
17
+ before do
18
+ @feed = RSSFeed.new
19
+ end
20
+
21
+ it 'should have an object identity' do
22
+ @feed.should_not == RSSFeed.new
23
+ end
24
+
25
+ it 'should have useful defaults' do
26
+ @feed.rssc_error.should == nil
27
+ @feed.rssc_raw.should == nil
28
+ end
29
+ end
30
+
31
+ describe 'parsing' do
32
+ it 'can read a normal feed' do
33
+ RSSFeed.fetch('http://rubyforge.org/export/rss_sfnews.php').entries.size.should >= 5
34
+ end
35
+
36
+ it 'can read weird feeds' do
37
+ RSSFeed.fetch('http://dotmovfest.blogspot.com/feeds/posts/default').entries.size.should >= 5
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rss-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.9
4
+ version: 2.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stoyan Zhekov
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-18 00:00:00 +09:00
12
+ date: 2010-01-05 00:00:00 +09:00
13
13
  default_executable: rssclient
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: feed-normalizer
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -21,35 +22,31 @@ dependencies:
21
22
  - !ruby/object:Gem::Version
22
23
  version: 1.4.0
23
24
  version:
24
- description:
25
- email: stoyan@gmail.com
25
+ description: Ruby library for fetching (http-access2) and parsing (feed-normalizer) RSS (and Atom) feeds.
26
+ email: zh@zhware.net
26
27
  executables:
27
28
  - rssclient
28
29
  extensions: []
29
30
 
30
31
  extra_rdoc_files:
31
- - lib
32
- - README
33
- - MIT-LICENSE
32
+ - LICENSE
33
+ - README.rdoc
34
34
  files:
35
- - lib
36
- - README
37
- - MIT-LICENSE
38
- - install.rb
35
+ - LICENSE
36
+ - README.rdoc
39
37
  - Rakefile
40
38
  - bin/rssclient
41
39
  - lib/rss-client.rb
42
- - lib/rss-client
43
40
  - lib/rss-client/http-access2.rb
44
- - lib/rss-client/http-access2
45
41
  - lib/rss-client/http-access2/cookie.rb
46
42
  - lib/rss-client/http-access2/http.rb
47
- - rake_tasks/annotations.rake
48
43
  - spec/helper.rb
49
- - spec/spec_http_access2.rb
50
- - spec/spec_rss_client.rb
44
+ - spec/spec_http_access2_spec.rb
45
+ - spec/spec_rss_client_spec.rb
51
46
  has_rdoc: true
52
- homepage: http://www.assembla.com/wiki/show/rss-client
47
+ homepage: http://github.com/zh/rss-client
48
+ licenses: []
49
+
53
50
  post_install_message:
54
51
  rdoc_options:
55
52
  - --line-numbers
@@ -57,9 +54,9 @@ rdoc_options:
57
54
  - --all
58
55
  - --quiet
59
56
  - --title
60
- - "RSSClient: Fetching and parsing RSS feeds with easy"
57
+ - "rss-client: Fetching and parsing RSS feeds with easy"
61
58
  - --main
62
- - README
59
+ - README.rdoc
63
60
  - --exclude
64
61
  - "\"^(_darcs|.hg|.svn|spec|bin|pkg)/\""
65
62
  require_paths:
@@ -79,10 +76,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
76
  requirements: []
80
77
 
81
78
  rubyforge_project: rss-client
82
- rubygems_version: 1.0.1
79
+ rubygems_version: 1.3.5
83
80
  signing_key:
84
- specification_version: 2
81
+ specification_version: 3
85
82
  summary: Fetching and parsing RSS feeds with easy
86
83
  test_files:
87
- - spec/spec_http_access2.rb
88
- - spec/spec_rss_client.rb
84
+ - spec/spec_http_access2_spec.rb
85
+ - spec/spec_rss_client_spec.rb
data/install.rb DELETED
@@ -1,84 +0,0 @@
1
- require 'rbconfig'
2
- require 'find'
3
- require 'ftools'
4
-
5
- include Config
6
-
7
- $ruby = CONFIG['ruby_install_name']
8
-
9
- ##
10
- # Install a binary file. We patch in on the way through to
11
- # insert a #! line. If this is a Unix install, we name
12
- # the command (for example) 'rssclient' and let the shebang line
13
- # handle running it. Under windows, we add a '.rb' extension
14
- # and let file associations to their stuff
15
- #
16
-
17
- def installBIN(from, opfile)
18
-
19
- tmp_dir = nil
20
- for t in [".", "/tmp", "c:/temp", $bindir]
21
- stat = File.stat(t) rescue next
22
- if stat.directory? and stat.writable?
23
- tmp_dir = t
24
- break
25
- end
26
- end
27
-
28
- fail "Cannot find a temporary directory" unless tmp_dir
29
- tmp_file = File.join(tmp_dir, "_tmp")
30
-
31
- File.open(from) do |ip|
32
- File.open(tmp_file, "w") do |op|
33
- ruby = File.join($realbindir, $ruby)
34
- op.puts "#!#{ruby} -w"
35
- op.write ip.read
36
- end
37
- end
38
-
39
- opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i
40
- File::install(tmp_file, File.join($bindir, opfile), 0755, true)
41
- File::unlink(tmp_file)
42
- end
43
-
44
- $sitedir = CONFIG["sitelibdir"]
45
- unless $sitedir
46
- version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
47
- $libdir = File.join(CONFIG["libdir"], "ruby", version)
48
- $sitedir = $:.find {|x| x =~ /site_ruby/}
49
- if !$sitedir
50
- $sitedir = File.join($libdir, "site_ruby")
51
- elsif $sitedir !~ Regexp.quote(version)
52
- $sitedir = File.join($sitedir, version)
53
- end
54
- end
55
-
56
- $bindir = CONFIG["bindir"]
57
-
58
- $realbindir = $bindir
59
-
60
- bindir = CONFIG["bindir"]
61
- if (destdir = ENV['DESTDIR'])
62
- $bindir = destdir + $bindir
63
- $sitedir = destdir + $sitedir
64
-
65
- File::makedirs($bindir)
66
- File::makedirs($sitedir)
67
- end
68
-
69
- # The library files
70
-
71
- files = Dir.chdir('lib') { Dir['**/*.rb'] }
72
-
73
- for fn in files
74
- fn_dir = File.dirname(fn)
75
- target_dir = File.join($sitedir, fn_dir)
76
- if ! File.exist?(target_dir)
77
- File.makedirs(target_dir)
78
- end
79
- File::install(File.join('lib', fn), File.join($sitedir, fn), 0644, true)
80
- end
81
-
82
- # and the executable
83
-
84
- installBIN("bin/rssclient", "rssclient")
@@ -1,84 +0,0 @@
1
- class SourceAnnotationExtractor
2
- class Annotation < Struct.new(:line, :tag, :text)
3
- def to_s(options={})
4
- s = "[%3d] " % line
5
- s << "[#{tag}] " if options[:tag]
6
- s << text
7
- end
8
- end
9
-
10
- def self.enumerate(tag, options={})
11
- extractor = new(tag)
12
- extractor.display(extractor.find, options)
13
- end
14
-
15
- attr_reader :tag
16
-
17
- def initialize(tag)
18
- @tag = tag
19
- end
20
-
21
- def find(dirs=%w(app lib test))
22
- dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
23
- end
24
-
25
- def find_in(dir)
26
- results = {}
27
-
28
- Dir.glob("#{dir}/*") do |item|
29
- next if File.basename(item)[0] == ?.
30
-
31
- if File.directory?(item)
32
- results.update(find_in(item))
33
- elsif item =~ /\.(builder|(r(?:b|xml|js)))$/
34
- results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
35
- elsif item =~ /\.(rhtml|erb)$/
36
- results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
37
- end
38
- end
39
-
40
- results
41
- end
42
-
43
- def extract_annotations_from(file, pattern)
44
- lineno = 0
45
- result = File.readlines(file).inject([]) do |list, line|
46
- lineno += 1
47
- next list unless line =~ pattern
48
- list << Annotation.new(lineno, $1, $2)
49
- end
50
- result.empty? ? {} : { file => result }
51
- end
52
-
53
- def display(results, options={})
54
- results.keys.sort.each do |file|
55
- puts "#{file}:"
56
- results[file].each do |note|
57
- puts " * #{note.to_s(options)}"
58
- end
59
- puts
60
- end
61
- end
62
- end
63
-
64
- desc "Enumerate all annotations"
65
- task :notes do
66
- SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
67
- end
68
-
69
- namespace :notes do
70
- desc "Enumerate all OPTIMIZE annotations"
71
- task :optimize do
72
- SourceAnnotationExtractor.enumerate "OPTIMIZE"
73
- end
74
-
75
- desc "Enumerate all FIXME annotations"
76
- task :fixme do
77
- SourceAnnotationExtractor.enumerate "FIXME"
78
- end
79
-
80
- desc "Enumerate all TODO annotations"
81
- task :todo do
82
- SourceAnnotationExtractor.enumerate "TODO"
83
- end
84
- end
@@ -1,22 +0,0 @@
1
- require 'spec/helper'
2
-
3
- class RSSFeed
4
- include RSSClient
5
- end
6
-
7
- describe 'rss-client' do
8
-
9
- before do
10
- @feed = RSSFeed.new
11
- end
12
-
13
- it 'should have an object identity' do
14
- @feed.should.not.be.same_as RSSFeed.new
15
- end
16
-
17
- it 'should have useful defaults' do
18
- @feed.rssc_error.should == nil
19
- @feed.rssc_raw.should == nil
20
- end
21
-
22
- end