feedium 0.1.8 → 0.1.9

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: 88e09c4e19588e353222c2e1acf629fa23a296dd
4
- data.tar.gz: 74cd929cc1d75047ee71656cc1980cde167a6c20
3
+ metadata.gz: c30edaee350209df22641b98d9a71c5304052d65
4
+ data.tar.gz: 283e0d3c69211aa2bda023102b49cd16be590407
5
5
  SHA512:
6
- metadata.gz: b539844393655def8253380f6f5d0bab699a80d3a3bd2763eb004212d29d2402b7b0e8284f1518f56bb8ecb044c601fd94aab932c8782b01ad939fa7bc9cc6a8
7
- data.tar.gz: 06d966f060970c067ee085273f5d7e38edfeaa359f6889df08f8a7a82c2c20501dbf73374dfd46b3cd6473f8a6c0dc53aee835d5cc2f96032f523d71a672e3b7
6
+ metadata.gz: 64ed566cf25077d6956c79b7dfcea583014dddfb02763da53e021d5c56a2e86e645a4ddf48a304ac962a51926fc2609570454fb10bb8fdb046219535f8e2fb67
7
+ data.tar.gz: d6df389edbe20371e837080700105eab42ae75ed6e9a90d672db027b1081c91eeb2ca606bcaf2a0495d4b96ec116a4c3b8531eb71af0111c16beed851a70d58b
data/examples/parse.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  require File.join(dir, 'feedium')
3
3
 
4
- puts Feedium.parse('http://mangastream.com/rss')
4
+ puts Feedium.find('https://github.com/Stajor/feedium')
data/lib/feedium.rb CHANGED
@@ -22,7 +22,8 @@ module Feedium
22
22
  def self.find(url)
23
23
  return @request.url if self.feed?(url)
24
24
 
25
- doc = Nokogiri::HTML(@request.io.read)
25
+ @body = @body || @request.io.read
26
+ doc = Nokogiri::HTML(@body)
26
27
 
27
28
  if doc.at('base') && doc.at('base')['href']
28
29
  @base_uri = doc.at('base')['href']
@@ -64,13 +65,26 @@ module Feedium
64
65
  content_type = @request.io.content_type.downcase
65
66
  content_type = @request.io.meta['content-type'].gsub(/;.*$/, '') if content_type == 'application/octet-stream'
66
67
 
67
- CONTENT_TYPES.include?(content_type) ? true : false
68
+ is_feed = CONTENT_TYPES.include?(content_type) ? true : false
69
+
70
+ if !is_feed
71
+ begin
72
+ @body = @request.io.read
73
+ is_feed = !self.parse(url, @body).class.name.index('Feedjira::Parser').nil?
74
+ rescue
75
+ end
76
+ end
77
+
78
+ is_feed
68
79
  end
69
80
 
70
- def self.parse(url)
71
- request = Request.new(url)
72
- request.send
81
+ def self.parse(url, content = nil)
82
+ if content.nil?
83
+ request = Request.new(url)
84
+ request.send
85
+ content = request.io.read
86
+ end
73
87
 
74
- Feedjira::Feed.parse(request.io.read)
88
+ Feedjira::Feed.parse(content)
75
89
  end
76
90
  end
@@ -1,3 +1,3 @@
1
1
  module Feedium
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
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.8
4
+ version: 0.1.9
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-22 00:00:00.000000000 Z
11
+ date: 2017-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler