tvrage_api 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -13
- data/lib/tvrage_api/base.rb +25 -6
- data/lib/tvrage_api/client.rb +13 -0
- data/lib/tvrage_api/search.rb +9 -0
- data/lib/tvrage_api/show.rb +14 -19
- data/lib/tvrage_api/update.rb +5 -0
- data/lib/tvrage_api/version.rb +1 -1
- data/lib/tvrage_api.rb +3 -7
- data/spec/integrations/client_spec.rb +55 -0
- data/spec/integrations/search_spec.rb +7 -7
- data/spec/integrations/show_spec.rb +12 -12
- data/spec/integrations/update_spec.rb +5 -6
- data/spec/tvrage_api/base_spec.rb +56 -0
- data/spec/tvrage_api/client_spec.rb +23 -0
- data/spec/tvrage_api/search_spec.rb +22 -0
- data/spec/tvrage_api/show_spec.rb +18 -59
- data/spec/tvrage_api/update_spec.rb +14 -0
- data/tvrage_api.gemspec +1 -2
- metadata +15 -53
- data/lib/tvrage_api/element.rb +0 -3
- data/lib/tvrage_api/episode.rb +0 -9
- data/lib/tvrage_api/request/base.rb +0 -57
- data/lib/tvrage_api/request/search.rb +0 -13
- data/lib/tvrage_api/request/show.rb +0 -37
- data/lib/tvrage_api/request/update.rb +0 -13
- data/lib/tvrage_api/utility/aka_array.rb +0 -9
- data/lib/tvrage_api/utility/date.rb +0 -9
- data/lib/tvrage_api/utility/date_or_integer.rb +0 -11
- data/lib/tvrage_api/utility/episode_array.rb +0 -15
- data/lib/tvrage_api/utility/genre_array.rb +0 -9
- data/lib/tvrage_api/utility/hashie/extensions/key_replace.rb +0 -42
- data/lib/tvrage_api/utility/integer.rb +0 -5
- data/lib/tvrage_api/utility/string.rb +0 -11
- data/lib/tvrage_api/utility.rb +0 -8
- data/spec/tvrage_api/episode_spec.rb +0 -51
- data/spec/tvrage_api/request/base_spec.rb +0 -113
- data/spec/tvrage_api/request/search_spec.rb +0 -30
- data/spec/tvrage_api/request/show_spec.rb +0 -71
- data/spec/tvrage_api/request/update_spec.rb +0 -28
- data/spec/tvrage_api/utility/aka_array_spec.rb +0 -17
- data/spec/tvrage_api/utility/date_or_integer_spec.rb +0 -13
- data/spec/tvrage_api/utility/date_spec.rb +0 -13
- data/spec/tvrage_api/utility/genre_array_spec.rb +0 -17
- data/spec/tvrage_api/utility/integer_spec.rb +0 -9
- data/spec/tvrage_api/utility/string_spec.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62f7f9d558b9cd8fe834e83c4349bcdf5665d4bf
|
4
|
+
data.tar.gz: 5c079055971ba0d4b341e3099c30c3d09e5d080b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54736a76669139e2e0cb92c85d472d5a68978f2a86ab03359a3d6bd957e02c934a91d5d8e7c7c461e59d29c27c411c4575f093ca04af06919a9eb97f9ebeaf6b
|
7
|
+
data.tar.gz: 173775ab0e8a14ae56c73b18744dca37950ff84c632ff249c16b7842134daa90d21a7064a67512fc2ee800b463e1c75e76fee718be02eeff2fff66b36a0d162e
|
data/README.md
CHANGED
@@ -19,23 +19,36 @@ Run the bundle command to install it.
|
|
19
19
|
|
20
20
|
## How to use
|
21
21
|
|
22
|
-
|
22
|
+
There is one entry point:
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
```ruby
|
25
|
+
client = TvrageApi::Client.new
|
26
|
+
```
|
27
|
+
|
28
|
+
Search show by name:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
client = TvrageApi::Client.new
|
32
|
+
client.search.by_name('buffy') # return pure Hash
|
33
|
+
client.search.full_by_name('buffy') # return pure Hash
|
29
34
|
```
|
30
35
|
|
31
|
-
|
32
|
-
* TvrageApi::Request::Search.find_full(show_name) - return collection of show with more details
|
33
|
-
* TvrageApi::Request::Show.find(show_id) - return show
|
34
|
-
* TvrageApi::Request::Show.find_full(show_id) - return show with more details
|
35
|
-
* TvrageApi::Request::Show.episodes(show_id) - return simple show information with all episodes
|
36
|
-
* TvrageApi::Request::Show.episode(show_id, season, episode) - return simple show information with specific episode
|
37
|
-
* TvrageApi::Request::Update.all - return all shows (simple information: id, name)
|
36
|
+
Search show by id:
|
38
37
|
|
38
|
+
```ruby
|
39
|
+
client = TvrageApi::Client.new
|
40
|
+
client.show.find('123') # return pure Hash
|
41
|
+
client.show.find_full('123') # return pure Hash
|
42
|
+
client.show.episodes('123') # return pure Hash, with all episodes
|
43
|
+
client.show.episode('123', season, episode) # return pure Hash, with specific episode
|
44
|
+
```
|
45
|
+
|
46
|
+
Search all show ids:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
client = TvrageApi::Client.new
|
50
|
+
client.update.all # return pure Hash
|
51
|
+
```
|
39
52
|
|
40
53
|
## Contributing
|
41
54
|
|
data/lib/tvrage_api/base.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
|
-
require '
|
1
|
+
require 'httparty'
|
2
2
|
|
3
|
-
class TvrageApi::Base
|
4
|
-
include
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class TvrageApi::Base
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
attr_reader :uri, :options
|
7
|
+
|
8
|
+
def get(uri, options = {})
|
9
|
+
@uri = uri
|
10
|
+
@options = options
|
11
|
+
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def response
|
16
|
+
response = self.class.get(uri, request_options(options))
|
17
|
+
response.code == 200 ? response.parsed_response : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def request_options(options = {})
|
21
|
+
{
|
22
|
+
query: options,
|
23
|
+
base_uri: 'http://services.tvrage.com/feeds/'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
data/lib/tvrage_api/show.rb
CHANGED
@@ -1,22 +1,17 @@
|
|
1
1
|
class TvrageApi::Show < TvrageApi::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
replace_key :totalseasons, :total_seasons
|
2
|
+
def find(id)
|
3
|
+
get('showinfo.php', sid: id).response
|
4
|
+
end
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
coerce_key :startdate, Date
|
19
|
-
coerce_key :started, Integer
|
20
|
-
coerce_key :status, Integer
|
21
|
-
coerce_key :total_seasons, Integer
|
6
|
+
def find_full(id)
|
7
|
+
get('full_show_info.php', sid: id).response
|
8
|
+
end
|
9
|
+
|
10
|
+
def episodes(show_id)
|
11
|
+
get('episode_list.php', sid: show_id).response
|
12
|
+
end
|
13
|
+
|
14
|
+
def episode(series_id, season, episode)
|
15
|
+
get('episodeinfo.php', sid: series_id, ep: "#{season}x#{episode}").response
|
16
|
+
end
|
22
17
|
end
|
data/lib/tvrage_api/version.rb
CHANGED
data/lib/tvrage_api.rb
CHANGED
@@ -3,12 +3,8 @@ module TvrageApi
|
|
3
3
|
end
|
4
4
|
|
5
5
|
require 'tvrage_api/version'
|
6
|
-
require 'tvrage_api/
|
6
|
+
require 'tvrage_api/client'
|
7
7
|
require 'tvrage_api/base'
|
8
|
-
require 'tvrage_api/
|
9
|
-
require 'tvrage_api/episode'
|
8
|
+
require 'tvrage_api/search'
|
10
9
|
require 'tvrage_api/show'
|
11
|
-
require 'tvrage_api/
|
12
|
-
require 'tvrage_api/request/search'
|
13
|
-
require 'tvrage_api/request/show'
|
14
|
-
require 'tvrage_api/request/update'
|
10
|
+
require 'tvrage_api/update'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TvrageApi::Client do
|
4
|
+
let(:client) { TvrageApi::Client.new }
|
5
|
+
|
6
|
+
describe 'real request' do
|
7
|
+
describe '.search' do
|
8
|
+
describe '.by_name' do
|
9
|
+
it 'should return Hash class' do
|
10
|
+
client.search.by_name('buffy').class.should == Hash
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.full_by_name' do
|
15
|
+
it 'should return show class' do
|
16
|
+
client.search.full_by_name('buffy').class.should == Hash
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.show' do
|
22
|
+
describe '.find' do
|
23
|
+
it 'should return Hash class' do
|
24
|
+
client.show.find('2930').class.should == Hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.find_full' do
|
29
|
+
it 'should return Hash class' do
|
30
|
+
client.show.find_full('2930').class.should == Hash
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.episodes' do
|
35
|
+
it 'should return show class' do
|
36
|
+
client.show.episodes('2930').class.should == Hash
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.episode' do
|
41
|
+
it 'should return show class' do
|
42
|
+
client.show.episode('2930', '2', '4').class.should == Hash
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.update' do
|
48
|
+
describe '.all' do
|
49
|
+
it 'should return Hash class' do
|
50
|
+
client.update.all.class.should == Hash
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TvrageApi::
|
4
|
-
let(:
|
3
|
+
describe TvrageApi::Search do
|
4
|
+
let(:model) { TvrageApi::Search.new }
|
5
5
|
|
6
6
|
describe 'real request' do
|
7
|
-
describe '
|
8
|
-
it 'should return
|
9
|
-
|
7
|
+
describe '.by_name' do
|
8
|
+
it 'should return Hash class' do
|
9
|
+
model.by_name('buffy').class.should == Hash
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe '
|
13
|
+
describe '.full_by_name' do
|
14
14
|
it 'should return show class' do
|
15
|
-
|
15
|
+
model.full_by_name('buffy').class.should == Hash
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TvrageApi::
|
4
|
-
let(:
|
3
|
+
describe TvrageApi::Show do
|
4
|
+
let(:model) { TvrageApi::Show.new }
|
5
5
|
|
6
6
|
describe 'real request' do
|
7
|
-
describe '
|
8
|
-
it 'should return
|
9
|
-
|
7
|
+
describe '.find' do
|
8
|
+
it 'should return Hash class' do
|
9
|
+
model.find('2930').class.should == Hash
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe '
|
14
|
-
it 'should return
|
15
|
-
|
13
|
+
describe '.find_full' do
|
14
|
+
it 'should return Hash class' do
|
15
|
+
model.find_full('2930').class.should == Hash
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe '
|
19
|
+
describe '.episodes' do
|
20
20
|
it 'should return show class' do
|
21
|
-
|
21
|
+
model.episodes('2930').class.should == Hash
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe '
|
25
|
+
describe '.episode' do
|
26
26
|
it 'should return show class' do
|
27
|
-
|
27
|
+
model.episode('2930', '2', '4').class.should == Hash
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TvrageApi::
|
4
|
-
let(:
|
3
|
+
describe TvrageApi::Update do
|
4
|
+
let(:model) { TvrageApi::Update.new }
|
5
5
|
|
6
6
|
describe 'real request' do
|
7
|
-
describe '
|
8
|
-
it 'should return
|
9
|
-
|
10
|
-
# klass.all.result.class.should == Array
|
7
|
+
describe '.all' do
|
8
|
+
it 'should return Hash class' do
|
9
|
+
model.all.class.should == Hash
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class ExampleRequestClass < TvrageApi::Base
|
4
|
+
end
|
5
|
+
|
6
|
+
describe TvrageApi::Base do
|
7
|
+
let(:klass) { ExampleRequestClass }
|
8
|
+
let(:model) { klass.new }
|
9
|
+
|
10
|
+
describe '.get' do
|
11
|
+
it 'should set uri' do
|
12
|
+
model.get('http://example.com')
|
13
|
+
|
14
|
+
model.uri.should == 'http://example.com'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should set options' do
|
18
|
+
model.get('http://example.com', sample_options: true)
|
19
|
+
|
20
|
+
model.options.should == { sample_options: true }
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return self' do
|
24
|
+
model.get('http://example.com').should == model
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.response' do
|
29
|
+
it 'should call get klass method' do
|
30
|
+
klass.should_receive(:get).and_return(double(code: 200, parsed_response: {}))
|
31
|
+
model.stub(:request_options).and_return({})
|
32
|
+
|
33
|
+
model.response
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should return Hash' do
|
37
|
+
klass.should_receive(:get).and_return(double(code: 200, parsed_response: {}))
|
38
|
+
model.stub(:request_options).and_return({})
|
39
|
+
|
40
|
+
model.response.class.should == Hash
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should return nil' do
|
44
|
+
klass.should_receive(:get).and_return(double(code: 400))
|
45
|
+
model.stub(:request_options).and_return({})
|
46
|
+
|
47
|
+
model.response.should be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '.request_options' do
|
52
|
+
it 'should return correct keys' do
|
53
|
+
model.request_options.keys.sort.should == [:query, :base_uri].sort
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TvrageApi::Client do
|
4
|
+
let(:klass) { TvrageApi::Client }
|
5
|
+
|
6
|
+
describe '.search' do
|
7
|
+
it 'should return search class' do
|
8
|
+
klass.new.search.class.should == TvrageApi::Search
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.show' do
|
13
|
+
it 'should return show class' do
|
14
|
+
klass.new.show.class.should == TvrageApi::Show
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.update' do
|
19
|
+
it 'should return update class' do
|
20
|
+
klass.new.update.class.should == TvrageApi::Update
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TvrageApi::Search do
|
4
|
+
let(:klass) { TvrageApi::Search }
|
5
|
+
let(:model) { klass.new }
|
6
|
+
|
7
|
+
describe '#find' do
|
8
|
+
it 'should call new with specific params' do
|
9
|
+
model.should_receive(:get).with('search.php', show: 'buffy').and_return(double(response: true))
|
10
|
+
|
11
|
+
model.by_name('buffy')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#find_full' do
|
16
|
+
it 'should call new with specific params' do
|
17
|
+
model.should_receive(:get).with('full_search.php', show: 'buffy').and_return(double(response: true))
|
18
|
+
|
19
|
+
model.full_by_name('buffy')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,78 +2,37 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe TvrageApi::Show do
|
4
4
|
let(:klass) { TvrageApi::Show }
|
5
|
+
let(:model) { klass.new }
|
5
6
|
|
6
|
-
|
7
|
-
it
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
shared_examples 'integer mapping' do |field|
|
13
|
-
it 'should save as Integer' do
|
14
|
-
klass.new(field => '123').send(field).should == 123
|
15
|
-
end
|
16
|
-
end
|
7
|
+
describe '#find' do
|
8
|
+
it 'should call new with specific params' do
|
9
|
+
model.should_receive(:get).with('showinfo.php', sid: 123).and_return(double(response: true))
|
17
10
|
|
18
|
-
|
19
|
-
it 'should save as Date' do
|
20
|
-
klass.new(field => '2000-01-01').send(field).should == Date.new(2000, 1, 1)
|
11
|
+
model.find(123)
|
21
12
|
end
|
22
13
|
end
|
23
14
|
|
24
|
-
describe '
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
15
|
+
describe '#find_full' do
|
16
|
+
it 'should call new with specific params' do
|
17
|
+
model.should_receive(:get).with('full_show_info.php', sid: 123).and_return(double(response: true))
|
29
18
|
|
30
|
-
|
31
|
-
describe 'Episodelist attribute' do
|
32
|
-
it 'should mapping' do
|
33
|
-
TvrageApi::Show.new(Episodelist: double(season: [double(episode: [double(to_hash: {})])])).send(:episode_list).should_not == nil
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'showid attribute' do
|
38
|
-
include_examples 'mapping', :showid, :show_id
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'totalseasons attribute' do
|
42
|
-
include_examples 'mapping', :totalseasons, :total_seasons
|
19
|
+
model.find_full(123)
|
43
20
|
end
|
44
21
|
end
|
45
22
|
|
46
|
-
describe '
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'runtime attribute' do
|
52
|
-
include_examples 'integer mapping', :runtime
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'seasons attribute' do
|
56
|
-
include_examples 'integer mapping', :seasons
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'show_id attribute' do
|
60
|
-
include_examples 'integer mapping', :show_id
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'startdate attribute' do
|
64
|
-
include_examples 'date mapping', :startdate
|
65
|
-
end
|
23
|
+
describe '#episodes' do
|
24
|
+
it 'should call new with specific params' do
|
25
|
+
model.should_receive(:get).with('episode_list.php', sid: 123).and_return(double(response: true))
|
66
26
|
|
67
|
-
|
68
|
-
include_examples 'integer mapping', :started
|
27
|
+
model.episodes(123)
|
69
28
|
end
|
29
|
+
end
|
70
30
|
|
71
|
-
|
72
|
-
|
73
|
-
|
31
|
+
describe '#episode' do
|
32
|
+
it 'should call new with specific params' do
|
33
|
+
model.should_receive(:get).with('episodeinfo.php', sid: 123, ep: '1x2').and_return(double(response: true))
|
74
34
|
|
75
|
-
|
76
|
-
include_examples 'integer mapping', :total_seasons
|
35
|
+
model.episode(123, 1, 2)
|
77
36
|
end
|
78
37
|
end
|
79
38
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TvrageApi::Update do
|
4
|
+
let(:klass) { TvrageApi::Update }
|
5
|
+
let(:model) { klass.new }
|
6
|
+
|
7
|
+
describe '#all' do
|
8
|
+
it 'should call new with specific params' do
|
9
|
+
model.should_receive(:get).with('show_list.php').and_return(double(response: true))
|
10
|
+
|
11
|
+
model.all
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/tvrage_api.gemspec
CHANGED
@@ -18,8 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.
|
22
|
-
spec.add_runtime_dependency 'hashie', '>= 2.0.5'
|
21
|
+
spec.add_runtime_dependency 'httparty', '>= 0.12.0'
|
23
22
|
|
24
23
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
24
|
spec.add_development_dependency 'rake'
|