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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77bc420c0f28c252e64072f5327ee79df42c52f2
4
- data.tar.gz: eeb940e3c0f7bce3837c5ad4140f4c051e88618f
3
+ metadata.gz: c3448cd833a302e8e7aac84cbf3170ed80b1641b
4
+ data.tar.gz: e8cdc967003e665c5386201e15410be1048062f3
5
5
  SHA512:
6
- metadata.gz: 9aa9cec6aec5ebaaa589a2911c71aa37488117657fdeca31e5ee773b6093536d888946959a2198846eab3125317c0e14dbc4c406128a300a2c8b623955678982
7
- data.tar.gz: 2a10ba1150d48817bc994a00b38f3a2cd2255b4e17f8c3a748991b25d95a8a7f040c5ffca853dde77d4d8e289a48071601315cdfea822ab73f897a00ea573fb0
6
+ metadata.gz: a6026af1949334730b162b3c056cb8ef17617a68844551d395dc16169b251115dd5b0f99a947c2bfe2b4dfe0623d2b5934a383c2102a38cfde1f5f1e4d646070
7
+ data.tar.gz: 7fd5e35ebded26a114b69c3955e960ef17b484120d659c7fa8b62c4f0d28721d99a683c54b594d04001acca1df7c04c6b972d223bb54f72314ccdb8d22a819db
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.7 (2014/12/09)
2
+
3
+ * Output error reports when exceptions occurd in the parsing process.
4
+
1
5
  ## 0.0.6 (2014/10/18)
2
6
 
3
7
  * Disable SSLv3 and use TLSv1 because of POODLE vulnerability
@@ -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
@@ -2,6 +2,8 @@ class Nicorepo
2
2
  class Report
3
3
  attr_accessor :body, :title, :url, :author, :kind, :date
4
4
 
5
+ ERROR_KIND = 'error'
6
+
5
7
  def initialize(attrs)
6
8
  @body = attrs[:body]
7
9
  @title = attrs[:title]
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Nicorepo
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -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.6
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-10-17 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize