syoboi_calendar 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +7 -1
- data/lib/syoboi_calendar/comment.rb +66 -0
- data/lib/syoboi_calendar/comment_section.rb +107 -0
- data/lib/syoboi_calendar/personality.rb +31 -0
- data/lib/syoboi_calendar/resources/title_resource.rb +58 -2
- data/lib/syoboi_calendar/song.rb +40 -0
- data/lib/syoboi_calendar/version.rb +1 -1
- data/lib/syoboi_calendar.rb +4 -0
- data/spec/syoboi_calendar/client_spec.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b67926b1fd893f4d44887464f9b8d160d7789032
|
4
|
+
data.tar.gz: c1df3c20468b121b117ef08e3a42a79075aa0aec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 977d4653b70a7e7fde5ddaf83c25c759854d6b9c41325e3e1653f42fcb0fa35d7baf2e86b7dca1762d28ce5fb51ff7b7408a2b86ab1fd6e5a414c5a29bafa067
|
7
|
+
data.tar.gz: '058558e1d50597c9938b84d94743bddd5e6957d38151874d71848a69092c394aa2bb61a073061c455b0ea6f7563283779085eb525a9b36bd333541eeb270c010'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 0.9.0
|
2
|
+
|
3
|
+
- Add `SyoboiCalendar::Resources::TitleResource#casts`
|
4
|
+
- Add `SyoboiCalendar::Resources::TitleResource#staffs`
|
5
|
+
- Add `SyoboiCalendar::Resources::TitleResource#songs_ending`
|
6
|
+
- Add `SyoboiCalendar::Resources::TitleResource#songs_inserted`
|
7
|
+
- Add `SyoboiCalendar::Resources::TitleResource#songs_opening`
|
8
|
+
- Add `SyoboiCalendar::Resources::TitleResource#songs_theme`
|
9
|
+
- Change `SyoboiCalendar::Resources::TitleResource#comment` returned value
|
10
|
+
|
1
11
|
## 0.8.0
|
2
12
|
|
3
13
|
- Add some methods for error handling
|
data/README.md
CHANGED
@@ -170,6 +170,7 @@ Available attributes:
|
|
170
170
|
|
171
171
|
Available attributes:
|
172
172
|
|
173
|
+
- `#casts`
|
173
174
|
- `#category_id`
|
174
175
|
- `#comment`
|
175
176
|
- `#english_name`
|
@@ -184,6 +185,11 @@ Available attributes:
|
|
184
185
|
- `#keywords`
|
185
186
|
- `#name`
|
186
187
|
- `#short_title`
|
188
|
+
- `#songs_ending`
|
189
|
+
- `#songs_inserted`
|
190
|
+
- `#songs_opening`
|
191
|
+
- `#songs_theme`
|
192
|
+
- `#staffs`
|
187
193
|
- `#sub_titles`
|
188
|
-
- `#user_point`
|
189
194
|
- `#user_point_rank`
|
195
|
+
- `#user_point`
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
class Comment
|
3
|
+
PATTERN_SPLITTING_SECTIONS = /\n{1,2}(?=\*(?!\*))/
|
4
|
+
|
5
|
+
# @return [String]
|
6
|
+
attr_reader :source
|
7
|
+
|
8
|
+
# @param source [String]
|
9
|
+
def initialize(source)
|
10
|
+
@source = source
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Array<SyoboiCalendar::Personality>]
|
14
|
+
def casts
|
15
|
+
if comment_section = comment_sections.find(&:about_casts?)
|
16
|
+
comment_section.personalities
|
17
|
+
else
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array<SyoboiCalendar::CommentSection>]
|
23
|
+
def comment_sections
|
24
|
+
source.split(PATTERN_SPLITTING_SECTIONS).map do |comment_section_source|
|
25
|
+
::SyoboiCalendar::CommentSection.new(comment_section_source)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Array<SyoboiCalendar::Song>]
|
30
|
+
def songs_ending
|
31
|
+
comment_sections.select(&:about_song_ending?).map do |comment_section|
|
32
|
+
::SyoboiCalendar::Song.new(comment_section.song_attributes)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Array<SyoboiCalendar::Song>]
|
37
|
+
def songs_inserted
|
38
|
+
comment_sections.select(&:about_song_inserted?).map do |comment_section|
|
39
|
+
::SyoboiCalendar::Song.new(comment_section.song_attributes)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Array<SyoboiCalendar::Song>]
|
44
|
+
def songs_opening
|
45
|
+
comment_sections.select(&:about_song_opening?).map do |comment_section|
|
46
|
+
::SyoboiCalendar::Song.new(comment_section.song_attributes)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Array<SyoboiCalendar::Song>]
|
51
|
+
def songs_theme
|
52
|
+
comment_sections.select(&:about_song_theme?).map do |comment_section|
|
53
|
+
::SyoboiCalendar::Song.new(comment_section.song_attributes)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Array<SyoboiCalendar::Personality>]
|
58
|
+
def staffs
|
59
|
+
if comment_section = comment_sections.find(&:about_staffs?)
|
60
|
+
comment_section.personalities
|
61
|
+
else
|
62
|
+
[]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
class CommentSection
|
3
|
+
NAME_CASTS = "キャスト"
|
4
|
+
NAME_STAFFS = "スタッフ"
|
5
|
+
PATTERN_NAME_SONG_ENDING = /\Aエンディング\d*\s*「(.+)」\z/
|
6
|
+
PATTERN_NAME_SONG_INSERTED = /\A挿入歌\d*\s*「(.+)」\z/
|
7
|
+
PATTERN_NAME_SONG_OPENING = /\Aオープニング\d*\s*「(.+)」\z/
|
8
|
+
PATTERN_NAME_SONG_THEME = /\A主題歌\d*\s*「(.+)」\z/
|
9
|
+
|
10
|
+
attr_reader :source
|
11
|
+
|
12
|
+
# @param source [String]
|
13
|
+
def initialize(source)
|
14
|
+
@source = source
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Boolean]
|
18
|
+
def about_song_ending?
|
19
|
+
PATTERN_NAME_SONG_ENDING === name
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Boolean]
|
23
|
+
def about_song_inserted?
|
24
|
+
PATTERN_NAME_SONG_INSERTED === name
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Boolean]
|
28
|
+
def about_song_opening?
|
29
|
+
PATTERN_NAME_SONG_OPENING === name
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Boolean]
|
33
|
+
def about_song_theme?
|
34
|
+
PATTERN_NAME_SONG_THEME === name
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Boolean]
|
38
|
+
def about_casts?
|
39
|
+
name == NAME_CASTS
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Boolean]
|
43
|
+
def about_personalities?
|
44
|
+
about_casts? || about_staffs?
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Boolean]
|
48
|
+
def about_staffs?
|
49
|
+
name == NAME_STAFFS
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Array<String>]
|
53
|
+
def array
|
54
|
+
if lines[1][0] == "-"
|
55
|
+
lines[1..-1].grep(/\A-/).map do |line|
|
56
|
+
line[1..-1]
|
57
|
+
end
|
58
|
+
else
|
59
|
+
lines
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# @return [Boolean]
|
64
|
+
def has_hash?
|
65
|
+
lines[1][0] == ":"
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [Hash{String => String}]
|
69
|
+
def hash
|
70
|
+
lines[1..-1].grep(/\A:/).each_with_object({}) do |line, result|
|
71
|
+
key_or_keys, value = line[1..-1].split(":", 2)
|
72
|
+
key_or_keys.split("・").each do |key|
|
73
|
+
result[key] = value.split("、")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [Array<String>]
|
79
|
+
def lines
|
80
|
+
source.strip.split("\n")
|
81
|
+
end
|
82
|
+
|
83
|
+
# @return [String]
|
84
|
+
def name
|
85
|
+
lines[0][1..-1]
|
86
|
+
end
|
87
|
+
|
88
|
+
# @return [Array, nil]
|
89
|
+
def personalities
|
90
|
+
if about_personalities?
|
91
|
+
hash.flat_map do |role, sources|
|
92
|
+
sources.map do |source|
|
93
|
+
::SyoboiCalendar::Personality.new(role: role, source: source)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# @return [Hash]
|
100
|
+
def song_attributes
|
101
|
+
{
|
102
|
+
name: name,
|
103
|
+
source: hash,
|
104
|
+
}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
class Personality
|
3
|
+
# @return [String]
|
4
|
+
attr_reader :role
|
5
|
+
|
6
|
+
# @param role [String]
|
7
|
+
# @param source [String]
|
8
|
+
def initialize(role:, source:)
|
9
|
+
@role = role
|
10
|
+
@source = source
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
def name
|
15
|
+
source.sub(/\(.+\)/, "")
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String, nil]
|
19
|
+
def name_annotation
|
20
|
+
source[/\((.+)\)/, 1]
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# @private
|
26
|
+
# @return [String]
|
27
|
+
def source
|
28
|
+
@source
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -19,9 +19,20 @@ module SyoboiCalendar
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
# @return [
|
22
|
+
# @return [Array<SyoboiCalendar::Personality>]
|
23
|
+
def casts
|
24
|
+
if comment
|
25
|
+
comment.casts
|
26
|
+
else
|
27
|
+
[]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [SyoboiCalendar::Comment, nil]
|
23
32
|
def comment
|
24
|
-
source["Comment"]
|
33
|
+
if source["Comment"]
|
34
|
+
::SyoboiCalendar::Comment.new(source["Comment"])
|
35
|
+
end
|
25
36
|
end
|
26
37
|
|
27
38
|
# @return [String, nil]
|
@@ -91,11 +102,56 @@ module SyoboiCalendar
|
|
91
102
|
source["Title"]
|
92
103
|
end
|
93
104
|
|
105
|
+
# @return [Array<SyoboiCalendar::Song>]
|
106
|
+
def songs_ending
|
107
|
+
if comment
|
108
|
+
comment.songs_ending
|
109
|
+
else
|
110
|
+
[]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# @return [Array<SyoboiCalendar::Song>]
|
115
|
+
def songs_inserted
|
116
|
+
if comment
|
117
|
+
comment.songs_inserted
|
118
|
+
else
|
119
|
+
[]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# @return [Array<SyoboiCalendar::Song>]
|
124
|
+
def songs_opening
|
125
|
+
if comment
|
126
|
+
comment.songs_opening
|
127
|
+
else
|
128
|
+
[]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# @return [Array<SyoboiCalendar::Song>]
|
133
|
+
def songs_theme
|
134
|
+
if comment
|
135
|
+
comment.songs_theme
|
136
|
+
else
|
137
|
+
[]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
94
141
|
# @return [String, nil]
|
95
142
|
def short_title
|
96
143
|
source["ShortTitle"]
|
97
144
|
end
|
98
145
|
|
146
|
+
# @return [Array<SyoboiCalendar::Personality>]
|
147
|
+
def staffs
|
148
|
+
if comment
|
149
|
+
comment.staffs
|
150
|
+
else
|
151
|
+
[]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
99
155
|
# @return [String, nil]
|
100
156
|
def sub_titles
|
101
157
|
source["SubTitles"]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
class Song
|
3
|
+
KEY_ARRANGERS = "編曲"
|
4
|
+
KEY_COMPOSERS = "作曲"
|
5
|
+
KEY_LYRIC_WRITERS = "作詞"
|
6
|
+
|
7
|
+
# @return [String]
|
8
|
+
attr_reader :name
|
9
|
+
|
10
|
+
# @param name [String]
|
11
|
+
# @param source [Hash]
|
12
|
+
def initialize(name:, source:)
|
13
|
+
@name = name
|
14
|
+
@source = source
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Array<String>]
|
18
|
+
def arrangers
|
19
|
+
source[KEY_ARRANGERS]
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array<String>]
|
23
|
+
def composers
|
24
|
+
source[KEY_COMPOSERS]
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Array<String>]
|
28
|
+
def lyric_writers
|
29
|
+
source[KEY_LYRIC_WRITERS]
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# @private
|
35
|
+
# @return [Hash]
|
36
|
+
def source
|
37
|
+
@source
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/syoboi_calendar.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require "syoboi_calendar/client"
|
2
|
+
require "syoboi_calendar/comment"
|
3
|
+
require "syoboi_calendar/comment_section"
|
4
|
+
require "syoboi_calendar/personality"
|
2
5
|
require "syoboi_calendar/queries/base_query"
|
3
6
|
require "syoboi_calendar/queries/list_channel_groups_query"
|
4
7
|
require "syoboi_calendar/queries/list_channels_query"
|
@@ -14,3 +17,4 @@ require "syoboi_calendar/responses/list_channel_groups_response"
|
|
14
17
|
require "syoboi_calendar/responses/list_channels_response"
|
15
18
|
require "syoboi_calendar/responses/list_programs_response"
|
16
19
|
require "syoboi_calendar/responses/list_titles_response"
|
20
|
+
require "syoboi_calendar/song"
|
@@ -532,7 +532,7 @@ describe ::SyoboiCalendar::Client do
|
|
532
532
|
it "returns titles" do
|
533
533
|
titles = subject
|
534
534
|
titles.first.category_id.should == 4
|
535
|
-
titles.first.comment.should
|
535
|
+
titles.first.comment.should be_a ::SyoboiCalendar::Comment
|
536
536
|
titles.first.first_channel.should == "DummyChannel"
|
537
537
|
titles.first.first_end_month.should == 1
|
538
538
|
titles.first.first_end_year.should == 2000
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syoboi_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -138,6 +138,9 @@ files:
|
|
138
138
|
- Rakefile
|
139
139
|
- lib/syoboi_calendar.rb
|
140
140
|
- lib/syoboi_calendar/client.rb
|
141
|
+
- lib/syoboi_calendar/comment.rb
|
142
|
+
- lib/syoboi_calendar/comment_section.rb
|
143
|
+
- lib/syoboi_calendar/personality.rb
|
141
144
|
- lib/syoboi_calendar/queries/base_query.rb
|
142
145
|
- lib/syoboi_calendar/queries/list_channel_groups_query.rb
|
143
146
|
- lib/syoboi_calendar/queries/list_channels_query.rb
|
@@ -153,6 +156,7 @@ files:
|
|
153
156
|
- lib/syoboi_calendar/responses/list_channels_response.rb
|
154
157
|
- lib/syoboi_calendar/responses/list_programs_response.rb
|
155
158
|
- lib/syoboi_calendar/responses/list_titles_response.rb
|
159
|
+
- lib/syoboi_calendar/song.rb
|
156
160
|
- lib/syoboi_calendar/version.rb
|
157
161
|
- spec/spec_helper.rb
|
158
162
|
- spec/syoboi_calendar/client_spec.rb
|