simple2ch 0.0.1
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 +7 -0
- data/.gitignore +123 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/doc/Simple2ch/Board.html +711 -0
- data/doc/Simple2ch/Dat.html +502 -0
- data/doc/Simple2ch/DatParseException.html +131 -0
- data/doc/Simple2ch/KakoLogException.html +131 -0
- data/doc/Simple2ch/NotA2chUrlException.html +131 -0
- data/doc/Simple2ch/Res.html +1034 -0
- data/doc/Simple2ch/Simple2chException.html +127 -0
- data/doc/Simple2ch/Thre.html +792 -0
- data/doc/Simple2ch.html +314 -0
- data/doc/_index.html +214 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +111 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +111 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +215 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/simple2ch/board.rb +70 -0
- data/lib/simple2ch/dat.rb +57 -0
- data/lib/simple2ch/res.rb +70 -0
- data/lib/simple2ch/simple2ch_exception.rb +6 -0
- data/lib/simple2ch/thre.rb +49 -0
- data/lib/simple2ch/version.rb +3 -0
- data/lib/simple2ch.rb +31 -0
- data/simple2ch.gemspec +33 -0
- data/spec/board_spec.rb +45 -0
- data/spec/dat_spec.rb +27 -0
- data/spec/res_spec.rb +42 -0
- data/spec/simple2ch_spec.rb +33 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/thre_spec.rb +37 -0
- metadata +176 -0
data/spec/board_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Simple2ch::Board do
|
5
|
+
let(:title) { 'ニュー速VIP' }
|
6
|
+
let(:url) do
|
7
|
+
{
|
8
|
+
sc: 'http://viper.2ch.sc/news4vip/',
|
9
|
+
net: 'http://viper.2ch.net/news4vip/',
|
10
|
+
#open: 'http://viper.open2ch.net/news4vip/', #TODO
|
11
|
+
not_a_2ch_format: 'http://test.example.com/hoge/',
|
12
|
+
invalid_url: 'http://abc_def.com/foobar/' # under score in host is invalid
|
13
|
+
}
|
14
|
+
end
|
15
|
+
let(:board) { Simple2ch::Board.new(title, url[:sc]) }
|
16
|
+
|
17
|
+
context 'should get board title' do
|
18
|
+
subject { board.title }
|
19
|
+
it { is_expected.to be_a_kind_of(String) }
|
20
|
+
it { is_expected.to eq title }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'should get board url' do
|
24
|
+
subject { board.url }
|
25
|
+
it { is_expected.to be_a_kind_of(URI) }
|
26
|
+
it { is_expected.to eq URI.parse(url[:sc]) }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'should get all of thread' do
|
30
|
+
subject { board.threads }
|
31
|
+
it { is_expected.to be_a_kind_of(Array) }
|
32
|
+
it { subject.each{ |t| expect(t).to be_a_kind_of(Simple2ch::Thre) } }
|
33
|
+
its(:size) { is_expected.to be > 0 }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'should raise NotA2chUrlException if URL is not a 2ch format' do
|
37
|
+
subject { lambda{ Simple2ch::Board.new(title, url[:not_a_2ch_format]) } }
|
38
|
+
it { is_expected.to raise_error Simple2ch::NotA2chUrlException }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'should raise URI::InvalidURL if URL is invalid format' do
|
42
|
+
subject { lambda{ Simple2ch::Board.new(title, url[:invalid_url]) } }
|
43
|
+
it { is_expected.to raise_error URI::InvalidURIError }
|
44
|
+
end
|
45
|
+
end
|
data/spec/dat_spec.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Simple2ch::Dat do
|
5
|
+
let(:board) { Simple2ch::Board.new 'ニュース速報(VIP)', 'http://viper.2ch.sc/news4vip/' }
|
6
|
+
let(:dat_data) { '1409796283.dat<>C言語の勉強始めたんだがな (144)' }
|
7
|
+
let(:thre) { Simple2ch::Thre.new(board, dat_data) }
|
8
|
+
let(:thread_key) { '1409796283' }
|
9
|
+
let(:dat) { Simple2ch::Dat.new thre }
|
10
|
+
|
11
|
+
context 'should have thread key' do
|
12
|
+
subject { dat.thread_key }
|
13
|
+
it { is_expected.to be_a_kind_of(String) }
|
14
|
+
it { is_expected.to match /\d{10}/ }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'should have reses' do
|
18
|
+
subject { dat.reses }
|
19
|
+
it { is_expected.to be_a_kind_of(Array) }
|
20
|
+
its(:size) { is_expected.to be > 0 }
|
21
|
+
it do
|
22
|
+
subject.each do |r|
|
23
|
+
expect(r).to be_a_kind_of(Simple2ch::Res)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/res_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Simple2ch::Res do
|
5
|
+
let(:dat_data) { %q{以下、\(^o^)/でVIPがお送りします<><>2014/09/04(木) 18:46:36.03 ID:wBAvTswZ0.net<> http://livedoor.blogimg.jp/hatima/imgs/b/c/bccae87d.jpg <br> <br> <br> ※二次創作ではなく、公式です <>古参よ、これが今の東方projectだ
|
6
|
+
以下、\(^o^)/でVIPがお送りします<><>2014/09/04(木) 18:47:10.12 ID:X4fy/81O0.net<> うそつけ <>
|
7
|
+
以下、\(^o^)/でVIPがお送りします<><>2014/09/04(木) 18:47:14.08 ID:WDyAzc5v0.net<> 嘘乙 <>
|
8
|
+
以下、\(^o^)/でVIPがお送りします<><>2014/09/04(木) 18:47:19.71 ID:9QYJSuKn0.net<> 正直楽しみ <>
|
9
|
+
以下、\(^o^)/でVIPがお送りします<><>2014/09/04(木) 18:47:35.65 ID:rbjZvMWo0.net<> はてぃま <>
|
10
|
+
以下、\(^o^)/でVIPがお送りします<><>2014/09/04(木) 18:47:41.41 ID:bHgEtoQU0.net<> 思い切り二次創作じゃねえか <br> PS4でやるんだっけ <>} }
|
11
|
+
let(:res) { dat_data.split(/\n/).map.with_index(1) { |d, i| Simple2ch::Res.parse i, d } }
|
12
|
+
|
13
|
+
context 'should have res number' do
|
14
|
+
subject { res[0].res_num }
|
15
|
+
it { is_expected.to be_a_kind_of(Numeric) }
|
16
|
+
it { is_expected.to be > 0 }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'should have author' do
|
20
|
+
subject { res[0].author }
|
21
|
+
it { is_expected.to be_a_kind_of(String) }
|
22
|
+
it { is_expected.not_to be eq nil }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'should have author_id' do
|
26
|
+
subject { res[0].author_id }
|
27
|
+
it { is_expected.to be_a_kind_of(String) }
|
28
|
+
it { is_expected.not_to be eq nil }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'should have contents' do
|
32
|
+
subject { res[0].contents }
|
33
|
+
it { is_expected.to be_a_kind_of(String) }
|
34
|
+
it { is_expected.not_to be eq nil }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'should have date' do
|
38
|
+
subject { res[0].date }
|
39
|
+
it { is_expected.to be_a_kind_of(Time) }
|
40
|
+
it { is_expected.not_to be eq nil }
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Simple2ch do
|
5
|
+
context 'should get reses from board url' do
|
6
|
+
before(:all) do
|
7
|
+
board_name = 'ニュー速VIP'
|
8
|
+
board_url = 'http://viper.2ch.sc/news4vip/'
|
9
|
+
@board = Board.new board_name, board_url
|
10
|
+
@threads= @board.threads
|
11
|
+
@res = @threads[0].reses[0]
|
12
|
+
end
|
13
|
+
it{ expect(@board.threads).to be_a_kind_of Array }
|
14
|
+
it do
|
15
|
+
#@threads = board.threads
|
16
|
+
expect(@board.threads.size).to be > 0
|
17
|
+
end
|
18
|
+
|
19
|
+
it { expect(@threads[0]).to be_a_kind_of Thre }
|
20
|
+
it { expect(@threads[0].reses).to be_a_kind_of Array }
|
21
|
+
|
22
|
+
it do
|
23
|
+
#@res = @threads[0].reses[0]
|
24
|
+
expect(@res).to be_a_kind_of Res
|
25
|
+
end
|
26
|
+
it { expect(@res.date).to be < Time.now }
|
27
|
+
it { expect(@res.author_id.size).to be > 0 }
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
#its(:reses){ is_expected.to be a_kind_of Array}
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
#uncomment the following line to use spork with the debugger
|
3
|
+
#require 'spork/ext/ruby-debug'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'simple2ch'
|
6
|
+
require 'rspec'
|
7
|
+
require 'rspec/its'
|
8
|
+
include Simple2ch
|
9
|
+
|
10
|
+
# カスタムマッチャを書きたかったらここに。
|
11
|
+
#RSpec::Matchers.define :my_matcher do |expected|
|
12
|
+
# match do |actual|
|
13
|
+
# true
|
14
|
+
# end
|
15
|
+
#end
|
16
|
+
|
17
|
+
# --- Instructions ---
|
18
|
+
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
|
19
|
+
# block.
|
20
|
+
#
|
21
|
+
# The Spork.prefork block is run only once when the spork server is started.
|
22
|
+
# You typically want to place most of your (slow) initializer code in here, in
|
23
|
+
# particular, require'ing any 3rd-party gems that you don't normally modify
|
24
|
+
# during development.
|
25
|
+
#
|
26
|
+
# The Spork.each_run block is run each time you run your specs. In case you
|
27
|
+
# need to load files that tend to change during development, require them here.
|
28
|
+
# With Rails, your application modules are loaded automatically, so sometimes
|
29
|
+
# this block can remain empty.
|
30
|
+
#
|
31
|
+
# Note: You can modify files loaded *from* the Spork.each_run block without
|
32
|
+
# restarting the spork server. However, this file itself will not be reloaded,
|
33
|
+
# so if you change any of the code inside the each_run block, you still need to
|
34
|
+
# restart the server. In general, if you have non-trivial code in this file,
|
35
|
+
# it's advisable to move it into a separate file so you can easily edit it
|
36
|
+
# without restarting spork. (For example, with RSpec, you could move
|
37
|
+
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
|
38
|
+
# spec/support/* files are require'd from inside the each_run block.)
|
39
|
+
#
|
40
|
+
# Any code that is left outside the two blocks will be run during preforking
|
41
|
+
# *and* during each_run -- that's probably not what you want.
|
42
|
+
#
|
43
|
+
# These instructions should self-destruct in 10 seconds. If they don't, feel
|
44
|
+
# free to delete them.
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
data/spec/thre_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Simple2ch::Thre do
|
5
|
+
let(:board) { Simple2ch::Board.new 'ニュース速報(VIP)', 'http://viper.2ch.sc/news4vip/'}
|
6
|
+
let(:dat_data) { '1409796283.dat<>C言語の勉強始めたんだがな (144)' }
|
7
|
+
let(:thre) { Simple2ch::Thre.new(board, dat_data) }
|
8
|
+
|
9
|
+
context 'should have title' do
|
10
|
+
subject { thre.title }
|
11
|
+
it { is_expected.to be_a_kind_of(String) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'should have thread key' do
|
15
|
+
subject { thre.thread_key }
|
16
|
+
it { is_expected.to be_a_kind_of(String) }
|
17
|
+
it { is_expected.to match /\d{10}/ }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'should have numbers of responses' do
|
21
|
+
subject { thre.num_of_response }
|
22
|
+
it { is_expected.to be_a_kind_of(Fixnum) }
|
23
|
+
it { is_expected.to be > 0 }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'should have responses' do
|
27
|
+
subject { thre.reses }
|
28
|
+
it { is_expected.to be_a_kind_of(Array) }
|
29
|
+
it { subject.each{ |r| expect(r).to be_a_kind_of(Simple2ch::Res) } }
|
30
|
+
its(:size) { is_expected.to be > 0 }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'should have if Kako log' do
|
34
|
+
subject { thre.kako_log? }
|
35
|
+
it { is_expected.to be_truthy }
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple2ch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dogwood008
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-core
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-its
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: spork
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A gem to read 2ch bbs.
|
98
|
+
email:
|
99
|
+
- dogwood008+rubygems@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- doc/Simple2ch.html
|
110
|
+
- doc/Simple2ch/Board.html
|
111
|
+
- doc/Simple2ch/Dat.html
|
112
|
+
- doc/Simple2ch/DatParseException.html
|
113
|
+
- doc/Simple2ch/KakoLogException.html
|
114
|
+
- doc/Simple2ch/NotA2chUrlException.html
|
115
|
+
- doc/Simple2ch/Res.html
|
116
|
+
- doc/Simple2ch/Simple2chException.html
|
117
|
+
- doc/Simple2ch/Thre.html
|
118
|
+
- doc/_index.html
|
119
|
+
- doc/class_list.html
|
120
|
+
- doc/css/common.css
|
121
|
+
- doc/css/full_list.css
|
122
|
+
- doc/css/style.css
|
123
|
+
- doc/file.README.html
|
124
|
+
- doc/file_list.html
|
125
|
+
- doc/frames.html
|
126
|
+
- doc/index.html
|
127
|
+
- doc/js/app.js
|
128
|
+
- doc/js/full_list.js
|
129
|
+
- doc/js/jquery.js
|
130
|
+
- doc/method_list.html
|
131
|
+
- doc/top-level-namespace.html
|
132
|
+
- lib/simple2ch.rb
|
133
|
+
- lib/simple2ch/board.rb
|
134
|
+
- lib/simple2ch/dat.rb
|
135
|
+
- lib/simple2ch/res.rb
|
136
|
+
- lib/simple2ch/simple2ch_exception.rb
|
137
|
+
- lib/simple2ch/thre.rb
|
138
|
+
- lib/simple2ch/version.rb
|
139
|
+
- simple2ch.gemspec
|
140
|
+
- spec/board_spec.rb
|
141
|
+
- spec/dat_spec.rb
|
142
|
+
- spec/res_spec.rb
|
143
|
+
- spec/simple2ch_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
145
|
+
- spec/thre_spec.rb
|
146
|
+
homepage: https://github.com/dogwood008/simple2ch
|
147
|
+
licenses:
|
148
|
+
- MIT
|
149
|
+
metadata: {}
|
150
|
+
post_install_message:
|
151
|
+
rdoc_options: []
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 2.2.2
|
167
|
+
signing_key:
|
168
|
+
specification_version: 4
|
169
|
+
summary: A gem to read 2ch bbs.
|
170
|
+
test_files:
|
171
|
+
- spec/board_spec.rb
|
172
|
+
- spec/dat_spec.rb
|
173
|
+
- spec/res_spec.rb
|
174
|
+
- spec/simple2ch_spec.rb
|
175
|
+
- spec/spec_helper.rb
|
176
|
+
- spec/thre_spec.rb
|