bf_multi_rss 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +86 -0
- data/.travis.yml +5 -0
- data/bf_multi_rss.gemspec +27 -0
- data/lib/bf_multi_rss.rb +2 -0
- data/lib/bf_multi_rss/fetcher.rb +80 -0
- data/lib/bf_multi_rss/rss_error.rb +9 -0
- data/lib/bf_multi_rss/rss_result.rb +11 -0
- metadata +13 -4
- data/Gemfile.lock +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52417ce78b48cad3fceead305a2fcacff48a9004
|
4
|
+
data.tar.gz: a86c24913778cd6ab30bc5f0ee63273b0bb40161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ffec392ce382bdde93b3057f2b9715b48e0a06bcfe5e37ddb1cee34be6b88ebdf63494a2bf4e5f3626456db778dff4c1497119be7d7b334be0fad063c5676f6
|
7
|
+
data.tar.gz: 3c516378eb75b04235d1d8f9afc540b814212e9528bb61bce0e498f6f69db6005af3441966ddb8a382603f95d0378deb9d1c3bd2027c0a2f194ac0f68cb1016d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
Metrics/BlockLength:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
# Disable global vars
|
5
|
+
Style/SpecialGlobalVars:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
# Disable class length restriction
|
9
|
+
Metrics/ClassLength:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
# Disable module length restriction
|
13
|
+
Metrics/ModuleLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
# Disable method length restriction
|
17
|
+
Metrics/MethodLength:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
# Disable checking of ABC metrics (assignment, branch, condition)
|
21
|
+
Metrics/AbcSize:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
# Disable method perceived complexity (how it is hard to read a method)
|
25
|
+
Metrics/PerceivedComplexity:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
# Disable cyclomatic complexity which is a number of paths through a method
|
29
|
+
Metrics/CyclomaticComplexity:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# Block nesting is 5
|
33
|
+
Metrics/BlockNesting:
|
34
|
+
Max: 5
|
35
|
+
|
36
|
+
# Set max line length to 120
|
37
|
+
Metrics/LineLength:
|
38
|
+
Max: 120
|
39
|
+
|
40
|
+
Style/Documentation:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# Trailing comma helps not to forget to put it
|
44
|
+
# if you want to add new value below
|
45
|
+
Style/TrailingCommaInLiteral:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# It is totally ok to use block chain by my preference
|
49
|
+
# It promotes functional programming style
|
50
|
+
Style/MultilineBlockChain:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
# Empty lines are enabled to simplify vim paragraph selection
|
54
|
+
Style/EmptyLinesAroundBlockBody:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Style/EmptyLinesAroundClassBody:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Style/EmptyLinesAroundMethodBody:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
# Disable multiline method indentation, not comfortable with it
|
64
|
+
Style/MultilineMethodCallIndentation:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
# extend self uses ruby inheritance instead of copying methods
|
68
|
+
Style/ModuleFunction:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
Style/Lambda:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
AllCops:
|
75
|
+
DisplayCopNames: true
|
76
|
+
Exclude:
|
77
|
+
- db/**/*
|
78
|
+
- bin/**
|
79
|
+
- config/**/**
|
80
|
+
- spec/dummy/bin/**
|
81
|
+
- spec/dummy/db/**
|
82
|
+
- Guardfile
|
83
|
+
|
84
|
+
Rails:
|
85
|
+
Enabled: false
|
86
|
+
Exclude:
|
data/.travis.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'bf_multi_rss'
|
7
|
+
spec.version = '0.3.6'
|
8
|
+
spec.authors = ['Sebastian Schürmann']
|
9
|
+
spec.email = ['sebs@2xs.org']
|
10
|
+
|
11
|
+
spec.summary = 'Parallel rss fetching'
|
12
|
+
spec.homepage = 'https://github.com/bundesfeeds'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
spec.add_runtime_dependency 'http', '~> 2.2'
|
26
|
+
spec.add_runtime_dependency 'parallel', '~> 1.10'
|
27
|
+
end
|
data/lib/bf_multi_rss.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rss'
|
2
|
+
require 'http'
|
3
|
+
require 'parallel'
|
4
|
+
require 'bf_multi_rss/rss_result'
|
5
|
+
require 'bf_multi_rss/rss_error'
|
6
|
+
|
7
|
+
module BfMultiRss
|
8
|
+
class NotInvertibleError < StandardError
|
9
|
+
end
|
10
|
+
|
11
|
+
class Fetcher
|
12
|
+
attr_reader :concurrency, :errors
|
13
|
+
def initialize(concurrency = 4)
|
14
|
+
@concurrency = concurrency
|
15
|
+
@errors = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def fetch_uri(uri)
|
19
|
+
response = HTTP.get(uri)
|
20
|
+
raise_errors(response, uri)
|
21
|
+
response.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def fetch_rss(uri)
|
25
|
+
response = fetch_uri(uri)
|
26
|
+
rss = RSS::Parser.parse(response, false)
|
27
|
+
if rss.nil?
|
28
|
+
err = 'ParseErr ' + uri
|
29
|
+
raise NotInvertibleError, err
|
30
|
+
end
|
31
|
+
rss.items
|
32
|
+
end
|
33
|
+
|
34
|
+
def raise_errors(response, uri)
|
35
|
+
case response.status
|
36
|
+
when 500
|
37
|
+
err = 'Http500 ' + uri
|
38
|
+
raise NotInvertibleError, err
|
39
|
+
when 404
|
40
|
+
err = 'Http404 ' + uri
|
41
|
+
raise NotInvertibleError, err
|
42
|
+
when 301
|
43
|
+
err = 'Http301 ' + uri
|
44
|
+
raise NotInvertibleError, err
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def fetch_all(uris)
|
49
|
+
@errors = []
|
50
|
+
results = Parallel.map(
|
51
|
+
uris,
|
52
|
+
in_processes: @concurrency
|
53
|
+
) do |uri|
|
54
|
+
begin
|
55
|
+
posts = fetch_rss(uri)
|
56
|
+
BfMultiRss::RssResult.new(uri, posts)
|
57
|
+
|
58
|
+
rescue REXML::ParseException,
|
59
|
+
OpenURI::HTTPError,
|
60
|
+
Errno::EHOSTUNREACH,
|
61
|
+
Errno::ETIMEDOUT,
|
62
|
+
RSS::NotWellFormedError,
|
63
|
+
Net::OpenTimeout,
|
64
|
+
Net::ReadTimeout,
|
65
|
+
Errno::ECONNREFUSED,
|
66
|
+
Errno::ECONNRESET,
|
67
|
+
NotInvertibleError => e
|
68
|
+
BfMultiRss::RssError.new(uri, e)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
errors = results.select do |result|
|
72
|
+
result.is_a? BfMultiRss::RssError
|
73
|
+
end
|
74
|
+
@errors = errors
|
75
|
+
results.select do |result|
|
76
|
+
!result.is_a? BfMultiRss::RssError
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bf_multi_rss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Schürmann
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -81,20 +81,29 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.10'
|
83
83
|
description:
|
84
|
-
email:
|
84
|
+
email:
|
85
|
+
- sebs@2xs.org
|
85
86
|
executables: []
|
86
87
|
extensions: []
|
87
88
|
extra_rdoc_files: []
|
88
89
|
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".travis.yml"
|
89
94
|
- CODE_OF_CONDUCT.md
|
90
95
|
- Gemfile
|
91
|
-
- Gemfile.lock
|
92
96
|
- Guardfile
|
93
97
|
- LICENSE.txt
|
94
98
|
- README.md
|
95
99
|
- Rakefile
|
100
|
+
- bf_multi_rss.gemspec
|
96
101
|
- bin/console
|
97
102
|
- bin/setup
|
103
|
+
- lib/bf_multi_rss.rb
|
104
|
+
- lib/bf_multi_rss/fetcher.rb
|
105
|
+
- lib/bf_multi_rss/rss_error.rb
|
106
|
+
- lib/bf_multi_rss/rss_result.rb
|
98
107
|
homepage: https://github.com/bundesfeeds
|
99
108
|
licenses:
|
100
109
|
- MIT
|
data/Gemfile.lock
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
bf_multi_rss (0.3.5)
|
5
|
-
http (~> 2.2)
|
6
|
-
parallel (~> 1.10)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.5.0)
|
12
|
-
public_suffix (~> 2.0, >= 2.0.2)
|
13
|
-
ast (2.3.0)
|
14
|
-
coderay (1.1.1)
|
15
|
-
crack (0.4.3)
|
16
|
-
safe_yaml (~> 1.0.0)
|
17
|
-
diff-lcs (1.3)
|
18
|
-
domain_name (0.5.20170223)
|
19
|
-
unf (>= 0.0.5, < 1.0.0)
|
20
|
-
ffi (1.9.18)
|
21
|
-
formatador (0.2.5)
|
22
|
-
guard (2.14.1)
|
23
|
-
formatador (>= 0.2.4)
|
24
|
-
listen (>= 2.7, < 4.0)
|
25
|
-
lumberjack (~> 1.0)
|
26
|
-
nenv (~> 0.1)
|
27
|
-
notiffany (~> 0.0)
|
28
|
-
pry (>= 0.9.12)
|
29
|
-
shellany (~> 0.0)
|
30
|
-
thor (>= 0.18.1)
|
31
|
-
guard-compat (1.2.1)
|
32
|
-
guard-rspec (4.7.3)
|
33
|
-
guard (~> 2.1)
|
34
|
-
guard-compat (~> 1.1)
|
35
|
-
rspec (>= 2.99.0, < 4.0)
|
36
|
-
guard-rubocop (1.2.0)
|
37
|
-
guard (~> 2.0)
|
38
|
-
rubocop (~> 0.20)
|
39
|
-
hashdiff (0.3.2)
|
40
|
-
http (2.2.1)
|
41
|
-
addressable (~> 2.3)
|
42
|
-
http-cookie (~> 1.0)
|
43
|
-
http-form_data (~> 1.0.1)
|
44
|
-
http_parser.rb (~> 0.6.0)
|
45
|
-
http-cookie (1.0.3)
|
46
|
-
domain_name (~> 0.5)
|
47
|
-
http-form_data (1.0.1)
|
48
|
-
http_parser.rb (0.6.0)
|
49
|
-
listen (3.1.5)
|
50
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
51
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
52
|
-
ruby_dep (~> 1.2)
|
53
|
-
lumberjack (1.0.11)
|
54
|
-
method_source (0.8.2)
|
55
|
-
nenv (0.3.0)
|
56
|
-
notiffany (0.1.1)
|
57
|
-
nenv (~> 0.1)
|
58
|
-
shellany (~> 0.0)
|
59
|
-
parallel (1.11.1)
|
60
|
-
parser (2.4.0.0)
|
61
|
-
ast (~> 2.2)
|
62
|
-
powerpack (0.1.1)
|
63
|
-
pry (0.10.4)
|
64
|
-
coderay (~> 1.1.0)
|
65
|
-
method_source (~> 0.8.1)
|
66
|
-
slop (~> 3.4)
|
67
|
-
public_suffix (2.0.5)
|
68
|
-
rainbow (2.2.1)
|
69
|
-
rake (10.5.0)
|
70
|
-
rb-fsevent (0.9.8)
|
71
|
-
rb-inotify (0.9.8)
|
72
|
-
ffi (>= 0.5.0)
|
73
|
-
rspec (3.5.0)
|
74
|
-
rspec-core (~> 3.5.0)
|
75
|
-
rspec-expectations (~> 3.5.0)
|
76
|
-
rspec-mocks (~> 3.5.0)
|
77
|
-
rspec-core (3.5.4)
|
78
|
-
rspec-support (~> 3.5.0)
|
79
|
-
rspec-expectations (3.5.0)
|
80
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
-
rspec-support (~> 3.5.0)
|
82
|
-
rspec-mocks (3.5.0)
|
83
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
-
rspec-support (~> 3.5.0)
|
85
|
-
rspec-support (3.5.0)
|
86
|
-
rubocop (0.47.1)
|
87
|
-
parser (>= 2.3.3.1, < 3.0)
|
88
|
-
powerpack (~> 0.1)
|
89
|
-
rainbow (>= 1.99.1, < 3.0)
|
90
|
-
ruby-progressbar (~> 1.7)
|
91
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
92
|
-
ruby-progressbar (1.8.1)
|
93
|
-
ruby_dep (1.5.0)
|
94
|
-
safe_yaml (1.0.4)
|
95
|
-
shellany (0.0.1)
|
96
|
-
slop (3.6.0)
|
97
|
-
thor (0.19.4)
|
98
|
-
unf (0.1.4)
|
99
|
-
unf_ext
|
100
|
-
unf_ext (0.0.7.2)
|
101
|
-
unicode-display_width (1.1.3)
|
102
|
-
webmock (2.3.2)
|
103
|
-
addressable (>= 2.3.6)
|
104
|
-
crack (>= 0.3.2)
|
105
|
-
hashdiff
|
106
|
-
|
107
|
-
PLATFORMS
|
108
|
-
ruby
|
109
|
-
|
110
|
-
DEPENDENCIES
|
111
|
-
bf_multi_rss!
|
112
|
-
bundler (~> 1.14)
|
113
|
-
guard
|
114
|
-
guard-rspec
|
115
|
-
guard-rubocop
|
116
|
-
rake (~> 10.0)
|
117
|
-
rspec
|
118
|
-
rubocop
|
119
|
-
webmock
|
120
|
-
|
121
|
-
BUNDLED WITH
|
122
|
-
1.14.6
|