simple2ch 0.1.4 → 0.1.5
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/README.md +7 -4
- data/UPDATES.md +6 -0
- data/lib/simple2ch/board.rb +17 -9
- data/lib/simple2ch/res.rb +6 -6
- data/lib/simple2ch/simple2ch_exception.rb +1 -1
- data/lib/simple2ch/version.rb +1 -1
- data/spec/board_spec.rb +8 -1
- 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: a768ea004e48d4fd18ae5c19c52646469b7d97b2
|
4
|
+
data.tar.gz: 15615e279f263ce11fb4173be0d6cab0aa10d860
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06123263022a7c964e11198bfc79a25d6c1ddbed030b7e8e1e74b3d89fe6dd491e2566abaa2c18ba122c5d8119b7a71da31ab7624e8f7301a0178a4b6effe543
|
7
|
+
data.tar.gz: 83a07323fbf88d98da9e004dbf10e3840bac8e77d598c0e908189d2dc5eb4b403a43d9a2fb3580cb313ca80f3fc02a187d0cc9ee7ce819daaf2c71fd1bf325ee
|
data/README.md
CHANGED
@@ -8,16 +8,19 @@ Ruby用の2chの簡易リーダーです。
|
|
8
8
|
[リファレンス](http://dogwood008.github.io/simple2ch/)
|
9
9
|
|
10
10
|
## 更新内容
|
11
|
+
[v0.1.5]
|
12
|
+
* デバッグ
|
13
|
+
* StandardErrorで例外を捕縛できない問題を修正
|
14
|
+
* DatParseException, NotA2chUrlException発生時に与えられたURLを表示するよう変更
|
15
|
+
* 機能追加
|
16
|
+
* おーぷん2ちゃんねる対応
|
17
|
+
|
11
18
|
[v0.1.4]
|
12
19
|
* デバッグ
|
13
20
|
* Thre#resesを実行した際に、IDを持たないレスがあれば、DatParseExceptionが起きる問題を修正
|
14
21
|
* エイリアス追加
|
15
22
|
* Thre#resをThre#resesのエイリアスに設定
|
16
23
|
|
17
|
-
[v0.1.3]
|
18
|
-
* デバッグ
|
19
|
-
* Res#received_anchors呼び出し時にNoThreGivenExceptionが起きる場合がある問題を修正
|
20
|
-
|
21
24
|
|
22
25
|
## Installation
|
23
26
|
|
data/UPDATES.md
CHANGED
data/lib/simple2ch/board.rb
CHANGED
@@ -29,6 +29,12 @@ module Simple2ch
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
# おーぷん2chか否かを返す
|
33
|
+
# @return [Boolean] おーぷん2chか否か
|
34
|
+
def open2ch?
|
35
|
+
@f_open2ch && true
|
36
|
+
end
|
37
|
+
|
32
38
|
private
|
33
39
|
# URLが正しいかバリデーションする
|
34
40
|
# @param [URI] url
|
@@ -40,18 +46,20 @@ module Simple2ch
|
|
40
46
|
|
41
47
|
if sp_uri.host.index '2ch'
|
42
48
|
case url
|
43
|
-
when /http:\/\/(
|
44
|
-
/http:\/\/(
|
45
|
-
/http:\/\/(
|
46
|
-
/http:\/\/(
|
47
|
-
/http:\/\/(
|
48
|
-
@server_name =
|
49
|
-
|
49
|
+
when /http:\/\/(?<server_name>.+)\.(?<openflag>open)?2ch.(?<tld>net|sc)\/test\/read.cgi\/(?<board_name>.+)\/(?<thread_key>[0-9]+)/,
|
50
|
+
/http:\/\/(?<server_name>.+)\.(?<openflag>open)?2ch.(?<tld>net|sc)\/(?<board_name>.+)\/subject\.txt/,
|
51
|
+
/http:\/\/(?<server_name>.+)\.(?<openflag>open)?2ch\.(?<tld>net|sc)\/(?<board_name>.+)\//,
|
52
|
+
/http:\/\/(?<server_name>.+)\.(?<openflag>open)?2ch\.(?<tld>net|sc)\/(?<board_name>\w+)/,
|
53
|
+
/http:\/\/(?<server_name>.+)\.(?<openflag>open)?2ch.(?<tld>net|sc)\/(.+)\/dat\/(?<thread_key>[0-9]+)\.dat/
|
54
|
+
@server_name = $~[:server_name]
|
55
|
+
@board_name = $~[:board_name]
|
56
|
+
@f_open2ch = ($~[:openflag] rescue false) && !$~[:openflag].empty? && true
|
57
|
+
board_url = URI.parse("http://#{server_name}.#{@f_open2ch ? 'open' : ''}2ch.#{@f_open2ch ? 'net' : 'sc'}/#{board_name}/")
|
50
58
|
else
|
51
|
-
raise NotA2chUrlException
|
59
|
+
raise NotA2chUrlException, "Given URL :#{url}"
|
52
60
|
end
|
53
61
|
else
|
54
|
-
raise NotA2chUrlException
|
62
|
+
raise NotA2chUrlException, "Given URL :#{url}"
|
55
63
|
end
|
56
64
|
end
|
57
65
|
|
data/lib/simple2ch/res.rb
CHANGED
@@ -103,7 +103,7 @@ module Simple2ch
|
|
103
103
|
# @param [String] dat datのデータ1行
|
104
104
|
# @raise [DatParseException] Datのパースに失敗したときに発生
|
105
105
|
def self.parse_dat(dat)
|
106
|
-
split_date_and_id_regex = /(
|
106
|
+
split_date_and_id_regex = /(?<time>^\d{4}\/\d{2}\/\d{2}\(.\) ?\d{2}:\d{2}:\d{2}(\.\d{2})?)(?: ID:(?<author_id>\S+)$){0,1}/
|
107
107
|
ret = {}
|
108
108
|
split = dat.split('<>')
|
109
109
|
ret[:author] = split[0]
|
@@ -111,12 +111,12 @@ module Simple2ch
|
|
111
111
|
date_and_author_id = split[2]
|
112
112
|
ret[:contents] = split[3].strip
|
113
113
|
|
114
|
-
|
115
|
-
|
116
|
-
|
114
|
+
if split_date_and_id_regex =~ date_and_author_id
|
115
|
+
ret[:date] = Time.parse $~[:time]
|
116
|
+
ret[:author_id] = $~[:author_id]
|
117
|
+
else
|
118
|
+
raise DatParseException, "Data didn't match regex. Data:#{date_and_author_id}"
|
117
119
|
end
|
118
|
-
ret[:date] = Time.parse $1
|
119
|
-
ret[:author_id] = $2
|
120
120
|
|
121
121
|
ret
|
122
122
|
end
|
data/lib/simple2ch/version.rb
CHANGED
data/spec/board_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Simple2ch::Board do
|
|
7
7
|
{
|
8
8
|
sc: 'http://viper.2ch.sc/news4vip/',
|
9
9
|
net: 'http://viper.2ch.net/news4vip/',
|
10
|
-
|
10
|
+
open: 'http://viper.open2ch.net/news4vip/',
|
11
11
|
not_a_2ch_format: 'http://test.example.com/hoge/',
|
12
12
|
invalid_url: 'http://abc_def.com/foobar/' # under score in host is invalid
|
13
13
|
}
|
@@ -33,6 +33,13 @@ describe Simple2ch::Board do
|
|
33
33
|
its(:size) { is_expected.to be > 0 }
|
34
34
|
end
|
35
35
|
|
36
|
+
context 'should be a valid Simple2ch::Board object' do
|
37
|
+
subject { Simple2ch::Board.new(title, url[:open]) }
|
38
|
+
its(:title) { is_expected.to be_a_kind_of String }
|
39
|
+
its(:title) { is_expected.to be == title }
|
40
|
+
its('url.to_s') { is_expected.to be == url[:open] }
|
41
|
+
end
|
42
|
+
|
36
43
|
context 'should raise NotA2chUrlException if URL is not a 2ch format' do
|
37
44
|
subject { lambda{ Simple2ch::Board.new(title, url[:not_a_2ch_format]) } }
|
38
45
|
it { is_expected.to raise_error Simple2ch::NotA2chUrlException }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple2ch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dogwood008
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|