trakt_api 0.1.0 → 0.1.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: 57fc329e9fdc3c30dce19c946a54748086a0f144
4
- data.tar.gz: 36cb6efb77dec44d517bff3bd2ea7036d19b64af
3
+ metadata.gz: 199f695eb7ddbd0b85d7ff6f40e305ced3dd7952
4
+ data.tar.gz: 8e8e4e61a8b20e8c857f1b6de15faba30b8c03de
5
5
  SHA512:
6
- metadata.gz: a3f9bd0db3afc61e0a8e99b8ad4afd9cc72e3231cf290d957d460694098b11343039e12aa84f4ecaba85954f75661f0264718c302d7bea36be550a73ff214d40
7
- data.tar.gz: ace82e63abf2a571a64d208a52455d10bd0ca7c4aed25277dd49f8378c41a828f9bfc6f4325c4235f06d9dd8a21dfeee90fad708dc681aeb23b1d4df5356bfcd
6
+ metadata.gz: 05fa65d8228e5e321055f8950979da24b0b8a30b58d7a5413c1060f735e3306ffc02f34ac2504dbac9824d734a2982179430fe7881068895155c0ba48709d0fb
7
+ data.tar.gz: 87e576cbf7902b61894a22c14b0202e45963aaab61273fc3b520fc9f5dc8cd3094d65c4e2dac33500be29b0c342650102943250cde28ad7b2d5f513be973569f
data/README.md CHANGED
@@ -35,7 +35,8 @@ Language attribute is optional with default value 'en'
35
35
 
36
36
  ```ruby
37
37
  client = TraktApi::Client.new(api_key: '...')
38
- client.search({..})
38
+ client.search # => #<TraktApi::Search>
39
+ client.show # => #<TraktApi::Show>
39
40
  ```
40
41
 
41
42
  * II case (direct access to api class, many entry points)
@@ -46,15 +47,25 @@ Language attribute is required
46
47
  ThetvdbApi::Search.new(api_key: '...').call({...})
