feedbag 0.10.1 → 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 +4 -4
- data/README.markdown +25 -0
- data/lib/feedbag.rb +11 -8
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
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/README.markdown
CHANGED
@@ -29,6 +29,31 @@ You can also use the command line tool for quick queries, if you install the gem
|
|
29
29
|
» feedbag https://www.ruby-lang.org/en/
|
30
30
|
== https://www.ruby-lang.org/en/:
|
31
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
|
+
|
32
57
|
|
33
58
|
### Why should you use it?
|
34
59
|
|
data/lib/feedbag.rb
CHANGED
@@ -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',
|
@@ -37,18 +36,21 @@ class Feedbag
|
|
37
36
|
'application/rss+xml',
|
38
37
|
'application/rdf+xml',
|
39
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 = URI.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(/;.*$/, '')
|
@@ -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,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feedbag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
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
11
|
date: 2020-11-28 00:00:00.000000000 Z
|
@@ -30,20 +30,6 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
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'
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0.2'
|
47
33
|
- !ruby/object:Gem::Dependency
|
48
34
|
name: shoulda
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,6 +78,20 @@ dependencies:
|
|
92
78
|
- - "~>"
|
93
79
|
- !ruby/object:Gem::Version
|
94
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'
|
95
95
|
description: Ruby's favorite feed auto-discovery tool
|
96
96
|
email: damog@damog.net
|
97
97
|
executables:
|
@@ -110,7 +110,7 @@ homepage: http://github.com/damog/feedbag
|
|
110
110
|
licenses:
|
111
111
|
- MIT
|
112
112
|
metadata: {}
|
113
|
-
post_install_message:
|
113
|
+
post_install_message:
|
114
114
|
rdoc_options:
|
115
115
|
- "--main"
|
116
116
|
- README.markdown
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubygems_version: 3.1.4
|
131
|
-
signing_key:
|
131
|
+
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: RSS/Atom feed auto-discovery tool
|
134
134
|
test_files: []
|