syoboi_calendar 0.6.0 → 0.6.1

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: 8facc19f2111d8b7daa7d7baeb1893e4744b0632
4
- data.tar.gz: 61e353b7d123d76c96dc948a605d2bb0b4e3a19c
3
+ metadata.gz: 50554d60ab1f6b9126cddd8c514a5ce17cddd1d5
4
+ data.tar.gz: 73028865860075ea3775b7859087d9240348425c
5
5
  SHA512:
6
- metadata.gz: ff535c1524af5faa35d84d8ebf6918d3de6cfe9753743fc93ede02f187f63213c3b557ee207be4101058a414d7304a1b814a0b2a44b4c4b7175b449f2f65114f
7
- data.tar.gz: 8b2efb2f7340359703684ccd38cb02cba56aae27d391f55278d3b53dfc9c0023d15e9695e49fcf0c843039754cf289e2fdf9fbfb61c3bcb3da1fd00fc07ef453
6
+ metadata.gz: 7bde1d4555f62fe9d7487b2dcf41541be301987a4cfbc43d49f43b1f2aa378930be477a64653a3401ede2999f693a3c3d663735faa657b42fb1e465562fd1528
7
+ data.tar.gz: f76685ba60c5b079b755711d47d255df64d93963092335088f497136e8304aa464cb670442be95ae07a17065c355ff5837eba9197e3e70009fff618ebf79faaa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.6.1
2
+
3
+ - Separate response and response parser
4
+
1
5
  ## 0.6.0
2
6
 
3
7
  - Support channel groups
@@ -1,8 +1,6 @@
1
- require "active_support/concern"
2
- require "active_support/core_ext/array/wrap"
3
- require "active_support/core_ext/object/try"
4
1
  require "faraday"
5
2
  require "faraday_middleware"
3
+ require "multi_xml"
6
4
 
7
5
  require "syoboi_calendar/client"
8
6
  require "syoboi_calendar/queries/base_query"
@@ -15,8 +13,9 @@ require "syoboi_calendar/resources/channel_group_resource"
15
13
  require "syoboi_calendar/resources/channel_resource"
16
14
  require "syoboi_calendar/resources/program_resource"
17
15
  require "syoboi_calendar/resources/title_resource"
18
- require "syoboi_calendar/responses/base_response"
19
- require "syoboi_calendar/responses/channel_groups_response"
20
- require "syoboi_calendar/responses/channels_response"
21
- require "syoboi_calendar/responses/programs_response"
22
- require "syoboi_calendar/responses/titles_response"
16
+ require "syoboi_calendar/response"
17
+ require "syoboi_calendar/response_parsers/base_response_parser"
18
+ require "syoboi_calendar/response_parsers/channel_groups_response_parser"
19
+ require "syoboi_calendar/response_parsers/channels_response_parser"
20
+ require "syoboi_calendar/response_parsers/programs_response_parser"
21
+ require "syoboi_calendar/response_parsers/titles_response_parser"
@@ -7,8 +7,6 @@ module SyoboiCalendar
7
7
  def connection
8
8
  @connection ||= ::Faraday::Connection.new(url: ENDPOINT_BASE_URL) do |connection|
9
9
  connection.adapter :net_http
10
- connection.response :mashify
11
- connection.response :xml
12
10
  connection.response :raise_error
13
11
  end
14
12
  end
@@ -17,28 +15,40 @@ module SyoboiCalendar
17
15
  def list_channel_groups(options = {})
18
16
  query = ::SyoboiCalendar::Queries::ChannelGroupQuery.new(options)
19
17
  faraday_response = get(query.to_hash)
20
- ::SyoboiCalendar::Responses::ChannelGroupsResponse.new(faraday_response)
18
+ ::SyoboiCalendar::Response.new(
19
+ faraday_response: faraday_response,
20
+ response_parser_class: ::SyoboiCalendar::ResponseParsers::ChannelGroupsResponseParser,
21
+ )
21
22
  end
22
23
 
