feedbag 0.9.8 → 0.10.2

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 +44 -13
  4. data/lib/feedbag.rb +14 -11
  5. metadata +28 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d849beafed42f6eaf06f5847d525b284990ea308
4
- data.tar.gz: 59de9e7d7692ef586d82812bec5086b7570e75e1
2
+ SHA256:
3
+ metadata.gz: 90acb0f6598522043d717b5fbba5f9675408b4f06c45659416a02581d64adecb
4
+ data.tar.gz: 71077f0a64463a4cae1bb8bd6d3af48bdf2efd9afdfecc1b5041161c97e1c638
5
5
  SHA512:
6
- metadata.gz: 9a3d98e90e7f48bcbb44a461ff35f674737b2c4d93c09f137e33b3afdba4fdfb69221681ae43778aa39c7724d5305ca12ae38f258d83ff08294d1799d8374819
7
- data.tar.gz: 367c78e9308d3e8ec85d3576c41d4f56057bc42766c5660d7adbdf7e6b52ccf3e4bd6062216b3031c240655168e557f37e55042584d2607d64ed530c84e90a17
6
+ metadata.gz: faa0ef3f90c3fb9d73f6f64253f6a3e7a3ecc4be7220017277a2c8d598b82ec09209b85cfcc39077925fd801e8034e98835a4514d1a8cc899d63a65c2a8c254c
7
+ data.tar.gz: 31ec8d217ac7b30f6180ac3c9447ef3f79cdb8a2baea2aee9d1e96dc203d7366af2ae494287fb4cc8291c57a7aa0537bcb677c5db2ae639d8da62990985e1cd0
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
data/README.markdown CHANGED
@@ -5,14 +5,16 @@ 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
 
