simple2ch 0.0.2 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1092af3dbb8c3dd2538bd14c839330a1652e263
4
- data.tar.gz: 4e4666e4a9a94da69ff319905109bd058e6bb78e
3
+ metadata.gz: f8552733fb50e08bfe9915357bb63a8aaf17d84d
4
+ data.tar.gz: 82efa518c0ae987591d658ac73d429ebbf0c5802
5
5
  SHA512:
6
- metadata.gz: 45832b276d0bd4bc7cd2b3a48f7051bee3176e1bb7acd91d3eee7f6552157edc2d5ef5b29023b88c6a73df27b18c65e9e828e8965eb087d05359a2088e9f8276
7
- data.tar.gz: b54626caf02c055714d315c699799261bf56534c8f284dcecca8104b6860c22c971434299ef08ea28da841c0828308e78fb0bc4ea35538b00ae3f6dbd05b7ef2
6
+ metadata.gz: f00a8e5b3f2abe43f2a7faa758580766341b0ef3843b019813674fbc7b6b0683fd14904d35de05c953c65f97a5ae4e08cbcae2c2a6bf41595a8199b338d001c7
7
+ data.tar.gz: 202e86fffa1cc8d79c2109bac3338e0e3ee0b7590a27956b3080908b877dd062937df171af73cfd7bbf5f603cc73ea96ea14f74c8e213bb5214644adc9ffa259
data/README.md CHANGED
@@ -1,6 +1,33 @@
1
1
  # Simple2ch
2
2
 