23
24
  # @return [Array<SyoboiCalendar::Resources::Channel>]
24
25
  def list_channels(options = {})
25
26
  query = ::SyoboiCalendar::Queries::ChannelQuery.new(options)
26
27
  faraday_response = get(query.to_hash)
27
- ::SyoboiCalendar::Responses::ChannelsResponse.new(faraday_response)
28
+ ::SyoboiCalendar::Response.new(
29
+ faraday_response: faraday_response,
30
+ response_parser_class: ::SyoboiCalendar::ResponseParsers::ChannelsResponseParser,
31
+ )
28
32
  end
29
33
 
30
34
  # @return [Array<SyoboiCalendar::Resources::Program>]
31
35
  def list_programs(options = {})
32
36
  query = ::SyoboiCalendar::Queries::ProgramQuery.new(options)
33
37
  faraday_response = get(query.to_hash)
34
- ::SyoboiCalendar::Responses::ProgramsResponse.new(faraday_response)
38
+ ::SyoboiCalendar::Response.new(
39
+ faraday_response: faraday_response,
40
+ response_parser_class: ::SyoboiCalendar::ResponseParsers::ProgramsResponseParser,
41
+ )
35
42
  end
36
43
 
37
44
  # @return [Array<SyoboiCalendar::Resources::Title>]
38
45
  def list_titles(options = {})
39
46
  query = ::SyoboiCalendar::Queries::TitleQuery.new(options)
40
47
  faraday_response = get(query.to_hash)
41
- ::SyoboiCalendar::Responses::TitlesResponse.new(faraday_response)
48
+ ::SyoboiCalendar::Response.new(
49
+ faraday_response: faraday_response,
50
+ response_parser_class: ::SyoboiCalendar::ResponseParsers::TitlesResponseParser,
51
+ )
42
52
  end
43
53
 
44
54
  private
@@ -49,10 +49,10 @@ module SyoboiCalendar
49
49
 
50
50
  private
51
51
 
52
- # @param [Array, Integer, String]
52
+ # @param value_or_values [Array, Integer, String]
53
53
  # @return [String]
54
- def format_comma_separated_values(values)
55
- ::Array.wrap(values).join(",")
54
+ def format_comma_separated_values(value_or_values)
55
+ Array(value_or_values).join(",")
56
56
  end
57
57
 
58
58
  # @param [Time, nil]
@@ -1,17 +1,23 @@
1
1
  module SyoboiCalendar
2
2
  module Resources
3
3
  class BaseResource
4
- # @return [Hashie::Mash]
5
- attr_reader :response
6
-
7
- # @param response [Hashie::Mash]
8
- def initialize(response)
9
- @response = response
4
+ # @param source [Hash]
5
+ def initialize(source)
6
+ @source = source
10
7
  end
11
8
 
12
- # @return [Time]
9
+ # @return [Time, nil]
13
10
  def updated_at
14
- ::Time.parse(response.LastUpdate)
11
+ if source["LastUpdate"]
12
+ ::Time.parse(source["LastUpdate"])
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ # @return [Hash]
19
+ def source
20
+ @source
15
21
  end
16
22
  end
17
23
  end
@@ -3,22 +3,26 @@ module SyoboiCalendar
3
3
  class ChannelGroupResource < BaseResource
4
4
  # @return [String, nil]
5
5
  def comment
6
- response.ChGroupComment
6
+ source["ChGroupComment"]
7
7
  end
8
8
 
9
9
  # @return [Integer, nil]
10
10
  def id
11
- response.ChGID.try(:to_i)
11
+ if source["ChGID"]
12
+ source["ChGID"].to_i
13
+ end
12
14
  end
13
15
 
14
16
  # @return [String, nil]
15
17
  def name
16
- response.ChGroupName
18
+ source["ChGroupName"]
17
19
  end
18
20
 
19
21
  # @return [Integer, nil]
20
22
  def order_score