@@ -20,13 +22,38 @@ Feedbag is Ruby's favorite auto-discovery tool/library!
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
32
+
33
+
34
+ ### Usage
35
+ Feedbag will find all RSS feed types. Here's an example of finding ATOM and JSON Feed
36
+
37
+ ```ruby
38
+ > Feedbag.find('https://daringfireball.net')
39
+ => ["https://daringfireball.net/feeds/main", "https://daringfireball.net/feeds/json", "https://daringfireball.net/linked/2021/02/17/bookfeed"]
40
+ ```
41
+
42
+ Feedbag defaults to a User-Agent string of **Feedbag/1.10.2**, however you can override this
43
+
44
+ ```ruby
45
+ 0> Feedbag.find('https://kottke.org', 'User-Agent' => "My Personal Agent/1.0.1")
46
+ => ["http://feeds.kottke.org/main", "http://feeds.kottke.org/json"]
47
+ ````
48
+
49
+ The other options passed to find, will be passed to OpenURI. For example:
50
+
51
+ ```ruby
52
+ Feedbag.find("https://kottke.org", 'User-Agent' => "My Personal Agent/1.0.1", open_timeout: 1000)
53
+ ```
54
+
55
+ You can find the other options to OpenURI [here](https://rubyapi.org/o/openuri/openread#method-i-open).
56
+
30
57
 
31
58
  ### Why should you use it?
32
59
 
@@ -35,13 +62,17 @@ You can also use the command line tool for quick queries, if you install the gem
35
62
  - Because it's a single file you can embed easily in your application.
36
63
  - Because it's faster than anything else.
37
64
 
65
+ ### Web Service
66
+
67
+ 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).
68
+
38
69
  ### Author
39
70
 
40
71
  [David Moreno](http://damog.net/) <[damog@damog.net](mailto:damog@damog.net)>.
41
72
 
42
73
  ### Donations
43
74
 
44
- ![Superfeedr](http://damog.net/files/misc/superfeedr_150.png)
75
+ ![Superfeedr](https://raw.githubusercontent.com/damog/feedbag/master/img/superfeedr_150.png)
45
76
 
46
77
  [Superfeedr](http://superfeedr.com) has kindly financially [supported](https://github.com/damog/feedbag/issues/9) the development of Feedbag.
47
78
 
data/lib/feedbag.rb CHANGED
@@ -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
@@ -25,10 +25,9 @@ require "rubygems"
25
25
  require "nokogiri"
26
26
  require "open-uri"
27
27
  require "net/http"
28
- require "open_uri_redirections"
29
28
 
30
29
  class Feedbag
31
-
30
+ VERSION = '0.10.2'
32
31
  CONTENT_TYPES = [
33
32
  'application/x.atom+xml',
34
33
  'application/atom+xml',
@@ -36,19 +35,22 @@ class Feedbag
36
35
  'text/xml',
37
36
  'application/rss+xml',
38
37
  'application/rdf+xml',
39
- 'application/json',
38
+ 'application/json',
39
+ 'application/feed+json'
40
40
  ].freeze
41
41
 
42
42
  def self.feed?(url)
43
43
  new.feed?(url)
44
44
  end
45
45
 
46
- def self.find(url, args = {})
47
- new.find(url, args = {})
46
+ def self.find(url, options = {})
47
+ new(options: options).find(url, **options)
48
48
  end
49
49
 
50
- def initialize
50
+ def initialize(options: nil)
51
51
  @feeds = []
52
+ @options = options || {}
53
+ @options["User-Agent"] ||= "Feedbag/#{VERSION}"
52
54
  end
53
55
 
54
56
  def feed?(url)
@@ -68,7 +70,7 @@ class Feedbag
68
70
  end
69
71
  end
70
72
 
71
- def find(url, args = {})
73
+ def find(url, options = {})
72
74
  url_uri = URI.parse(url)
73
75
  url = nil
74
76
  if url_uri.scheme.nil?
@@ -97,7 +99,7 @@ class Feedbag
97
99
  end
98
100
 
99
101
  begin
100
- html = open(url, :allow_redirections => :all) do |f|
102
+ html = URI.open(url, **@options) do |f|
101
103
  content_type = f.content_type.downcase
102
104
  if content_type == "application/octet-stream" # open failed
103
105
  content_type = f.meta["content-type"].gsub(/;.*$/, '')
@@ -128,7 +130,7 @@ class Feedbag
128
130
  end
129
131
  end
130
132
 
131
- doc.xpath("//link[@rel='alternate' and @type='application/json'][@href]").each do |e|
133
+ doc.xpath("//link[@rel='alternate' and @type='application/json'][@href]").each do |e|
132
134
  self.add_feed(e['href'], url, @base_uri) if self.looks_like_feed?(e['href'])
133
135
  end
134
136
 
@@ -166,7 +168,8 @@ class Feedbag
166
168
  end
167
169
 
168
170
  def looks_like_feed?(url)
169
- if url =~ /(\.(rdf|xml|rss)$|feed=(rss|atom)|(atom|feed)\/?$)/i
171
+ puts url
172
+ if url =~ /(\.(rdf|xml|rss)(\?([\w'\-%]?(=[\w'\-%.]*)?(&|#|\+|\;)?)+)?(:[\w'\-%]+)?$|feed=(rss|atom)|(atom|feed)\/?$)/i
170
173
  true
171
174
  else
172
175
  false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedbag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moreno
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-18 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -16,28 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: open_uri_redirections
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
19
+ version: '1.8'
20
+ - - ">="
32
21
  - !ruby/object:Gem::Version
33
- version: '0.2'
22
+ version: 1.8.2
34
23
  type: :runtime
35
24
  prerelease: false
36
25
  version_requirements: !ruby/object:Gem::Requirement
37
26
  requirements:
38
27
  - - "~>"
39
28
  - !ruby/object:Gem::Version
40
- version: '0.2'
29
+ version: '1.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.8.2
41
33
  - !ruby/object:Gem::Dependency
42
34
  name: shoulda
43
35
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +78,20 @@ dependencies:
86
78
  - - "~>"
87
79
  - !ruby/object:Gem::Version
88
80
  version: '3'
81
+ - !ruby/object:Gem::Dependency
82
+ name: byebug
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '11'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '11'
89
95
  description: Ruby's favorite feed auto-discovery tool
90
96
  email: damog@damog.net
91
97
  executables:
@@ -104,7 +110,7 @@ homepage: http://github.com/damog/feedbag
104
110
  licenses:
105
111
  - MIT
106
112
  metadata: {}
107
- post_install_message:
113
+ post_install_message:
108
114
  rdoc_options:
109
115
  - "--main"
110
116
  - README.markdown
@@ -121,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
127
  - !ruby/object:Gem::Version
122
128
  version: '0'
123
129
  requirements: []
124
- rubyforge_project: feedbag
125
- rubygems_version: 2.6.11
126
- signing_key:
130
+ rubygems_version: 3.1.4
131
+ signing_key:
127
132
  specification_version: 4
128
- summary: Ruby's favorite feed auto-discovery tool
133
+ summary: RSS/Atom feed auto-discovery tool
129
134
  test_files: []