fanart_api 0.2.1 → 0.3.0

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: 87290847861add7f96f125086e81788561a040c8
4
- data.tar.gz: 121bd4d1b3031347bff6a48e13c78989c4e5ec12
3
+ metadata.gz: 1f051fccf4b6b3ef7ef55291a8ef381a0a0fb5a8
4
+ data.tar.gz: 90110694c1bf982f7b3d956a8dd1d7e143bcce8a
5
5
  SHA512:
6
- metadata.gz: 121cb8ca1c63423d01d1c3afe1ae635885f72e8c2a11145dab494e6cfedd210512812fa225feebc9a3a5d2d179944ee1332dc962b2ee1724aa5d413536fffbd5
7
- data.tar.gz: 11566f7c858173aa35d028921627c8b243a80b706c6de55a28fa1719920445e44357c8502c00d312c92fdaaf71ec21300526084e3f3d86dfd35ac751e244db13
6
+ metadata.gz: ad47c30a859bd6001982736e351bddb1d7eefe14fce201b6e02a37af9a7f4237978a0a92066e2dbd85758bcc4a89c2315f66e3c6a90043b8d4c8f02c06800896
7
+ data.tar.gz: 44112006eccf4dc66800c719886dcc86b3f3c71755b927321a3bd092bb59ea01f35fe97ad4f38baa0d2d315962aee7dde5d2d3375eb48e4353bc931adef0fdfc
data/.gitignore CHANGED
@@ -1,19 +1,6 @@
1
1
  *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
2
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
3
  coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
4
 
