ellen-syoboi_calendar 0.0.2 → 0.0.3

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: b5407684549c70fbee83244ff539c04a37c962ee
4
- data.tar.gz: 0bdc13a03589da35e52cfa63811a6090d41bdbd8
3
+ metadata.gz: ea15cd5d60a6fa7f8513eaa618ad1657797f23e1
4
+ data.tar.gz: 1a6ec3fded40ee4d5b2d99b035d2b280cfbdd8e9
5
5
  SHA512:
6
- metadata.gz: 329582c7428aab4ee2b49ccf0540599f7bfc7b2ef89aea7aeb3bcbfaa4ad4826c0731ee966d76315e0598ac44c36890c46ffa141a37a83a13a8f1e04ec06a1e5
7
- data.tar.gz: 8955e82270eca0749206c7d89cf9d5878e8871c3931e86fd99a249732227f3f6343f04967ca6fd5a353bc2a004351648d6f070f0495fa550220ef0fda4033ee8
6
+ metadata.gz: c1fbf04a84627fa2e0ef80904d1e09f5c5631d0ce32d7d49ddd25fd62b3e2ea22f43fc5319ee51f45f153d90af5e6e2960588c0faa8367c670443765a98b6c45
7
+ data.tar.gz: d27a808acf33d45ede67bef683fda82259f095339d49bcf35e798d568c06a2c53d0cab2e0f0f0f92c6fcb2d4aeb5778ebf15baa27fda0a93579011b7fbc5a610
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.3
2
+ * Improve program count view
3
+ * Show channel name on description
4
+
1
5
  ## 0.0.2
2
6
  * Add SYOBOI_CALENDAR_CHANNEL_IDS ENV to filter programs
3
7
  * Search in 04:00..28:00
data/README.md CHANGED
@@ -12,5 +12,10 @@ gem "ellen-syoboi_calendar"
12
12
  @ellen list anime