21
- response.ChGroupOrder.try(:to_i)
23
+ if source["ChGroupOrder"]
24
+ source["ChGroupOrder"].to_i
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -3,42 +3,48 @@ module SyoboiCalendar
3
3
  class ChannelResource < BaseResource
4
4
  # @return [Integer, nil]
5
5
  def channel_group_id
6
- response.ChGID.try(:to_i)
6
+ if source["ChGID"]
7
+ source["ChGID"].to_i
8
+ end
7
9
  end
8
10
 
9
11
  # @return [String, nil]
10
12
  def comment
11
- response.ChComment
13
+ source["ChComment"]
12
14
  end
13
15
 
14
16
  # @return [String, nil]
15
17
  def epg_url
16
- response.ChEPGURL
18
+ source["ChEPGURL"]
17
19
  end
18
20
 
19
21
  # @return [Integer, nil]
20
22
  def id
21
- response.ChID.try(:to_i)
23
+ if source["ChID"]
24
+ source["ChID"].to_i
25
+ end
22
26
  end
23
27
 
24
28
  # @return [String, nil]
25
29
  def iepg_name
26
- response.ChiEPGName
30
+ source["ChiEPGName"]
27
31
  end
28
32
 
29
33
  # @return [String, nil]
30
34
  def name
31
- response.ChName
35
+ source["ChName"]
32
36
  end
33
37
 
34
38
  # @return [Integer, nil]
35
39
  def number
36
- response.ChNumber.try(:to_i)
40
+ if source["ChNumber"]
41
+ source["ChNumber"].to_i
42
+ end
37
43
  end
38
44
 
39
45
  # @return [String, nil]
40
46
  def url
41
- response.ChURL
47
+ source["ChURL"]
42
48
  end
43
49
  end
44
50
  end
@@ -1,75 +1,87 @@
1
1
  module SyoboiCalendar
2
2
  module Resources
3
3
  class ProgramResource < BaseResource
4
- # @return [SyoboiCalendar::Resources::Channel, nil]
5
- attr_accessor :channel
6
-
7
- # @return [SyoboiCalendar::Resources::Title, nil]
8
- attr_accessor :title
9
-
10
4
  # @return [Integer, nil]
11
5
  def channel_id
12
- response.ChID.try(:to_i)
6
+ if source["ChID"]
7
+ source["ChID"].to_i
8
+ end
13
9
  end
14
10
 
15
11
  # @return [String, nil]
16
12
  def comment
17
- response.ProgComment
13
+ source["ProgComment"]
18
14
  end
19
15
 
20
16
  # @return [Integer, nil]
21
17
  def count
22
- response.Count.try(:to_i)
18
+ if source["Count"]
19
+ source["Count"].to_i
20
+ end
23
21
  end
24
22
 
25
23
  # @return [Boolean]
26
24
  def deleted?
27
- response.Deleted != "0"
25
+ source["Deleted"] != "0"
28
26
  end
29
27
 
30
28
  # @return [Integer, nil]
31
29
  def flag
32
- response.Flag.try(:to_i)
30
+ if source["Flag"]
31
+ source["Flag"].to_i
32
+ end
33
33
  end
34
34
 
35
35
  # @return [Integer, nil]
36
36
  def id
37
- response.PID.try(:to_i)
37
+ if source["PID"]
38
+ source["PID"].to_i
39
+ end
38
40
  end
39
41
 
40
42
  # @return [String, nil]
41
43
  def iepg_name
42
- response.ChiEPGName
44
+ source["ChiEPGName"]
43
45
  end
44
46
 
45
- # @return [Time]
47
+ # @return [Time, nil]
46
48
  def finished_at
47
- ::Time.parse(response.EdTime)
49
+ if source["EdTime"]
50
+ ::Time.parse(source["EdTime"])
51
+ end
48
52
  end
49
53
 
50
54
  # @return [Integer, nil]
51
55
  def revision
52
- response.Revision.try(:to_i)
56
+ if source["Revision"]
57
+ source["Revision"].to_i
58
+ end
53
59
  end
54
60
 
55
- # @return [Time]
61
+ # @return [Time, nil]
56
62
  def started_at
