tvrage_api 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62f7f9d558b9cd8fe834e83c4349bcdf5665d4bf
4
- data.tar.gz: 5c079055971ba0d4b341e3099c30c3d09e5d080b
3
+ metadata.gz: 9cc485fd0b5d0192d75bfd365bc26843cd60ef6b
4
+ data.tar.gz: 1d30a3840cf19545ab13c8aee5548e84db2115d2
5
5
  SHA512:
6
- metadata.gz: 54736a76669139e2e0cb92c85d472d5a68978f2a86ab03359a3d6bd957e02c934a91d5d8e7c7c461e59d29c27c411c4575f093ca04af06919a9eb97f9ebeaf6b
7
- data.tar.gz: 173775ab0e8a14ae56c73b18744dca37950ff84c632ff249c16b7842134daa90d21a7064a67512fc2ee800b463e1c75e76fee718be02eeff2fff66b36a0d162e
6
+ metadata.gz: cfbf9c7afdea409cce8bad1f8fb0fe3a7af818ab4ade2daf379baa20dc339d7d672bf2c1f5cf555fb121c1226eddb077b251cdb33713f9d4edd4f5f7f9d52c17
7
+ data.tar.gz: 06e72ebd87168457edbd8629273517495f6902fa23d267cfae7d544d0253792f355949c84df20fbd79dda2b3a67cbfd95578e55cacf8e7a0377173ce1ee8ea60
data/README.md CHANGED
@@ -29,25 +29,25 @@ Search show by name:
29
29
 
30
30
  ```ruby
31
31
  client = TvrageApi::Client.new
32
- client.search.by_name('buffy') # return pure Hash
33
- client.search.full_by_name('buffy') # return pure Hash
32
+ client.search.by_name('buffy')
33
+ client.search.full_by_name('buffy')
34
34
  ```
35
35
 
36
36
  Search show by id:
37
37
 
38
38
  ```ruby
39
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
40
+ client.show.find('123')
41
+ client.show.find_full('123')
42
+ client.show.episodes('123') # show with all episodes
43
+ client.show.episode('123', season, episode) # show with specific episode
44
44
  ```
45
45
 
46
46
  Search all show ids:
47
47
 
48
48
  ```ruby
49
49
  client = TvrageApi::Client.new
50
- client.update.all # return pure Hash
50
+ client.update.all
51
51
  ```
52
52
 
53
53
  ## Contributing
@@ -2,25 +2,5 @@ require 'httparty'
2
2
 
3
3
  class TvrageApi::Base
4
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
5
+ base_uri 'http://services.tvrage.com/feeds/'
6
+ end
@@ -1,9 +1,9 @@
1
1
  class TvrageApi::Search < TvrageApi::Base
2
2
  def by_name(name)
3
- get('search.php', show: name).response
3
+ self.class.get('search.php', show: name)
4
4
  end
5
5
 
6
6
  def full_by_name(name)
7
- get('full_search.php', show: name).response
7
+ self.class.get('full_search.php', show: name)
8
8
  end
9
9
  end
@@ -1,17 +1,17 @@
1
1
  class TvrageApi::Show < TvrageApi::Base
2
2
  def find(id)
3
- get('showinfo.php', sid: id).response
3
+ self.class.get('showinfo.php', sid: id)
4
4
  end
5
5
 
6
6
  def find_full(id)
7
- get('full_show_info.php', sid: id).response
7
+ self.class.get('full_show_info.php', sid: id)
8
8
  end
9
9
 
10
10
  def episodes(show_id)
11
- get('episode_list.php', sid: show_id).response
11
+ self.class.get('episode_list.php', sid: show_id)
12
12
  end
13
13
 
14
14
  def episode(series_id, season, episode)
15
- get('episodeinfo.php', sid: series_id, ep: "#{season}x#{episode}").response
15
+ self.class.get('episodeinfo.php', sid: series_id, ep: "#{season}x#{episode}")
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  class TvrageApi::Update < TvrageApi::Base
2
2
  def all
3
- get('show_list.php').response
3
+ self.class.get('show_list.php')
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module TvrageApi
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -6,48 +6,48 @@ describe TvrageApi::Client do
6
6
  describe 'real request' do
7
7
  describe '.search' do
8
8
  describe '.by_name' do
