simple2ch 0.1.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +25 -0
- data/.travis.yml +8 -0
- data/README.md +24 -31
- data/UPDATES.md +46 -9
- data/lib/simple2ch.rb +67 -83
- data/lib/simple2ch/bbs.rb +54 -0
- data/lib/simple2ch/board.rb +26 -50
- data/lib/simple2ch/dat.rb +22 -20
- data/lib/simple2ch/regex.rb +16 -0
- data/lib/simple2ch/{res.rb → response.rb} +58 -57
- data/lib/simple2ch/simple2ch_error.rb +9 -0
- data/lib/simple2ch/thread.rb +113 -0
- data/lib/simple2ch/version.rb +1 -1
- data/simple2ch.gemspec +8 -0
- data/spec/bbs_spec.rb +30 -0
- data/spec/board_spec.rb +89 -54
- data/spec/dat_spec.rb +20 -19
- data/spec/response_spec.rb +131 -0
- data/spec/simple2ch_spec.rb +19 -50
- data/spec/spec_helper.rb +65 -37
- data/spec/thread_spec.rb +76 -0
- data/spec/vcr/Simple2ch_BBS/_boards/use_cache/behaves_like_boards/from_2ch_sc/1_1_1_1_1_2.yml +1117 -0
- data/spec/vcr/Simple2ch_BBS/_boards/use_cache/behaves_like_boards/from_open2ch_net/1_1_1_1_2_2.yml +1136 -0
- data/spec/vcr/Simple2ch_BBS/_boards/use_force_reload/behaves_like_boards/from_2ch_sc/1_1_2_1_1_2.yml +1117 -0
- data/spec/vcr/Simple2ch_BBS/_boards/use_force_reload/behaves_like_boards/from_2ch_sc/1_1_2_1_1_3.yml +1117 -0
- data/spec/vcr/Simple2ch_BBS/_boards/use_force_reload/behaves_like_boards/from_open2ch_net/1_1_2_1_2_2.yml +1136 -0
- data/spec/vcr/Simple2ch_BBS/_boards/use_force_reload/behaves_like_boards/from_open2ch_net/1_1_2_1_2_3.yml +1136 -0
- data/spec/vcr/Simple2ch_Board/_threads/1_4_1.yml +1238 -0
- data/spec/vcr/Simple2ch_Board/_threads/1_4_2.yml +1238 -0
- data/spec/vcr/Simple2ch_Board/_threads/1_4_3.yml +1238 -0
- data/spec/vcr/Simple2ch_Board/_threads/1_4_7.yml +1238 -0
- data/spec/vcr/Simple2ch_Board/_threads/1_4_8.yml +1238 -0
- data/spec/vcr/Simple2ch_Board/_threads/1_4_9.yml +1238 -0
- data/spec/vcr/Simple2ch_Dat/should_have_responses/1_2_1.yml +953 -0
- data/spec/vcr/Simple2ch_Dat/should_have_responses/1_2_3.yml +953 -0
- data/spec/vcr/Simple2ch_Dat/should_have_responses/1_2_4.yml +953 -0
- data/spec/vcr/Simple2ch_Dat/should_have_responses/size/1_2_2_1.yml +953 -0
- data/spec/vcr/Simple2ch_Response/_anchors/when_a_thre_have_both_id_and_non-id_responses/1_2_7_1.yml +5321 -0
- data/spec/vcr/Simple2ch_Response/_parse/when_real_data/when_2ch_sc/1_1_2_1_1.yml +1599 -0
- data/spec/vcr/Simple2ch_Response/_parse/when_real_data/when_open2ch_net/1_1_2_2_1.yml +1465 -0
- data/spec/vcr/Simple2ch_Thread/_new/2ch_sc/1_1_1_1.yml +1410 -0
- data/spec/vcr/Simple2ch_Thread/_new/2ch_sc/1_1_1_2.yml +1692 -0
- data/spec/vcr/Simple2ch_Thread/_new/open2ch_net/1_1_2_1.yml +1410 -0
- data/spec/vcr/Simple2ch_Thread/_new/open2ch_net/1_1_2_2.yml +1999 -0
- data/spec/vcr/Simple2ch_Thread/_responses/1_2_1.yml +1599 -0
- data/spec/vcr/Simple2ch_Thread/_responses/first/1_2_2_1.yml +1599 -0
- data/spec/vcr/Simple2ch_Thread/_responses/first/1_2_3_1.yml +1599 -0
- data/spec/vcr/Simple2ch_Thread/_title/1_3_1.yml +1599 -0
- data/spec/vcr/Simple2ch_Thread/_title/size/1_3_2_1.yml +1599 -0
- metadata +185 -11
- data/lib/simple2ch/simple2ch_exception.rb +0 -7
- data/lib/simple2ch/thre.rb +0 -140
- data/spec/res_spec.rb +0 -123
- data/spec/thre_spec.rb +0 -122
data/spec/thre_spec.rb
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
require 'rspec'
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
describe Simple2ch::Thre do
|
|
5
|
-
shared_examples 'have specified reses' do
|
|
6
|
-
subject { thre.reses(specified_reses) }
|
|
7
|
-
it { is_expected.to be_a_kind_of Array }
|
|
8
|
-
its(:size) { is_expected.to be == size }
|
|
9
|
-
end
|
|
10
|
-
shared_examples 'should be valid' do
|
|
11
|
-
describe 'should have title' do
|
|
12
|
-
subject { thre.title }
|
|
13
|
-
it { is_expected.to be_a_kind_of(String) }
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe 'should have thread key' do
|
|
17
|
-
subject { thre.thread_key }
|
|
18
|
-
it { is_expected.to be_a_kind_of(String) }
|
|
19
|
-
it { is_expected.to match /\d{10}/ }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe 'should have numbers of responses' do
|
|
23
|
-
subject { thre.num_of_response }
|
|
24
|
-
it { is_expected.to be_a_kind_of(Fixnum) }
|
|
25
|
-
it { is_expected.to be > 0 }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe 'should have responses' do
|
|
29
|
-
subject { thre.reses }
|
|
30
|
-
it { is_expected.to be_a_kind_of(Array) }
|
|
31
|
-
it { subject.each { |r| expect(r).to be_a_kind_of(Simple2ch::Res) } }
|
|
32
|
-
its(:size) { is_expected.to be > 0 }
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe 'should have if Kako log' do
|
|
36
|
-
subject { thre.kako_log? }
|
|
37
|
-
it { is_expected.to kako_log }
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe 'should be created from URL' do
|
|
43
|
-
shared_examples 'create from URL' do
|
|
44
|
-
let(:thre) { Simple2ch::Thre.create_from_url(url) }
|
|
45
|
-
subject{ thre }
|
|
46
|
-
it{ is_expected.to be_a_kind_of Simple2ch::Thre }
|
|
47
|
-
its(:board) { is_expected.to be_a_kind_of Simple2ch::Board }
|
|
48
|
-
its('board.title') { is_expected.not_to be_empty }
|
|
49
|
-
its(:title){ is_expected.not_to be_empty }
|
|
50
|
-
include_examples 'should be valid'
|
|
51
|
-
end
|
|
52
|
-
context 'from 2ch.net URL' do
|
|
53
|
-
let(:url) {'http://peace.2ch.net/test/read.cgi/tech/1158807229/l50'}
|
|
54
|
-
let(:kako_log){ be_falsey }
|
|
55
|
-
include_examples 'create from URL'
|
|
56
|
-
end
|
|
57
|
-
context 'from 2ch.sc URL' do
|
|
58
|
-
let(:url) {'http://peace.2ch.sc/test/read.cgi/tech/1158807229/l50'}
|
|
59
|
-
let(:kako_log){ be_falsey }
|
|
60
|
-
include_examples 'create from URL'
|
|
61
|
-
end
|
|
62
|
-
context 'from open2ch.net URL' do
|
|
63
|
-
let(:url) {'http://toro.open2ch.net/test/read.cgi/tech/1371956681/l50'}
|
|
64
|
-
let(:kako_log){ be_falsey }
|
|
65
|
-
include_examples 'create from URL'
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe 'should have a type of 2ch' do
|
|
70
|
-
subject{ Simple2ch::Thre.new(board, thread_key) }
|
|
71
|
-
context '2ch.net' do
|
|
72
|
-
let!(:board){ Simple2ch::Board.new 'ニュース速報(VIP)', 'http://viper.2ch.net/news4vip/' }
|
|
73
|
-
let(:thread_key){ board.thres[0].thread_key }
|
|
74
|
-
its(:type_of_2ch) { is_expected.to eq :net }
|
|
75
|
-
end
|
|
76
|
-
context '2ch.sc' do
|
|
77
|
-
let!(:board){ Simple2ch::Board.new 'ニュース速報(VIP)', 'http://viper.2ch.sc/news4vip/' }
|
|
78
|
-
let(:thread_key){ board.thres[0].thread_key }
|
|
79
|
-
its(:type_of_2ch) { is_expected.to eq :sc }
|
|
80
|
-
end
|
|
81
|
-
context '2ch.net' do
|
|
82
|
-
let!(:board){ Simple2ch::Board.new 'ニュース速報(VIP)', 'http://viper.open2ch.net/news4vip/' }
|
|
83
|
-
let(:thread_key){ board.thres[0].thread_key }
|
|
84
|
-
its(:type_of_2ch) { is_expected.to eq :open }
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe 'is valid' do
|
|
89
|
-
let(:board) { Simple2ch::Board.new 'ニュース速報(VIP)', 'http://viper.2ch.sc/news4vip/' }
|
|
90
|
-
let(:dat_data) { '1409796283.dat<>C言語の勉強始めたんだがな (144)' }
|
|
91
|
-
let(:thre) { Simple2ch::Thre.parse(board, dat_data) }
|
|
92
|
-
let(:kako_log) { be_truthy }
|
|
93
|
-
include_examples 'should be valid'
|
|
94
|
-
|
|
95
|
-
context 'when without res_num' do
|
|
96
|
-
let(:size) { 144 }
|
|
97
|
-
let(:specified_reses) { nil }
|
|
98
|
-
it_behaves_like 'have specified reses'
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context 'when with res_nums' do
|
|
102
|
-
let(:size) { 3 }
|
|
103
|
-
let(:specified_reses) { [1, 2, 10] }
|
|
104
|
-
it_behaves_like 'have specified reses'
|
|
105
|
-
it {
|
|
106
|
-
extracted_reses = thre.reses(specified_reses)
|
|
107
|
-
expect(extracted_reses[2]).to be == thre.reses.find { |r| r.res_num==10 }
|
|
108
|
-
}
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
context 'when with only a res_num' do
|
|
112
|
-
let(:size) { 3 }
|
|
113
|
-
let(:specified_res_num) { 10 }
|
|
114
|
-
subject { thre.reses(specified_res_num) }
|
|
115
|
-
it { is_expected.to be_a_kind_of Res }
|
|
116
|
-
it {
|
|
117
|
-
extracted_res = thre.reses(specified_res_num)
|
|
118
|
-
expect(extracted_res).to be == thre.reses.find { |r| r.res_num==specified_res_num }
|
|
119
|
-
}
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|