simple2ch 0.1.0 → 0.1.1

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: f8552733fb50e08bfe9915357bb63a8aaf17d84d
4
- data.tar.gz: 82efa518c0ae987591d658ac73d429ebbf0c5802
3
+ metadata.gz: f8e580fb8a083fea874c375ed71288ee4c76bf52
4
+ data.tar.gz: 3a224cbd6e35ba9a28d7f56840def63d8ddff198
5
5
  SHA512:
6
- metadata.gz: f00a8e5b3f2abe43f2a7faa758580766341b0ef3843b019813674fbc7b6b0683fd14904d35de05c953c65f97a5ae4e08cbcae2c2a6bf41595a8199b338d001c7
7
- data.tar.gz: 202e86fffa1cc8d79c2109bac3338e0e3ee0b7590a27956b3080908b877dd062937df171af73cfd7bbf5f603cc73ea96ea14f74c8e213bb5214644adc9ffa259
6
+ metadata.gz: eb35dbbc601c75272629e93c567f1cb1a92e2b4daf76d5d83454058f0cfb9dd12803ffb3aa947ba932ad18e03369b3a373e8b3824f77d4344d663a70522342d7
7
+ data.tar.gz: a4bea9013a2cd2f2a57cc2e8c59c22ee34e0b9109061c2877492fa7ca7a5053e4d2ec5d5c272c076c70925a55b61c5da73bdbd25d5b44f91549bc47bd279b716
data/UPDATES.md ADDED
@@ -0,0 +1,28 @@
1
+ [v0.1.1]
2
+ * メソッド追加
3
+ * Res#anchorsの追加
4
+ * レス中のアンカーを抽出する
5
+ * 必要gemの追加
6
+ * Charwidthを追加
7
+
8
+ [v0.1.0]
9
+ * メソッド名の変更
10
+ * Thre.new から Thre.parse に変更
11
+ * Thre.newは引数の数を変更
12
+ * この変更に伴い、v0.0.2以下とは一部互換性無し
13
+ * バグ修正
14
+ * Time.parseの呼び出しに失敗する問題を修正
15
+ * その他
16
+ * その他微細な修正
17
+
18
+ [v0.0.2]
19
+ * メソッド名の変更
20
+ * Board#threads から Board#thres に変更
21
+ * ドキュメントの再生成
22
+ * モジュール名が誤っていたため
23
+ * README.mdを修正
24
+ * 使用法などを追加
25
+ * yardの結果を追加
26
+
27
+ [v0.0.1]
28
+ * 初版
@@ -702,7 +702,7 @@
702
702
  </div>
703
703
 
704
704
  <div id="footer">
705
- Generated on Sun Sep 7 16:55:25 2014 by
705
+ Generated on Fri Sep 12 14:07:33 2014 by
706
706
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
707
707
  0.8.7.4 (ruby-2.1.2).
708
708
  </div>
@@ -493,7 +493,7 @@
493
493
  </div>
494
494
 
495
495
  <div id="footer">
496
- Generated on Sun Sep 7 16:55:25 2014 by
496
+ Generated on Fri Sep 12 14:07:32 2014 by
497
497
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
498
498
  0.8.7.4 (ruby-2.1.2).
499
499
  </div>
@@ -122,7 +122,7 @@
122
122
  </div>
123
123
 
124
124
  <div id="footer">
125
- Generated on Sun Sep 7 16:55:25 2014 by
125
+ Generated on Fri Sep 12 14:07:33 2014 by
126
126
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
127
127
  0.8.7.4 (ruby-2.1.2).
128
128
  </div>
@@ -122,7 +122,7 @@
122
122
  </div>
123
123
 
124
124
  <div id="footer">
125
- Generated on Sun Sep 7 16:55:25 2014 by
125
+ Generated on Fri Sep 12 14:07:33 2014 by
126
126
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
127
127
  0.8.7.4 (ruby-2.1.2).
128
128
  </div>
@@ -122,7 +122,7 @@
122
122
  </div>
123
123
 
124
124
  <div id="footer">
125
- Generated on Sun Sep 7 16:55:25 2014 by
125
+ Generated on Fri Sep 12 14:07:33 2014 by
126
126
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
127
127
  0.8.7.4 (ruby-2.1.2).
128
128
  </div>
@@ -341,6 +341,30 @@
341
341
  <li class="public ">
342
342
  <span class="summary_signature">
343
343
 