57
- ::Time.parse(response.StTime)
63
+ if source["StTime"]
64
+ ::Time.parse(source["StTime"])
65
+ end
58
66
  end
59
67
 
60
68
  # @return [String, nil]
61
69
  def sub_title
62
- response.STSubTitle
70
+ source["STSubTitle"]
63
71
  end
64
72
 
65
73
  # @return [Integer]
66
74
  def title_id
67
- response.TID.try(:to_i)
75
+ if source["TID"]
76
+ source["TID"].to_i
77
+ end
68
78
  end
69
79
 
70
80
  # @return [Integer, nil]
71
81
  def warn
72
- response.Warn.try(:to_i)
82
+ if source["Warn"]
83
+ source["Warn"].to_i
84
+ end
73
85
  end
74
86
  end
75
87
  end
@@ -14,87 +14,105 @@ module SyoboiCalendar
14
14
  # 10: アニメ(終了/再放送)
15
15
  # @return [Integer, nil]
16
16
  def category_id
17
- response.Cat.try(:to_i)
17
+ if source["Cat"]
18
+ source["Cat"].to_i
19
+ end
18
20
  end
19
21
 
20
22
  # @return [String, nil]
21
23
  def comment
22
- response.Comment
24
+ source["Comment"]
23
25
  end
24
26
 
25
27
  # @return [String, nil]
26
28
  def english_name
27
- response.TitleEN
29
+ source["TitleEN"]
28
30
  end
29
31
 
30
32
  # @return [String, nil]
31
33
  def first_channel
32
- response.FirstCh
34
+ source["FirstCh"]
33
35
  end
34
36
 
35
37
  # @return [Integer, nil]
36
38
  def first_end_month
37
- response.FirstEndMonth.try(:to_i)
39
+ if source["FirstEndMonth"]
40
+ source["FirstEndMonth"].to_i
41
+ end
38
42
  end
39
43
 
40
44
  # @return [Integer, nil]
41
45
  def first_end_year
42
- response.FirstEndYear.try(:to_i)
46
+ if source["FirstEndYear"]
47
+ source["FirstEndYear"].to_i
48
+ end
43
49
  end
44
50
 
45
51
  # @return [Integer, nil]
46
52
  def first_month
47
- response.FirstMonth.try(:to_i)
53
+ if source["FirstMonth"]
54
+ source["FirstMonth"].to_i
55
+ end
48
56
  end
49
57
 
50
58
  # @return [Integer, nil]
51
59
  def first_year
52
- response.FirstYear.try(:to_i)
60
+ if source["FirstYear"]
61
+ source["FirstYear"].to_i
62
+ end
53
63
  end
54
64
 
55
65
  # @return [Integer, nil]
56
- def id
57
- response.TID.try(:to_i)
58
- end
59
-
60
- # @return [String, nil]
61
- def name
62
- response.Title
66
+ def flag
67
+ if source["TitleFlag"]
68
+ source["TitleFlag"].to_i
69
+ end
63
70
  end
64
71
 
65
72
  # @return [Integer, nil]
66
- def flag
67
- response.TitleFlag.try(:to_i)
73
+ def id
74
+ if source["TID"]
75
+ source["TID"].to_i
76
+ end
68
77
  end
69
78
 
70
79
  # @return [String, nil]
71
80
  def kana
72
- response.TitleYomi
81
+ source["TitleYomi"]
73
82
  end
74
83
 
75
84
  # @return [String, nil]
76
85
  def keywords
77
- response.Keywords
78
- end
79
-
80
- # @return [String, nil]
81
- def short_title
82
- response.ShortTitle
86
+ source["Keywords"]
83
87
  end
84
88
 
85
89
  # @return [String, nil]
86
- def sub_titles
87
- response.SubTitles
90
+ def name
91
+ source["Title"]
88
92
  end
89
93
 
90
94
  # @return [Integer, nil]
91
95
  def point
