feedium 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/feedium/request.rb +2 -1
- data/lib/feedium/version.rb +1 -1
- data/lib/feedium.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4094acc1889ad67660ad785ef74fb706977bc157
|
4
|
+
data.tar.gz: 00473a229fc529edbab3d01653a5cf135014ac52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65b8e311d013a24083b5c12eecd563d4aa68bb549233d97de10b3d021070db165dd75c9353abcd7e820c68305366356c86417e2041707929374563e7ae58edbf
|
7
|
+
data.tar.gz: 45358b9a7b6cd0b2b1c87124dfeca32fa5fcdd22fcc0fa87930fd0f98af205e040bf3039aa4dfeb882490c46edf6aecc877eefaa109c78c72d92736eb1fa7a81
|
data/lib/feedium/request.rb
CHANGED
@@ -5,6 +5,7 @@ class Feedium::Request
|
|
5
5
|
MAX_CONTENT_SIZE = 5 * 1048576 # bytes in 1MB
|
6
6
|
|
7
7
|
def initialize(url, base_uri = nil)
|
8
|
+
url = url.downcase.strip
|
8
9
|
url = URI.parse(base_uri).merge(url).to_s if base_uri
|
9
10
|
|
10
11
|
begin
|
@@ -19,7 +20,7 @@ class Feedium::Request
|
|
19
20
|
query = @uri.query.nil? ? '' : "?#{@uri.query}"
|
20
21
|
@url = "#{@uri.scheme}://#{@uri.host}#{@uri.path}#{query}"
|
21
22
|
|
22
|
-
raise Feedium::RequestError.new('Not valid url') unless @url
|
23
|
+
raise Feedium::RequestError.new('Not valid url') unless @url =~ URI_REQEX
|
23
24
|
|
24
25
|
begin
|
25
26
|
@io = open(url, {
|
data/lib/feedium/version.rb
CHANGED
data/lib/feedium.rb
CHANGED
@@ -21,7 +21,7 @@ module Feedium
|
|
21
21
|
|
22
22
|
def self.find(url)
|
23
23
|
begin
|
24
|
-
uri = URI.parse(url.index('http') ? url : "http://#{url}")
|
24
|
+
uri = URI.parse(url.downcase.index('http') ? url : "http://#{url}")
|
25
25
|
query = uri.query.nil? ? '' : "?#{uri.query}"
|
26
26
|
url = "#{uri.scheme}://#{uri.host}#{uri.path}#{query}"
|
27
27
|
rescue URI::InvalidURIError => e
|
@@ -31,6 +31,7 @@ module Feedium
|
|
31
31
|
return @request.url if self.feed?(url)
|
32
32
|
|
33
33
|
@body = @body || @request.io.read
|
34
|
+
|
34
35
|
doc = Nokogiri::HTML(@body)
|
35
36
|
|
36
37
|
if doc.at('base') && doc.at('base')['href']
|
@@ -69,9 +70,10 @@ module Feedium
|
|
69
70
|
def self.feed?(url)
|
70
71
|
@request = Request.new(url, @base_uri)
|
71
72
|
@request.send
|
73
|
+
meta_type = @request.io.meta['content-type']
|
72
74
|
|
73
75
|
content_type = @request.io.content_type.downcase
|
74
|
-
content_type =
|
76
|
+
content_type = meta_type.gsub(/;.*$/, '') if content_type == 'application/octet-stream' && !meta_type.nil?
|
75
77
|
|
76
78
|
is_feed = CONTENT_TYPES.include?(content_type) ? true : false
|
77
79
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feedium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|