syobocal 0.12.0 → 0.13.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 +4 -4
- data/README.md +24 -5
- data/lib/syobocal.rb +1 -0
- data/lib/syobocal/comment/helper/fragment.rb +80 -0
- data/lib/syobocal/comment/music_data.rb +4 -4
- data/lib/syobocal/comment/person.rb +9 -0
- data/lib/syobocal/comment/section.rb +14 -1
- data/lib/syobocal/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2b86d38d425a78a79903d700e893f1bf830a862ac4cd088124ad613d24890f3
|
4
|
+
data.tar.gz: b911625bb75f55c90efd4cdf3ab66aa64501ce0cf329f01a022bc3e3ee131834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6efb4dad943bdffd02a0e75c1b9a21cfd25637e84f9d4822ffaab15a7eff5360669580ad22955d8d04cb5f79966d9292a1f9ad5c27d5aec1644e0b8d8060ad3b
|
7
|
+
data.tar.gz: 55590f077651aa76520e8d076cf8b122d8c1c7ea8dc2e06fc65c7e3a2bf9f0f58731c0a4cb44e3bb148084e051b6b4293ce97475a40d3944edf9244c33f67ffc
|
data/README.md
CHANGED
@@ -135,20 +135,39 @@ pp parser.casts.first
|
|
135
135
|
# [#<Syobocal::Comment::Person:0x0000564600051cd8 @name="悠木碧", @note=nil>]>
|
136
136
|
|
137
137
|
pp parser.musics.first
|
138
|
-
# #<Syobocal::Comment::Music:
|
138
|
+
# #<Syobocal::Comment::Music:0x0000561287c8f1a0
|
139
139
|
# @category="オープニングテーマ",
|
140
140
|
# @data_list=
|
141
|
-
# [#<Syobocal::Comment::MusicData:
|
141
|
+
# [#<Syobocal::Comment::MusicData:0x0000561287c8b8e8
|
142
142
|
# @attr="作詞・作曲",
|
143
|
+
# @attr_note=nil,
|
144
|
+
# @attr_text="作詞・作曲",
|
145
|
+
# @people=
|
146
|
+
# [#<Syobocal::Comment::Person:0x0000561287c8ba28 @name="渡辺翔", @note=nil>],
|
143
147
|
# @value="渡辺翔">,
|
144
|
-
# #<Syobocal::Comment::MusicData:
|
148
|
+
# #<Syobocal::Comment::MusicData:0x0000561287c8a3d0
|
145
149
|
# @attr="主題歌協力",
|
150
|
+
# @attr_note=nil,
|
151
|
+
# @attr_text="主題歌協力",
|
152
|
+
# @people=
|
153
|
+
# [#<Syobocal::Comment::Person:0x0000561287c8a510 @name="外村敬一", @note=nil>],
|
146
154
|
# @value="外村敬一">,
|
147
|
-
# #<Syobocal::Comment::MusicData:
|
155
|
+
# #<Syobocal::Comment::MusicData:0x0000561287c88e90
|
148
156
|
# @attr="歌",
|
157
|
+
# @attr_note=nil,
|
158
|
+
# @attr_text="歌",
|
159
|
+
# @people=
|
160
|
+
# [#<Syobocal::Comment::Person:0x0000561287c88fd0
|
161
|
+
# @name="ClariS",
|
162
|
+
# @note=nil>],
|
149
163
|
# @value="ClariS">,
|
150
|
-
# #<Syobocal::Comment::MusicData:
|
164
|
+
# #<Syobocal::Comment::MusicData:0x0000561287c8f2e0
|
151
165
|
# @attr="使用話数",
|
166
|
+
# @attr_note=nil,
|
167
|
+
# @attr_text="使用話数",
|
168
|
+
# @people=
|
169
|
+
# [#<Syobocal::Comment::Person:0x0000561287c8f560 @name="#1~#9", @note=nil>,
|
170
|
+
# #<Syobocal::Comment::Person:0x0000561287c8f420 @name="#11", @note=nil>],
|
152
171
|
# @value="#1~#9、#11">],
|
153
172
|
# @title="コネクト">
|
154
173
|
```
|
data/lib/syobocal.rb
CHANGED
@@ -20,6 +20,7 @@ require "syobocal/comment/element/row"
|
|
20
20
|
require "syobocal/comment/element/text"
|
21
21
|
require "syobocal/comment/element/text_node"
|
22
22
|
require "syobocal/comment/element/root"
|
23
|
+
require "syobocal/comment/helper/fragment"
|
23
24
|
require "syobocal/comment/parser"
|
24
25
|
require "syobocal/comment/staff"
|
25
26
|
require "syobocal/comment/cast"
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Syobocal
|
2
|
+
module Comment
|
3
|
+
module Helper
|
4
|
+
class Fragment
|
5
|
+
CHILD_BEGIN = '('
|
6
|
+
CHILD_END = ')'
|
7
|
+
SEPARATOR = '、'
|
8
|
+
|
9
|
+
attr_reader :text, :child, :following
|
10
|
+
|
11
|
+
def initialize(text, child, following)
|
12
|
+
@text, @child, @following = text, child, following
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.parse(str)
|
16
|
+
chars = str.each_char.to_a
|
17
|
+
|
18
|
+
parse_chars(chars)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.parse_chars(chars)
|
22
|
+
text = ""
|
23
|
+
child = nil
|
24
|
+
following = nil
|
25
|
+
|
26
|
+
until chars.empty?
|
27
|
+
c = chars.shift
|
28
|
+
|
29
|
+
case c
|
30
|
+
when CHILD_BEGIN
|
31
|
+
child = parse_chars(chars)
|
32
|
+
when CHILD_END
|
33
|
+
return Fragment.new(text, child, following)
|
34
|
+
when SEPARATOR
|
35
|
+
following = parse_chars(chars)
|
36
|
+
else
|
37
|
+
text << c
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Fragment.new(text, child, following)
|
42
|
+
end
|
43
|
+
|
44
|
+
def pretty_output(level = 0)
|
45
|
+
line = level.times.map{' '}.join
|
46
|
+
|
47
|
+
line << text
|
48
|
+
|
49
|
+
puts line
|
50
|
+
|
51
|
+
child&.pretty_output(level + 1)
|
52
|
+
|
53
|
+
following&.pretty_output(level)
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_a
|
57
|
+
array = [self]
|
58
|
+
target = self
|
59
|
+
|
60
|
+
while target.following
|
61
|
+
array << target.following
|
62
|
+
target = target.following
|
63
|
+
end
|
64
|
+
|
65
|
+
array
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
to_a.map{|f|
|
70
|
+
if f.child
|
71
|
+
"#{f.text}(#{f.child.to_s})"
|
72
|
+
else
|
73
|
+
"#{f.text}"
|
74
|
+
end
|
75
|
+
}.join(SEPARATOR)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Syobocal
|
2
2
|
module Comment
|
3
3
|
class MusicData
|
4
|
-
attr_reader :attr, :value
|
4
|
+
attr_reader :attr, :attr_text, :attr_note, :value, :people
|
5
5
|
|
6
|
-
def initialize(attr, value)
|
7
|
-
@attr, @value = attr, value
|
6
|
+
def initialize(attr, attr_text, attr_note, value, people)
|
7
|
+
@attr, @attr_text, @attr_note, @value, @people = attr, attr_text, attr_note, value, people
|
8
8
|
end
|
9
9
|
|
10
10
|
def ==(other)
|
11
|
-
other.instance_of?(self.class) && other.attr == attr && other.value == value
|
11
|
+
other.instance_of?(self.class) && other.attr == attr && other.attr_text == attr_text && other.attr_note == other.attr_note && other.value == value && other.people == people
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -52,8 +52,21 @@ module Syobocal
|
|
52
52
|
|
53
53
|
data_list = rows.map do |row|
|
54
54
|
attr = row.attr_node.inner_text
|
55
|
+
|
56
|
+
attr_fragment = Helper::Fragment.parse(attr)
|
57
|
+
|
58
|
+
if attr_fragment.to_a.size == 1
|
59
|
+
attr_text = attr_fragment.text
|
60
|
+
attr_note = attr_fragment&.child&.to_s
|
61
|
+
else
|
62
|
+
attr_text = attr_fragment.to_s
|
63
|
+
attr_note = nil
|
64
|
+
end
|
65
|
+
|
55
66
|
value = row.value_node.inner_text
|
56
|
-
|
67
|
+
people = Person.multi_parse(value)
|
68
|
+
|
69
|
+
MusicData.new(attr, attr_text, attr_note, value, people)
|
57
70
|
end
|
58
71
|
|
59
72
|
Music.new(title, category, data_list)
|
data/lib/syobocal/version.rb
CHANGED
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.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xmisao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/syobocal/comment/element/row.rb
|
101
101
|
- lib/syobocal/comment/element/text.rb
|
102
102
|
- lib/syobocal/comment/element/text_node.rb
|
103
|
+
- lib/syobocal/comment/helper/fragment.rb
|
103
104
|
- lib/syobocal/comment/music.rb
|
104
105
|
- lib/syobocal/comment/music_data.rb
|
105
106
|
- lib/syobocal/comment/parser.rb
|