92
- response.UserPoint.try(:to_i)
96
+ if source["UserPoint"]
97
+ source["UserPoint"].to_i
98
+ end
93
99
  end
94
100
 
95
101
  # @return [Integer, nil]
96
102
  def rank
97
- response.UserPointRank.try(:to_i)
103
+ if source["UserPointRank"]
104
+ source["UserPointRank"].to_i
105
+ end
106
+ end
107
+
108
+ # @return [String, nil]
109
+ def short_title
110
+ source["ShortTitle"]
111
+ end
112
+
113
+ # @return [String, nil]
114
+ def sub_titles
115
+ source["SubTitles"]
98
116
  end
99
117
  end
100
118
  end
@@ -0,0 +1,49 @@
1
+ module SyoboiCalendar
2
+ class Response
3
+ include ::Enumerable
4
+
5
+ # @param faraday_response [Faraday::Response]
6
+ # @param response_parser_class [Class]
7
+ def initialize(faraday_response:, response_parser_class:)
8
+ @faraday_response = faraday_response
9
+ @response_parser_class = response_parser_class
10
+ end
11
+
12
+ # @return [String]
13
+ def body
14
+ faraday_response.body
15
+ end
16
+
17
+ # @note Implementation for Enumerable
18
+ def each(&block)
19
+ resources.each(&block)
20
+ end
21
+
22
+ # @return [Hash]
23
+ def headers
24
+ faraday_response.headers
25
+ end
26
+
27
+ # @return [Array<SyoboiCalendar::Resources::BaseResource>]
28
+ def resources
29
+ @resources ||= response_parser_class.new(body).parse
30
+ end
31
+
32
+ # @return [Integer]
33
+ def status
34
+ faraday_response.status
35
+ end
36
+
37
+ private
38
+
39
+ # @return [Faraday::Response]
40
+ def faraday_response
41
+ @faraday_response
42
+ end
43
+
44
+ # @return [Class]
45
+ def response_parser_class
46
+ @response_parser_class
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,52 @@
1
+ module SyoboiCalendar
2
+ module ResponseParsers
3
+ class BaseResponseParser
4
+ # @param body [String]
5
+ def initialize(body)
6
+ @body = body
7
+ end
8
+
9
+ # @return [Array<SyoboiCalendar::Resources::BaseResource>]
10
+ def parse
11
+ sources.map do |source|
12
+ resource_class.new(source)
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ # @return [String]
19
+ def body
20
+ @body
21
+ end
22
+
23
+ # @return [Hash]
24
+ def parsed_body
25
+ ::MultiXml.parse(body)
26
+ end
27
+
28
+ # @return [Class]
29
+ def resource_class
30
+ raise ::NotImplementedError
31
+ end
32
+
33
+ # @return [Array<Hash>, Hash]
34
+ def source_or_sources
35
+ raise ::NotImplementedError
36
+ end
37
+
38
+ # @return [Array]
39
+ def sources
40
+ object = source_or_sources
41
+ case
42
+ when object.nil?
43
+ []
44
+ when object.respond_to?(:to_ary)
45
+ object.to_ary || [object]
46
+ else
47
+ [object]
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ module SyoboiCalendar
2
+ module ResponseParsers
3
+ class ChannelGroupsResponseParser < BaseResponseParser
4
+ private
5
+
6
+ # @note Override
7
+ def resource_class
8
+ ::SyoboiCalendar::Resources::ChannelGroupResource
9
+ end
10
+
11
+ # @note Override
12
+ def source_or_sources
13
+ parsed_body["ChGroupLookupResponse"]["ChGroupItems"]["ChGroupItem"]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module SyoboiCalendar
2
+ module ResponseParsers
3
+ class ChannelsResponseParser < BaseResponseParser
4
+ private
5
+
6
+ # @note Override
7
+ def resource_class
8
+ ::SyoboiCalendar::Resources::ChannelResource
9
+ end
10
+
11
+ # @note Override
12
+ def source_or_sources
13
+ parsed_body["ChLookupResponse"]["ChItems"]["ChItem"]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module SyoboiCalendar
2
+ module ResponseParsers
3
+ class ProgramsResponseParser < BaseResponseParser
4
+ private
5
+
6
+ # @note Override
7
+ def resource_class
8
+ ::SyoboiCalendar::Resources::ProgramResource
9
+ end
10
+
11
+ # @note Override
12
+ def source_or_sources
13
+ parsed_body["ProgLookupResponse"]["ProgItems"]["ProgItem"]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module SyoboiCalendar
2
+ module ResponseParsers
3
+ class TitlesResponseParser < BaseResponseParser
4
+ private
5
+
6
+ # @note Override
7
+ def resource_class
8
+ ::SyoboiCalendar::Resources::TitleResource
9
+ end
10
+
11
+ # @note Override
12
+ def source_or_sources
13
+ parsed_body["TitleLookupResponse"]["TitleItems"]["TitleItem"]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module SyoboiCalendar
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,8 @@
1
- require "webmock/rspec"
2
-
3
- require "syoboi_calendar"
1
+ require "active_support/core_ext/object/to_query"
2
+ require "active_support/core_ext/string/strip"
4
3
  require "rack"
