feedbag 0.9.8 → 0.10.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.
- checksums.yaml +5 -5
- data/COPYING +1 -1
- data/README.markdown +44 -13
- data/lib/feedbag.rb +14 -11
- metadata +28 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 90acb0f6598522043d717b5fbba5f9675408b4f06c45659416a02581d64adecb
|
4
|
+
data.tar.gz: 71077f0a64463a4cae1bb8bd6d3af48bdf2efd9afdfecc1b5041161c97e1c638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faa0ef3f90c3fb9d73f6f64253f6a3e7a3ecc4be7220017277a2c8d598b82ec09209b85cfcc39077925fd801e8034e98835a4514d1a8cc899d63a65c2a8c254c
|
7
|
+
data.tar.gz: 31ec8d217ac7b30f6180ac3c9447ef3f79cdb8a2baea2aee9d1e96dc203d7366af2ae494287fb4cc8291c57a7aa0537bcb677c5db2ae639d8da62990985e1cd0
|
data/COPYING
CHANGED
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
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
|
-
|
28
|
-
==
|
29
|
-
|
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
|
-

|
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-
|
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,
|
47
|
-
new.find(url,
|
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,
|
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,
|
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
|
-
|
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.
|
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:
|
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.
|
20
|
-
|
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:
|
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: '
|
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
|
-
|
125
|
-
|
126
|
-
signing_key:
|
130
|
+
rubygems_version: 3.1.4
|
131
|
+
signing_key:
|
127
132
|
specification_version: 4
|
128
|
-
summary:
|
133
|
+
summary: RSS/Atom feed auto-discovery tool
|
129
134
|
test_files: []
|