syoboi_calendar 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -4
- data/CHANGELOG.md +3 -0
- data/README.md +3 -2
- data/lib/syoboi_calendar/client.rb +23 -28
- data/lib/syoboi_calendar/connector.rb +27 -0
- data/lib/syoboi_calendar/parsers/base.rb +25 -0
- data/lib/syoboi_calendar/parsers/channel.rb +15 -0
- data/lib/syoboi_calendar/parsers/program.rb +15 -0
- data/lib/syoboi_calendar/parsers/title.rb +15 -0
- data/lib/syoboi_calendar/{queries → query_builders}/base.rb +5 -1
- data/lib/syoboi_calendar/{queries → query_builders}/channel.rb +1 -1
- data/lib/syoboi_calendar/{queries → query_builders}/channel_id_queriable.rb +1 -1
- data/lib/syoboi_calendar/{queries → query_builders}/program.rb +1 -1
- data/lib/syoboi_calendar/{queries → query_builders}/title.rb +1 -1
- data/lib/syoboi_calendar/resources/base.rb +15 -0
- data/lib/syoboi_calendar/resources/channel.rb +37 -0
- data/lib/syoboi_calendar/resources/program.rb +53 -0
- data/lib/syoboi_calendar/resources/title.rb +73 -0
- data/lib/syoboi_calendar/version.rb +1 -1
- data/lib/syoboi_calendar.rb +15 -5
- data/spec/spec_helper.rb +10 -1
- data/spec/syoboi_calendar/client_spec.rb +187 -0
- data/syoboi_calendar.gemspec +2 -0
- metadata +44 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c784bb59897bd758d21932242d40099f76a6620d
|
4
|
+
data.tar.gz: 9670e8cb32bce32fba0a8be526fe8c570bcf97b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c20a5b6d89934ae1ad18741d07e30052736f34beb257a595375ff9d39a952462c74c59ba2d217787c163877e8ead5294e9a489a44f7b714243113676ffb20e
|
7
|
+
data.tar.gz: f2cdf3fe11d729a1d657b1e6c08e3cf9714b92e5d32790c02ae97a5656bcd3fa89377aac2aef290d440fbe5c74e9e77328944f981915518e94dcdfdc38988f0b
|
data/.travis.yml
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
branches:
|
2
2
|
only:
|
3
|
-
|
3
|
+
- master
|
4
4
|
language: ruby
|
5
5
|
rvm:
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
- 1.9.3
|
7
|
+
- 2.0.0
|
8
|
+
- 2.1.0
|
9
|
+
env:
|
10
|
+
global:
|
11
|
+
secure: jireAT1B+27QH2v5EUjdIu9/ELwA+fj67PtCFiw7nSvzzQV4sC94/otyrPlNqsLKijWk+fQw5XcW9HvSTXvCgGguQn5AGW+MjPu9AbuZAbWf6ayZFHIgaPxmBzFYZaC2yK9XL0kVMG/UdhDM9Vy9auf1kDPphMhwAGZ2yjuSBj0=
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# SyoboiCalendar
|
1
|
+
# SyoboiCalendar [![Build Status](https://travis-ci.org/r7kamura/syoboi_calendar.png)](https://travis-ci.org/r7kamura/syoboi_calendar) [![Code Climate](https://codeclimate.com/github/r7kamura/syoboi_calendar.png)](https://codeclimate.com/github/r7kamura/syoboi_calendar) [![Code Climate](https://codeclimate.com/github/r7kamura/syoboi_calendar/coverage.png)](https://codeclimate.com/github/r7kamura/syoboi_calendar)
|
2
|
+
|
2
3
|
Search Japanese anime from [SyoboiCalendar](http://cal.syoboi.jp/).
|
3
4
|
|
4
5
|
## Installation
|
@@ -11,7 +12,7 @@ gem "syoboi_calendar"
|
|
11
12
|
```ruby
|
12
13
|
require "syoboi_calendar"
|
13
14
|
|
14
|
-
client = SyoboiCalendar::Client
|
15
|
+
client = SyoboiCalendar::Client.new
|
15
16
|
client.channels #=> a Hashie::Mash instance
|
16
17
|
client.programs #=> a Hashie::Mash instance
|
17
18
|
client.titles #=> a Hashie::Mash instance
|
@@ -1,48 +1,43 @@
|
|
1
1
|
module SyoboiCalendar
|
2
2
|
class Client
|
3
|
-
attr_reader :options
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
@options = options
|
7
|
-
end
|
8
|
-
|
9
3
|
def channels(options = {})
|
10
|
-
|
4
|
+
process(
|
5
|
+
QueryBuilders::Channel,
|
6
|
+
Parsers::Channel,
|
7
|
+
options,
|
8
|
+
)
|
11
9
|
end
|
12
10
|
|
13
11
|
def programs(options = {})
|
14
|
-
|
12
|
+
process(
|
13
|
+
QueryBuilders::Program,
|
14
|
+
Parsers::Program,
|
15
|
+
options,
|
16
|
+
)
|
15
17
|
end
|
16
18
|
|
17
19
|
def titles(options = {})
|
18
|
-
|
20
|
+
process(
|
21
|
+
QueryBuilders::Title,
|
22
|
+
Parsers::Title,
|
23
|
+
options,
|
24
|
+
)
|
19
25
|
end
|
20
26
|
|
21
27
|
private
|
22
28
|
|
23
|
-
def
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def connection
|
28
|
-
@connection ||= Faraday.new(url: url) do |connection|
|
29
|
-
connection.adapter :net_http
|
30
|
-
connection.response :mashify
|
31
|
-
connection.response :xml
|
32
|
-
connection.response :raise_error
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def url
|
37
|
-
"http://#{host}/"
|
29
|
+
def connector
|
30
|
+
@connector ||= Connector.new
|
38
31
|
end
|
39
32
|
|
40
|
-
def
|
41
|
-
|
33
|
+
def get(query)
|
34
|
+
connector.get(query).body
|
42
35
|
end
|
43
36
|
|
44
|
-
def
|
45
|
-
|
37
|
+
def process(builder, parser, options)
|
38
|
+
query = builder.build(options)
|
39
|
+
response = get(query)
|
40
|
+
parser.parse(response)
|
46
41
|
end
|
47
42
|
end
|
48
43
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
class Connector
|
3
|
+
URL = "http://cal.syoboi.jp/"
|
4
|
+
PATH = "/db.php"
|
5
|
+
|
6
|
+
def get(query)
|
7
|
+
connection.get(path, query)
|
8
|
+
end
|
9
|
+
|
10
|
+
def connection
|
11
|
+
@connection ||= Faraday.new(url: url) do |connection|
|
12
|
+
connection.adapter :net_http
|
13
|
+
connection.response :mashify
|
14
|
+
connection.response :xml
|
15
|
+
connection.response :raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def path
|
20
|
+
PATH
|
21
|
+
end
|
22
|
+
|
23
|
+
def url
|
24
|
+
URL
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
module Parsers
|
3
|
+
class Base
|
4
|
+
class << self
|
5
|
+
def parse(response)
|
6
|
+
new(response).parse
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader :response
|
11
|
+
|
12
|
+
def initialize(response)
|
13
|
+
@response = response
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse
|
17
|
+
items.map do |item|
|
18
|
+
resource_class.new(item)
|
19
|
+
end
|
20
|
+
rescue NoMethodError
|
21
|
+
[]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
module Resources
|
3
|
+
class Channel < Base
|
4
|
+
def comment
|
5
|
+
response.ChComment
|
6
|
+
end
|
7
|
+
|
8
|
+
def epg_url
|
9
|
+
response.ChEPGURL
|
10
|
+
end
|
11
|
+
|
12
|
+
def group_id
|
13
|
+
response.ChGID.try(:to_i)
|
14
|
+
end
|
15
|
+
|
16
|
+
def id
|
17
|
+
response.ChID.try(:to_i)
|
18
|
+
end
|
19
|
+
|
20
|
+
def name
|
21
|
+
response.ChName
|
22
|
+
end
|
23
|
+
|
24
|
+
def number
|
25
|
+
response.ChNumber.try(:to_i)
|
26
|
+
end
|
27
|
+
|
28
|
+
def url
|
29
|
+
response.ChURL
|
30
|
+
end
|
31
|
+
|
32
|
+
def iepg_name
|
33
|
+
response.ChiEPGName
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
module Resources
|
3
|
+
class Program < Base
|
4
|
+
def id
|
5
|
+
response.PID.try(:to_i)
|
6
|
+
end
|
7
|
+
|
8
|
+
def title_id
|
9
|
+
response.TID.try(:to_i)
|
10
|
+
end
|
11
|
+
|
12
|
+
def started_at
|
13
|
+
Time.parse(response.StTime)
|
14
|
+
end
|
15
|
+
|
16
|
+
def finished_at
|
17
|
+
Time.parse(response.EdTime)
|
18
|
+
end
|
19
|
+
|
20
|
+
def count
|
21
|
+
response.Count.try(:to_i)
|
22
|
+
end
|
23
|
+
|
24
|
+
def sub_title
|
25
|
+
response.STSubTitle
|
26
|
+
end
|
27
|
+
|
28
|
+
def comment
|
29
|
+
response.ProgComment
|
30
|
+
end
|
31
|
+
|
32
|
+
def flag
|
33
|
+
response.Flag.try(:to_i)
|
34
|
+
end
|
35
|
+
|
36
|
+
def deleted?
|
37
|
+
response.Deleted != "0"
|
38
|
+
end
|
39
|
+
|
40
|
+
def warn
|
41
|
+
response.Warn.try(:to_i)
|
42
|
+
end
|
43
|
+
|
44
|
+
def channel_id
|
45
|
+
response.ChID.try(:to_i)
|
46
|
+
end
|
47
|
+
|
48
|
+
def revision
|
49
|
+
response.Revision.try(:to_i)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module SyoboiCalendar
|
2
|
+
module Resources
|
3
|
+
class Title < Base
|
4
|
+
def category_id
|
5
|
+
response.Cat.try(:to_i)
|
6
|
+
end
|
7
|
+
|
8
|
+
def comment
|
9
|
+
response.Comment
|
10
|
+
end
|
11
|
+
|
12
|
+
def first_channel
|
13
|
+
response.FirstCh
|
14
|
+
end
|
15
|
+
|
16
|
+
def first_end_month
|
17
|
+
response.FirstEndMonth.try(:to_i)
|
18
|
+
end
|
19
|
+
|
20
|
+
def first_end_year
|
21
|
+
response.FirstEndYear.try(:to_i)
|
22
|
+
end
|
23
|
+
|
24
|
+
def first_month
|
25
|
+
response.FirstMonth.try(:to_i)
|
26
|
+
end
|
27
|
+
|
28
|
+
def first_year
|
29
|
+
response.FirstYear.try(:to_i)
|
30
|
+
end
|
31
|
+
|
32
|
+
def keywords
|
33
|
+
response.Keywords
|
34
|
+
end
|
35
|
+
|
36
|
+
def short_title
|
37
|
+
response.ShortTitle
|
38
|
+
end
|
39
|
+
|
40
|
+
def sub_titles
|
41
|
+
response.SubTitles
|
42
|
+
end
|
43
|
+
|
44
|
+
def id
|
45
|
+
response.TID.try(:to_i)
|
46
|
+
end
|
47
|
+
|
48
|
+
def name
|
49
|
+
response.Title
|
50
|
+
end
|
51
|
+
|
52
|
+
def english_name
|
53
|
+
response.TitleEN
|
54
|
+
end
|
55
|
+
|
56
|
+
def flag
|
57
|
+
response.TitleFlag.try(:to_i)
|
58
|
+
end
|
59
|
+
|
60
|
+
def kana
|
61
|
+
response.TitleYomi
|
62
|
+
end
|
63
|
+
|
64
|
+
def point
|
65
|
+
response.UserPoint.try(:to_i)
|
66
|
+
end
|
67
|
+
|
68
|
+
def rank
|
69
|
+
response.UserPointRank.try(:to_i)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/syoboi_calendar.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "active_support/concern"
|
2
|
+
require "active_support/core_ext/array/wrap"
|
2
3
|
require "active_support/core_ext/class/attribute"
|
3
4
|
require "active_support/core_ext/object/try"
|
4
5
|
require "active_support/core_ext/string/inflections"
|
@@ -6,8 +7,17 @@ require "faraday"
|
|
6
7
|
require "faraday_middleware"
|
7
8
|
|
8
9
|
require "syoboi_calendar/client"
|
9
|
-
require "syoboi_calendar/
|
10
|
-
require "syoboi_calendar/
|
11
|
-
require "syoboi_calendar/
|
12
|
-
require "syoboi_calendar/
|
13
|
-
require "syoboi_calendar/
|
10
|
+
require "syoboi_calendar/connector"
|
11
|
+
require "syoboi_calendar/parsers/base"
|
12
|
+
require "syoboi_calendar/parsers/channel"
|
13
|
+
require "syoboi_calendar/parsers/program"
|
14
|
+
require "syoboi_calendar/parsers/title"
|
15
|
+
require "syoboi_calendar/query_builders/base"
|
16
|
+
require "syoboi_calendar/query_builders/channel_id_queriable"
|
17
|
+
require "syoboi_calendar/query_builders/channel"
|
18
|
+
require "syoboi_calendar/query_builders/program"
|
19
|
+
require "syoboi_calendar/query_builders/title"
|
20
|
+
require "syoboi_calendar/resources/base"
|
21
|
+
require "syoboi_calendar/resources/channel"
|
22
|
+
require "syoboi_calendar/resources/program"
|
23
|
+
require "syoboi_calendar/resources/title"
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
require "simplecov"
|
2
2
|
SimpleCov.start
|
3
3
|
|
4
|
-
require "syoboi_calendar"
|
5
4
|
require "webmock/rspec"
|
6
5
|
|
6
|
+
if ENV["CI"]
|
7
|
+
WebMock.disable_net_connect!(allow: "codeclimate.com")
|
8
|
+
require "codeclimate-test-reporter"
|
9
|
+
CodeClimate::TestReporter.start
|
10
|
+
end
|
11
|
+
|
12
|
+
require "syoboi_calendar"
|
13
|
+
require "rack"
|
14
|
+
require "active_support/all"
|
15
|
+
|
7
16
|
RSpec.configure do |config|
|
8
17
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
18
|
config.run_all_when_everything_filtered = true
|
@@ -22,6 +22,122 @@ describe SyoboiCalendar::Client do
|
|
22
22
|
{}
|
23
23
|
end
|
24
24
|
|
25
|
+
let(:query) do
|
26
|
+
{}
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:dummy_channels_response) do
|
30
|
+
<<-EOS.strip_heredoc
|
31
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
32
|
+
<ChLookupResponse>
|
33
|
+
<Result>
|
34
|
+
<Code>200</Code>
|
35
|
+
<Message>
|
36
|
+
</Message>
|
37
|
+
</Result>
|
38
|
+
<ChItems>
|
39
|
+
<ChItem id="3">
|
40
|
+
<ChComment>DummyComment</ChComment>
|
41
|
+
<ChEPGURL>http://example.com/epg-url</ChEPGURL>
|
42
|
+
<ChGID>1</ChGID>
|
43
|
+
<ChID>3</ChID>
|
44
|
+
<ChName>DummyChannelName</ChName>
|
45
|
+
<ChNumber>3</ChNumber>
|
46
|
+
<ChURL>http://example.com/</ChURL>
|
47
|
+
<ChiEPGName>DummyiEPGName</ChiEPGName>
|
48
|
+
<LastUpdate>2000-01-01 00:00:00</LastUpdate>
|
49
|
+
</ChItem>
|
50
|
+
</ChItems>
|
51
|
+
</ChLookupResponse>
|
52
|
+
EOS
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:dummy_programs_response) do
|
56
|
+
<<-EOS.strip_heredoc
|
57
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
58
|
+
<ProgLookupResponse>
|
59
|
+
<ProgItems>
|
60
|
+
<ProgItem id="1">
|
61
|
+
<ChID>3</ChID>
|
62
|
+
<Count>1</Count>
|
63
|
+
<Deleted>0</Deleted>
|
64
|
+
<EdTime>2000-01-01 00:00:00</EdTime>
|
65
|
+
<Flag>9</Flag>
|
66
|
+
<LastUpdate>2000-01-01 00:00:00</LastUpdate>
|
67
|
+
<PID>1</PID>
|
68
|
+
<ProgComment>DummyComment</ProgComment>
|
69
|
+
<Revision>2</Revision>
|
70
|
+
<STSubTitle>DummySubTitle</STSubTitle>
|
71
|
+
<StOffset>0</StOffset>
|
72
|
+
<StTime>2000-01-01 00:00:00</StTime>
|
73
|
+
<SubTitle></SubTitle>
|
74
|
+
<TID>2</TID>
|
75
|
+
<Warn>1</Warn>
|
76
|
+
</ProgItem>
|
77
|
+
</ProgItems>
|
78
|
+
<Result>
|
79
|
+
<Code>200</Code>
|
80
|
+
<Message>
|
81
|
+
</Message>
|
82
|
+
</Result>
|
83
|
+
</ProgLookupResponse>
|
84
|
+
EOS
|
85
|
+
end
|
86
|
+
|
87
|
+
let(:dummy_titles_response) do
|
88
|
+
<<-EOS.strip_heredoc
|
89
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
90
|
+
<TitleLookupResponse>
|
91
|
+
<Result>
|
92
|
+
<Code>200</Code>
|
93
|
+
<Message>
|
94
|
+
</Message>
|
95
|
+
</Result>
|
96
|
+
<TitleItems>
|
97
|
+
<TitleItem id="2">
|
98
|
+
<Cat>4</Cat>
|
99
|
+
<Comment>DummyComment</Comment>
|
100
|
+
<FirstCh>DummyChannel</FirstCh>
|
101
|
+
<FirstEndMonth>1</FirstEndMonth>
|
102
|
+
<FirstEndYear>2000</FirstEndYear>
|
103
|
+
<FirstMonth>1</FirstMonth>
|
104
|
+
<FirstYear>2000</FirstYear>
|
105
|
+
<Keywords>DummyKeywords</Keywords>
|
106
|
+
<LastUpdate>2000-01-01 00:00:00</LastUpdate>
|
107
|
+
<ShortTitle>DummyShortTitle</ShortTitle>
|
108
|
+
<SubTitles>DummySubTitles</SubTitles>
|
109
|
+
<TID>2</TID>
|
110
|
+
<Title>DummyTitle</Title>
|
111
|
+
<TitleEN>DummyEnglishTitle</TitleEN>
|
112
|
+
<TitleFlag>0</TitleFlag>
|
113
|
+
<TitleYomi>ダミータイトル</TitleYomi>
|
114
|
+
<UserPoint>6</UserPoint>
|
115
|
+
<UserPointRank>1</UserPointRank>
|
116
|
+
</TitleItem>
|
117
|
+
</TitleItems>
|
118
|
+
</TitleLookupResponse>
|
119
|
+
EOS
|
120
|
+
end
|
121
|
+
|
122
|
+
let(:app) do
|
123
|
+
->(env) do
|
124
|
+
[
|
125
|
+
200,
|
126
|
+
{ "Content-type" => "application/xml" },
|
127
|
+
[
|
128
|
+
case env["QUERY_STRING"]
|
129
|
+
when /ProgLookup/
|
130
|
+
dummy_programs_response
|
131
|
+
when /ChLookup/
|
132
|
+
dummy_channels_response
|
133
|
+
else
|
134
|
+
dummy_titles_response
|
135
|
+
end,
|
136
|
+
],
|
137
|
+
]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
25
141
|
subject do
|
26
142
|
call
|
27
143
|
request
|
@@ -68,6 +184,25 @@ describe SyoboiCalendar::Client do
|
|
68
184
|
end
|
69
185
|
end
|
70
186
|
end
|
187
|
+
|
188
|
+
context "with real response" do
|
189
|
+
let!(:request) do
|
190
|
+
stub_request(:get, //).to_rack(app)
|
191
|
+
end
|
192
|
+
|
193
|
+
it "returns an Array of SyoboiCalendar::Resources::Channel" do
|
194
|
+
channels = client.channels
|
195
|
+
channels[0].should be_a SyoboiCalendar::Resources::Channel
|
196
|
+
channels[0].comment.should == "DummyComment"
|
197
|
+
channels[0].epg_url.should == "http://example.com/epg-url"
|
198
|
+
channels[0].group_id.should == 1
|
199
|
+
channels[0].id.should == 3
|
200
|
+
channels[0].iepg_name.should == "DummyiEPGName"
|
201
|
+
channels[0].name.should == "DummyChannelName"
|
202
|
+
channels[0].number.should == 3
|
203
|
+
channels[0].url.should == "http://example.com/"
|
204
|
+
end
|
205
|
+
end
|
71
206
|
end
|
72
207
|
|
73
208
|
describe "#titles" do
|
@@ -111,6 +246,34 @@ describe SyoboiCalendar::Client do
|
|
111
246
|
end
|
112
247
|
end
|
113
248
|
end
|
249
|
+
|
250
|
+
context "with real response" do
|
251
|
+
let!(:request) do
|
252
|
+
stub_request(:get, //).to_rack(app)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "returns an Array of SyoboiCalendar::Resources::Title" do
|
256
|
+
titles = client.titles
|
257
|
+
titles[0].should be_a SyoboiCalendar::Resources::Title
|
258
|
+
titles[0].category_id.should == 4
|
259
|
+
titles[0].comment.should == "DummyComment"
|
260
|
+
titles[0].first_channel.should == "DummyChannel"
|
261
|
+
titles[0].first_end_month.should == 1
|
262
|
+
titles[0].first_end_year.should == 2000
|
263
|
+
titles[0].first_month.should == 1
|
264
|
+
titles[0].first_year.should == 2000
|
265
|
+
titles[0].keywords.should == "DummyKeywords"
|
266
|
+
titles[0].short_title.should == "DummyShortTitle"
|
267
|
+
titles[0].sub_titles.should == "DummySubTitles"
|
268
|
+
titles[0].id.should == 2
|
269
|
+
titles[0].name.should == "DummyTitle"
|
270
|
+
titles[0].english_name.should == "DummyEnglishTitle"
|
271
|
+
titles[0].flag.should == 0
|
272
|
+
titles[0].kana.should == "ダミータイトル"
|
273
|
+
titles[0].point.should == 6
|
274
|
+
titles[0].rank.should == 1
|
275
|
+
end
|
276
|
+
end
|
114
277
|
end
|
115
278
|
|
116
279
|
describe "#programs" do
|
@@ -186,5 +349,29 @@ describe SyoboiCalendar::Client do
|
|
186
349
|
end
|
187
350
|
end
|
188
351
|
end
|
352
|
+
|
353
|
+
context "with real response" do
|
354
|
+
let!(:request) do
|
355
|
+
stub_request(:get, //).to_rack(app)
|
356
|
+
end
|
357
|
+
|
358
|
+
it "returns an Array of SyoboiCalendar::Resources::Program" do
|
359
|
+
programs = client.programs
|
360
|
+
programs[0].should be_a SyoboiCalendar::Resources::Program
|
361
|
+
programs[0].channel_id.should == 3
|
362
|
+
programs[0].comment.should == "DummyComment"
|
363
|
+
programs[0].count.should == 1
|
364
|
+
programs[0].deleted?.should == false
|
365
|
+
programs[0].finished_at.should == Time.parse("2000-01-01 00:00:00")
|
366
|
+
programs[0].flag.should == 9
|
367
|
+
programs[0].id.should == 1
|
368
|
+
programs[0].revision.should == 2
|
369
|
+
programs[0].started_at.should == Time.parse("2000-01-01 00:00:00")
|
370
|
+
programs[0].sub_title.should == "DummySubTitle"
|
371
|
+
programs[0].title_id.should == 2
|
372
|
+
programs[0].updated_at.should == Time.parse("2000-01-01 00:00:00")
|
373
|
+
programs[0].warn.should == 1
|
374
|
+
end
|
375
|
+
end
|
189
376
|
end
|
190
377
|
end
|
data/syoboi_calendar.gemspec
CHANGED
@@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "faraday_middleware"
|
22
22
|
spec.add_dependency "hashie"
|
23
23
|
spec.add_dependency "multi_xml"
|
24
|
+
spec.add_development_dependency "codeclimate-test-reporter", ">= 0.3.0"
|
24
25
|
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "rack"
|
25
27
|
spec.add_development_dependency "rake"
|
26
28
|
spec.add_development_dependency "rspec", "2.14.1"
|
27
29
|
spec.add_development_dependency "simplecov"
|
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.3.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: 2014-
|
11
|
+
date: 2014-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.3.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.3.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: pry
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rack
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: rake
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,11 +194,20 @@ files:
|
|
166
194
|
- Rakefile
|
167
195
|
- lib/syoboi_calendar.rb
|
168
196
|
- lib/syoboi_calendar/client.rb
|
169
|
-
- lib/syoboi_calendar/
|
170
|
-
- lib/syoboi_calendar/
|
171
|
-
- lib/syoboi_calendar/
|
172
|
-
- lib/syoboi_calendar/
|
173
|
-
- lib/syoboi_calendar/
|
197
|
+
- lib/syoboi_calendar/connector.rb
|
198
|
+
- lib/syoboi_calendar/parsers/base.rb
|
199
|
+
- lib/syoboi_calendar/parsers/channel.rb
|
200
|
+
- lib/syoboi_calendar/parsers/program.rb
|
201
|
+
- lib/syoboi_calendar/parsers/title.rb
|
202
|
+
- lib/syoboi_calendar/query_builders/base.rb
|
203
|
+
- lib/syoboi_calendar/query_builders/channel.rb
|
204
|
+
- lib/syoboi_calendar/query_builders/channel_id_queriable.rb
|
205
|
+
- lib/syoboi_calendar/query_builders/program.rb
|
206
|
+
- lib/syoboi_calendar/query_builders/title.rb
|
207
|
+
- lib/syoboi_calendar/resources/base.rb
|
208
|
+
- lib/syoboi_calendar/resources/channel.rb
|
209
|
+
- lib/syoboi_calendar/resources/program.rb
|
210
|
+
- lib/syoboi_calendar/resources/title.rb
|
174
211
|
- lib/syoboi_calendar/version.rb
|
175
212
|
- spec/spec_helper.rb
|
176
213
|
- spec/syoboi_calendar/client_spec.rb
|