5
- require "active_support/all"
4
+ require "syoboi_calendar"
5
+ require "webmock/rspec"
6
6
 
7
7
  RSpec.configure do |config|
8
8
  config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -14,9 +14,9 @@ describe ::SyoboiCalendar::Client do
14
14
  </Result>
15
15
  <ChGroupItems>
16
16
  <ChGroupItem id="3">
17
- <ChGroupComment>DummyComment</ChComment>
17
+ <ChGroupComment>DummyComment</ChGroupComment>
18
18
  <ChGID>1</ChGID>
19
- <ChGroupName>DummyChannelName</ChName>
19
+ <ChGroupName>DummyChannelName</ChGroupName>
20
20
  <Order>1000</Order>
21
21
  <LastUpdate>2000-01-01 00:00:00</LastUpdate>
22
22
  </ChGroupItem>
@@ -202,7 +202,7 @@ describe ::SyoboiCalendar::Client do
202
202
  end
203
203
 
204
204
  it "sends an HTTP request to http://cal.syoboi.jp/db.php?#{example[:query].to_query}" do
205
- stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}")
205
+ stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}").to_return(body: dummy_channel_groups_response)
206
206
  subject
207
207
  expect(stub).to have_been_made
208
208
  end
@@ -270,7 +270,7 @@ describe ::SyoboiCalendar::Client do
270
270
  end
271
271
 
272
272
  it "sends an HTTP request to http://cal.syoboi.jp/db.php?#{example[:query].to_query}" do
273
- stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}")
273
+ stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}").to_return(body: dummy_channels_response)
274
274
  subject
275
275
  expect(stub).to have_been_made
276
276
  end
@@ -445,7 +445,7 @@ describe ::SyoboiCalendar::Client do
445
445
  end
446
446
 
447
447
  it "sends an HTTP request to http://cal.syoboi.jp/db.php?#{example[:query].to_query}" do
448
- stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}")
448
+ stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}").to_return(body: dummy_programs_response)
449
449
  subject
450
450
  expect(stub).to have_been_made
451
451
  end
@@ -541,7 +541,7 @@ describe ::SyoboiCalendar::Client do
541
541
  end
542
542
 
543
543
  it "sends an HTTP request to http://cal.syoboi.jp/db.php?#{example[:query].to_query}" do
544
- stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}")
544
+ stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}").to_return(body: dummy_titles_response)
545
545
  subject
546
546
  expect(stub).to have_been_made
547
547
  end
@@ -18,11 +18,10 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = ">= 2.2.2"
20
20
 
21
- spec.add_dependency "activesupport"
22
21
  spec.add_dependency "faraday"
23
22
  spec.add_dependency "faraday_middleware"
24
- spec.add_dependency "hashie"
25
23
  spec.add_dependency "multi_xml"
24
+ spec.add_development_dependency "activesupport"
26
25
  spec.add_development_dependency "pry"
