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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a79e7dd51899b473c9b768f80850c492bc329aeb
4
- data.tar.gz: a7255ae3b952fa9170b903df048af6bd5e13e818
3
+ metadata.gz: 4094acc1889ad67660ad785ef74fb706977bc157
4
+ data.tar.gz: 00473a229fc529edbab3d01653a5cf135014ac52
5
5
  SHA512:
6
- metadata.gz: 5cccf7735c415e839549fe1fbb9922b410abd039396554e93f5e8337e092de8cd40f4820ac61d764d6710958e49c0e33e1a9956f2b3b13fe7de934b5655a778d
7
- data.tar.gz: df78c05128014fd4d35f42269f8b01347dd8079a0c27fb60534a9d0df44c216a26fc781e6f2b2a2543ccca7c41f1aa5dd69edbb4c0969bf33a45d249e1d937c8
6
+ metadata.gz: 65b8e311d013a24083b5c12eecd563d4aa68bb549233d97de10b3d021070db165dd75c9353abcd7e820c68305366356c86417e2041707929374563e7ae58edbf
7
+ data.tar.gz: 45358b9a7b6cd0b2b1c87124dfeca32fa5fcdd22fcc0fa87930fd0f98af205e040bf3039aa4dfeb882490c46edf6aecc877eefaa109c78c72d92736eb1fa7a81
@@ -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.downcase =~ URI_REQEX
23
+ raise Feedium::RequestError.new('Not valid url') unless @url =~ URI_REQEX
23
24
 
24
25
  begin
25
26
  @io = open(url, {
@@ -1,3 +1,3 @@
1
1
  module Feedium
2
- VERSION = '0.1.12'
2
+ VERSION = '0.1.13'
3
3
  end
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 = @request.io.meta['content-type'].gsub(/;.*$/, '') if content_type == 'application/octet-stream'
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.12
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-28 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler