fanart_api 0.0.2 → 0.1.2

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: fb1a89e7dd959723e7d8858d0c62adbb23adbd8a
4
- data.tar.gz: c1024c52abcacb924cdcae44aefe3b45596f34d7
3
+ metadata.gz: ef2dba3cffc94ef7e4bed3436ff6e42f9c6bb728
4
+ data.tar.gz: 85b7c8f1c8ca861add36acc61353dd06a68aa5cd
5
5
  SHA512:
6
- metadata.gz: 3bee85b645cf8cba13c2d1e63af1c9ef8e35ac358efdeb9619ef78071cfffdd7d253a0b6357afe8761c378add72b686493d9e5ed4096d4ab3d43ab3904d190f8
7
- data.tar.gz: ba3e2106f429644761c2f7567b27dc4a649281d8a23df2a1802a361e6af0a6d9c8615152e7cf9cc9d26eb80e4c716888440c009ebe5f92c5edc542bc362788e1
6
+ metadata.gz: aec65185a5098923afa1aaf38571c337981ac23be9a5e44bff8310ecd4f0f47dc6df1b783f834a9748634a07ecbfb26b93af45e8b389e7dbda5b75893fa41b11
7
+ data.tar.gz: f223699e44968598e86ae6010a53cf8e8844405fb9dbddb91ecf315bbcdf91eef362d960383fd583deb30be2fcd92e5098dd6d1a7a997502ffde835e1c8ec205
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
- script: 'bundle exec rspec spec/fanart_api'
2
+ script: 'bundle exec rspec spec/functionals'
3
3
  rvm:
4
+ - 1.9.3
4
5
  - 2.0.0
6
+ - 2.1.0
data/README.md CHANGED
@@ -16,14 +16,6 @@ You can add it to your Gemfile with:
16
16
  gem 'fanart_api'
17
17
  ```
18
18
 
19
- Run the bundle command to install it.
20
-
21
- ```console
22
- rails generate fanart_api:install
23
- ```
24
-
25
- The generator will install an initializer where you must past your api_key.
26
-
27
19
  ## How to use
28
20
 
29
21
  There is one entry point, in initialize you can past hash with api_key value, or leave empty:
@@ -37,24 +29,24 @@ client = FanartApi::Client.new(api_key: 'API_KEY')
37
29
  Movie API
38
30
 
39
31
  ```ruby
40
- client.movie.find(id, type = 'all', sort = '1', limit = '2')
41
- client.movie.update(timestamp)
32
+ client.movie.find(id: id, type: 'all', sort: '1', limit: '2')
33
+ client.movie.update(timestamp: 1...)
42
34
  ```
43
35
 
44
36
  Music API
45
37
 
46
38
  ```ruby
47
- client.music.artist(id, type = 'all', sort = '1', limit = '2')
48
- client.music.album(id, type = 'all', sort = '1', limit = '2')
49
- client.music.label(id, type = 'all', sort = '1', limit = '2')
50
- client.music.update(timestamp)
39
+ client.music.artist(id: id, type: 'all', sort: '1', limit: '2')
40
+ client.music.album(id: id, type: 'all', sort: '1', limit: '2')
41
+ client.music.label(id: id, type: 'all', sort: '1', limit: '2')
42
+ client.music.update(timestamp: 1...)
51
43
  ```
52
44
 
53
45
  Tv API
54
46
 
55
47
  ```ruby
