feedbag 0.9.4 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +5 -5
  2. data/COPYING +1 -1
  3. data/README.markdown +28 -17
  4. data/lib/feedbag.rb +14 -9
  5. metadata +44 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 94365be8a983babf63632ca645a62c54a841de68
4
- data.tar.gz: 740c148f54225e5e8294c57389b8d1d8936909e5
2
+ SHA256:
3
+ metadata.gz: 221831541154a34ade903d403c0c546cd01d7a683c69d27dee92eadd9c6bd2be
4
+ data.tar.gz: a633436162c4eb75fcb7222267d533a4bc05fa08506e55bd66865eb2b6bf29a2
5
5
  SHA512:
6
- metadata.gz: f06c1b71898a144012b1f38b6c5f036776cd0b4899be3e6952fb2b5daa4bbafdccc4d007a653cd73c85aaa79b03f61b0ee34f82b4a712092a0a1849ce3965b27
7
- data.tar.gz: cb16d0536e2dc7ec3b125f3b0c3557412901ee92ffa2f519f8ce19340e279698114f4c836b310166ca2768d9984811fea3214112fed15af197e45986ba23be11
6
+ metadata.gz: d18f37165eb5b0d8ee2095bc6f0d0e7356b8b4247722cb02d115899664fbb97898b4d216ff52f0691c63d5c828e0ddd6c4cdc1bf61e9ae37963e19b3ee641c75
7
+ data.tar.gz: 77c58a1de3a75ec6d0075d2ac98893d47a8711250fdb48259fab329e846424532ebb3858bef3f5923f18a2b75a029da52e7eb5cb144d26b4964bf6f0f09d843a
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2008-2014 David Moreno <david@axiombox.com>
1
+ Copyright (C) 2008-2021 David Moreno <damog@damog.net>
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
@@ -5,41 +5,52 @@ Feedbag is Ruby's favorite auto-discovery tool/library!
5
5
 
6
6
  ### Quick synopsis
7
7
 
8
- >> require "feedbag"
9
- => true
10
- >> Feedbag.find "damog.net/blog"
11
- => ["http://damog.net/blog/index.rss", "http://damog.net/blog/tags/feed", "http://damog.net/blog/tags/rfeed"]
12
- >> Feedbag.feed? "perl.org"
13
- => false
14
- >> Feedbag.feed?("http://jobs.perl.org/rss/standard.rss")
15
- => true
8
+ ```ruby
9
+ >> require "feedbag"
10
+ => true
11
+ >> Feedbag.find "damog.net/blog"
12
+ => ["http://damog.net/blog/atom.xml"]
13
+ >> Feedbag.feed? "perl.org"
14
+ => false
15
+ >> Feedbag.feed?("https://m.signalvnoise.com/feed")
16
+ => true
17
+ ```
16
18
 
17
19
  ### Installation
18
20
 
19
- $ gem install feedbag
21
+ $ gem install feedbag
20
22
 
21
23
  Or just grab feedbag.rb and use it on your own project:
22
24
 
23
- $ wget http://github.com/damog/feedbag/raw/master/lib/feedbag.rb
25
+ $ wget https://raw.githubusercontent.com/damog/feedbag/master/lib/feedbag.rb
24
26
 
25
27
  You can also use the command line tool for quick queries, if you install the gem:
26
28
 
27
- $ feedbag http://rubygems.org/profiles/damog
28
- == http://rubygems.org/profiles/damog:
29
- - http://feeds.feedburner.com/gemcutter-latest
29
+ » feedbag https://www.ruby-lang.org/en/
30
+ == https://www.ruby-lang.org/en/:
31
+ - https://www.ruby-lang.org/en/feeds/news.rss
30
32
 
31
33
  ### Why should you use it?
32
34
 
