syobocal 0.11.0 → 0.12.0

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
  SHA256:
3
- metadata.gz: 7edc7c39022835637c4c5683b9e9192f98f5f8722b3f77218b6203227a055e17
4
- data.tar.gz: 78e539ace20bd227556bcea06508733f8f6e30e07377bbd058e6084308a69485
3
+ metadata.gz: d0398de2d798888a3de127fc65f3d5b7e80571e9ce0fb14a5167787dae9714d4
4
+ data.tar.gz: 4851e93fe58065998cbecba8ea6c598b2e0971c145a755157636aa5f2f91ed11
5
5
  SHA512:
6
- metadata.gz: 343c5fd86a55a8d630e70660555b18e463a3fe3401b10f210dd5e1f44b619a32c4fe7f1cff2de2e7b5ada88a9bf03f7603f970ec69bc7e32d7e981409e0142a4
7
- data.tar.gz: f0c1727b6e11244f4af5d3b9ef14eba96deb4244e7aef2322277f21a70d23414d5ce36b333a2ed853761822d3d1c6b1e0c09923afea85f66e0976d8be50a3e6a
6
+ metadata.gz: 4b617073199d1f4e2ecb320e908d9874cbc67ad4a3154b268ff35466712397f4e802b07aa4fd30697f5803feb2cea9bbae3b2f92cfd7ea3d0f5a04c8536e9603
7
+ data.tar.gz: 3d8cde4777e1de49b68fcf533e3171fbc658e48292ab75970c428ed5dcadc8302d0fe37d428492c7fe34a9dfa86072abedc115d005472c8a0b2f339f66b61411
data/README.md CHANGED
@@ -153,6 +153,57 @@ pp parser.musics.first
153
153
  # @title="コネクト">
154
154
  ```
155
155
 
156
+ ### サブタイトルパーサ(ベータ版)
157
+
158
+ しょぼいカレンダーの`sub_titles`属性をパースして扱いやすい形にして取り出すパーサです。
159
+
160
+ ```ruby
161
+ require 'syobocal'
162
+ require 'pp'
163
+
164
+ title = Syobocal::DB::TitleLookup.get({'TID' => '2077'})
165
+ sub_titles = title.first[:sub_titles]
166
+ parser = Syobocal::SubTitles::Parser.new(sub_titles)
167
+
168
+ pp parser.parse
169
+ # [#<Syobocal::SubTitles::SubTitle:0x00005591edc37830
170
+ # @episode="01",
171
+ # @title="夢の中で会った、ような・・・・・">,
172
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc37448
173
+ # @episode="02",
174
+ # @title="それはとっても嬉しいなって">,
175
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc370b0
176
+ # @episode="03",
177
+ # @title="もう何も恐くない">,
178
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc36d40
179
+ # @episode="04",
180
+ # @title="奇跡も、魔法も、あるんだよ">,
181
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc36c00
182
+ # @episode="05",
183
+ # @title="後悔なんて、あるわけない">,
184
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc36700
185
+ # @episode="06",
186
+ # @title="こんなの絶対おかしいよ">,
187
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc36408
188
+ # @episode="07",
189
+ # @title="本当の気持ちと向き合えますか?">,
190
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc36110
191
+ # @episode="08",
192
+ # @title="あたしって、ほんとバカ">,
193
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc35c88
194
+ # @episode="09",
195
+ # @title="そんなの、あたしが許さない">,
196
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc34d38
197
+ # @episode="10",
198
+ # @title="もう誰にも頼らない">,
199
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc34a68
200
+ # @episode="11",
201
+ # @title="最後に残った道しるべ">,
202
+ # #<Syobocal::SubTitles::SubTitle:0x00005591edc34900
203
+ # @episode="12",
204
+ # @title="わたしの、最高の友達">]
205
+ ```
206
+
156
207
  ## おまけ
157
208
 
158
209
  テスト用の`syobocal`コマンドと、これから放送される首都圏のアニメを表示する`anime`コマンドを同梱しています。
data/lib/syobocal.rb CHANGED
@@ -27,5 +27,7 @@ require "syobocal/comment/person"
27
27
  require "syobocal/comment/music"
28
28
  require "syobocal/comment/music_data"
29
29
  require "syobocal/comment/section"
30
+ require "syobocal/sub_titles/sub_title"
31
+ require "syobocal/sub_titles/parser"
30
32
 
31
33
  module Syobocal; end
@@ -0,0 +1,21 @@
1
+ module Syobocal
2
+ module SubTitles
3
+ class Parser
4
+ FORMAT_REGEXP = /\A\*(.*?)\*(.*)\Z/
5
+
6
+ def initialize(sub_titles)
7
+ @sub_titles = sub_titles
8
+ end
9
+
10
+ def parse
11
+ return @parse if defined? @parse
12
+
13
+ @sub_titles.each_line.each_with_object([]){|line, array|
14
+ m = FORMAT_REGEXP.match(line)
15
+
16
+ array << SubTitle.new(m[1], m[2]) if m
17
+ }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ module Syobocal
2
+ module SubTitles
3
+ class SubTitle
4
+ attr_reader :episode, :title
5
+
6
+ def initialize(episode, title)
7
+ @episode, @title = episode, title
8
+ end
9
+
10
+ def ==(other)
11
+ other.instance_of?(self.class) && other.episode == episode && other.title == title
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Syobocal
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syobocal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - xmisao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-22 00:00:00.000000000 Z
11
+ date: 2020-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,6 +110,8 @@ files:
110
110
  - lib/syobocal/json.rb
111
111
  - lib/syobocal/rss.rb
112
112
  - lib/syobocal/rss2.rb
113
+ - lib/syobocal/sub_titles/parser.rb
114
+ - lib/syobocal/sub_titles/sub_title.rb
113
115
  - lib/syobocal/util.rb
114
116
  - lib/syobocal/version.rb
115
117
  - scripts/download_db_title_lookup.rb