13
13
  ```
14
14
 
15
+ ## ENV
16
+ ```
17
+ SYOBOI_CALENDAR_CHANNEL_IDS - Comma-separated channel IDs to filter programs
18
+ ```
19
+
15
20
  ## Screenshot
16
21
  ![](https://raw.githubusercontent.com/r7kamura/ellen-syoboi_calendar/master/images/screenshot.gif)
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.add_dependency "activesupport"
20
20
  spec.add_dependency "ellen", ">= 0.2.0"
21
- spec.add_dependency "syoboi_calendar", "0.2.1"
21
+ spec.add_dependency "syoboi_calendar", "0.3.1"
22
22
  spec.add_development_dependency "bundler", "~> 1.6"
23
23
  spec.add_development_dependency "pry"
24
24
  spec.add_development_dependency "rack"
Binary file
@@ -17,76 +17,18 @@ module Ellen
17
17
  private
18
18
 
19
19
  def description
20
- if descriptions.empty?
20
+ if programs.empty?
21
21
  "No programs found"
22
22
  else
23
- descriptions.join("\n")
23
+ programs.sort_by(&:started_at).map do |program|
24
+ count = " ##{program.count}" if program.count
25
+ %<#{program.started_at.strftime("%Y-%m-%d %H:%M")} #{program.title.name}#{count} (#{program.channel.name})>
26
+ end.join("\n")
24
27
  end
25
28
  end
26
29
 
27
- def descriptions
28
- @descriptions ||= programs_sorted_by_started_at.map do |program|
29
- "#{program.started_at_in_string} #{titles_index_by_id[program.title_id].title} #{program.count}"
30
- end
31
- end
32
-
33
- def client
34
- @client ||= ::SyoboiCalendar::Client.new
35
- end
36
-
37
- def titles_index_by_id
38
- @titles_by_id ||= titles.index_by(&:id)
39
- end
40
-
41
- def titles
42
- [get_titles.TitleLookupResponse.TitleItems.TitleItem].flatten.map do |title|
43
- Ellen::SyoboiCalendar::Title.new(
44
- id: title.id,
45
- title: title.Title,
46
- short_title: title.ShortTitle,
47
- )
48
- end
49
- end
50
-
51
- def get_titles
52
- client.titles(title_options)
53
- end
54
-
55
- def title_options
56
- {
57
- title_id: title_ids_in_programs.join(",")
58
- }
59
- end
60
-
61
- def title_ids_in_programs
62
- programs.map do |program|
63
- program.title_id
64
- end
65
- end
66
-
67
- def programs_sorted_by_started_at
68
- programs.sort_by(&:started_at)
69
- end
70
-
71
30
  def programs
72
- @programs ||= get_programs.map do |program|
73
- Ellen::SyoboiCalendar::Program.new(
74
- count: program.Count,
75
- channel_id: program.ChID,
76
- sub_title: program.STSubTitle,
77
- title_id: program.TID,
78
- started_at: program.StTime,
79
- finished_at: program.EdTime,
80
- )
81
- end
82
- end
83
-
84
- def get_programs
85
- if items = client.programs(program_options).ProgLookupResponse.ProgItems
86
- [items.ProgItem].flatten.compact
87
- else
88
- []
89
- end
31
+ @programs ||= ::SyoboiCalendar::Client.new.programs(program_options)
90
32
  end
91
33
 
92
34
  def program_options
@@ -94,6 +36,7 @@ module Ellen
94
36
  played_from: played_from,
95
37
  played_to: played_to,
96
38
  channel_id: channel_ids,
39
+ includes: [:channel, :title],
97
40
  }.reject {|key, value| value.nil? }
98
41
  end
99
42
 
@@ -3,6 +3,3 @@ require "syoboi_calendar"
3
3
 
4
4
  require "ellen/handlers/syoboi_calendar"
5
5
  require "ellen/syoboi_calendar/version"
6
- require "ellen/syoboi_calendar/record"
7
- require "ellen/syoboi_calendar/program"
8
- require "ellen/syoboi_calendar/title"
@@ -1,5 +1,5 @@
1
1
  module Ellen
2
2
  module SyoboiCalendar
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -9,27 +9,53 @@ describe Ellen::Handlers::SyoboiCalendar do
9
9
  Ellen::Robot.new
10
10
  end
11
11
 
12
+ let(:dummy_channels_response) do
13
+ <<-EOS.strip_heredoc
14
+ <?xml version="1.0" encoding="UTF-8"?>
15
+ <ChLookupResponse>
16
+ <Result>
17
+ <Code>200</Code>
18
+ <Message>
19
+ </Message>
20
+ </Result>
21
+ <ChItems>
22
+ <ChItem id="3">
23
+ <ChComment>DummyComment</ChComment>
24
+ <ChEPGURL>http://example.com/epg-url</ChEPGURL>
25
+ <ChGID>1</ChGID>
26
+ <ChID>3</ChID>
27
+ <ChName>DummyChannelName</ChName>
28
+ <ChNumber>3</ChNumber>
29
+ <ChURL>http://example.com/</ChURL>
30
+ <ChiEPGName>DummyiEPGName</ChiEPGName>
31
+ <LastUpdate>2000-01-01 00:00:00</LastUpdate>
32
+ </ChItem>
33
+ </ChItems>
34
+ </ChLookupResponse>
35
+ EOS
36
+ end
37
+
12
38
  let(:dummy_programs_response) do
13
39
  <<-EOS.strip_heredoc
14
40
  <?xml version="1.0" encoding="UTF-8"?>
15
41
  <ProgLookupResponse>
16
42
  <ProgItems>
17
43
  <ProgItem id="1">
44
+ <ChID>3</ChID>
45
+ <Count>1</Count>
46
+ <Deleted>0</Deleted>
47
+ <EdTime>2000-01-01 00:00:00</EdTime>
48
+ <Flag>9</Flag>
18
49
  <LastUpdate>2000-01-01 00:00:00</LastUpdate>
19
50
  <PID>1</PID>
20
- <TID>2</TID>
21
- <StTime>2000-01-01 00:00:00</StTime>
51
+ <ProgComment>DummyComment</ProgComment>
52
+ <Revision>2</Revision>
53
+ <STSubTitle>DummySubTitle</STSubTitle>
22
54
  <StOffset>0</StOffset>
23
- <EdTime>2000-01-01 00:00:00</EdTime>
24
- <Count>1</Count>
55
+ <StTime>2000-01-01 00:00:00</StTime>
25
56
  <SubTitle></SubTitle>
26
- <ProgComment></ProgComment>
27
- <Flag>9</Flag>
28
- <Deleted>0</Deleted>
57
+ <TID>2</TID>
29
58
  <Warn>1</Warn>
30
- <ChID>3</ChID>
31
- <Revision>2</Revision>
32
- <STSubTitle></STSubTitle>
33
59
  </ProgItem>
34
60
  </ProgItems>
35
61
  <Result>
@@ -52,24 +78,24 @@ describe Ellen::Handlers::SyoboiCalendar do
52
78
  </Result>
53
79
  <TitleItems>
54
80
  <TitleItem id="2">
55
- <TID>2</TID>
81
+ <Cat>4</Cat>
82
+ <Comment>DummyComment</Comment>
83
+ <FirstCh>DummyChannel</FirstCh>
84
+ <FirstEndMonth>1</FirstEndMonth>
85
+ <FirstEndYear>2000</FirstEndYear>
86
+ <FirstMonth>1</FirstMonth>
87
+ <FirstYear>2000</FirstYear>
88
+ <Keywords>DummyKeywords</Keywords>
56
89
  <LastUpdate>2000-01-01 00:00:00</LastUpdate>
90
+ <ShortTitle>DummyShortTitle</ShortTitle>
91
+ <SubTitles>DummySubTitles</SubTitles>
92
+ <TID>2</TID>
57
93
  <Title>DummyTitle</Title>
58
- <ShortTitle></ShortTitle>
59
- <TitleYomi>ダミータイトル</TitleYomi>
60
- <TitleEN></TitleEN>
61
- <Comment></Comment>
62
- <Cat>4</Cat>
94
+ <TitleEN>DummyEnglishTitle</TitleEN>
63
95
  <TitleFlag>0</TitleFlag>
64
- <FirstYear>2000</FirstYear>
65
- <FirstMonth>1</FirstMonth>
66
- <FirstEndYear>2000</FirstEndYear>
67
- <FirstEndMonth>1</FirstEndMonth>
68
- <FirstCh>DummyChannel</FirstCh>
69
- <Keywords></Keywords>
96
+ <TitleYomi>ダミータイトル</TitleYomi>
70
97
  <UserPoint>6</UserPoint>
71
98
  <UserPointRank>1</UserPointRank>
72
- <SubTitles></SubTitles>
73
99
  </TitleItem>
74
100
  </TitleItems>
75
101
  </TitleLookupResponse>
@@ -78,11 +104,20 @@ describe Ellen::Handlers::SyoboiCalendar do
78
104
 
79
105
  let(:app) do
80
106
  ->(env) do
81
- if env["QUERY_STRING"] =~ /ProgLookup/
82
- [200, { "Content-type" => "application/xml" }, [dummy_programs_response]]
83
- else
84
- [200, { "Content-type" => "application/xml" }, [dummy_titles_response]]
85
- end
107
+ [
108
+ 200,
109
+ { "Content-type" => "application/xml" },
110
+ [
111
+ case env["QUERY_STRING"]
112
+ when /ProgLookup/
113
+ dummy_programs_response
114
+ when /ChLookup/
115
+ dummy_channels_response
116
+ else
117
+ dummy_titles_response
118
+ end,
119
+ ],
120
+ ]
86
121
  end
87
122
  end
88
123
 
@@ -100,7 +135,7 @@ describe Ellen::Handlers::SyoboiCalendar do
100
135
  end
101
136
 
102
137
  it "replies today's anime list" do
103
- Ellen.logger.should_receive(:info).with("2000-01-01 00:00 DummyTitle 1")
138
+ Ellen.logger.should_receive(:info).with("2000-01-01 00:00 DummyTitle #1 (DummyChannelName)")
104
139
  robot.receive(message)
105
140
  end
106
141
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ellen-syoboi_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.1
47
+ version: 0.3.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.1
54
+ version: 0.3.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -153,9 +153,6 @@ files:
153
153
  - images/screenshot.gif
154
154
  - lib/ellen/handlers/syoboi_calendar.rb
155
155
  - lib/ellen/syoboi_calendar.rb
156
- - lib/ellen/syoboi_calendar/program.rb
157
- - lib/ellen/syoboi_calendar/record.rb
158
- - lib/ellen/syoboi_calendar/title.rb
159
156
  - lib/ellen/syoboi_calendar/version.rb
160
157
  - spec/ellen/handlers/syoboi_calendar_spec.rb
161
158
  - spec/spec_helper.rb
@@ -1,22 +0,0 @@
1
- module Ellen
2
- module SyoboiCalendar
3
- class Program < Record
4
-
5
- property(
6
- :channel_id,
7
- :count,
8
- :sub_title,
9
- :title_id,
10
- )
11
-
12
- time_property(
13
- :finished_at,
14
- :started_at,
15
- )
16
-
17
- def started_at_in_string
18
- started_at.strftime("%Y-%m-%d %H:%M")
19
- end
20
- end
21
- end
22
- end
@@ -1,29 +0,0 @@
1
- module Ellen
2
- module SyoboiCalendar
3
- class Record
4
- class << self
5
- def property(*names)
6
- names.each do |name|
7
- define_method(name) do
8
- properties[name]
9
- end
10
- end
11
- end
12
-
13
- def time_property(*names)
14
- names.each do |name|
15
- define_method(name) do
16
- Time.parse(properties[name])
17
- end
18
- end
19
- end
20
- end
21
-
22
- attr_reader :properties
23
-
24
- def initialize(properties)
25
- @properties = properties
26
- end
27
- end
28
- end
29
- end
@@ -1,12 +0,0 @@
1
- module Ellen
2
- module SyoboiCalendar
3
- class Title < Record
4
-
5
- property(
6
- :id,
7
- :short_title,
8
- :title,
9
- )
10
- end
11
- end
12
- end