27
26
  spec.add_development_dependency "rack"
28
27
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syoboi_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
@@ -10,20 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: faraday
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +39,7 @@ dependencies:
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: hashie
42
+ name: multi_xml
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - ">="
@@ -67,13 +53,13 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: multi_xml
56
+ name: activesupport
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
74
60
  - !ruby/object:Gem::Version
75
61
  version: '0'
76
- type: :runtime
62
+ type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
@@ -176,11 +162,12 @@ files:
176
162
  - lib/syoboi_calendar/resources/channel_resource.rb
177
163
  - lib/syoboi_calendar/resources/program_resource.rb
178
164
  - lib/syoboi_calendar/resources/title_resource.rb
179
- - lib/syoboi_calendar/responses/base_response.rb
180
- - lib/syoboi_calendar/responses/channel_groups_response.rb
181
- - lib/syoboi_calendar/responses/channels_response.rb
182
- - lib/syoboi_calendar/responses/programs_response.rb
183
- - lib/syoboi_calendar/responses/titles_response.rb
165
+ - lib/syoboi_calendar/response.rb
166
+ - lib/syoboi_calendar/response_parsers/base_response_parser.rb
167
+ - lib/syoboi_calendar/response_parsers/channel_groups_response_parser.rb
168
+ - lib/syoboi_calendar/response_parsers/channels_response_parser.rb
169
+ - lib/syoboi_calendar/response_parsers/programs_response_parser.rb
170
+ - lib/syoboi_calendar/response_parsers/titles_response_parser.rb
184
171
  - lib/syoboi_calendar/version.rb
185
172
  - spec/spec_helper.rb
186
173
  - spec/syoboi_calendar/client_spec.rb
@@ -1,31 +0,0 @@
1
- module SyoboiCalendar
2
- module Responses
3
- class BaseResponse
4
- include ::Enumerable
5
-
6
- # @param faraday_response [Faraday::Response]
7
- def initialize(faraday_response)
8
- @faraday_response = faraday_response
9
- end
10
-
11
- # @note Override
12
- def each
13
- resources.map do |resource|
14
- yield resource
15
- end
16
- end
17
-
18
- private
19
-
20
- # @return [Array<SyoboiCalendar::Resources::BaseResource>]
21
- def resources
22
- raise ::NotImplementedError
23
- end
24
-
25
- # @return [Faraday::Response]
26
- def faraday_response
27
- @faraday_response
28
- end
29
- end
30
- end
31
- end
@@ -1,12 +0,0 @@
1
- module SyoboiCalendar
2
- module Responses
3
- class ChannelGroupsResponse < BaseResponse
4
- # @note Override
5
- def resources
6
- ::Array.wrap(faraday_response.body.ChGroupLookupResponse.ChGroupItems.ChGroupItem).map do |element|
7
- ::SyoboiCalendar::Resources::ChannelGroupResource.new(element)
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module SyoboiCalendar
2
- module Responses
3
- class ChannelsResponse < BaseResponse
4
- # @note Override
5
- def resources
6
- ::Array.wrap(faraday_response.body.ChLookupResponse.ChItems.ChItem).map do |element|
7
- ::SyoboiCalendar::Resources::ChannelResource.new(element)
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module SyoboiCalendar
2
- module Responses
3
- class ProgramsResponse < BaseResponse
4
- # @note Override
5
- def resources
6
- ::Array.wrap(faraday_response.body.ProgLookupResponse.ProgItems.ProgItem).map do |element|
7
- ::SyoboiCalendar::Resources::ProgramResource.new(element)
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module SyoboiCalendar
2
- module Responses
3
- class TitlesResponse < BaseResponse
4
- # @note Override
5
- def resources
6
- ::Array.wrap(faraday_response.body.TitleLookupResponse.TitleItems.TitleItem).map do |element|
7
- ::SyoboiCalendar::Resources::TitleResource.new(element)
8
- end
9
- end
10
- end
11
- end
12
- end