feedbag 0.10 → 0.10.3
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 +29 -0
- data/lib/feedbag.rb +11 -9
- metadata +20 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c5439ea287031a4c8aa34a87ade233f73c89acaffb8c03e05f4a1bc9fc1f9eb7
|
4
|
+
data.tar.gz: 043fd828e69509b5a15260c8dc0e0991a70dbc2c01c7128176f74680b640d6f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b3d6f64e975c623f8bc8046670fef214a0209cd09fb33e81b6a27e9684175f48fa950a1803609bb7334b31160df5cd107eaf3af525fcb423bba2b06f8986102
|
7
|
+
data.tar.gz: a5c04f3e465f4e36c570e6a6f42f4c75246d4ef94fbb1e815530d1b9c9efd5e5cdbb7b248eca2ab97044ae18a7630b820aacdfcf8538721d59299ecfc40e82f7
|
data/COPYING
CHANGED
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
|
|
@@ -37,6 +62,10 @@ You can also use the command line tool for quick queries, if you install the gem
|
|
37
62
|
- Because it's a single file you can embed easily in your application.
|
38
63
|
- Because it's faster than anything else.
|
39
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
|
+
|
40
69
|
### Author
|
41
70
|
|
42
71
|
[David Moreno](http://damog.net/) <[damog@damog.net](mailto:damog@damog.net)>.
|
data/lib/feedbag.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
# Copyright (c) 2008-2019 David Moreno <
|
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.3'
|
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 = 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,7 @@ class Feedbag
|
|
166
168
|
end
|
167
169
|
|
168
170
|
def looks_like_feed?(url)
|
169
|
-
if url =~ /(\.(rdf|xml|rss)(\?([\w'\-%]?(=[\w'\-%.]*)?(
|
171
|
+
if url =~ /(\.(rdf|xml|rss)(\?([\w'\-%]?(=[\w'\-%.]*)?(&|#|\+|\;)?)+)?(:[\w'\-%]+)?$|feed=(rss|atom)|(atom|feed)\/?$)/i
|
170
172
|
true
|
171
173
|
else
|
172
174
|
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:
|
4
|
+
version: 0.10.3
|
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
|
@@ -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
|
@@ -127,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
|
-
|
131
|
-
|
132
|
-
signing_key:
|
130
|
+
rubygems_version: 3.1.4
|
131
|
+
signing_key:
|
133
132
|
specification_version: 4
|
134
133
|
summary: RSS/Atom feed auto-discovery tool
|
135
134
|
test_files: []
|