3
- 2ch Japanese BBS simple reader.
3
+ 2ch Japanese BBS simple reader for Ruby.
4
+
5
+ Ruby用の2chの簡易リーダーです。
6
+
7
+ ![gem version](https://badge.fury.io/rb/simple2ch.svg)
8
+ [リファレンス](http://dogwood008.github.io/simple2ch/)
9
+
10
+ ## 更新内容
11
+ [v0.1.0]
12
+ * メソッド名の変更
13
+ * Thre.new から Thre.parse に変更
14
+ * Thre.newは引数の数を変更
15
+ * この変更に伴い、v0.0.2以下とは一部互換性無し
16
+ * バグ修正
17
+ * Time.parseの呼び出しに失敗する問題を修正
18
+ * その他
19
+ * その他微細な修正
20
+
21
+ [v0.0.2]
22
+ * メソッド名の変更
23
+ * Board#threads から Board#thres に変更
24
+ * ドキュメントの再生成
25
+ * モジュール名が誤っていたため
26
+ * README.mdを修正
27
+ * 使用法などを追加
28
+ * yardの結果を追加
29
+
30
+
4
31
 
5
32
  ## Installation
6
33
 
@@ -31,12 +58,14 @@ board.thres #=>[#<Simple2ch::Thre>, ..., #<Simple2ch::Thre>]
31
58
 
32
59
  * レス取得
33
60
  ```ruby
61
+ hoge = SUM_OF_NUMBER1
34
62
  thre = board.thres[hoge] #=> #<Simple2ch::Thre>
35
63
  thre.reses #=> [#<Simple2ch::Res>, ..., #<Simple2ch::Res>]
36
64
  ```
37
65
 
38
66
  * 書き込み内容取得
39
67
  ```ruby
68
+ foo = SUM_OF_NUMBER2
40
69
  res = thre.reses[foo] #=> #<Simple2ch::Res>
41
70
  res.author #=> "以下、\(^o^)/でVIPがお送りします"
42
71
  res.contents #=> "hoge foo bar"
@@ -62,7 +62,7 @@ module Simple2ch
62
62
 
63
63
  subject_txt = Simple2ch.fetch(subject_url)
64
64
  subject_txt.each_line do |line|
65
- @thres << Thre.new(self, line)
65
+ @thres << Thre.parse(self, line)
66
66
  end
67
67
  @thres
68
68
  end
@@ -10,17 +10,31 @@ module Simple2ch
10
10
  attr_reader :board
11
11
 
12
12
  # @param [Board] board スレッドが属する板情報
13
- # @param [String] thread_data 0000000000.dat<>スレッドタイトル (レス数)
14
- def initialize(board, thread_data)
13
+ # @param [String] thread_key スレッドキー
14
+ # @param [String] title スレッド名
15
+ # @param [Fixnum] num_of_response 総書き込み数
16
+ def initialize(board, thread_key, title: '', num_of_response: '')
15
17
  @board = board
16
- thread_data =~ /(\d{10})\.dat<>(.+) \((\d+)\)/
17
- @thread_key = $1
18
- @title = $2
19
- @num_of_response = $3.to_i
18
+ @thread_key = thread_key
19
+ @title = title
20
+ @num_of_response = num_of_response
20
21
  @reses = nil
21
22
  @f_kako_log = nil
22
23
  end
23
24
 
25
+ # 板オブジェクトとsubject.txtの1行データを渡すとスレオブジェクトを返す
26
+ # @param [Board] board スレッドが属する板情報
27
+ # @param [String] thread_data 0000000000.dat<>スレッドタイトル (レス数)
28
+ # @return [Thre] スレ
29
+ def self.parse(board, thread_data)
30
+ thread_data =~ /(\d{10})\.dat<>(.+) \((\d+)\)/
31
+ hash = {}
32
+ thread_key = $1
33
+ hash[:title] = $2
34
+ hash[:num_of_response] = $3.to_i
35
+ self.new board, thread_key, hash
36
+ end
37
+
24
38
  # Datを解析して、レスを返す
25
39
  # @return [Array<Res>] レスの配列
26
40
  def reses
@@ -43,7 +57,5 @@ module Simple2ch
43
57
  dat = nil
44
58
  return @reses, @f_kako_log
45
59
  end
46
-
47
- #TODO: スコアリング
48
60
  end
49
61
  end
@@ -1,3 +1,3 @@
1
1
  module Simple2ch
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/simple2ch.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "simple2ch/version"
2
2
 
3
3
  module Simple2ch
4
- DEBUG = true
4
+ DEBUG = false
5
5
 
6
6
  require 'simple2ch/simple2ch_exception'
7
7
  require 'simple2ch/board'
@@ -9,6 +9,7 @@ module Simple2ch
9
9
  require 'simple2ch/res'
10
10
  require 'simple2ch/thre'
11
11
  require 'net/http'
12
+ require 'time'
12
13
  require 'pp' if DEBUG
13
14
 
14
15
  def self.root
data/simple2ch.gemspec CHANGED
@@ -4,12 +4,22 @@ $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
  spec.name = "simple2ch"
8
18
  spec.version = Simple2ch::VERSION
9
19
  spec.authors = ["dogwood008"]
10
20
  spec.email = ["dogwood008+rubygems@gmail.com"]
11
- spec.summary = %q{A gem to read 2ch bbs.}
12
- spec.description = spec.summary
21
+ spec.summary = %q{2ch Japanese BBS simple reader.}
22
+ spec.description = spec.summary+"\n"+updates
13
23
  spec.homepage = "https://github.com/dogwood008/simple2ch"
14
24
  spec.license = "MIT"
15
25
 
data/spec/dat_spec.rb CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  describe Simple2ch::Dat do
5
5
  let(:board) { Simple2ch::Board.new 'ニュース速報(VIP)', 'http://viper.2ch.sc/news4vip/' }
6
6
  let(:dat_data) { '1409796283.dat<>C言語の勉強始めたんだがな (144)' }
7
- let(:thre) { Simple2ch::Thre.new(board, dat_data) }
7
+ let(:thre) { Simple2ch::Thre.parse(board, dat_data) }
8
8
  let(:thread_key) { '1409796283' }
9
9
  let(:dat) { Simple2ch::Dat.new thre }
10
10
 
data/spec/thre_spec.rb CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  describe Simple2ch::Thre do
5
5
  let(:board) { Simple2ch::Board.new 'ニュース速報(VIP)', 'http://viper.2ch.sc/news4vip/'}
6
6
  let(:dat_data) { '1409796283.dat<>C言語の勉強始めたんだがな (144)' }
7
- let(:thre) { Simple2ch::Thre.new(board, dat_data) }
7
+ let(:thre) { Simple2ch::Thre.parse(board, dat_data) }
8
8
 
9
9
  context 'should have title' do
10
10
  subject { thre.title }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple2ch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dogwood008
@@ -94,7 +94,17 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: A gem to read 2ch bbs.
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
+ * その他微細な修正
98
108
  email:
99
109
  - dogwood008+rubygems@gmail.com
100
110
  executables: []
@@ -166,7 +176,7 @@ rubyforge_project:
166
176
  rubygems_version: 2.2.2
167
177
  signing_key:
168
178
  specification_version: 4
169
- summary: A gem to read 2ch bbs.
179
+ summary: 2ch Japanese BBS simple reader.
170
180
  test_files:
171
181
  - spec/board_spec.rb
172
182
  - spec/dat_spec.rb