47
48
  ```
48
49
 
49
- ## Usage
50
+ ## Methods
50
51
 
51
52
  Full documentation is available here: [http://docs.trakt.apiary.io](http://docs.trakt.apiary.io)
52
53
 
53
- Search API
54
+ ### Search methods
54
55
 
55
- ```ruby
56
- client.search({...})
57
- ```
56
+ * call
57
+ * call_url
58
+
59
+ ### Show methods
60
+
61
+ * find
62
+ * find_url
63
+ * seasons
64
+ * seasons.all
65
+ * seasons.all_url
66
+ * seasons.episodes
67
+ * seasons.episodes.find
68
+ * seasons.episodes.find_url
58
69
 
59
70
  ## Contributing
60
71
 
data/lib/trakt_api.rb CHANGED
@@ -1,8 +1,9 @@
1
- require 'ov'
2
-
3
1
  module TraktApi; end
4
2
 
5
3
  require 'trakt_api/version'
6
4
  require 'trakt_api/base'
7
5
  require 'trakt_api/client'
8
6
  require 'trakt_api/search'
7
+ require 'trakt_api/shows'
8
+ require 'trakt_api/shows/seasons'
9
+ require 'trakt_api/shows/seasons/episodes'
@@ -1,5 +1,4 @@
1
1
  require 'service_api'
2
- require 'string_to_sha1'
3
2
 
4
3
  class TraktApi::Base
5
4
  include ServiceApi::BaseFaraday
@@ -48,9 +47,9 @@ class TraktApi::Base
48
47
 
49
48
  def base_url
50
49
  if @config[:sandbox]
51
- 'https://api.staging.trakt.tv'
50
+ 'https://api.staging.trakt.tv/'
52
51
  else
53
- 'https://api.trakt.tv'
52
+ 'https://api.trakt.tv/'
54
53
  end
55
54
  end
56
55
  end
@@ -7,7 +7,11 @@ class TraktApi::Client
7
7
  @config[:adapter] ||= :net_http
8
8
  end
9
9
 
10
- def search(options)
11
- @search ||= TraktApi::Search.new(config).call(options)
10
+ def search
11
+ @search ||= TraktApi::Search.new(config)
12
+ end
13
+
14
+ def shows
15
+ @search ||= TraktApi::Shows.new(config)
12
16
  end
13
17
  end
@@ -3,6 +3,10 @@ class TraktApi::Search < TraktApi::Base
3
3
  search_path_with_params(options).get
4
4
  end
5
5
 
6
+ def call_url(options)
7
+ search_path_with_params(options).url
8
+ end
9
+
6
10
  private
7
11
 
8
12
  def search_path_with_params(options)
@@ -0,0 +1,23 @@
1
+ class TraktApi::Shows < TraktApi::Base
2
+ def find(options)
3
+ find_path_with_params(options).get
4
+ end
5
+
6
+ def find_url(options)
7
+ find_path_with_params(options).url
8
+ end
9
+
10
+ def seasons
11
+ @seasons ||= TraktApi::Shows::Seasons.new(@config)
12
+ end
13
+
14
+ private
15
+
16
+ def find_path_with_params(options)
17
+ path(find_path).params(options)
18
+ end
19
+
20
+ def find_path
21
+ 'shows/:id'
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ class TraktApi::Shows::Seasons < TraktApi::Base
2
+ def all(options)
3
+ all_path_with_params(options).get
4
+ end
5
+
6
+ def all_url(options)
7
+ all_path_with_params(options).url
8
+ end
9
+
10
+ def episodes
11
+ @episodes ||= TraktApi::Shows::Seasons::Episodes.new(@config)
12
+ end
13
+
14
+ private
15
+
16
+ def all_path_with_params(options)
17
+ path(all_path).params(options)
18
+ end
19
+
20
+ def all_path
21
+ 'shows/:id/seasons'
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ class TraktApi::Shows::Seasons::Episodes < TraktApi::Base
2
+ def find(options)
3
+ find_path_with_params(options).get
4
+ end
5
+
6
+ def find_url(options)
7
+ find_path_with_params(options).url
8
+ end
9
+
10
+ private
11
+
12
+ def find_path_with_params(options)
13
+ path(find_path).params(options)
14
+ end
15
+
16
+ def find_path
17
+ 'shows/:id/seasons/:season/episodes/:episode'
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module TraktApi
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -0,0 +1,12 @@
1
+ {
2
+ "season": 1,
3
+ "number": 1,
4
+ "title": "Winter Is Coming",
5
+ "ids": {
6
+ "trakt": 36440,
7
+ "tvdb": 3254641,
8
+ "imdb": "tt1480055",
9
+ "tmdb": 63056,
10
+ "tvrage": null
11
+ }
12
+ }
@@ -0,0 +1,47 @@
1
+ [
2
+ {
3
+ "number": 0,
4
+ "ids": {
5
+ "trakt": 1,
6
+ "tvdb": 137481,
7
+ "tmdb": 3627,
8
+ "tvrage": null
9
+ }
10
+ },
11
+ {
12
+ "number": 1,
13
+ "ids": {
14
+ "trakt": 2,
15
+ "tvdb": 364731,
16
+ "tmdb": 3624,
17
+ "tvrage": null
18
+ }
19
+ },
20
+ {
21
+ "number": 2,
22
+ "ids": {
23
+ "trakt": 3,
24
+ "tvdb": 473271,
25
+ "tmdb": 3625,
26
+ "tvrage": null
27
+ }
28
+ },
29
+ {
30
+ "number": 3,
31
+ "ids": {
32
+ "trakt": 4,
33
+ "tvdb": 488434,
34
+ "tmdb": 3626,
35
+ "tvrage": null
36
+ }
37
+ },
38
+ {
39
+ "number": 4,
40
+ "ids": {
41
+ "trakt": 5,
42
+ "tvdb": 522882,
43
+ "tmdb": 3628,
44
+ "tvrage": null
45
+ }
46
+ }
47
+ ]
@@ -0,0 +1,12 @@
1
+ {
2
+ "title": "Game of Thrones",
3
+ "year": 2011,
4
+ "ids": {
5
+ "trakt": 353,
6
+ "slug": "game-of-thrones",
7
+ "tvdb": 121361,
8
+ "imdb": "tt0944947",
9
+ "tmdb": 1399,
10
+ "tvrage": 24493
11
+ }
12
+ }
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe TraktApi::Search do
4
4
  let(:client) { TraktApi::Client.new(api_key: '123456789', adapter: :test, adapter_options: faraday_stubs) }
5
+ let(:model) { client.search }
5
6
 
6
7
  let(:faraday_stubs) do
7
8
  Faraday::Adapter::Test::Stubs.new do |stub|
@@ -11,13 +12,19 @@ describe TraktApi::Search do
11
12
  end
12
13
  end
13
14
 
14
- describe '.search' do
15
+ describe '.call' do
15
16
  it 'should return Faraday::Response class' do
16
- expect(client.search(query: 'batman', type: 'show')).to be_a(Faraday::Response)
17
+ expect(model.call(query: 'batman', type: 'show')).to be_a(Faraday::Response)
17
18
  end
18
19
 
19
- it 'should return Hash class for body reponse' do
20
- expect(client.search(query: 'batman', type: 'show').body).to be_a(Array)
20
+ it 'should return Array class for body reponse' do
21
+ expect(model.call(query: 'batman', type: 'show').body).to be_a(Array)
21
22
  end
22
23
  end
23
- end
24
+
25
+ describe '.call_url' do
26
+ it 'should return String class' do
27
+ expect(model.call_url(query: 'batman', type: 'show')).to eq('https://api.trakt.tv/search?query=batman&type=show')
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe TraktApi::Shows::Seasons::Episodes do
4
+ let(:client) { TraktApi::Client.new(api_key: '123456789', adapter: :test, adapter_options: faraday_stubs) }
5
+ let(:model) { client.shows.seasons.episodes }
6
+
7
+ let(:faraday_stubs) do
8
+ Faraday::Adapter::Test::Stubs.new do |stub|
9
+ stub.get('/shows/123/seasons/1/episodes/1') do
10
+ [200, { content_type: 'json' }, File.read('spec/fixtures/episode.json')]
11
+ end
12
+ end
13
+ end
14
+
15
+ describe '.find' do
16
+ it 'should return Faraday::Response class' do
17
+ expect(model.find(id: '123', season: 1, episode: 1)).to be_a(Faraday::Response)
18
+ end
19
+
20
+ it 'should return Hash class for body reponse' do
21
+ expect(model.find(id: '123', season: 1, episode: 1).body).to be_a(Hash)
22
+ end
23
+ end
24
+
25
+ describe '.find_url' do
26
+ it 'should return String class' do
27
+ expect(model.find_url(id: '123', season: 1, episode: 1)).to eq('https://api.trakt.tv/shows/123/seasons/1/episodes/1')
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe TraktApi::Shows::Seasons do
4
+ let(:client) { TraktApi::Client.new(api_key: '123456789', adapter: :test, adapter_options: faraday_stubs) }
5
+ let(:model) { client.shows.seasons }
6
+
7
+ let(:faraday_stubs) do
8
+ Faraday::Adapter::Test::Stubs.new do |stub|
9
+ stub.get('/shows/123/seasons') do
10
+ [200, { content_type: 'json' }, File.read('spec/fixtures/seasons.json')]
11
+ end
12
+ end
13
+ end
14
+
15
+ describe '.all' do
16
+ it 'should return Faraday::Response class' do
17
+ expect(model.all(id: '123')).to be_a(Faraday::Response)
18
+ end
19
+
20
+ it 'should return Array class for body reponse' do
21
+ expect(model.all(id: '123').body).to be_a(Array)
22
+ end
23
+ end
24
+
25
+ describe '.all_url' do
26
+ it 'should return String class' do
27
+ expect(model.all_url(id: '123')).to eq('https://api.trakt.tv/shows/123/seasons')
28
+ end
29
+ end
30
+
31
+ describe '.seasons' do
32
+ it 'should return TraktApi::Shows::Seasons::Episodes class' do
33
+ expect(model.episodes).to be_a(TraktApi::Shows::Seasons::Episodes)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe TraktApi::Shows do
4
+ let(:client) { TraktApi::Client.new(api_key: '123456789', adapter: :test, adapter_options: faraday_stubs) }
5
+ let(:model) { client.shows }
6
+
7
+ let(:faraday_stubs) do
8
+ Faraday::Adapter::Test::Stubs.new do |stub|
9
+ stub.get('/shows/123') do
10
+ [200, { content_type: 'json' }, File.read('spec/fixtures/show.json')]
11
+ end
12
+ end
13
+ end
14
+
15
+ describe '.find' do
16
+ it 'should return Faraday::Response class' do
17
+ expect(model.find(id: '123')).to be_a(Faraday::Response)
18
+ end
19
+
20
+ it 'should return Hash class for body reponse' do
21
+ expect(model.find(id: '123').body).to be_a(Hash)
22
+ end
23
+ end
24
+
25
+ describe '.find_url' do
26
+ it 'should return String class' do
27
+ expect(model.find_url(id: '123')).to eq('https://api.trakt.tv/shows/123')
28
+ end
29
+ end
30
+
31
+ describe '.seasons' do
32
+ it 'should return TraktApi::Shows::Seasons class' do
33
+ expect(model.seasons).to be_a(TraktApi::Shows::Seasons)
34
+ end
35
+ end
36
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe TraktApi::Search do
4
4
  let(:model) { TraktApi::Search.new(api_key: API_KEY) }
5
5
 
6
- describe '.search' do
6
+ describe '.find' do
7
7
  it 'should return response class' do
8
8
  response = model.call(query: 'batman', type: 'show')
9
9
  ap response.body
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe TraktApi::Shows::Seasons do
4
+ let(:model) { TraktApi::Shows::Seasons.new(api_key: API_KEY) }
5
+
6
+ describe '.find' do
7
+ it 'should return response class' do
8
+ response = model.all(id: 'game-of-thrones')
9
+ ap response.body
10
+
11
+ expect(response).to be_a(Faraday::Response)
12
+ expect(response.status).to eq(200)
13
+ expect(response.body).to be_a(Array)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe TraktApi::Shows do
4
+ let(:model) { TraktApi::Shows.new(api_key: API_KEY) }
5
+
6
+ describe '.find' do
7
+ it 'should return response class' do
8
+ response = model.find(id: 'game-of-thrones')
9
+ ap response.body
10
+
11
+ expect(response).to be_a(Faraday::Response)
12
+ expect(response.status).to eq(200)
13
+ expect(response.body).to be_a(Hash)
14
+ end
15
+ end
16
+ end
data/trakt_api.gemspec CHANGED
@@ -19,8 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'service_api', '~> 0.1.0'
22
- spec.add_runtime_dependency 'string_to_sha1', '>= 1.0.0'
23
- spec.add_runtime_dependency 'ov', '~> 0.1.0'
24
22
 
25
23
  spec.add_development_dependency 'bundler', '~> 1.3'
26
24
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trakt_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: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: service_api
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.0
27
- - !ruby/object:Gem::Dependency
28
- name: string_to_sha1
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: 1.0.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: 1.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: ov
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: 0.1.0
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 0.1.0
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: bundler
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -139,10 +111,21 @@ files:
139
111
  - lib/trakt_api/base.rb
140
112
  - lib/trakt_api/client.rb
141
113
  - lib/trakt_api/search.rb
114
+ - lib/trakt_api/shows.rb
115
+ - lib/trakt_api/shows/seasons.rb
116
+ - lib/trakt_api/shows/seasons/episodes.rb
142
117
  - lib/trakt_api/version.rb
118
+ - spec/fixtures/episode.json
143
119
  - spec/fixtures/search.json
120
+ - spec/fixtures/seasons.json
121
+ - spec/fixtures/show.json
144
122
  - spec/functionals/search_spec.rb
123
+ - spec/functionals/shows/seasons/episodes_spec.rb
124
+ - spec/functionals/shows/seasons_spec.rb
125
+ - spec/functionals/shows_spec.rb
145
126
  - spec/integrations/search_spec.rb
127
+ - spec/integrations/shows/seasons_spec.rb
128
+ - spec/integrations/shows_spec.rb
146
129
  - spec/spec_helper.rb
147
130
  - spec/support/.keep
148
131
  - spec/support/trakt_api.rb.example
@@ -172,9 +155,17 @@ signing_key:
172
155
  specification_version: 4
173
156
  summary: Ruby client for trakt.tv API
174
157
  test_files:
158
+ - spec/fixtures/episode.json
175
159
  - spec/fixtures/search.json
160
+ - spec/fixtures/seasons.json
161
+ - spec/fixtures/show.json
176
162
  - spec/functionals/search_spec.rb
163
+ - spec/functionals/shows/seasons/episodes_spec.rb
164
+ - spec/functionals/shows/seasons_spec.rb
165
+ - spec/functionals/shows_spec.rb
177
166
  - spec/integrations/search_spec.rb
167
+ - spec/integrations/shows/seasons_spec.rb
168
+ - spec/integrations/shows_spec.rb
178
169
  - spec/spec_helper.rb
179
170
  - spec/support/.keep
180
171
  - spec/support/trakt_api.rb.example