9
- it 'should return Hash class' do
10
- client.search.by_name('buffy').class.should == Hash
9
+ it 'should return response class' do
10
+ client.search.by_name('buffy').class.should == HTTParty::Response
11
11
  end
12
12
  end
13
13
 
14
14
  describe '.full_by_name' do
15
- it 'should return show class' do
16
- client.search.full_by_name('buffy').class.should == Hash
15
+ it 'should return response class' do
16
+ client.search.full_by_name('buffy').class.should == HTTParty::Response
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
21
  describe '.show' do
22
22
  describe '.find' do
23
- it 'should return Hash class' do
24
- client.show.find('2930').class.should == Hash
23
+ it 'should return response class' do
24
+ client.show.find('2930').class.should == HTTParty::Response
25
25
  end
26
26
  end
27
27
 
28
28
  describe '.find_full' do
29
- it 'should return Hash class' do
30
- client.show.find_full('2930').class.should == Hash
29
+ it 'should return response class' do
30
+ client.show.find_full('2930').class.should == HTTParty::Response
31
31
  end
32
32
  end
33
33
 
34
34
  describe '.episodes' do
35
- it 'should return show class' do
36
- client.show.episodes('2930').class.should == Hash
35
+ it 'should return response class' do
36
+ client.show.episodes('2930').class.should == HTTParty::Response
37
37
  end
38
38
  end
39
39
 
40
40
  describe '.episode' do
41
- it 'should return show class' do
42
- client.show.episode('2930', '2', '4').class.should == Hash
41
+ it 'should return response class' do
42
+ client.show.episode('2930', '2', '4').class.should == HTTParty::Response
43
43
  end
44
44
  end
45
45
  end
46
46
 
47
47
  describe '.update' do
48
48
  describe '.all' do
49
- it 'should return Hash class' do
50
- client.update.all.class.should == Hash
49
+ it 'should return response class' do
50
+ client.update.all.class.should == HTTParty::Response
51
51
  end
52
52
  end
53
53
  end
@@ -5,14 +5,14 @@ describe TvrageApi::Search do
5
5
 
6
6
  describe 'real request' do
7
7
  describe '.by_name' do
8
- it 'should return Hash class' do
9
- model.by_name('buffy').class.should == Hash
8
+ it 'should return response class' do
9
+ model.by_name('buffy').class.should == HTTParty::Response
10
10
  end
11
11
  end
12
12
 
13
13
  describe '.full_by_name' do
14
- it 'should return show class' do
15
- model.full_by_name('buffy').class.should == Hash
14
+ it 'should return response class' do
15
+ model.full_by_name('buffy').class.should == HTTParty::Response
16
16
  end
17
17
  end
18
18
  end
@@ -5,26 +5,26 @@ describe TvrageApi::Show do
5
5
 
6
6
  describe 'real request' do
7
7
  describe '.find' do
8
- it 'should return Hash class' do
9
- model.find('2930').class.should == Hash
8
+ it 'should return response class' do
9
+ model.find('2930').class.should == HTTParty::Response
10
10
  end
11
11
  end
12
12
 
13
13
  describe '.find_full' do
14
- it 'should return Hash class' do
15
- model.find_full('2930').class.should == Hash
14
+ it 'should return response class' do
15
+ model.find_full('2930').class.should == HTTParty::Response
16
16
  end
17
17
  end
18
18
 
19
19
  describe '.episodes' do
20
- it 'should return show class' do
21
- model.episodes('2930').class.should == Hash
20
+ it 'should return response class' do
21
+ model.episodes('2930').class.should == HTTParty::Response
22
22
  end
23
23
  end
24
24
 
25
25
  describe '.episode' do
26
- it 'should return show class' do
27
- model.episode('2930', '2', '4').class.should == Hash
26
+ it 'should return response class' do
27
+ model.episode('2930', '2', '4').class.should == HTTParty::Response
28
28
  end
29
29
  end
30
30
  end
@@ -5,8 +5,8 @@ describe TvrageApi::Update do
5
5
 
6
6
  describe 'real request' do
7
7
  describe '.all' do
8
- it 'should return Hash class' do
9
- model.all.class.should == Hash
8
+ it 'should return response class' do
9
+ model.all.class.should == HTTParty::Response
10
10
  end
