nicorepo 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/nicorepo/parser.rb +13 -0
- data/lib/nicorepo/report.rb +2 -0
- data/lib/nicorepo/reports.rb +1 -1
- data/lib/nicorepo/version.rb +1 -1
- data/spec/nicorepo_spec.rb +24 -0
- 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: c3448cd833a302e8e7aac84cbf3170ed80b1641b
|
4
|
+
data.tar.gz: e8cdc967003e665c5386201e15410be1048062f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6026af1949334730b162b3c056cb8ef17617a68844551d395dc16169b251115dd5b0f99a947c2bfe2b4dfe0623d2b5934a383c2102a38cfde1f5f1e4d646070
|
7
|
+
data.tar.gz: 7fd5e35ebded26a114b69c3955e960ef17b484120d659c7fa8b62c4f0d28721d99a683c54b594d04001acca1df7c04c6b972d223bb54f72314ccdb8d22a819db
|
data/CHANGELOG.md
CHANGED
data/lib/nicorepo/parser.rb
CHANGED
@@ -28,6 +28,8 @@ class Nicorepo
|
|
28
28
|
kind: parse_kind(node),
|
29
29
|
date: parse_date(node)
|
30
30
|
}
|
31
|
+
rescue => e
|
32
|
+
error_report(node, e)
|
31
33
|
end
|
32
34
|
|
33
35
|
def report_nodes(page)
|
@@ -70,5 +72,16 @@ class Nicorepo
|
|
70
72
|
d = node.search('div.log-footer/div.log-footer-inner/a.log-footer-date/time').first['datetime']
|
71
73
|
Time.xmlschema(d).localtime
|
72
74
|
end
|
75
|
+
|
76
|
+
def error_report(node, e)
|
77
|
+
{
|
78
|
+
body: node.inner_html.gsub(/\r|\n|\t/, ''),
|
79
|
+
title: "An exception occured: #{e.message}",
|
80
|
+
url: '',
|
81
|
+
author: '',
|
82
|
+
kind: Report::ERROR_KIND,
|
83
|
+
date: ''
|
84
|
+
}
|
85
|
+
end
|
73
86
|
end
|
74
87
|
end
|
data/lib/nicorepo/report.rb
CHANGED
data/lib/nicorepo/reports.rb
CHANGED
@@ -47,7 +47,7 @@ class Nicorepo
|
|
47
47
|
reach_oldest_page = (reports.last.date < filter[:since])
|
48
48
|
reports.reject! { |report| report.date < filter[:since] }
|
49
49
|
end
|
50
|
-
reports.select! { |report| report.kind =~ /#{filter[:kind]}/ } if filter[:kind]
|
50
|
+
reports.select! { |report| report.kind =~ /#{filter[:kind]}|#{Report::ERROR_KIND}/ } if filter[:kind]
|
51
51
|
|
52
52
|
return reports[0, request_num] if reports.size >= request_num
|
53
53
|
return reports if filter[:since] && reach_oldest_page
|
data/lib/nicorepo/version.rb
CHANGED
data/spec/nicorepo_spec.rb
CHANGED
@@ -7,6 +7,18 @@ describe Nicorepo do
|
|
7
7
|
@nicorepo.login(mail, pass)
|
8
8
|
end
|
9
9
|
|
10
|
+
shared_examples_for 'an error report in parsing' do
|
11
|
+
context "when an error occured" do
|
12
|
+
before do
|
13
|
+
allow_any_instance_of(Nicorepo::Parser).to receive(:parse_title).and_raise("SomeError")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return erorr reports" do
|
17
|
+
expect(report.title).to eq("An exception occured: SomeError")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
10
22
|
describe "#login" do
|
11
23
|
context "with right account" do
|
12
24
|
it "should be success" do
|
@@ -34,6 +46,10 @@ describe Nicorepo do
|
|
34
46
|
expect(@nicorepo.all(50).size).to eq(50)
|
35
47
|
end
|
36
48
|
end
|
49
|
+
|
50
|
+
it_behaves_like 'an error report in parsing' do
|
51
|
+
let(:report) { @nicorepo.all(1).first }
|
52
|
+
end
|
37
53
|
end
|
38
54
|
|
39
55
|
describe "#videos" do
|
@@ -48,6 +64,10 @@ describe Nicorepo do
|
|
48
64
|
expect(@nicorepo.videos(5, 3).size).to be <= 5
|
49
65
|
end
|
50
66
|
end
|
67
|
+
|
68
|
+
it_behaves_like 'an error report in parsing' do
|
69
|
+
let(:report) { @nicorepo.videos(1).first }
|
70
|
+
end
|
51
71
|
end
|
52
72
|
|
53
73
|
describe "#lives" do
|
@@ -56,6 +76,10 @@ describe Nicorepo do
|
|
56
76
|
not_lives = lives.reject{ |l| l.kind =~ /live/ }
|
57
77
|
expect(not_lives.size).to eq(0)
|
58
78
|
end
|
79
|
+
|
80
|
+
it_behaves_like 'an error report in parsing' do
|
81
|
+
let(:report) { @nicorepo.lives(1).first }
|
82
|
+
end
|
59
83
|
end
|
60
84
|
end
|
61
85
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nicorepo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- upinetree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|