344
+ <a href="#anchors-instance_method" title="#anchors (instance method)">- (Array&lt;Fixnum&gt;) <strong>anchors</strong> </a>
345
+
346
+
347
+
348
+ </span>
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+ <span class="summary_desc"><div class='inline'>
359
+ <p>アンカーを抽出する 荒らしの場合は空配列を返す.</p>
360
+ </div></span>
361
+
362
+ </li>
363
+
364
+
365
+ <li class="public ">
366
+ <span class="summary_signature">
367
+
344
368
  <a href="#initialize-instance_method" title="#initialize (instance method)">- (Res) <strong>initialize</strong>(res_num, author: &#39;&#39;, author_id: &#39;&#39;, date: nil, mail: &#39;&#39;, contents: &#39;&#39;) </a>
345
369
 
346
370
 
@@ -1010,7 +1034,7 @@
1010
1034
 
1011
1035
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_res_num'>res_num</span><span class='comma'>,</span> <span class='id identifier rubyid_contents'>contents</span><span class='rparen'>)</span>
1012
1036
  <span class='kw'>unless</span> <span class='id identifier rubyid_contents'>contents</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='op'>==</span> <span class='const'>KAKO_LOG_INFO</span>
1013
- <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='id identifier rubyid_res_num'>res_num</span><span class='comma'>,</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse_dat'>parse_dat</span><span class='lparen'>(</span><span class='id identifier rubyid_contents'>contents</span><span class='rparen'>)</span>
1037
+ <span class='kw'>return</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res_num'>res_num</span><span class='comma'>,</span> <span class='id identifier rubyid_parse_dat'>parse_dat</span><span class='lparen'>(</span><span class='id identifier rubyid_contents'>contents</span><span class='rparen'>)</span><span class='rparen'>)</span>
1014
1038
  <span class='kw'>else</span>
1015
1039
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>KakoLogException</span>
1016
1040
  <span class='kw'>end</span>
@@ -1018,6 +1042,107 @@
1018
1042
  </td>
1019
1043
  </tr>
1020
1044
  </table>
1045
+ </div>
1046
+
1047
+ </div>
1048
+
1049
+ <div id="instance_method_details" class="method_details_list">
1050
+ <h2>Instance Method Details</h2>
1051
+
1052
+
1053
+ <div class="method_details first">
1054
+ <h3 class="signature first" id="anchors-instance_method">
1055
+
1056
+ - (<tt>Array&lt;Fixnum&gt;</tt>) <strong>anchors</strong>
1057
+
1058
+
1059
+
1060
+
1061
+
1062
+ </h3><div class="docstring">
1063
+ <div class="discussion">
1064
+
1065
+ <p>アンカーを抽出する 荒らしの場合は空配列を返す</p>
1066
+
1067
+
1068
+ </div>
1069
+ </div>
1070
+ <div class="tags">
1071
+
1072
+ <p class="tag_title">Returns:</p>
1073
+ <ul class="return">
1074
+
1075
+ <li>
1076
+
1077
+
1078
+ <span class='type'>(<tt>Array&lt;Fixnum&gt;</tt>)</span>
1079
+
1080
+
1081
+
1082
+ &mdash;
1083
+ <div class='inline'>
1084
+ <p>昇順ソート済みアンカー、荒らしの場合は空配列</p>
1085
+ </div>
1086
+
1087
+ </li>
1088
+
1089
+ </ul>
1090
+
1091
+ </div><table class="source_code">
1092
+ <tr>
1093
+ <td>
1094
+ <pre class="lines">
1095
+
1096
+
1097
+ 49
1098
+ 50
1099
+ 51
1100
+ 52
1101
+ 53
1102
+ 54
1103
+ 55
1104
+ 56
1105
+ 57
1106
+ 58
1107
+ 59
1108
+ 60
1109
+ 61
1110
+ 62
1111
+ 63
1112
+ 64
1113
+ 65
1114
+ 66
1115
+ 67
1116
+ 68
1117
+ 69</pre>
1118
+ </td>
1119
+ <td>
1120
+ <pre class="code"><span class="info file"># File 'lib/simple2ch/res.rb', line 49</span>
1121
+
1122
+ <span class='kw'>def</span> <span class='id identifier rubyid_anchors'>anchors</span>
1123
+ <span class='id identifier rubyid_arashi_removal_regex'>arashi_removal_regex</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(?:\d{1,4}(?:\]*&gt;)?(?:&gt;|\[>,+-\]){1,2}){9}</span><span class='regexp_end'>/</span></span>
1124
+ <span class='kw'>unless</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_contents'>contents</span> <span class='op'>=~</span> <span class='id identifier rubyid_arashi_removal_regex'>arashi_removal_regex</span>
1125
+ <span class='id identifier rubyid_splitter_regex'>splitter_regex</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>[,、,  ]</span><span class='tstring_end'>&#39;</span></span>
1126
+ <span class='id identifier rubyid_digit_regex'>digit_regex</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>(?:\d|[0-9])+</span><span class='tstring_end'>&#39;</span></span>
1127
+ <span class='id identifier rubyid_hyphen_regex'>hyphen_regex</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>[−ーー\-〜~〜]</span><span class='tstring_end'>&#39;</span></span>
1128
+ <span class='id identifier rubyid_extracted'>extracted</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_contents'>contents</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>&amp;gt;((?:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_digit_regex'>digit_regex</span><span class='embexpr_end'>}</span><span class='tstring_content'>(?:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_splitter_regex'>splitter_regex</span><span class='embexpr_end'>}</span><span class='tstring_content'>|</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_hyphen_regex'>hyphen_regex</span><span class='embexpr_end'>}</span><span class='tstring_content'>)*)+)</span><span class='regexp_end'>/</span></span>
1129
+ <span class='id identifier rubyid_anchors'>anchors</span> <span class='op'>=</span> <span class='id identifier rubyid_extracted'>extracted</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>[\&quot;\[\]]</span><span class='regexp_end'>/</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_splitter_regex'>splitter_regex</span><span class='embexpr_end'>}</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
1130
+ <span class='id identifier rubyid_anchors'>anchors</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
1131
+ <span class='id identifier rubyid_anchors'>anchors</span><span class='period'>.</span><span class='id identifier rubyid_map!'>map!</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='op'>|</span>
1132
+ <span class='kw'>if</span> <span class='id identifier rubyid_a'>a</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_digit_regex'>digit_regex</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_hyphen_regex'>hyphen_regex</span><span class='embexpr_end'>}</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_digit_regex'>digit_regex</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='regexp_end'>/</span></span>
1133
+ <span class='lparen'>(</span><span class='const'>Range</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='id identifier rubyid_parseInt'>parseInt</span><span class='lparen'>(</span><span class='backref'>$1</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_parseInt'>parseInt</span><span class='lparen'>(</span><span class='backref'>$2</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
1134
+ <span class='kw'>else</span>
1135
+ <span class='id identifier rubyid_parseInt'>parseInt</span><span class='lparen'>(</span><span class='id identifier rubyid_a'>a</span><span class='rparen'>)</span>
1136
+ <span class='kw'>end</span>
1137
+ <span class='kw'>end</span>
1138
+ <span class='id identifier rubyid_anchors'>anchors</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span>
1139
+ <span class='kw'>else</span>
1140
+ <span class='lbracket'>[</span><span class='rbracket'>]</span>
1141
+ <span class='kw'>end</span>
1142
+ <span class='kw'>end</span></pre>
1143
+ </td>
1144
+ </tr>
1145
+ </table>
1021
1146
  </div>
1022
1147
 
1023
1148
  </div>
@@ -1025,7 +1150,7 @@
1025
1150
  </div>
1026
1151
 
1027
1152
  <div id="footer">
1028
- Generated on Sun Sep 7 16:55:25 2014 by
1153
+ Generated on Fri Sep 12 14:07:33 2014 by
1029
1154
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1030
1155
  0.8.7.4 (ruby-2.1.2).
1031
1156
  </div>
@@ -118,7 +118,7 @@
118
118
  </div>
119
119
 
120
120
  <div id="footer">
121
- Generated on Sun Sep 7 16:55:25 2014 by
121
+ Generated on Fri Sep 12 14:07:33 2014 by
122
122
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
123
  0.8.7.4 (ruby-2.1.2).
124
124
  </div>
@@ -228,6 +228,39 @@
228
228
 
229
229
 
230
230
 
231
+ <h2>
232
+ Class Method Summary
233
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
234
+ </h2>
235
+
236
+ <ul class="summary">
237
+
238
+ <li class="public ">
239
+ <span class="summary_signature">
240
+
241
+ <a href="#parse-class_method" title="parse (class method)">+ (Thre) <strong>parse</strong>(board, thread_data) </a>
242
+
243
+
244
+
245
+ </span>
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+ <span class="summary_desc"><div class='inline'>
256
+ <p>板オブジェクトとsubject.txtの1行データを渡すとスレオブジェクトを返す.</p>
257
+ </div></span>
258
+
259
+ </li>
260
+
261
+
262
+ </ul>
263
+
231
264
  <h2>
232
265
  Instance Method Summary
233
266
  <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
@@ -238,7 +271,7 @@
238
271
  <li class="public ">
239
272
  <span class="summary_signature">
240
273
 
241
- <a href="#initialize-instance_method" title="#initialize (instance method)">- (Thre) <strong>initialize</strong>(board, thread_data) </a>
274
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Thre) <strong>initialize</strong>(board, thread_key, title: &#39;&#39;, num_of_response: &#39;&#39;) </a>
242
275
 
243
276
 
244
277
 
@@ -318,7 +351,7 @@
318
351
  <div class="method_details first">
319
352
  <h3 class="signature first" id="initialize-instance_method">
320
353
 
321
- - (<tt><span class='object_link'><a href="" title="Simple2ch::Thre (class)">Thre</a></span></tt>) <strong>initialize</strong>(board, thread_data)
354
+ - (<tt><span class='object_link'><a href="" title="Simple2ch::Thre (class)">Thre</a></span></tt>) <strong>initialize</strong>(board, thread_key, title: &#39;&#39;, num_of_response: &#39;&#39;)
322
355
 
323
356
 
324
357
 
@@ -354,7 +387,7 @@
354
387
 
355
388
  <li>
356
389
 
357
- <span class='name'>thread_data</span>
390
+ <span class='name'>thread_key</span>
358
391
 
359
392
 
360
393
  <span class='type'>(<tt>String</tt>)</span>
@@ -363,7 +396,39 @@
363
396
 
364
397
  &mdash;
365
398
  <div class='inline'>
366
- <p>0000000000.dat&lt;&gt;スレッドタイトル (レス数)</p>
399
+ <p>スレッドキー</p>
400
+ </div>
401
+
402
+ </li>
403
+
404
+ <li>
405
+
406
+ <span class='name'>title</span>
407
+
408
+
409
+ <span class='type'>(<tt>String</tt>)</span>
410
+
411
+
412
+
413
+ &mdash;
414
+ <div class='inline'>
415
+ <p>スレッド名</p>
416
+ </div>
417
+
418
+ </li>
419
+
420
+ <li>
421
+
422
+ <span class='name'>num_of_response</span>
423
+
424
+
425
+ <span class='type'>(<tt>Fixnum</tt>)</span>
426
+
427
+
428
+
429
+ &mdash;
430
+ <div class='inline'>
431
+ <p>総書き込み数</p>
367
432
  </div>
368
433
 
369
434
  </li>
@@ -377,25 +442,23 @@
377
442
  <pre class="lines">
378
443
 
379
444
 
380
- 14
381
- 15
382
445
  16
383
446
  17
384
447
  18
385
448
  19
386
449
  20
387
450
  21
388
- 22</pre>
451
+ 22
452
+ 23</pre>
389
453
  </td>
390
454
  <td>
391
- <pre class="code"><span class="info file"># File 'lib/simple2ch/thre.rb', line 14</span>
455
+ <pre class="code"><span class="info file"># File 'lib/simple2ch/thre.rb', line 16</span>
392
456
 
393
- <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_board'>board</span><span class='comma'>,</span> <span class='id identifier rubyid_thread_data'>thread_data</span><span class='rparen'>)</span>
457
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_board'>board</span><span class='comma'>,</span> <span class='id identifier rubyid_thread_key'>thread_key</span><span class='comma'>,</span> <span class='label'>title:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>num_of_response:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
394
458
  <span class='ivar'>@board</span> <span class='op'>=</span> <span class='id identifier rubyid_board'>board</span>
395
- <span class='id identifier rubyid_thread_data'>thread_data</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\d{10})\.dat&lt;&gt;(.+) \((\d+)\)</span><span class='regexp_end'>/</span></span>
396
- <span class='ivar'>@thread_key</span> <span class='op'>=</span> <span class='backref'>$1</span>
397
- <span class='ivar'>@title</span> <span class='op'>=</span> <span class='backref'>$2</span>
398
- <span class='ivar'>@num_of_response</span> <span class='op'>=</span> <span class='backref'>$3</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
459
+ <span class='ivar'>@thread_key</span> <span class='op'>=</span> <span class='id identifier rubyid_thread_key'>thread_key</span>
460
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_title'>title</span>
461
+ <span class='ivar'>@num_of_response</span> <span class='op'>=</span> <span class='id identifier rubyid_num_of_response'>num_of_response</span>
399
462
  <span class='ivar'>@reses</span> <span class='op'>=</span> <span class='kw'>nil</span>
400
463
  <span class='ivar'>@f_kako_log</span> <span class='op'>=</span> <span class='kw'>nil</span>
401
464
  <span class='kw'>end</span></pre>
@@ -656,6 +719,117 @@
656
719
  </div>
657
720
 
658
721
 
722
+ <div id="class_method_details" class="method_details_list">
723
+ <h2>Class Method Details</h2>
724
+
725
+
726
+ <div class="method_details first">
727
+ <h3 class="signature first" id="parse-class_method">
728
+
729
+ + (<tt><span class='object_link'><a href="" title="Simple2ch::Thre (class)">Thre</a></span></tt>) <strong>parse</strong>(board, thread_data)
730
+
731
+
732
+
733
+
734
+
735
+ </h3><div class="docstring">
736
+ <div class="discussion">
737
+
738
+ <p>板オブジェクトとsubject.txtの1行データを渡すとスレオブジェクトを返す</p>
739
+
740
+
741
+ </div>
742
+ </div>
743
+ <div class="tags">
744
+ <p class="tag_title">Parameters:</p>
745
+ <ul class="param">
746
+
747
+ <li>
748
+
749
+ <span class='name'>board</span>
750
+
751
+
752
+ <span class='type'>(<tt><span class='object_link'><a href="Board.html" title="Simple2ch::Board (class)">Board</a></span></tt>)</span>
753
+
754
+
755
+
756
+ &mdash;
757
+ <div class='inline'>
758
+ <p>スレッドが属する板情報</p>
759
+ </div>
760
+
761
+ </li>
762
+
763
+ <li>
764
+
765
+ <span class='name'>thread_data</span>
766
+
767
+
768
+ <span class='type'>(<tt>String</tt>)</span>
769
+
770
+
771
+
772
+ &mdash;
773
+ <div class='inline'>
774
+ <p>0000000000.dat&lt;&gt;スレッドタイトル (レス数)</p>
775
+ </div>
776
+
777
+ </li>
778
+
779
+ </ul>
780
+
781
+ <p class="tag_title">Returns:</p>
782
+ <ul class="return">
783
+
784
+ <li>
785
+
786
+
787
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Simple2ch::Thre (class)">Thre</a></span></tt>)</span>
788
+
789
+
790
+
791
+ &mdash;
792
+ <div class='inline'>
793
+ <p>スレ</p>
794
+ </div>
795
+
796
+ </li>
797
+
798
+ </ul>
799
+
800
+ </div><table class="source_code">
801
+ <tr>
802
+ <td>
803
+ <pre class="lines">
804
+
805
+
806
+ 29
807
+ 30
808
+ 31
809
+ 32
810
+ 33
811
+ 34
812
+ 35
813
+ 36</pre>
814
+ </td>
815
+ <td>
816
+ <pre class="code"><span class="info file"># File 'lib/simple2ch/thre.rb', line 29</span>
817
+
818
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_board'>board</span><span class='comma'>,</span> <span class='id identifier rubyid_thread_data'>thread_data</span><span class='rparen'>)</span>
819
+ <span class='id identifier rubyid_thread_data'>thread_data</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\d{10})\.dat&lt;&gt;(.+) \((\d+)\)</span><span class='regexp_end'>/</span></span>
820
+ <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
821
+ <span class='id identifier rubyid_thread_key'>thread_key</span> <span class='op'>=</span> <span class='backref'>$1</span>
822
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:title</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='backref'>$2</span>
823
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:num_of_response</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='backref'>$3</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
824
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='id identifier rubyid_board'>board</span><span class='comma'>,</span> <span class='id identifier rubyid_thread_key'>thread_key</span><span class='comma'>,</span> <span class='id identifier rubyid_hash'>hash</span>
825
+ <span class='kw'>end</span></pre>
826
+ </td>
827
+ </tr>
828
+ </table>
829
+ </div>
830
+
831
+ </div>
832
+
659
833
  <div id="instance_method_details" class="method_details_list">
660
834
  <h2>Instance Method Details</h2>
661
835
 
@@ -704,12 +878,12 @@
704
878
  <pre class="lines">
705
879
 
706
880
 
707
- 32
708
- 33
709
- 34</pre>
881
+ 46
882
+ 47
883
+ 48</pre>
710
884
  </td>
711
885
  <td>
712
- <pre class="code"><span class="info file"># File 'lib/simple2ch/thre.rb', line 32</span>
886
+ <pre class="code"><span class="info file"># File 'lib/simple2ch/thre.rb', line 46</span>
713
887
 
714
888
  <span class='kw'>def</span> <span class='id identifier rubyid_kako_log?'>kako_log?</span>
715
889
  <span class='ivar'>@f_kako_log</span> <span class='op'>||</span> <span class='id identifier rubyid_fetch_dat'>fetch_dat</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
@@ -763,12 +937,12 @@
763
937
  <pre class="lines">
764
938
 
765
939
 
766
- 26
767
- 27
768
- 28</pre>
940
+ 40
941
+ 41
942
+ 42</pre>
769
943
  </td>
770
944
  <td>
771
- <pre class="code"><span class="info file"># File 'lib/simple2ch/thre.rb', line 26</span>
945
+ <pre class="code"><span class="info file"># File 'lib/simple2ch/thre.rb', line 40</span>
772
946
 
773
947
  <span class='kw'>def</span> <span class='id identifier rubyid_reses'>reses</span>
774
948
  <span class='ivar'>@reses</span> <span class='op'>||</span> <span class='id identifier rubyid_fetch_dat'>fetch_dat</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
@@ -783,7 +957,7 @@
783
957
  </div>
784
958
 
785
959
  <div id="footer">
786
- Generated on Sun Sep 7 16:55:25 2014 by
960
+ Generated on Fri Sep 12 14:07:33 2014 by
787
961
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
788
962
  0.8.7.4 (ruby-2.1.2).
789
963
  </div>
data/doc/Simple2ch.html CHANGED
@@ -104,12 +104,12 @@
104
104
  <dt id="DEBUG-constant" class="">DEBUG =
105
105
 
106
106
  </dt>
107
- <dd><pre class="code"><span class='kw'>true</span></pre></dd>
107
+ <dd><pre class="code"><span class='kw'>false</span></pre></dd>
108
108
 
109
109
  <dt id="VERSION-constant" class="">VERSION =
110
110
 
111
111
  </dt>
112
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.0.2</span><span class='tstring_end'>&quot;</span></span></pre></dd>
112
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.1</span><span class='tstring_end'>&quot;</span></span></pre></dd>
113
113
 
114
114
  </dl>
115
115
 
@@ -247,16 +247,16 @@
247
247
  <pre class="lines">
248
248
 
249
249
 
250
- 21
251
- 22
252
250
  23
253
251
  24
254
252
  25
255
253
  26
256
- 27</pre>
254
+ 27
255
+ 28
256
+ 29</pre>
257
257
  </td>
258
258
  <td>
259
- <pre class="code"><span class="info file"># File 'lib/simple2ch.rb', line 21</span>
259
+ <pre class="code"><span class="info file"># File 'lib/simple2ch.rb', line 23</span>
260
260
 
261
261
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
262
262
  <span class='id identifier rubyid_req'>req</span> <span class='op'>=</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='op'>::</span><span class='const'>Get</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
@@ -285,12 +285,12 @@
285
285
  <pre class="lines">
286
286
 
287
287
 
288
- 14
289
- 15
290
- 16</pre>
288
+ 16
289
+ 17
290
+ 18</pre>
291
291
  </td>
292
292
  <td>
293
- <pre class="code"><span class="info file"># File 'lib/simple2ch.rb', line 14</span>
293
+ <pre class="code"><span class="info file"># File 'lib/simple2ch.rb', line 16</span>
294
294
 
295
295
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_root'>root</span>
296
296
  <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span> <span class='id identifier rubyid___dir__'>__dir__</span>
@@ -305,7 +305,7 @@
305
305
  </div>
306
306
 
307
307
  <div id="footer">
308
- Generated on Sun Sep 7 16:55:25 2014 by
308
+ Generated on Fri Sep 12 14:07:32 2014 by
309
309
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
310
310
  0.8.7.4 (ruby-2.1.2).
311
311
  </div>
data/doc/_index.html CHANGED
@@ -205,7 +205,7 @@
205
205
  </div>
206
206
 
207
207
  <div id="footer">
208
- Generated on Sun Sep 7 16:55:25 2014 by
208
+ Generated on Fri Sep 12 14:07:32 2014 by
209
209
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
210
210
  0.8.7.4 (ruby-2.1.2).
211
211
  </div>
data/doc/file.README.html CHANGED
@@ -64,7 +64,21 @@
64
64
  <div id="content"><div id='filecontents'>
65
65
  <h1 id="label-Simple2ch">Simple2ch</h1>
66
66
 
67
- <p>2ch Japanese BBS simple reader.</p>
67
+ <p>2ch Japanese BBS simple reader for Ruby.</p>
68
+
69
+ <p>Ruby用の2chの簡易リーダーです。</p>
70
+
71
+ <p><img src="https://badge.fury.io/rb/simple2ch.svg"> <a
72
+ href="http://dogwood008.github.io/simple2ch/">リファレンス</a></p>
73
+
74
+ <h2 id="label-%E6%9B%B4%E6%96%B0%E5%86%85%E5%AE%B9">更新内容</h2>
75
+
76
+ <p>[v0.1.0] * メソッド名の変更 * Thre.new から Thre.parse に変更 * Thre.newは引数の数を変更 *
77
+ この変更に伴い、v0.0.2以下とは一部互換性無し * バグ修正 * Time.parseの呼び出しに失敗する問題を修正 * その他 *
78
+ その他微細な修正</p>
79
+
80
+ <p>[v0.0.2] * メソッド名の変更 * Board#threads から Board#thres に変更 * ドキュメントの再生成 *
81
+ モジュール名が誤っていたため * README.mdを修正 * 使用法などを追加 * yardの結果を追加</p>
68
82
 
69
83
  <h2 id="label-Installation">Installation</h2>
70
84
 
@@ -88,13 +102,13 @@
88
102
  &#39;http://viper.2ch.sc/news4vip/&#39;) board.thres
89
103
  #=&gt;[#&lt;Simple2ch::Thre&gt;, ..., #&lt;Simple2ch::Thre&gt;] </code></p>
90
104
  </li><li>
91
- <p>レス取得 <code>ruby thre = board.thres[hoge] #=&gt; #&lt;Simple2ch::Thre&gt;
92
- thre.reses #=&gt; [#&lt;Simple2ch::Res&gt;, ..., #&lt;Simple2ch::Res&gt;]
93
- </code></p>
105
+ <p>レス取得 <code>ruby hoge = SUM_OF_NUMBER1 thre = board.thres[hoge] #=&gt;
106
+ #&lt;Simple2ch::Thre&gt; thre.reses #=&gt; [#&lt;Simple2ch::Res&gt;, ...,
107
+ #&lt;Simple2ch::Res&gt;] </code></p>
94
108
  </li><li>
95
- <p>書き込み内容取得 <code>ruby res = thre.reses[foo] #=&gt; #&lt;Simple2ch::Res&gt;
96
- res.author #=&gt; &quot;以下、\(^o^)/でVIPがお送りします&quot; res.contents #=&gt;
97
- &quot;hoge foo bar&quot; </code></p>
109
+ <p>書き込み内容取得 <code>ruby foo = SUM_OF_NUMBER2 res = thre.reses[foo] #=&gt;
110
+ #&lt;Simple2ch::Res&gt; res.author #=&gt; &quot;以下、\(^o^)/でVIPがお送りします&quot;
111
+ res.contents #=&gt; &quot;hoge foo bar&quot; </code></p>
98
112
  </li></ul>
99
113
 
100
114
  <h2 id="label-Contributing">Contributing</h2>
@@ -115,7 +129,7 @@ feature&#39;</code>)</p>
115
129
  </div></div>
116
130
 
117
131
  <div id="footer">
118
- Generated on Sun Sep 7 16:55:25 2014 by
132
+ Generated on Fri Sep 12 14:07:32 2014 by
119
133
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
120
134
  0.8.7.4 (ruby-2.1.2).
121
135
  </div>
data/doc/index.html CHANGED
@@ -64,7 +64,21 @@
64
64
  <div id="content"><div id='filecontents'>
65
65
  <h1 id="label-Simple2ch">Simple2ch</h1>
66
66
 
67
- <p>2ch Japanese BBS simple reader.</p>
67
+ <p>2ch Japanese BBS simple reader for Ruby.</p>
68
+
69
+ <p>Ruby用の2chの簡易リーダーです。</p>
70
+
71
+ <p><img src="https://badge.fury.io/rb/simple2ch.svg"> <a
72
+ href="http://dogwood008.github.io/simple2ch/">リファレンス</a></p>
73
+
74
+ <h2 id="label-%E6%9B%B4%E6%96%B0%E5%86%85%E5%AE%B9">更新内容</h2>
75
+
76
+ <p>[v0.1.0] * メソッド名の変更 * Thre.new から Thre.parse に変更 * Thre.newは引数の数を変更 *
77
+ この変更に伴い、v0.0.2以下とは一部互換性無し * バグ修正 * Time.parseの呼び出しに失敗する問題を修正 * その他 *
78
+ その他微細な修正</p>
79
+
80
+ <p>[v0.0.2] * メソッド名の変更 * Board#threads から Board#thres に変更 * ドキュメントの再生成 *
81
+ モジュール名が誤っていたため * README.mdを修正 * 使用法などを追加 * yardの結果を追加</p>
68
82
 
69
83
  <h2 id="label-Installation">Installation</h2>
70
84
 
@@ -88,13 +102,13 @@
88
102
  &#39;http://viper.2ch.sc/news4vip/&#39;) board.thres
89
103
  #=&gt;[#&lt;Simple2ch::Thre&gt;, ..., #&lt;Simple2ch::Thre&gt;] </code></p>
90
104
  </li><li>
91
- <p>レス取得 <code>ruby thre = board.thres[hoge] #=&gt; #&lt;Simple2ch::Thre&gt;
92
- thre.reses #=&gt; [#&lt;Simple2ch::Res&gt;, ..., #&lt;Simple2ch::Res&gt;]
93
- </code></p>
105
+ <p>レス取得 <code>ruby hoge = SUM_OF_NUMBER1 thre = board.thres[hoge] #=&gt;
106
+ #&lt;Simple2ch::Thre&gt; thre.reses #=&gt; [#&lt;Simple2ch::Res&gt;, ...,
107
+ #&lt;Simple2ch::Res&gt;] </code></p>
94
108
  </li><li>
95
- <p>書き込み内容取得 <code>ruby res = thre.reses[foo] #=&gt; #&lt;Simple2ch::Res&gt;
96
- res.author #=&gt; &quot;以下、\(^o^)/でVIPがお送りします&quot; res.contents #=&gt;
97
- &quot;hoge foo bar&quot; </code></p>
109
+ <p>書き込み内容取得 <code>ruby foo = SUM_OF_NUMBER2 res = thre.reses[foo] #=&gt;
110
+ #&lt;Simple2ch::Res&gt; res.author #=&gt; &quot;以下、\(^o^)/でVIPがお送りします&quot;
111
+ res.contents #=&gt; &quot;hoge foo bar&quot; </code></p>
98
112
  </li></ul>
99
113
 
100
114
  <h2 id="label-Contributing">Contributing</h2>
@@ -115,7 +129,7 @@ feature&#39;</code>)</p>
115
129
  </div></div>
116
130
 
117
131
  <div id="footer">
118
- Generated on Sun Sep 7 16:55:25 2014 by
132
+ Generated on Fri Sep 12 14:07:32 2014 by
119
133
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
120
134
  0.8.7.4 (ruby-2.1.2).
121
135
  </div>
data/doc/method_list.html CHANGED
@@ -48,59 +48,59 @@
48
48
 
49
49
 
50
50
  <li class="r1 ">
51
- <span class='object_link'><a href="Simple2ch/Res.html#author-instance_method" title="Simple2ch::Res#author (method)">#author</a></span>
51
+ <span class='object_link'><a href="Simple2ch/Res.html#anchors-instance_method" title="Simple2ch::Res#anchors (method)">#anchors</a></span>
52
52
  <small>Simple2ch::Res</small>
53
53
  </li>
54
54
 
55
55
 
56
56
  <li class="r2 ">
57
- <span class='object_link'><a href="Simple2ch/Res.html#author_id-instance_method" title="Simple2ch::Res#author_id (method)">#author_id</a></span>
57
+ <span class='object_link'><a href="Simple2ch/Res.html#author-instance_method" title="Simple2ch::Res#author (method)">#author</a></span>
58
58
  <small>Simple2ch::Res</small>
59
59
  </li>
60
60
 
61
61
 
62
62
  <li class="r1 ">
63
+ <span class='object_link'><a href="Simple2ch/Res.html#author_id-instance_method" title="Simple2ch::Res#author_id (method)">#author_id</a></span>
64
+ <small>Simple2ch::Res</small>
65
+ </li>
66
+
67
+
68
+ <li class="r2 ">
63
69
  <span class='object_link'><a href="Simple2ch/Thre.html#board-instance_method" title="Simple2ch::Thre#board (method)">#board</a></span>
64
70
  <small>Simple2ch::Thre</small>
65
71
  </li>
66
72
 
67
73
 
68
- <li class="r2 ">
74
+ <li class="r1 ">
69
75
  <span class='object_link'><a href="Simple2ch/Board.html#board_name-instance_method" title="Simple2ch::Board#board_name (method)">#board_name</a></span>
70
76
  <small>Simple2ch::Board</small>
71
77
  </li>
72
78
 
73
79
 
74
- <li class="r1 ">
80
+ <li class="r2 ">
75
81
  <span class='object_link'><a href="Simple2ch/Res.html#contents-instance_method" title="Simple2ch::Res#contents (method)">#contents</a></span>
76
82
  <small>Simple2ch::Res</small>
77
83
  </li>
78
84
 
79
85
 
80
- <li class="r2 ">
86
+ <li class="r1 ">
81
87
  <span class='object_link'><a href="Simple2ch/Res.html#date-instance_method" title="Simple2ch::Res#date (method)">#date</a></span>
82
88
  <small>Simple2ch::Res</small>
83
89
  </li>
84
90
 
85
91
 
86
- <li class="r1 ">
92
+ <li class="r2 ">
87
93
  <span class='object_link'><a href="Simple2ch.html#fetch-class_method" title="Simple2ch.fetch (method)">fetch</a></span>
88
94
  <small>Simple2ch</small>
89
95
  </li>
90
96
 
91
97
 
92
- <li class="r2 ">
98
+ <li class="r1 ">
93
99
  <span class='object_link'><a href="Simple2ch/Board.html#initialize-instance_method" title="Simple2ch::Board#initialize (method)">#initialize</a></span>
94
100
  <small>Simple2ch::Board</small>
95
101
  </li>
96
102
 
97
103
 
98
- <li class="r1 ">
99
- <span class='object_link'><a href="Simple2ch/Res.html#initialize-instance_method" title="Simple2ch::Res#initialize (method)">#initialize</a></span>
100
- <small>Simple2ch::Res</small>
101
- </li>
102
-
103
-
104
104
  <li class="r2 ">
105
105
  <span class='object_link'><a href="Simple2ch/Dat.html#initialize-instance_method" title="Simple2ch::Dat#initialize (method)">#initialize</a></span>
106
106
  <small>Simple2ch::Dat</small>
@@ -114,8 +114,8 @@
114
114
 
115
115
 
116
116
  <li class="r2 ">
117
- <span class='object_link'><a href="Simple2ch/Thre.html#kako_log%3F-instance_method" title="Simple2ch::Thre#kako_log? (method)">#kako_log?</a></span>
118
- <small>Simple2ch::Thre</small>
117
+ <span class='object_link'><a href="Simple2ch/Res.html#initialize-instance_method" title="Simple2ch::Res#initialize (method)">#initialize</a></span>
118
+ <small>Simple2ch::Res</small>
119
119
  </li>
120
120
 
121
121
 
@@ -126,23 +126,35 @@
126
126
 
127
127
 
128
128
  <li class="r2 ">
129
+ <span class='object_link'><a href="Simple2ch/Thre.html#kako_log%3F-instance_method" title="Simple2ch::Thre#kako_log? (method)">#kako_log?</a></span>
130
+ <small>Simple2ch::Thre</small>
131
+ </li>
132
+
133
+
134
+ <li class="r1 ">
129
135
  <span class='object_link'><a href="Simple2ch/Res.html#mail-instance_method" title="Simple2ch::Res#mail (method)">#mail</a></span>
130
136
  <small>Simple2ch::Res</small>
131
137
  </li>
132
138
 
133
139
 
134
- <li class="r1 ">
140
+ <li class="r2 ">
135
141
  <span class='object_link'><a href="Simple2ch/Thre.html#num_of_response-instance_method" title="Simple2ch::Thre#num_of_response (method)">#num_of_response</a></span>
136
142
  <small>Simple2ch::Thre</small>
137
143
  </li>
138
144
 
139
145
 
140
- <li class="r2 ">
146
+ <li class="r1 ">
141
147
  <span class='object_link'><a href="Simple2ch/Res.html#parse-class_method" title="Simple2ch::Res.parse (method)">parse</a></span>
142
148
  <small>Simple2ch::Res</small>
143
149
  </li>
144
150
 
145
151
 
152
+ <li class="r2 ">
153
+ <span class='object_link'><a href="Simple2ch/Thre.html#parse-class_method" title="Simple2ch::Thre.parse (method)">parse</a></span>
154
+ <small>Simple2ch::Thre</small>
155
+ </li>
156
+
157
+
146
158
  <li class="r1 ">
147
159
  <span class='object_link'><a href="Simple2ch/Res.html#res_num-instance_method" title="Simple2ch::Res#res_num (method)">#res_num</a></span>
148
160
  <small>Simple2ch::Res</small>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sun Sep 7 16:55:25 2014 by
106
+ Generated on Fri Sep 12 14:07:32 2014 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.4 (ruby-2.1.2).
109
109
  </div>
data/lib/simple2ch/res.rb CHANGED
@@ -38,13 +38,44 @@ module Simple2ch
38
38
  # @raise [KakoLogException] 過去ログ情報をパースしようとした際に発生
39
39
  def self.parse(res_num, contents)
40
40
  unless contents.strip == KAKO_LOG_INFO
41
- self.new res_num, self.parse_dat(contents)
41
+ return self.new(res_num, parse_dat(contents))
42
42
  else
43
43
  raise KakoLogException
44
44
  end
45
45
  end
46
46
 
47
+ # アンカーを抽出する 荒らしの場合は空配列を返す
48
+ # @return [Array<Fixnum>] 昇順ソート済みアンカー、荒らしの場合は空配列
49
+ def anchors
50
+ arashi_removal_regex = /(?:\d{1,4}(?:\]*>)?(?:>|\[>,+-\]){1,2}){9}/
51
+ unless self.contents =~ arashi_removal_regex
52
+ splitter_regex = '[,、,  ]'
53
+ digit_regex = '(?:\d|[0-9])+'
54
+ hyphen_regex = '[−ーー\-〜~〜]'
55
+ extracted = self.contents.scan /&gt;((?:#{digit_regex}(?:#{splitter_regex}|#{hyphen_regex})*)+)/
56
+ anchors = extracted.flatten.to_s.gsub(/[\"\[\]]/,'').split(/#{splitter_regex}/)
57
+ anchors.delete('')
58
+ anchors.map! do |a|
59
+ if a =~ /(#{digit_regex})#{hyphen_regex}(#{digit_regex})/
60
+ (Range.new parseInt($1), parseInt($2)).to_a
61
+ else
62
+ parseInt(a)
63
+ end
64
+ end
65
+ anchors.flatten.uniq.sort
66
+ else
67
+ []
68
+ end
69
+ end
70
+
47
71
  private
72
+ # 全角数字をFixnumへ変換する
73
+ # @param [String] strnum 全角数字
74
+ # @return [Fixnum] 数字
75
+ def parseInt(strnum)
76
+ (Charwidth.normalize strnum).to_i
77
+ end
78
+
48
79
  # Datの1行から各項目を分離して、Resオブジェクトを返すメソッドの実体
49
80
  # @param [String] dat datのデータ1行
50
81
  # @raise [DatParseException] Datのパースに失敗したときに発生
@@ -1,3 +1,3 @@
1
1
  module Simple2ch
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/simple2ch.rb CHANGED
@@ -10,6 +10,7 @@ module Simple2ch
10
10
  require 'simple2ch/thre'
11
11
  require 'net/http'
12
12
  require 'time'
13
+ require 'charwidth'
13
14
  require 'pp' if DEBUG
14
15
 
15
16
  def self.root
data/simple2ch.gemspec CHANGED
@@ -4,22 +4,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'simple2ch/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- updates = %q{[v0.1.0]
8
- * メソッド名の変更
9
- * Thre.new から Thre.parse に変更
10
- * Thre.newは引数の数を変更
11
- * この変更に伴い、v0.0.2以下とは一部互換性無し
12
- * バグ修正
13
- * Time.parseの呼び出しに失敗する問題を修正
14
- * その他
15
- * その他微細な修正}
16
7
 
17
8
  spec.name = "simple2ch"
18
9
  spec.version = Simple2ch::VERSION
19
10
  spec.authors = ["dogwood008"]
20
11
  spec.email = ["dogwood008+rubygems@gmail.com"]
21
12
  spec.summary = %q{2ch Japanese BBS simple reader.}
22
- spec.description = spec.summary+"\n"+updates
13
+ spec.description = spec.summary
23
14
  spec.homepage = "https://github.com/dogwood008/simple2ch"
24
15
  spec.license = "MIT"
25
16
 
@@ -33,9 +24,9 @@ Gem::Specification.new do |spec|
33
24
  spec.add_development_dependency "rspec"
34
25
  spec.add_development_dependency "rspec-core"
35
26
  spec.add_development_dependency 'rspec-its'
36
- spec.add_development_dependency 'spork'
37
27
 
38
28
  spec.required_ruby_version = '~> 2.0'
29
+ spec.add_dependency 'charwidth', '~> 0.1.3'
39
30
 
40
31
  # spec.add_development_dependency 'spring'
41
32
  # spec.add_development_dependency 'zeus'
data/spec/res_spec.rb CHANGED
@@ -39,4 +39,60 @@ describe Simple2ch::Res do
39
39
  it { is_expected.to be_a_kind_of(Time) }
40
40
  it { is_expected.not_to be eq nil }
41
41
  end
42
+
43
+ describe '#anchors' do
44
+ shared_examples('have valid anchors') do
45
+ let(:res_num) { 100 }
46
+ subject { Res.new(res_num, contents: contents) }
47
+
48
+ describe 'that\'s anchored res is valid' do
49
+ its(:anchors) { is_expected.to be_a_kind_of Array }
50
+ its(:anchors) { is_expected.to be == anchor }
51
+ its('anchors.size') { is_expected.to be == anchor.size }
52
+ end
53
+ end
54
+ context 'when it have anchors separated commas' do
55
+ let(:contents) { %Q{&gt;&gt;1, 2, 3,12, 34\n9} }
56
+ let(:anchor) { [1, 2, 3, 12, 34] }
57
+ it_behaves_like 'have valid anchors'
58
+ end
59
+ context 'when it have anchors separated commas & spaces' do
60
+ let(:contents) { %Q{&gt;&gt;1, 2, 3 4 5 6, 12、 34\n9} }
61
+ let(:anchor) { [1, 2, 3, 4, 5, 6, 12, 34] }
62
+ it_behaves_like 'have valid anchors'
63
+ end
64
+ context 'when it have anchors range' do
65
+ let(:contents) { %Q{&gt;1-5\n9} }
66
+ let(:anchor) { (1..5).to_a }
67
+ it_behaves_like 'have valid anchors'
68
+ end
69
+ context 'when it have range and separated anchors pattern#1' do
70
+ let(:contents){%Q{&gt;1-5,6,8}}
71
+ let(:anchor) {[1,2,3,4,5,6,8]}
72
+ it_behaves_like 'have valid anchors'
73
+ end
74
+ context 'when it have range and separated anchors pattern#2' do
75
+ let(:contents){%Q{&gt;1,3, 9−13\n25}}
76
+ let(:anchor) {[1,3,9,10,11,12,13]}
77
+ it_behaves_like 'have valid anchors'
78
+ end
79
+ context 'when it have ARASHI anchors' do
80
+ let(:contents) { %Q{>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
81
+ >52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,
82
+
83
+ >>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
84
+   ∧_∧
85
+   (´・ω・`)     n
86
+  ̄ ..    \    ( E)
87
+ フ ア.フ.ィ /ヽ ヽ_//
88
+ >>21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
89
+   ∧_∧
90
+   (´・ω・`)     n
91
+  ̄   ..  \    ( E)
92
+ フ ア.フ.ィ /ヽ ヽ_//
93
+ >>41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60 } }
94
+ let(:anchor) { [] }
95
+ it_behaves_like 'have valid anchors'
96
+ end
97
+ end
42
98
  end
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dogwood008
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-07 00:00:00.000000000 Z
11
+ date: 2014-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,30 +81,20 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: spork
84
+ name: charwidth
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
89
+ version: 0.1.3
90
+ type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
97
- description: |-
98
- 2ch Japanese BBS simple reader.
99
- [v0.1.0]
100
- * メソッド名の変更
101
- * Thre.new から Thre.parse に変更
102
- * Thre.newは引数の数を変更
103
- * この変更に伴い、v0.0.2以下とは一部互換性無し
104
- * バグ修正
105
- * Time.parseの呼び出しに失敗する問題を修正
106
- * その他
107
- * その他微細な修正
96
+ version: 0.1.3
97
+ description: 2ch Japanese BBS simple reader.
108
98
  email:
109
99
  - dogwood008+rubygems@gmail.com
110
100
  executables: []
@@ -116,6 +106,7 @@ files:
116
106
  - LICENSE.txt
117
107
  - README.md
118
108
  - Rakefile
109
+ - UPDATES.md
119
110
  - doc/Simple2ch.html
120
111
  - doc/Simple2ch/Board.html
121
112
  - doc/Simple2ch/Dat.html