11
11
  end
12
12
  end
@@ -1,23 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe TvrageApi::Client do
4
- let(:klass) { TvrageApi::Client }
4
+ let(:model) { TvrageApi::Client.new }
5
5
 
6
6
  describe '.search' do
7
7
  it 'should return search class' do
8
- klass.new.search.class.should == TvrageApi::Search
8
+ model.search.class.should == TvrageApi::Search
9
9
  end
10
10
  end
11
11
 
12
12
  describe '.show' do
13
13
  it 'should return show class' do
14
- klass.new.show.class.should == TvrageApi::Show
14
+ model.show.class.should == TvrageApi::Show
15
15
  end
16
16
  end
17
17
 
18
18
  describe '.update' do
19
19
  it 'should return update class' do
20
- klass.new.update.class.should == TvrageApi::Update
20
+ model.update.class.should == TvrageApi::Update
21
21
  end
22
22
  end
23
23
  end
@@ -6,7 +6,7 @@ describe TvrageApi::Search do
6
6
 
7
7
  describe '#find' do
8
8
  it 'should call new with specific params' do
9
- model.should_receive(:get).with('search.php', show: 'buffy').and_return(double(response: true))
9
+ klass.should_receive(:get).with('search.php', show: 'buffy')
10
10
 
11
11
  model.by_name('buffy')
12
12
  end
@@ -14,7 +14,7 @@ describe TvrageApi::Search do
14
14
 
15
15
  describe '#find_full' do
16
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))
17
+ klass.should_receive(:get).with('full_search.php', show: 'buffy')
18
18
 
19
19
  model.full_by_name('buffy')
20
20
  end
@@ -6,7 +6,7 @@ describe TvrageApi::Show do
6
6
 
7
7
  describe '#find' do
8
8
  it 'should call new with specific params' do
9
- model.should_receive(:get).with('showinfo.php', sid: 123).and_return(double(response: true))
9
+ klass.should_receive(:get).with('showinfo.php', sid: 123)
10
10
 
11
11
  model.find(123)
12
12
  end
@@ -14,7 +14,7 @@ describe TvrageApi::Show do
14
14
 
15
15
  describe '#find_full' do
16
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))
17
+ klass.should_receive(:get).with('full_show_info.php', sid: 123)
18
18
 
19
19
  model.find_full(123)
20
20
  end
@@ -22,7 +22,7 @@ describe TvrageApi::Show do
22
22
 
23
23
  describe '#episodes' do
24
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))
25
+ klass.should_receive(:get).with('episode_list.php', sid: 123)
26
26
 
27
27
  model.episodes(123)
28
28
  end
@@ -30,7 +30,7 @@ describe TvrageApi::Show do
30
30
 
31
31
  describe '#episode' do
32
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))
33
+ klass.should_receive(:get).with('episodeinfo.php', sid: 123, ep: '1x2')
34
34
 
35
35
  model.episode(123, 1, 2)
36
36
  end
@@ -6,7 +6,7 @@ describe TvrageApi::Update do
6
6
 
7
7
  describe '#all' do
8
8
  it 'should call new with specific params' do
9
- model.should_receive(:get).with('show_list.php').and_return(double(response: true))
9
+ klass.should_receive(:get).with('show_list.php')
10
10
 
11
11
  model.all
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tvrage_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Wawer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-10 00:00:00.000000000 Z
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -105,7 +105,6 @@ files:
105
105
  - spec/integrations/show_spec.rb
106
106
  - spec/integrations/update_spec.rb
107
107
  - spec/spec_helper.rb
108
- - spec/tvrage_api/base_spec.rb
109
108
  - spec/tvrage_api/client_spec.rb
110
109
  - spec/tvrage_api/search_spec.rb
111
110
  - spec/tvrage_api/show_spec.rb
@@ -141,7 +140,6 @@ test_files:
141
140
  - spec/integrations/show_spec.rb
142
141
  - spec/integrations/update_spec.rb
143
142
  - spec/spec_helper.rb
144
- - spec/tvrage_api/base_spec.rb
145
143
  - spec/tvrage_api/client_spec.rb
146
144
  - spec/tvrage_api/search_spec.rb
147
145
  - spec/tvrage_api/show_spec.rb
@@ -1,56 +0,0 @@
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