56
- client.tv.find(id, type = 'all', sort = '1', limit = '2')
57
- client.tv.update(timestamp)
48
+ client.tv.find(id: id, type: 'all', sort: '1', limit: '2')
49
+ client.tv.update(timestamp: 1...)
58
50
  ```
59
51
 
60
52
  ## Contributing
@@ -18,9 +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.add_runtime_dependency 'confiture', '>= 0.1.4'
22
- spec.add_runtime_dependency 'httparty', '>= 0.12.0'
23
- spec.add_runtime_dependency 'uri_template', '~> 0.6.0'
21
+ spec.add_runtime_dependency 'service_api', '~> 0.0.4'
24
22
 
25
23
  spec.add_development_dependency 'bundler', '~> 1.3'
26
24
  spec.add_development_dependency 'rake'
@@ -1,7 +1,6 @@
1
1
  module FanartApi; end
2
2
 
3
3
  require 'fanart_api/version'
4
- require 'fanart_api/configuration'
5
4
  require 'fanart_api/base'
6
5
  require 'fanart_api/movie'
7
6
  require 'fanart_api/music'
@@ -1,47 +1,43 @@
1
- require 'httparty'
2
- require 'uri_template'
1
+ require 'service_api'
3
2
 
4
3
  class FanartApi::Base
5
- include HTTParty
6
- base_uri 'http://api.fanart.tv/webservice//'
4
+ include ServiceApi::BaseFaraday
7
5
 
8
- def initialize(client)
9
- @client = client
10
- @params = {}
6
+ def api_key_options
7
+ { api_key: @client.options[:api_key] }
11
8
  end
12
9
 
13
- def get(uri)
14
- @uri_template = URITemplate.new(uri)
15
-
16
- self
10
+ def path_with_params(path, options)
11
+ path(path).params(api_key_options.merge(options))
17
12
  end
18
13
 
19
- def params(options)
20
- @params = options
21
-
22
- self
14
+ def find_path
15
+ ':kind/:api_key/:id/json/:type/:sort/:limit'
23
16
  end
24
17
 
25
- def response
26
- @uri_template ? self.class.get(uri, body: @options) : nil
18
+ def update_path
19
+ ':kind/:api_key/:timestamp'
27
20
  end
28
21
 
29
- def prepare_uri
30
- @uri_template ? @uri_template.expand(@params.merge(api_key: @client.api_key)) : nil
22
+ def default_options
23
+ {
24
+ type: 'all',
25
+ sort: 1,
26
+ limit: 2
27
+ }
31
28
  end
32
29
 
33
- def uri
34
- uri = prepare_uri
35
- @params.reject!{ |param| restful_param_keys(uri).include?(param.to_s) }
30
+ private
36
31
 
37
- uri
32
+ def uri_kind
33
+ :colon
38
34
  end
39
35
 
40
- def restful_param_keys(uri_expanded)
41
- @uri_template.extract(uri_expanded).keys
36
+ def base_url
37
+ 'http://api.fanart.tv/webservice/'
42
38
  end
43
39
 
44
- def shared_uri
45
- '{api_key}/{id}/json/{type}/{sort}/{limit}'
46
- end
40
+ # def shared_uri
41
+ # '{api_key}/{id}/json/{type}/{sort}/{limit}'
42
+ # end
47
43
  end
@@ -1,10 +1,10 @@
1
- require 'httparty'
2
-
3
1
  class FanartApi::Client
4
- attr_reader :api_key
2
+ attr_reader :options
5
3
 
6
4
  def initialize(options = {})
7
- @api_key = options[:api_key] ? options[:api_key] : FanartApi::Configuration.api_key
5
+ @options = options
6
+
7
+ @options[:adapter] ||= :net_http
8
8
  end
9
9
 
10
10
  def movie
@@ -1,10 +1,28 @@
1
1
  # documentation: http://fanart.tv/api-docs/movie-api
2
2
  class FanartApi::Movie < FanartApi::Base
3
- def find(id, type = 'all', sort = '1', limit = '2')
4
- get("movies/#{shared_uri}").params(id: id, type: type, sort: sort, limit: limit).response
3
+ def find(options = {})
4
+ find_path_with_params(options).get
5
5
  end
6
6
 
7
- def update(timestamp = (Time.now - 172800).to_i)
8
- get('newmovies/{api_key}/{timestamp}').params(timestamp: timestamp).response
7
+ def find_url(options = {})
8
+ find_path_with_params(options).url
9
9
  end
10
- end
10
+
11
+ def update(options = {})
12
+ update_path_with_params(options).get
13
+ end
14
+
15
+ def update_url(options = {})
16
+ update_path_with_params(options).url
17
+ end
18
+
19
+ private
20
+
21
+ def find_path_with_params(options)
22
+ path_with_params(find_path, default_options.merge(options.merge(kind: :movie)))
23
+ end
24
+
25
+ def update_path_with_params(options)
26
+ path_with_params(update_path, default_options.merge(options.merge(kind: :newmovies)))
27
+ end
28
+ end
@@ -1,12 +1,52 @@
1
1
  # documentation: http://fanart.tv/api-docs/music-api
2
2
  class FanartApi::Music < FanartApi::Base
3
- [:artist, :album, :label].each do |method_name|
4
- define_method(method_name) do |id, type = 'all', sort = '1', limit = '2'|
5
- get("#{method_name}/#{shared_uri}").params(id: id, type: type, sort: sort, limit: limit).response
6
- end
3
+ def artist(options = {})
4
+ artist_path_with_params(options).get
7
5
  end
8
6
 
9
- def update(timestamp = (Time.now - 172800).to_i)
10
- get('newmusic/{api_key}/{timestamp}').params(timestamp: timestamp).response
7
+ def artist_url(options = {})
8
+ artist_path_with_params(options).url
9
+ end
10
+
11
+ def album(options = {})
12
+ album_path_with_params(options).get
13
+ end
14
+
15
+ def album_url(options = {})
16
+ album_path_with_params(options).url
17
+ end
18
+
19
+ def label(options = {})
20
+ label_path_with_params(options).get
21
+ end
22
+
23
+ def label_url(options = {})
24
+ label_path_with_params(options).url
25
+ end
26
+
27
+ def update(options = {})
28
+ update_path_with_params(options).get
29
+ end
30
+
31
+ def update_url(options = {})
32
+ update_path_with_params(options).url
33
+ end
34
+
35
+ private
36
+
37
+ def artist_path_with_params(options)
38
+ path_with_params(find_path, default_options.merge(options.merge(kind: :artist)))
39
+ end
40
+
41
+ def album_path_with_params(options)
42
+ path_with_params(find_path, default_options.merge(options.merge(kind: :album)))
43
+ end
44
+
45
+ def label_path_with_params(options)
46
+ path_with_params(find_path, default_options.merge(options.merge(kind: :label)))
47
+ end
48
+
49
+ def update_path_with_params(options)
50
+ path_with_params(update_path, default_options.merge(options.merge(kind: :newmusic)))
11
51
  end
12
52
  end
@@ -1,10 +1,28 @@
1
1
  # documentation: http://fanart.tv/api-docs/tv-api
2
2
  class FanartApi::Tv < FanartApi::Base
3
- def find(id, type = 'all', sort = '1', limit = '2')
4
- get("series/#{shared_uri}").params(id: id, type: type, sort: sort, limit: limit).response
3
+ def find(options = {})
4
+ find_path_with_params(options).get
5
5
  end
6
6
 
7
- def update(timestamp = (Time.now - 172800).to_i)
8
- get('newtv/{api_key}/{timestamp}').params(timestamp: timestamp).response
7
+ def find_url(options = {})
8
+ find_path_with_params(options).url
9
+ end
10
+
11
+ def update(options = {})
12
+ update_path_with_params(options).get
13
+ end
14
+
15
+ def update_url(options = {})
16
+ update_path_with_params(options).url
17
+ end
18
+
19
+ private
20
+
21
+ def find_path_with_params(options)
22
+ path_with_params(find_path, default_options.merge(options.merge(kind: :series)))
23
+ end
24
+
25
+ def update_path_with_params(options)
26
+ path_with_params(update_path, default_options.merge(options.merge(kind: :newtv)))
9
27
  end
10
28
  end
@@ -1,3 +1,3 @@
1
1
  module FanartApi
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -0,0 +1,39 @@
1
+ {
2
+ "Evanescence": {
3
+ "mbid_id": "f4a31f0a-51dd-4fa7-986d-3095c40c5ed9",
4
+ "artistbackground": [
5
+ {
6
+ "id": "9",
7
+ "url": "http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/9/evanescence-4dc719c5cc68f.jpg",
8
+ "likes": "1"
9
+ }
10
+ ],
11
+ "musiclogo": [
12
+ {
13
+ "id": "5239",
14
+ "url": "http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/musiclogo/5239/evanescence-4df6263dee3c6.png",
15
+ "likes": "1"
16
+ }
17
+ ],
18
+ "albums": {
19
+ "2187d248-1a3b-35d0-a4ec-bead586ff547": {
20
+ "albumcover": [
21
+ {
22
+ "id": "43",
23
+ "url": "http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/43/fallen-4dc8683fa58fe.jpg",
24
+ "likes": "0"
25
+ }
26
+ ],
27
+ "cdart": [
28
+ {
29
+ "id": "17739",
30
+ "url": "http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/17739/fallen-4f133f8a16d25.png",
31
+ "likes": "0",
32
+ "disc": "1",
33
+ "size": "1000"
34
+ }
35
+ ]
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "The Lord of the Rings: The Fellowship of the Ring": {
3
+ "tmdb_id": "120",
4
+ "imdb_id": "tt0120737",
5
+ "moviedisc": [
6
+ {
7
+ "id": "101",
8
+ "url": "http://fanart.tv/fanart/movies/120/moviedisc/101/the-lord-of-the-rings-the-fellowship-of-the-ring-4eea008189187.png",
9
+ "lang": "en",
10
+ "likes": "0",
11
+ "disc": "1",
12
+ "disc_type": "bluray"
13
+ },
14
+ {
15
+ "id": "102",
16
+ "url": "http://fanart.tv/fanart/movies/120/moviedisc/102/the-lord-of-the-rings-the-fellowship-of-the-ring-4eea017193bf6.png",
17
+ "lang": "en",
18
+ "likes": "0",
19
+ "disc": "2",
20
+ "disc_type": "bluray"
21
+ }
22
+ ],
23
+ "movielogo": [
24
+ {
25
+ "id": "222",
26
+ "url": "http://fanart.tv/fanart/movies/120/movielogo/222/the-lord-of-the-rings-the-fellowship-of-the-ring-4ef23158be031.png",
27
+ "lang": "en",
28
+ "likes": "0"
29
+ }
30
+ ]
31
+ }
32
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "series":"Bones",
3
+ "clearlogos":[
4
+ {
5
+ "id":"13571",
6
+ "url":"http:\/\/fanart.tv\/tv\/75682\/clearlogo\/bones-4e764b27c454d.png",
7
+ "lang":"ar",
8
+ "likes":"0"
9
+ }
10
+ ],
11
+ "cleararts":[
12
+ {
13
+ "id":"11780",
14
+ "url":"http:\/\/fanart.tv\/tv\/75682\/clearart\/bones-4df372a733e83.png",
15
+ "lang":"en",
16
+ "likes":"0"
17
+ }
18
+ ],
19
+ "tvthumbs":[
20
+ {
21
+ "id":"4321",
22
+ "url":"http:\/\/fanart.tv\/tv\/75682\/tvthumb\/B_75682.jpg",
23
+ "lang":"en",
24
+ "likes":"0"
25
+ }
26
+ ],
27
+ "seasonthumbs":[
28
+ {
29
+ "id":"4308",
30
+ "url":"http:\/\/fanart.tv\/tv\/75682\/seasonthumb\/Bones (7).jpg",
31
+ "lang":"en",
32
+ "likes":"0",
33
+ "season":"3"
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe FanartApi::Movie do
4
+ let(:client) { FanartApi::Client.new(api_key: '123456789', adapter: :test, adapter_options: faraday_stubs) }
5
+ let(:model) { client.movie }
6
+
7
+ let(:movies_data) { File.read('spec/fixtures/find_movies.json') }
8
+
9
+ let(:faraday_stubs) do
10
+ Faraday::Adapter::Test::Stubs.new do |stub|
11
+ stub.get('/webservice/movie/123456789/1234/json/all/1/2') { [200, { content_type: 'json' }, movies_data] }
12
+ stub.get('/webservice/newmovies/123456789/123') { [200, { content_type: 'json' }, {}] }
13
+ end
14
+ end
15
+
16
+ describe '.find' do
17
+ it 'should return Faraday::Response class' do
18
+ model.find(id: 1234, type: 'all', sort: '1', limit: 2).class.should == Faraday::Response
19
+ end
20
+
21
+ it 'should return Hash class for body reponse' do
22
+ model.find(id: 1234, type: 'all', sort: '1', limit: 2).body == Hash
23
+ end
24
+ end
25
+
26
+ describe '.find_url' do
27
+ it 'should return correct url' do
28
+ model.find_url(id: 1234, type: 'all', sort: '1', limit: 2).should == 'http://api.fanart.tv/webservice/movie/123456789/1234/json/all/1/2'
29
+ end
30
+ end
31
+
32
+ describe '.update' do
33
+ it 'should return Faraday::Response class' do
34
+ model.update(timestamp: 123).class.should == Faraday::Response
35
+ end
36
+
37
+ it 'should return Hash class for body reponse' do
38
+ model.update(timestamp: 123).body == Hash
39
+ end
40
+ end
41
+
42
+ describe '.update_url' do
43
+ it 'should return correct url' do
44
+ model.update_url(timestamp: 123).should == 'http://api.fanart.tv/webservice/newmovies/123456789/123'
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe FanartApi::Music do
4
+ let(:client) { FanartApi::Client.new(api_key: '123456789', adapter: :test, adapter_options: faraday_stubs) }
5
+ let(:model) { client.music }
6
+
7
+ let(:music_data) { File.read('spec/fixtures/artist.json') }
8
+
9
+ let(:faraday_stubs) do
10
+ Faraday::Adapter::Test::Stubs.new do |stub|
11
+ stub.get('/webservice/artist/123456789/1234/json/all/1/2') { [200, { content_type: 'json' }, music_data] }
12
+ stub.get('/webservice/album/123456789/1234/json/all/1/2') { [200, { content_type: 'json' }, music_data] }
13
+ stub.get('/webservice/label/123456789/1234/json/all/1/2') { [200, { content_type: 'json' }, music_data] }
14
+ stub.get('/webservice/newmusic/123456789/123') { [200, { content_type: 'json' }, {}] }
15
+ end
16
+ end
17
+
18
+ describe '.artist' do
19
+ it 'should return Faraday::Response class' do
20
+ model.artist(id: 1234, type: 'all', sort: '1', limit: 2).class.should == Faraday::Response
21
+ end
22
+
23
+ it 'should return Hash class for body reponse' do
24
+ model.artist(id: 1234, type: 'all', sort: '1', limit: 2).body == Hash
25
+ end
26
+ end
27
+
28
+ describe '.artist_url' do
29
+ it 'should return correct url' do
30
+ model.artist_url(id: 1234, type: 'all', sort: '1', limit: 2).should == 'http://api.fanart.tv/webservice/artist/123456789/1234/json/all/1/2'
31
+ end
32
+ end
33
+
34
+ describe '.album' do
35
+ it 'should return Faraday::Response class' do
36
+ model.album(id: 1234, type: 'all', sort: '1', limit: 2).class.should == Faraday::Response
37
+ end
38
+
39
+ it 'should return Hash class for body reponse' do
40
+ model.album(id: 1234, type: 'all', sort: '1', limit: 2).body == Hash
41
+ end
42
+ end
43
+
44
+ describe '.album_url' do
45
+ it 'should return correct url' do
46
+ model.album_url(id: 1234, type: 'all', sort: '1', limit: 2).should == 'http://api.fanart.tv/webservice/album/123456789/1234/json/all/1/2'
47
+ end
48
+ end
49
+
50
+ describe '.label' do
51
+ it 'should return Faraday::Response class' do
52
+ model.label(id: 1234, type: 'all', sort: '1', limit: 2).class.should == Faraday::Response
53
+ end
54
+
55
+ it 'should return Hash class for body reponse' do
56
+ model.label(id: 1234, type: 'all', sort: '1', limit: 2).body == Hash
57
+ end
58
+ end
59
+
60
+ describe '.label_url' do
61
+ it 'should return correct url' do
62
+ model.label_url(id: 1234, type: 'all', sort: '1', limit: 2).should == 'http://api.fanart.tv/webservice/label/123456789/1234/json/all/1/2'
63
+ end
64
+ end
65
+
66
+ describe '.update' do
67
+ it 'should return Faraday::Response class' do
68
+ model.update(timestamp: 123).class.should == Faraday::Response
69
+ end
70
+
71
+ it 'should return Hash class for body reponse' do
72
+ model.update(timestamp: 123).body == Hash
73
+ end
74
+ end
75
+
76
+ describe '.update_url' do
77
+ it 'should return correct url' do
78
+ model.update_url(timestamp: 123).should == 'http://api.fanart.tv/webservice/newmusic/123456789/123'
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe FanartApi::Tv do
4
+ let(:client) { FanartApi::Client.new(api_key: '123456789', adapter: :test, adapter_options: faraday_stubs) }
5
+ let(:model) { client.tv }
6
+
7
+ let(:tv_data) { File.read('spec/fixtures/find_series.json') }
8
+
9
+ let(:faraday_stubs) do
10
+ Faraday::Adapter::Test::Stubs.new do |stub|
11
+ stub.get('/webservice/series/123456789/1234/json/all/1/2') { [200, { content_type: 'json' }, tv_data] }
12
+ stub.get('/webservice/newtv/123456789/123') { [200, { content_type: 'json' }, {}] }
13
+ end
14
+ end
15
+
16
+ describe '.find' do
17
+ it 'should return Faraday::Response class' do
18
+ model.find(id: 1234, type: 'all', sort: '1', limit: 2).class.should == Faraday::Response
19
+ end
20
+
21
+ it 'should return Hash class for body reponse' do
22
+ model.find(id: 1234, type: 'all', sort: '1', limit: 2).body == Hash
23
+ end
24
+ end
25
+
26
+ describe '.find_url' do
27
+ it 'should return correct url' do
28
+ model.find_url(id: 1234, type: 'all', sort: '1', limit: 2).should == 'http://api.fanart.tv/webservice/series/123456789/1234/json/all/1/2'
29
+ end
30
+ end
31
+
32
+ describe '.update' do
33
+ it 'should return Faraday::Response class' do
34
+ model.update(timestamp: 123).class.should == Faraday::Response
35
+ end
36
+
37
+ it 'should return Hash class for body reponse' do
38
+ model.update(timestamp: 123).body == Hash
39
+ end
40
+ end
41
+
42
+ describe '.update_url' do
43
+ it 'should return correct url' do
44
+ model.update_url(timestamp: 123).should == 'http://api.fanart.tv/webservice/newtv/123456789/123'
45
+ end
46
+ end
47
+ end
@@ -5,22 +5,5 @@ Coveralls.wear!
5
5
 
6
6
  require 'fanart_api'
7
7
 
8
- FanartApi::Configuration.configure do |config|
9
- config.api_key = ''
10
- end
11
-
12
- class SampleModel
13
- def get(uri)
14
- self
15
- end
16
-
17
- def params(options = {})
18
- self
19
- end
20
-
21
- def response
22
- end
23
- end
24
-
25
8
  RSpec.configure do |config|
26
9
  end
metadata CHANGED
@@ -1,57 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanart_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.2
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-17 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: confiture
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: 0.1.4
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: 0.1.4
27
- - !ruby/object:Gem::Dependency
28
- name: httparty
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: 0.12.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: 0.12.0
41
- - !ruby/object:Gem::Dependency
42
- name: uri_template
14
+ name: service_api
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - ~>
46
18
  - !ruby/object:Gem::Version
47
- version: 0.6.0
19
+ version: 0.0.4
48
20
  type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - ~>
53
25
  - !ruby/object:Gem::Version
54
- version: 0.6.0
26
+ version: 0.0.4
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: bundler
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -125,22 +97,18 @@ files:
125
97
  - lib/fanart_api.rb
126
98
  - lib/fanart_api/base.rb
127
99
  - lib/fanart_api/client.rb
128
- - lib/fanart_api/configuration.rb
129
100
  - lib/fanart_api/movie.rb
130
101
  - lib/fanart_api/music.rb
131
102
  - lib/fanart_api/tv.rb
132
103
  - lib/fanart_api/version.rb
133
- - lib/generators/fanart_api/install_generator.rb
134
- - lib/generators/templates/fanart_api.rb
135
- - spec/fanart_api/base_spec.rb
136
- - spec/fanart_api/client_spec.rb
137
- - spec/fanart_api/movie_spec.rb
138
- - spec/fanart_api/music_spec.rb
139
- - spec/fanart_api/tv_spec.rb
140
- - spec/integration_spec_helper.rb
104
+ - spec/fixtures/artist.json
105
+ - spec/fixtures/find_movies.json
106
+ - spec/fixtures/find_series.json
107
+ - spec/functionals/movie_spec.rb
108
+ - spec/functionals/music_spec.rb
109
+ - spec/functionals/tv_spec.rb
141
110
  - spec/integrations/movie_spec.rb
142
111
  - spec/integrations/music_spec.rb
143
- - spec/integrations/support/fanart_api.rb.example
144
112
  - spec/integrations/tv_spec.rb
145
113
  - spec/spec_helper.rb
146
114
  homepage: http://github.com/wafcio/fanart_api
@@ -163,19 +131,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
131
  version: '0'
164
132
  requirements: []
165
133
  rubyforge_project:
166
- rubygems_version: 2.0.0
134
+ rubygems_version: 2.0.3
167
135
  signing_key:
168
136
  specification_version: 4
169
137
  summary: Ruby client for fanart.tv API
170
138
  test_files:
171
- - spec/fanart_api/base_spec.rb
172
- - spec/fanart_api/client_spec.rb
173
- - spec/fanart_api/movie_spec.rb
174
- - spec/fanart_api/music_spec.rb
175
- - spec/fanart_api/tv_spec.rb
176
- - spec/integration_spec_helper.rb
139
+ - spec/fixtures/artist.json
140
+ - spec/fixtures/find_movies.json
141
+ - spec/fixtures/find_series.json
142
+ - spec/functionals/movie_spec.rb
143
+ - spec/functionals/music_spec.rb
144
+ - spec/functionals/tv_spec.rb
177
145
  - spec/integrations/movie_spec.rb
178
146
  - spec/integrations/music_spec.rb
179
- - spec/integrations/support/fanart_api.rb.example
180
147
  - spec/integrations/tv_spec.rb
181
148
  - spec/spec_helper.rb
@@ -1,7 +0,0 @@
1
- require 'confiture'
2
-
3
- class FanartApi::Configuration
4
- include Confiture::Configuration
5
-
6
- confiture_allowed_keys(:api_key)
7
- end
@@ -1,12 +0,0 @@
1
- module FanartApi
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path('../../templates', __FILE__)
5
-
6
- desc 'Creates a FanartApi::Configuration initializer and copy locale files to your application.'
7
- def copy_initializer
8
- template 'fanart_api.rb', 'config/initializers/fanart_api.rb'
9
- end
10
- end
11
- end
12
- end
@@ -1,3 +0,0 @@
1
- FanartApi::Configuration.configure do |config|
2
- config.api_key = ''
3
- end
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class ExampleClass < FanartApi::Base
4
- end
5
-
6
- describe FanartApi::Base do
7
- let(:klass) { ExampleClass }
8
- let(:model) { klass.new(FanartApi::Client.new) }
9
-
10
- describe '.get' do
11
- it 'should set @uri_template' do
12
- model.get('http://example.com')
13
-
14
- model.instance_variable_get('@uri_template').class.should == URITemplate::RFC6570
15
- end
16
-
17
- it 'should return self' do
18
- model.get('http://example.com').should == model
19
- end
20
- end
21
-
22
- describe '.params' do
23
- it 'should set @params' do
24
- model.params(sample: 'test')
25
-
26
- model.instance_variable_get('@params').should == { sample: 'test' }
27
- end
28
-
29
- it 'should return self' do
30
- model.params(sample: 'test').should == model
31
- end
32
- end
33
-
34
- describe '.response' do
35
- it 'should call get klass method' do
36
- model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
37
- klass.should_receive(:get)
38
-
39
- model.response
40
- end
41
- end
42
-
43
- describe '.prepare_uri' do
44
- it 'should receive correct uri string' do
45
- model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
46
-
47
- model.prepare_uri.should == "#{FanartApi::Configuration.api_key}/series/"
48
- end
49
- end
50
-
51
- describe '.uri' do
52
- it 'should receive correct uri string' do
53
- model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
54
- model.instance_variable_set('@params', id: '1234')
55
-
56
- model.uri.should == "#{FanartApi::Configuration.api_key}/series/1234"
57
- end
58
- end
59
-
60
- describe '.restful_param_keys' do
61
- it 'should receive correct uri string' do
62
- uri_template = URITemplate.new('{api_key}/series/{id}')
63
- model.instance_variable_set('@uri_template', uri_template)
64
-
65
- model.restful_param_keys(uri_template.expand).sort.should == ['api_key', 'id'].sort
66
- end
67
- end
68
-
69
- describe '.shared_uri' do
70
- it 'should return correct string' do
71
- model.shared_uri.should == '{api_key}/{id}/json/{type}/{sort}/{limit}'
72
- end
73
- end
74
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FanartApi::Client do
4
- let(:model) { FanartApi::Client.new }
5
-
6
- describe '.movie' do
7
- it 'should return movie class' do
8
- model.movie.class.should == FanartApi::Movie
9
- end
10
- end
11
-
12
- describe '.music' do
13
- it 'should return music class' do
14
- model.music.class.should == FanartApi::Music
15
- end
16
- end
17
-
18
- describe '.tv' do
19
- it 'should return tv class' do
20
- model.tv.class.should == FanartApi::Tv
21
- end
22
- end
23
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FanartApi::Movie do
4
- let(:klass) { FanartApi::Movie }
5
- let(:model) { klass.new(FanartApi::Client.new) }
6
- let(:mock_model) { SampleModel.new }
7
-
8
- describe '.find' do
9
- it 'should call get with specific params' do
10
- model.should_receive(:get).with('movies/{api_key}/{id}/json/{type}/{sort}/{limit}').and_return(mock_model)
11
-
12
- model.find('1234')
13
- end
14
-
15
- it 'should call params with specific params' do
16
- model.should_receive(:params).with(id: '1234', type: 'all', sort: '1', limit: '2').and_return(mock_model)
17
-
18
- model.find('1234')
19
- end
20
- end
21
-
22
- describe '.update' do
23
- it 'should call get with specific params' do
24
- model.should_receive(:get).with('newmovies/{api_key}/{timestamp}').and_return(mock_model)
25
-
26
- model.update(1234)
27
- end
28
-
29
- it 'should call params with specific params' do
30
- model.should_receive(:params).with(timestamp: 1234).and_return(mock_model)
31
-
32
- model.update(1234)
33
- end
34
- end
35
- end
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FanartApi::Music do
4
- let(:klass) { FanartApi::Music }
5
- let(:model) { klass.new(FanartApi::Client.new) }
6
- let(:mock_model) { SampleModel.new }
7
-
8
- describe '.artist' do
9
- it 'should call get with specific params' do
10
- model.should_receive(:get).with('artist/{api_key}/{id}/json/{type}/{sort}/{limit}').and_return(mock_model)
11
-
12
- model.artist('1234')
13
- end
14
-
15
- it 'should call params with specific params' do
16
- model.should_receive(:params).with(id: '1234', type: 'all', sort: '1', limit: '2').and_return(mock_model)
17
-
18
- model.artist('1234')
19
- end
20
- end
21
-
22
- describe '.album' do
23
- it 'should call get with specific params' do
24
- model.should_receive(:get).with('album/{api_key}/{id}/json/{type}/{sort}/{limit}').and_return(mock_model)
25
-
26
- model.album('1234')
27
- end
28
-
29
- it 'should call params with specific params' do
30
- model.should_receive(:params).with(id: '1234', type: 'all', sort: '1', limit: '2').and_return(mock_model)
31
-
32
- model.album('1234')
33
- end
34
- end
35
-
36
- describe '.label' do
37
- it 'should call get with specific params' do
38
- model.should_receive(:get).with('label/{api_key}/{id}/json/{type}/{sort}/{limit}').and_return(mock_model)
39
-
40
- model.label('1234')
41
- end
42
-
43
- it 'should call params with specific params' do
44
- model.should_receive(:params).with(id: '1234', type: 'all', sort: '1', limit: '2').and_return(mock_model)
45
-
46
- model.label('1234')
47
- end
48
- end
49
-
50
- describe '.update' do
51
- it 'should call get with specific params' do
52
- model.should_receive(:get).with('newmusic/{api_key}/{timestamp}').and_return(mock_model)
53
-
54
- model.update(1234)
55
- end
56
-
57
- it 'should call params with specific params' do
58
- model.should_receive(:params).with(timestamp: 1234).and_return(mock_model)
59
-
60
- model.update(1234)
61
- end
62
- end
63
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FanartApi::Tv do
4
- let(:klass) { FanartApi::Tv }
5
- let(:model) { klass.new(FanartApi::Client.new) }
6
- let(:mock_model) { SampleModel.new }
7
-
8
- describe '.find' do
9
- it 'should call get with specific params' do
10
- model.should_receive(:get).with('series/{api_key}/{id}/json/{type}/{sort}/{limit}').and_return(mock_model)
11
-
12
- model.find('1234')
13
- end
14
-
15
- it 'should call params with specific params' do
16
- model.should_receive(:params).with(id: '1234', type: 'all', sort: '1', limit: '2').and_return(mock_model)
17
-
18
- model.find('1234')
19
- end
20
- end
21
-
22
- describe '.update' do
23
- it 'should call get with specific params' do
24
- model.should_receive(:get).with('newtv/{api_key}/{timestamp}').and_return(mock_model)
25
-
26
- model.update(1234)
27
- end
28
-
29
- it 'should call params with specific params' do
30
- model.should_receive(:params).with(timestamp: 1234).and_return(mock_model)
31
-
32
- model.update(1234)
33
- end
34
- end
35
- end
@@ -1,3 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require File.join(File.dirname(__FILE__), 'integrations/support/fanart_api.rb')
@@ -1,3 +0,0 @@
1
- FanartApi::Configuration.configure do |config|
2
- config.api_key = ''
3
- end