33
35
  - Because it only uses [Nokogiri](http://nokogiri.org/) as dependency.
34
36
  - Because it follows modern feed filename conventions (like those ones used by WordPress blogs, or Blogger, etc).
35
37
  - Because it's a single file you can embed easily in your application.
36
- - Because it's faster than rfeedfinder.
38
+ - Because it's faster than anything else.
39
+
40
+ ### Web Service
41
+
42
+ Now you can also POST directly into an AWS Lambda function webservice that runs `Feedbag.find()`. Don't overuse it. It's [here](https://github.com/damog/aws-lambda-feedbag).
37
43
 
38
44
  ### Author
39
45
 
40
- [David Moreno](http://damog.net/) <[david@axiombox.com](mailto:david@axiombox.com)>.
46
+ [David Moreno](http://damog.net/) <[damog@damog.net](mailto:damog@damog.net)>.
41
47
 
42
- ### Copyright
48
+ ### Donations
43
49
 
44
- This is free software. See [COPYING](http://github.com/damog/feedbag/master/COPYING) for more information.
50
+ ![Superfeedr](https://raw.githubusercontent.com/damog/feedbag/master/img/superfeedr_150.png)
51
+
52
+ [Superfeedr](http://superfeedr.com) has kindly financially [supported](https://github.com/damog/feedbag/issues/9) the development of Feedbag.
53
+
54
+ ### Copyright
45
55
 
56
+ This is and will always be free software. See [COPYING](https://raw.githubusercontent.com/damog/feedbag/master/COPYING) for more information.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- # Copyright (c) 2008-2014 David Moreno <david@axiombox.com>
3
+ # Copyright (c) 2008-2019 David Moreno <damog@damog.net>
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining
6
6
  # a copy of this software and associated documentation files (the
@@ -9,10 +9,10 @@
9
9
  # distribute, sublicense, and/or sell copies of the Software, and to
10
10
  # permit persons to whom the Software is furnished to do so, subject to
11
11
  # the following conditions:
12
- #
12
+ #
13
13
  # The above copyright notice and this permission notice shall be
14
14
  # included in all copies or substantial portions of the Software.
15
- #
15
+ #
16
16
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
17
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
18
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -25,6 +25,7 @@ require "rubygems"
25
25
  require "nokogiri"
26
26
  require "open-uri"
27
27
  require "net/http"
28
+ require "open_uri_redirections"
28
29
 
29
30
  class Feedbag
30
31
 
@@ -35,6 +36,7 @@ class Feedbag
35
36
  'text/xml',
36
37
  'application/rss+xml',
37
38
  'application/rdf+xml',
39
+ 'application/json',
38
40
  ].freeze
39
41
 
40
42
  def self.feed?(url)
@@ -95,7 +97,7 @@ class Feedbag
95
97
  end
96
98
 
97
99
  begin
98
- html = open(url) do |f|
100
+ html = URI.open(url, :allow_redirections => :all) do |f|
99
101
  content_type = f.content_type.downcase
100
102
  if content_type == "application/octet-stream" # open failed
101
103
  content_type = f.meta["content-type"].gsub(/;.*$/, '')
@@ -114,19 +116,22 @@ class Feedbag
114
116
 
115
117
  # first with links
116
118
  (doc/"atom:link").each do |l|
117
- next unless l["rel"]
119
+ next unless l["rel"] && l["href"].present?
118
120
  if l["type"] and CONTENT_TYPES.include?(l["type"].downcase.strip) and l["rel"].downcase == "self"
119
121
  self.add_feed(l["href"], url, @base_uri)
120
122
  end
121
123
  end
122
124
 
123
- (doc/"link").each do |l|
124
- next unless l["rel"]
125
- if l["type"] and CONTENT_TYPES.include?(l["type"].downcase.strip) and (l["rel"].downcase =~ /alternate/i or l["rel"] == "service.feed")
125
+ doc.xpath("//link[@rel='alternate' or @rel='service.feed'][@href][@type]").each do |l|
126
+ if CONTENT_TYPES.include?(l['type'].downcase.strip)
126
127
  self.add_feed(l["href"], url, @base_uri)
127
128
  end
128
129
  end
129
130
 
131
+ doc.xpath("//link[@rel='alternate' and @type='application/json'][@href]").each do |e|
132
+ self.add_feed(e['href'], url, @base_uri) if self.looks_like_feed?(e['href'])
133
+ end
134
+
130
135
  (doc/"a").each do |a|
131
136
  next unless a["href"]
132
137
  if self.looks_like_feed?(a["href"]) and (a["href"] =~ /\// or a["href"] =~ /#{url_uri.host}/)
@@ -161,7 +166,7 @@ class Feedbag
161
166
  end
162
167
 
163
168
  def looks_like_feed?(url)
164
- if url =~ /(\.(rdf|xml|rdf|rss)$|feed=(rss|atom)|(atom|feed)\/?$)/i
169
+ if url =~ /(\.(rdf|xml|rss)(\?([\w'\-%]?(=[\w'\-%.]*)?(&|#)?)+)?(:[\w'\-%]+)?$|feed=(rss|atom)|(atom|feed)\/?$)/i
165
170
  true
166
171
  else
167
172
  false
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedbag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moreno
8
- - Derek Willis
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-03 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nokogiri
@@ -17,28 +16,48 @@ dependencies:
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: '0'
19
+ version: '1.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.8.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.8.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: open_uri_redirections
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.2'
21
40
  type: :runtime
22
41
  prerelease: false
23
42
  version_requirements: !ruby/object:Gem::Requirement
24
43
  requirements:
25
44
  - - "~>"
26
45
  - !ruby/object:Gem::Version
27
- version: '0'
46
+ version: '0.2'
28
47
  - !ruby/object:Gem::Dependency
29
48
  name: shoulda
30
49
  requirement: !ruby/object:Gem::Requirement
31
50
  requirements:
32
51
  - - "~>"
33
52
  - !ruby/object:Gem::Version
34
- version: '0'
53
+ version: '3'
35
54
  type: :development
36
55
  prerelease: false
37
56
  version_requirements: !ruby/object:Gem::Requirement
38
57
  requirements:
39
58
  - - "~>"
40
59
  - !ruby/object:Gem::Version
41
- version: '0'
60
+ version: '3'
42
61
  - !ruby/object:Gem::Dependency
43
62
  name: mocha
44
63
  requirement: !ruby/object:Gem::Requirement
@@ -59,8 +78,22 @@ dependencies:
59
78
  - - ">="
60
79
  - !ruby/object:Gem::Version
61
80
  version: 0.12.0
62
- description: Ruby's favorite feed auto-discoverty tool
63
- email: david@axiombox.com
81
+ - !ruby/object:Gem::Dependency
82
+ name: webmock
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '3'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '3'
95
+ description: Ruby's favorite feed auto-discovery tool
96
+ email: damog@damog.net
64
97
  executables:
65
98
  - feedbag
66
99
  extensions: []
@@ -94,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
127
  - !ruby/object:Gem::Version
95
128
  version: '0'
96
129
  requirements: []
97
- rubyforge_project: feedbag
98
- rubygems_version: 2.2.2
130
+ rubygems_version: 3.1.4
99
131
  signing_key:
100
132
  specification_version: 4
101
- summary: Ruby's favorite feed auto-discovery tool
133
+ summary: RSS/Atom feed auto-discovery tool
102
134
  test_files: []