19
- spec/integrations/support/fanart_api.rb
5
+ spec/integrations/support/fanart_api.rb
6
+ spec/support/api_key.rb
@@ -3,4 +3,5 @@ script: 'bundle exec rspec spec/functionals'
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.0
6
+ - 2.1.5
7
+ - 2.2.0
@@ -0,0 +1,31 @@
1
+ ## 0.3.0 (January 25, 2015)
2
+
3
+ - use ov gem for multimethod
4
+ - fix test for rspec 3 syntax
5
+ - add more tests
6
+
7
+ ## 0.2.1 (September 3, 2014)
8
+
9
+ - fix gemspec dependency
10
+
11
+ ## 0.2.0 (July 18, 2014)
12
+
13
+ - use APIv3
14
+
15
+ ## 0.1.3 (June 28, 2014)
16
+
17
+ - fix for default options
18
+
19
+ ## 0.1.2 (June 28, 2014)
20
+
21
+ - refactored
22
+ - replaced HTTParty by Faraday
23
+
24
+ ## 0.0.2 (December 17, 2013)
25
+
26
+ - little performance improvement
27
+ - used uri_template for better way to format uri and map variables
28
+
29
+ ## 0.0.1 (December 15, 2013)
30
+
31
+ First release with HTTParty
data/README.md CHANGED
@@ -1,63 +1,96 @@
1
- [![Build Status](https://travis-ci.org/wafcio/fanart_api.png?branch=master)](https://travis-ci.org/wafcio/fanart_api)
2
- [![Dependency Status](https://gemnasium.com/wafcio/fanart_api.png)](https://gemnasium.com/wafcio/fanart_api)
3
- [![Code Climate](https://codeclimate.com/github/wafcio/fanart_api.png)](https://codeclimate.com/github/wafcio/fanart_api)
4
- [![Coverage Status](https://coveralls.io/repos/wafcio/fanart_api/badge.png)](https://coveralls.io/r/wafcio/fanart_api)
1
+ [![Build Status](https://travis-ci.org/tvapi/fanart_api.png?branch=master)](https://travis-ci.org/tvapi/fanart_api)
2
+ [![Dependency Status](https://gemnasium.com/tvapi/fanart_api.png)](https://gemnasium.com/tvapi/fanart_api)
3
+ [![Code Climate](https://codeclimate.com/github/tvapi/fanart_api.png)](https://codeclimate.com/github/tvapi/fanart_api)
4
+ [![Coverage Status](https://coveralls.io/repos/tvapi/fanart_api/badge.png)](https://coveralls.io/r/tvapi/fanart_api)
5
5
  [![Gem Version](https://badge.fury.io/rb/fanart_api.png)](http://badge.fury.io/rb/fanart_api)
6
6
 
7
7
  # FanartApi
8
8
 
9
- Ruby client for fanart.tv API
9
+ fanart_api is a simple ruby client for accessing TV shows information from the fanart.tv API.
10
10
 
11
- fanart.tv APIv2 - FanartApi gem v0.1.x (lastest v0.1.3)
12
- fanart.tv APIv3 - FanartApi gem v0.2.x (from v0.2.0)
11
+ ## Installation
13
12
 
14
- ## Getting started
15
-
16
- You can add it to your Gemfile with:
13
+ With Bundler:
17
14
 
18
15
  ```ruby
19
- gem 'fanart_api'
16
+ gem 'thetvdb_api'
20
17
  ```
21
18
 
22
- ## How to use
23
-
24
- There is one entry point, in initialize you can past hash with api_key value, or leave empty:
25
-
26
19
  ```ruby
27
- client = FanartApi::Client.new(api_key: 'API_KEY')
20
+ $ bundle install
28
21
  ```
29
22
 
30
- Optional you can add option proxy: false which will not send request to proxy.
23
+ Otherwhise:
31
24
 
32
25
  ```ruby
33
- client = FanartApi::Client.new(api_key: 'API_KEY', proxy: false)
26
+ $ gem install thetvdb_api
34
27
  ```
35
28
 
36
- ## Usage
29
+ ## How to use
37
30
 
38
- Movie API
31
+ You have two way for access to api:
39
32
 
40
33
  ```ruby
41
- client.movie.find(id: id)
42
- client.movie.latest(date: 1...)
34
+ client = FanartApi::Client.new(api_key: '...')
43
35
  ```
36
+ ```ruby
37
+ client = FanartApi::Client.new(api_key: '...', proxy_url: '...')
38
+ client.movie # => #<FanartApi::Movie>
39
+ client.music # => #<FanartApi::Music>
40
+ client.tv # => #<FanartApi::Tv>
41
+ ```
42
+
43
+ * II case (direct access to api class, many entry points)
44
44
 
45
- Music API
45
+ Language attribute is required
46
46
 
47
47
  ```ruby
48
- client.music.artist(id: id)
49
- client.music.album(id: id)
50
- client.music.label(id: id)
51
- client.music.latest(date: 1...)
48
+ ThetvdbApi::Actor.new(api_key: '...')
49
+ ThetvdbApi::Banner.new(api_key: '...')
50
+ ThetvdbApi::Episode.new(api_key: '...')
52
51
  ```
53
52
 
54
- Tv API
55
-
56
53
  ```ruby
57
- client.tv.find(id: id)
58
- client.tv.latest(date: 1...)
54
+ ThetvdbApi::Actor.new(api_key: '...', proxy_url: '...')
55
+ ThetvdbApi::Banner.new(api_key: '...', proxy_url: '...')
56
+ ThetvdbApi::Episode.new(api_key: '...', proxy_url: '...')
59
57
  ```
60
58
 
59
+ ## Methods
60
+
61
+ For all methods you can pass hash attributes or multiple attributes specified in method comment.
62
+
63
+ ### Movie methods
64
+
65
+ For method attributes read https://github.com/tvapi/fanart_api/blob/master/lib/fanart_api/movie.rb
66
+
67
+ * find
68
+ * find_url
69
+ * latest
70
+ * latest_url
71
+
72
+ ### Music methods
73
+
74
+ For method attributes read https://github.com/tvapi/fanart_api/blob/master/lib/fanart_api/music.rb
75
+
76
+ * artist
77
+ * artist_url
78
+ * album
79
+ * album_url
80
+ * label
81
+ * label_url
82
+ * latest
83
+ * latest_url
84
+
85
+ ### Tv methods
86
+
87
+ For method attributes read https://github.com/tvapi/fanart_api/blob/master/lib/fanart_api/tv.rb
88
+
89
+ * find
90
+ * find_url
91
+ * latest
92
+ * latest_url
93
+
61
94
  ## Contributing
62
95
 
63
96
  1. Fork it
@@ -18,10 +18,12 @@ 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 'service_api', '0.0.4'
21
+ spec.add_runtime_dependency 'service_api', '~> 0.1.0'
22
+ spec.add_runtime_dependency 'ov', '~> 0.1.0'
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.3'
24
25
  spec.add_development_dependency 'rake'
25
- spec.add_development_dependency 'rspec', '>= 2.14.1'
26
- spec.add_development_dependency 'coveralls', '>= 0.7'
26
+ spec.add_development_dependency 'rspec', '~> 3.1.0'
27
+ spec.add_development_dependency 'coveralls', '~> 0.7'
28
+ spec.add_development_dependency 'awesome_print', '~> 1.6.0'
27
29
  end
@@ -1,3 +1,5 @@
1
+ require 'ov'
2
+
1
3
  module FanartApi; end
2
4
 
3
5
  require 'fanart_api/version'
@@ -4,7 +4,7 @@ class FanartApi::Base
4
4
  include ServiceApi::BaseFaraday
5
5
 
6
6
  def api_key_options
7
- { api_key: @client.options[:api_key] }
7
+ { api_key: @config[:api_key] }
8
8
  end
9
9
 
10
10
  def path_with_params(path, options)
@@ -26,10 +26,10 @@ class FanartApi::Base
26
26
  end
27
27
 
28
28
  def base_url
29
- if @client.options[:proxy] == false
30
- 'http://webservice.fanart.tv/v3/'
29
+ if @config[:proxy_url]
30
+ @config[:proxy_url]
31
31
  else
32
- 'http://fanarttv.apiary-proxy.com/v3/'
32
+ 'http://webservice.fanart.tv/v3/'
33
33
  end
34
34
  end
35
35
  end
@@ -1,21 +1,21 @@
1
1
  class FanartApi::Client
2
- attr_reader :options
2
+ attr_reader :config
3
3
 
4
- def initialize(options = {})
5
- @options = options
4
+ def initialize(config = {})
5
+ @config = config
6
6
 
7
- @options[:adapter] ||= :net_http
7
+ @config[:adapter] ||= :net_http
8
8
  end
9
9
 
10
10
  def movie
11
- @movie ||= FanartApi::Movie.new(self)
11
+ @movie ||= FanartApi::Movie.new(config)
12
12
  end
13
13
 
14
14
  def music
15
- @music ||= FanartApi::Music.new(self)
15
+ @music ||= FanartApi::Music.new(config)
16
16
  end
17
17
 
18
18
  def tv
19
- @tv ||= FanartApi::Tv.new(self)
19
+ @tv ||= FanartApi::Tv.new(config)
20
20
  end
21
21
  end
@@ -1,18 +1,110 @@
1
- # documentation: http://fanart.tv/api-docs/movie-api
2
1
  class FanartApi::Movie < FanartApi::Base
3
- def find(options = {})
2
+ include Ov
3
+
4
+ # Find specific movie data.
5
+ #
6
+ # access: FREE
7
+ # param:
8
+ # find(1234)
9
+ # output: Faraday::Response instance with Hash body
10
+ # example: http://docs.fanarttv.apiary.io/#movies
11
+ let :find, Any do |id|
12
+ find(id: id)
13
+ end
14
+
15
+
16
+ # Find specific movie data.
17
+ #
18
+ # access: FREE
19
+ # param:
20
+ # find(id: 1234)
21
+ # output: Faraday::Response instance with Hash body
22
+ # example: http://docs.fanarttv.apiary.io/#movies
23
+ let :find, Hash do |options|
4
24
  find_path_with_params(options).get
5
25
  end
6
26
 
7
- def find_url(options = {})
27
+ # Find specific movie data - return only url.
28
+ #
29
+ # access: FREE
30
+ # param:
31
+ # find_url(1234)
32
+ # output: url string
33
+ let :find_url, Any do |id|
34
+ find_url(id: id)
35
+ end
36
+
37
+ # Find specific movie data - return only url.
38
+ #
39
+ # access: FREE
40
+ # param:
41
+ # find_url(id: 1234)
42
+ # output: url string
43
+ let :find_url, Hash do |options|
8
44
  find_path_with_params(options).url
9
45
  end
10
46
 
11
- def latest(options = {})
47
+ # Get latest movies data.
48
+ #
49
+ # access: FREE
50
+ # param:
51
+ # latest
52
+ # output: Faraday::Response instance with Array body
53
+ # example: http://docs.fanarttv.apiary.io/#movies
54
+ let :latest do |date|
55
+ latest({})
56
+ end
57
+
58
+ # Get latest movies data.
59
+ #
60
+ # access: FREE
61
+ # param:
62
+ # latest(1234)
63
+ # output: Faraday::Response instance with Array body
64
+ # example: http://docs.fanarttv.apiary.io/#movies
65
+ let :latest, Any do |date|
66
+ latest(date: date)
67
+ end
68
+
69
+
70
+ # Get latest movies data.
71
+ #
72
+ # access: FREE
73
+ # param:
74
+ # latest(date: 1234)
75
+ # output: Faraday::Response instance with Array body
76
+ # example: http://docs.fanarttv.apiary.io/#movies
77
+ let :latest, Hash do |options|
12
78
  latest_path_with_params(options).get
13
79
  end
14
80
 
15
- def latest_url(options = {})
81
+ # Get latest movies data - return only url.
82
+ #
83
+ # access: FREE
84
+ # param:
85
+ # latest_url
86
+ # output: url string
87
+ let :latest_url do |date|
88
+ latest_url({})
89
+ end
90
+
91
+ # Get latest movies data - return only url.
92
+ #
93
+ # access: FREE
94
+ # param:
95
+ # latest_url(1234)
96
+ # output: url string
97
+ let :latest_url, Any do |date|
98
+ latest_url(date: date)
99
+ end
100
+
101
+ # Get latest movies data - return only url.
102
+ #
103
+ # access: FREE
104
+ # param:
105
+ # latest_url(date: 1234)
106
+ # output: url string
107
+ let :latest_url, Hash do |options|
16
108
  latest_path_with_params(options).url
17
109
  end
18
110
 
@@ -1,34 +1,192 @@
1
- # documentation: http://fanart.tv/api-docs/music-api
2
1
  class FanartApi::Music < FanartApi::Base
3
- def artist(options = {})
2
+ include Ov
3
+
4
+ # Find specific artist data.
5
+ #
6
+ # access: FREE
7
+ # param:
8
+ # artist(1234)
9
+ # output: Faraday::Response instance with Hash body
10
+ # example: http://docs.fanarttv.apiary.io/#music
11
+ let :artist, Any do |id|
12
+ artist(id: id)
13
+ end
14
+
15
+ # Find specific artist data.
16
+ #
17
+ # access: FREE
18
+ # param:
19
+ # artist(id: 1234)
20
+ # output: Faraday::Response instance with Hash body
21
+ # example: http://docs.fanarttv.apiary.io/#music
22
+ let :artist, Hash do |options|
4
23
  artist_path_with_params(options).get
5
24
  end
6
25
 
7
- def artist_url(options = {})
26
+ # Find specific artist data - return only url.
27
+ #
28
+ # access: FREE
29
+ # param:
30
+ # artist_url(1234)
31
+ # output: url string
32
+ let :artist_url, Any do |id|
33
+ artist_url(id: id)
34
+ end
35
+
36
+ # Find specific artist data - return only url.
37
+ #
38
+ # access: FREE
39
+ # param:
40
+ # artist_url(id: 1234)
41
+ # output: url string
42
+ let :artist_url, Hash do |options|
8
43
  artist_path_with_params(options).url
9
44
  end
10
45
 
11
- def album(options = {})
46
+ # Find specific album data.
47
+ #
48
+ # access: FREE
49
+ # param:
50
+ # album(1234)
51
+ # output: Faraday::Response instance with Hash body
52
+ # example: http://docs.fanarttv.apiary.io/#music
53
+ let :album, Any do |id|
54
+ album(id: id)
55
+ end
56
+
57
+ # Find specific album data.
58
+ #
59
+ # access: FREE
60
+ # param:
61
+ # album(id: 1234)
62
+ # output: Faraday::Response instance with Hash body
63
+ # example: http://docs.fanarttv.apiary.io/#music
64
+ let :album, Hash do |options|
12
65
  album_path_with_params(options).get
13
66
  end
14
67
 
15
- def album_url(options = {})
68
+ # Find specific album data - return only url.
69
+ #
70
+ # access: FREE
71
+ # param:
72
+ # album_url(1234)
73
+ # output: url string
74
+ let :album_url, Any do |id|
75
+ album_url(id: id)
76
+ end
77
+
78
+ # Find specific album data - return only url.
79
+ #
80
+ # access: FREE
81
+ # param:
82
+ # album_url(id: 1234)
83
+ # output: url string
84
+ let :album_url, Hash do |options|
16
85
  album_path_with_params(options).url
17
86
  end
18
87
 
19
- def label(options = {})
88
+ # Find specific label data.
89
+ #
90
+ # access: FREE
91
+ # param:
92
+ # label(1234)
93
+ # output: Faraday::Response instance with Hash body
94
+ # example: http://docs.fanarttv.apiary.io/#music
95
+ let :label, Any do |id|
96
+ label(id: id)
97
+ end
98
+
99
+ # Find specific label data.
100
+ #
101
+ # access: FREE
102
+ # param:
103
+ # label(id: 1234)
104
+ # output: Faraday::Response instance with Hash body
105
+ # example: http://docs.fanarttv.apiary.io/#music
106
+ let :label, Hash do |options|
20
107
  label_path_with_params(options).get
21
108
  end
22
109
 
23
- def label_url(options = {})
110
+ # Find specific label data - return only url.
111
+ #
112
+ # access: FREE
113
+ # param:
114
+ # label_url(1234)
115
+ # output: url string
116
+ let :label_url, Any do |id|
117
+ label_url(id: id)
118
+ end
119
+
120
+ # Find specific label data - return only url.
121
+ #
122
+ # access: FREE
123
+ # param:
124
+ # label_url(id: 1234)
125
+ # output: url string
126
+ let :label_url, Hash do |options|
24
127
  label_path_with_params(options).url
25
128
  end
26
129
 
27
- def latest(options = {})
130
+ # Get latest artists data.
131
+ #
132
+ # access: FREE
133
+ # param:
134
+ # latest
135
+ # output: Faraday::Response instance with Array body
136
+ # example: http://docs.fanarttv.apiary.io/#tv
137
+ let :latest do |date|
138
+ latest({})
139
+ end
140
+
141
+ # Get latest artists data.
142
+ #
143
+ # access: FREE
144
+ # param:
145
+ # latest(1234)
146
+ # output: Faraday::Response instance with Array body
147
+ # example: http://docs.fanarttv.apiary.io/#tv
148
+ let :latest, Any do |date|
149
+ latest(date: date)
150
+ end
151
+
152
+ # Get latest artists data.
153
+ #
154
+ # access: FREE
155
+ # param:
156
+ # latest(date: 1234)
157
+ # output: Faraday::Response instance with Array body
158
+ # example: http://docs.fanarttv.apiary.io/#tv
159
+ let :latest, Hash do |options|
28
160
  latest_path_with_params(options).get
29
161
  end
30
162
 
31
- def latest_url(options = {})
163
+ # Get latest artists data - return only url.
164
+ #
165
+ # access: FREE
166
+ # param:
167
+ # latest_url
168
+ # output: url string
169
+ let :latest_url do |date|
170
+ latest_url({})
171
+ end
172
+
173
+ # Get latest artists data - return only url.
174
+ #
175
+ # access: FREE
176
+ # param:
177
+ # latest_url(1234)
178
+ # output: url string
179
+ let :latest_url, Any do |date|
180
+ latest_url(date: date)
181
+ end
182
+
183
+ # Get latest artists data - return only url.
184
+ #
185
+ # access: FREE
186
+ # param:
187
+ # latest_url(date: 1234)
188
+ # output: url string
189
+ let :latest_url, Hash do |options|
32
190
  latest_path_with_params(options).url
33
191
  end
34
192