fanart_tv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@fanart --create
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "faraday"
4
+ gem "faraday_middleware"
5
+ gem "json"
6
+
7
+ group :development do
8
+ gem "minitest"
9
+ gem "rdoc"
10
+ gem "bundler"
11
+ gem "jeweler"
12
+ gem "fakeweb"
13
+ end
@@ -0,0 +1,33 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ fakeweb (1.3.0)
5
+ faraday (0.8.4)
6
+ multipart-post (~> 1.1)
7
+ faraday_middleware (0.9.0)
8
+ faraday (>= 0.7.4, < 0.9)
9
+ git (1.2.5)
10
+ jeweler (1.8.4)
11
+ bundler (~> 1.0)
12
+ git (>= 1.2.5)
13
+ rake
14
+ rdoc
15
+ json (1.7.6)
16
+ minitest (4.3.3)
17
+ multipart-post (1.1.5)
18
+ rake (10.0.3)
19
+ rdoc (3.12)
20
+ json (~> 1.4)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ bundler
27
+ fakeweb
28
+ faraday
29
+ faraday_middleware
30
+ jeweler
31
+ json
32
+ minitest
33
+ rdoc
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Aleksandr Lossenko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ = fanart_tv
2
+
3
+ A ruby wrapper for fanart.tv API. http://fanart.tv
4
+
5
+ == Installation
6
+
7
+ gem install fanart_tv
8
+
9
+ or add this line to your Gemfile
10
+
11
+ gem "fanart_tv"
12
+
13
+ == Configuration
14
+
15
+ FanartTv.configure do |c|
16
+ # Application identity (required)
17
+ c.app_name = "Your App Name"
18
+ c.app_version = "1.0"
19
+ c.contact = "Your email, or website"
20
+
21
+ # Cache config (optional)
22
+ c.cache_path = "/tmp/musicbrainz-cache"
23
+ c.perform_caching = true
24
+
25
+ c.api_key = "Your API key for fanart.tv"
26
+ end
27
+
28
+ == Usage
29
+
30
+ require "fanart_tv"
31
+
32
+ # Search for artist by musicbrainz_id
33
+ @evanescence = FanartTv::Artist.find("f4a31f0a-51dd-4fa7-986d-3095c40c5ed9")
34
+
35
+ == Api
36
+
37
+ === FanartTv::Artist
38
+
39
+ @artist = FanartTv::Artist.find(musicbrainz_id)
40
+
41
+
42
+ == Contributing to fanart_tv
43
+
44
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
45
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
46
+ * Fork the project.
47
+ * Start a feature/bugfix branch.
48
+ * Commit and push until you are happy with your contribution.
49
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
50
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "fanart_tv"
18
+ gem.homepage = "http://github.com/egze/fanart_tv"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A ruby wrapper for fanart.tv API.}
21
+ gem.description = %Q{A ruby wrapper for fanart.tv API.}
22
+ gem.email = "aleksandr.lossenko@gmail.com"
23
+ gem.authors = ["Aleksandr Lossenko"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'rdoc/task'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "fanart_tv #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,82 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fanart_tv"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Aleksandr Lossenko"]
12
+ s.date = "2013-01-03"
13
+ s.description = "A ruby wrapper for fanart.tv API."
14
+ s.email = "aleksandr.lossenko@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rvmrc",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "fanart_tv.gemspec",
29
+ "lib/fanart_tv.rb",
30
+ "lib/fanart_tv/bindings/artist.rb",
31
+ "lib/fanart_tv/client.rb",
32
+ "lib/fanart_tv/client_modules/transparent_proxy.rb",
33
+ "lib/fanart_tv/configuration.rb",
34
+ "lib/fanart_tv/models/album.rb",
35
+ "lib/fanart_tv/models/artist.rb",
36
+ "lib/fanart_tv/models/base_model.rb",
37
+ "lib/fanart_tv/models/photo.rb",
38
+ "lib/fanart_tv/version.rb",
39
+ "test/fixtures/artist.json",
40
+ "test/helper.rb",
41
+ "test/test_artist.rb"
42
+ ]
43
+ s.homepage = "http://github.com/egze/fanart_tv"
44
+ s.licenses = ["MIT"]
45
+ s.require_paths = ["lib"]
46
+ s.rubygems_version = "1.8.24"
47
+ s.summary = "A ruby wrapper for fanart.tv API."
48
+
49
+ if s.respond_to? :specification_version then
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_runtime_dependency(%q<faraday>, [">= 0"])
54
+ s.add_runtime_dependency(%q<faraday_middleware>, [">= 0"])
55
+ s.add_runtime_dependency(%q<json>, [">= 0"])
56
+ s.add_development_dependency(%q<minitest>, [">= 0"])
57
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
58
+ s.add_development_dependency(%q<bundler>, [">= 0"])
59
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
60
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
61
+ else
62
+ s.add_dependency(%q<faraday>, [">= 0"])
63
+ s.add_dependency(%q<faraday_middleware>, [">= 0"])
64
+ s.add_dependency(%q<json>, [">= 0"])
65
+ s.add_dependency(%q<minitest>, [">= 0"])
66
+ s.add_dependency(%q<rdoc>, [">= 0"])
67
+ s.add_dependency(%q<bundler>, [">= 0"])
68
+ s.add_dependency(%q<jeweler>, [">= 0"])
69
+ s.add_dependency(%q<fakeweb>, [">= 0"])
70
+ end
71
+ else
72
+ s.add_dependency(%q<faraday>, [">= 0"])
73
+ s.add_dependency(%q<faraday_middleware>, [">= 0"])
74
+ s.add_dependency(%q<json>, [">= 0"])
75
+ s.add_dependency(%q<minitest>, [">= 0"])
76
+ s.add_dependency(%q<rdoc>, [">= 0"])
77
+ s.add_dependency(%q<bundler>, [">= 0"])
78
+ s.add_dependency(%q<jeweler>, [">= 0"])
79
+ s.add_dependency(%q<fakeweb>, [">= 0"])
80
+ end
81
+ end
82
+
@@ -0,0 +1,16 @@
1
+ require 'json'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+
5
+ require "fanart_tv/version"
6
+ require "fanart_tv/configuration"
7
+
8
+ require "fanart_tv/client_modules/transparent_proxy"
9
+ require "fanart_tv/client"
10
+
11
+ require "fanart_tv/models/base_model"
12
+ require "fanart_tv/models/artist"
13
+ require "fanart_tv/models/photo"
14
+ require "fanart_tv/models/album"
15
+
16
+ require "fanart_tv/bindings/artist"
@@ -0,0 +1,12 @@
1
+ # encoding: UTF-8
2
+ module FanartTv
3
+ module Bindings
4
+ module Artist
5
+ def parse(json)
6
+ json[json.keys[0]]
7
+ end
8
+
9
+ extend self
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,49 @@
1
+ module FanartTv
2
+ module Client
3
+ def http
4
+ @faraday ||= Faraday.new do |f|
5
+ f.request :json
6
+ #f.use :instrumentation
7
+ f.adapter Faraday.default_adapter # make requests with Net::HTTP
8
+ f.response :json
9
+ #f.use FanartTv::Middleware # run requests with correct headers
10
+ end
11
+ end
12
+
13
+ def load(resource, query, params)
14
+ raise Exception.new("You need to run FanartTv.configure before querying") if FanartTv.config.nil?
15
+
16
+ response = contents_of(build_url(params[:url], query))
17
+ data = params[:binding].parse(response.body)
18
+
19
+ if params[:create_model]
20
+ params[:create_model].new(data)
21
+ elsif params[:create_models]
22
+ models = data.map{ |item| params[:create_models].new(item) }
23
+ models.sort!{ |a, b| a.send(params[:sort]) <=> b.send(params[:sort]) } if params[:sort]
24
+ models
25
+ else
26
+ data
27
+ end
28
+ rescue Faraday::Error::ParsingError
29
+ nil
30
+ end
31
+
32
+ def contents_of(url)
33
+ if method_defined? :get_contents
34
+ get_contents url
35
+ else
36
+ http.get url
37
+ end
38
+ end
39
+
40
+ def build_url(url, params)
41
+ url % params.merge({api_key: FanartTv.config.api_key})
42
+ end
43
+
44
+ include ClientModules::TransparentProxy
45
+ #include ClientModules::FailsafeProxy
46
+ #include ClientModules::CachingProxy
47
+ extend self
48
+ end
49
+ end
@@ -0,0 +1,9 @@
1
+ module FanartTv
2
+ module ClientModules
3
+ module TransparentProxy
4
+ def get_contents(url)
5
+ http.get url
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,47 @@
1
+ module FanartTv
2
+ class Configuration
3
+ attr_accessor :app_name, :app_version, :contact,
4
+ :api_key, :webservice_url_artist,
5
+ :query_interval, :tries_limit,
6
+ :cache_path, :perform_caching
7
+
8
+ DEFAULT_QUERY_INTERVAL = 1.5
9
+ DEFAULT_TRIES_LIMIT = 5
10
+ DEFAULT_CACHE_PATH = File.join(File.dirname(__FILE__), "..", "tmp", "cache")
11
+ DEFAULT_PERFORM_CACHING = false
12
+ DEFAULT_WEBSERVICE_URL_ARTIST = "http://api.fanart.tv/webservice/artist/%{api_key}/%{musicbrainz_id}/JSON/%{type}/%{sort}/%{limit}/"
13
+
14
+ def initialize
15
+ @webservice_url_artist = DEFAULT_WEBSERVICE_URL_ARTIST
16
+ @query_interval = DEFAULT_QUERY_INTERVAL
17
+ @tries_limit = DEFAULT_TRIES_LIMIT
18
+ @cache_path = DEFAULT_CACHE_PATH
19
+ @perform_caching = DEFAULT_PERFORM_CACHING
20
+ end
21
+
22
+ def api_key
23
+ raise "api_key must be set" if @api_key.nil?
24
+ @api_key
25
+ end
26
+
27
+ def user_agent_string
28
+ %w[ app_name app_version contact ].each do |param|
29
+ raise "#{param} must be set" if instance_variable_get("@#{param}").nil?
30
+ end
31
+
32
+ "#{@app_name}/#{@app_version} ( #{@contact} )"
33
+ end
34
+ end
35
+
36
+ module Configurable
37
+ def configure
38
+ raise "Configuration missing" unless block_given?
39
+ yield @config ||= FanartTv::Configuration.new
40
+ end
41
+
42
+ def config
43
+ @config
44
+ end
45
+ end
46
+ extend Configurable
47
+ end
@@ -0,0 +1,18 @@
1
+ module FanartTv
2
+ class Album
3
+ include BaseModel
4
+
5
+ field :mbid_id, String
6
+ field :albumcover, Array
7
+ field :cdart, Array
8
+
9
+ def albumcover=(value)
10
+ @albumcover = (value || []).map {|ml| FanartTv::Photo.new(ml) }
11
+ end
12
+
13
+ def cdart=(value)
14
+ @cdart = (value || []).map {|ml| FanartTv::Photo.new(ml) }
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,49 @@
1
+ module FanartTv
2
+ class Artist
3
+ include BaseModel
4
+
5
+ field :mbid_id, String
6
+ field :musiclogo, Array
7
+ field :artistbackground, Array
8
+ field :artistthumb, Array
9
+ field :albums, Array
10
+ field :hdmusiclogo, Array
11
+ field :musicbanner, Array
12
+
13
+ private
14
+ def musiclogo=(value)
15
+ @musiclogo = (value || []).map {|ml| FanartTv::Photo.new(ml) }
16
+ end
17
+
18
+ def artistbackground=(value)
19
+ @artistbackground = (value || []).map {|ml| FanartTv::Photo.new(ml) }
20
+ end
21
+
22
+ def artistthumb=(value)
23
+ @artistthumb = (value || []).map {|ml| FanartTv::Photo.new(ml) }
24
+ end
25
+
26
+ def albums=(value)
27
+ @albums = []
28
+ (value || {}).each {|k,v| @albums << FanartTv::Album.new(v.merge({mbid_id: k})) }
29
+ end
30
+
31
+ def hdmusiclogo=(value)
32
+ @hdmusiclogo = (value || []).map {|ml| FanartTv::Photo.new(ml) }
33
+ end
34
+
35
+ def musicbanner=(value)
36
+ @musicbanner = (value || []).map {|ml| FanartTv::Photo.new(ml) }
37
+ end
38
+
39
+ class << self
40
+ def find(id, type="all", sort=1, limit=1)
41
+ Client.load(:artist, { musicbrainz_id: id, type: type, sort: sort, limit: limit}, {
42
+ binding: FanartTv::Bindings::Artist,
43
+ create_model: FanartTv::Artist,
44
+ url: FanartTv.config.webservice_url_artist
45
+ })
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ module FanartTv
2
+ module BaseModel
3
+ def self.included(klass)
4
+ klass.send(:include, InstanceMethods)
5
+ klass.send(:extend, ClassMethods)
6
+ end
7
+
8
+ module ClassMethods
9
+ def field(name, type)
10
+ self.class_exec do
11
+ attr_reader name
12
+
13
+ define_method("#{name}=") do |val|
14
+ instance_variable_set("@#{name}", validate_type(val, type))
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ module InstanceMethods
21
+ def initialize(params = {})
22
+ params.each do |field, value|
23
+ self.send :"#{field}=", value
24
+ end
25
+ end
26
+
27
+ def validate_type(val, type)
28
+ if type == Integer
29
+ val.to_i
30
+ elsif type == Float
31
+ val.to_f
32
+ elsif type == String
33
+ val.to_s
34
+ elsif type == Time
35
+ if val.nil? or val == ""
36
+ val = "2030-12-31"
37
+ elsif val.split("-").length == 1
38
+ val << "-12-31"
39
+ elsif val.split("-").length == 2
40
+ val << "-31"
41
+ end
42
+ Time.utc(*val.split("-"))
43
+ else
44
+ val
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,12 @@
1
+ module FanartTv
2
+ class Photo
3
+ include BaseModel
4
+
5
+ field :id, Integer
6
+ field :url, String
7
+ field :likes, Integer
8
+ field :disc, Integer
9
+ field :size, Integer
10
+
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module FanartTv
2
+
3
+ VERSION = Gem::Specification::load("fanart_tv.gemspec").version.to_s
4
+
5
+ end
@@ -0,0 +1 @@
1
+ {"Evanescence":{"mbid_id":"f4a31f0a-51dd-4fa7-986d-3095c40c5ed9","musiclogo":[{"id":"5474","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/musiclogo/5474/evanescence-4df95bceb4b1c.png","likes":"2"},{"id":"5239","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/musiclogo/5239/evanescence-4df6263dee3c6.png","likes":"1"},{"id":"27702","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/musiclogo/27702/evanescence-4f8acb2ae6002.png","likes":"1"}],"artistbackground":[{"id":"6","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/6/evanescence-4dc7198199ccd.jpg","likes":"1"},{"id":"9","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/9/evanescence-4dc719c5cc68f.jpg","likes":"1"},{"id":"8588","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/8588/evanescence-4e483b0e8633f.jpg","likes":"1"},{"id":"14196","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14196/evanescence-4ec894676162e.jpeg","likes":"1"},{"id":"5","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/5/evanescence-4dc7197019e85.jpg","likes":"0"},{"id":"7","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/7/evanescence-4dc719b1d861a.jpg","likes":"0"},{"id":"10","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/10/evanescence-4dc71a04e1e89.jpg","likes":"0"},{"id":"3396","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/3396/evanescence-4ddfd78af0fd3.jpg","likes":"0"},{"id":"5475","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/5475/evanescence-4df95ca6e7111.jpg","likes":"0"},{"id":"5476","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/5476/evanescence-4df95caedbaf5.jpg","likes":"0"},{"id":"5478","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/5478/evanescence-4df95cbf30fa0.jpg","likes":"0"},{"id":"8589","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/8589/evanescence-4e483b19c707e.jpg","likes":"0"},{"id":"14175","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14175/evanescence-4ec7ffe2a03c5.jpg","likes":"0"},{"id":"14176","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14176/evanescence-4ec7fff9a70b0.jpg","likes":"0"},{"id":"14177","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14177/evanescence-4ec80010aaaca.jpg","likes":"0"},{"id":"14178","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14178/evanescence-4ec800228a6cd.jpg","likes":"0"},{"id":"14179","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14179/evanescence-4ec800351536c.jpg","likes":"0"},{"id":"14195","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14195/evanescence-4ec89451be6e6.jpg","likes":"0"},{"id":"14197","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14197/evanescence-4ec894e3976de.jpg","likes":"0"},{"id":"14198","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/14198/evanescence-4ec898215a517.jpg","likes":"0"},{"id":"62542","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/62542/evanescence-50af6e9ce0c22.jpg","likes":"0"},{"id":"62543","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/62543/evanescence-50af6e9ce67ad.jpeg","likes":"0"}],"artistthumb":[{"id":"33339","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistthumb/33339/evanescence-4fc7468829e99.jpg","likes":"1"},{"id":"33340","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistthumb/33340/evanescence-4fc746882a7fe.jpg","likes":"1"},{"id":"34596","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistthumb/34596/evanescence-4fcbdd28a70c4.jpg","likes":"1"},{"id":"60344","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistthumb/60344/evanescence-5097c77793b6f.jpg","likes":"1"},{"id":"33338","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistthumb/33338/evanescence-4fc74688241ad.jpg","likes":"0"},{"id":"34595","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistthumb/34595/evanescence-4fcbdd16176f9.jpg","likes":"0"}],"albums":{"2187d248-1a3b-35d0-a4ec-bead586ff547":{"albumcover":[{"id":"43","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/43/fallen-4dc8683fa58fe.jpg","likes":"0"}],"cdart":[{"id":"17739","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/17739/fallen-4f133f8a16d25.png","likes":"0","disc":"1","size":"1000"}]},"e7e5eaa6-baf3-3539-b163-759431597f3a":{"albumcover":[{"id":"44","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/44/the-open-door-4dc868f23430d.jpg","likes":"0"}],"cdart":[{"id":"11882","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/11882/the-open-door-4e837a41d0937.png","likes":"0","disc":"1","size":"1000"}]},"ac7dd865-3c32-3bb9-9241-a4c63d940f67":{"cdart":[{"id":"1874","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/1874/le-nouveau-gothique-4dd43ab8d1af6.png","likes":"0","disc":"1","size":"450"}]},"9ba659df-5814-32f6-b95f-02b738698e7c":{"albumcover":[{"id":"3399","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/3399/anywhere-but-home-4ddfdc3ddfe8e.jpg","likes":"0"}],"cdart":[{"id":"12420","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/12420/anywhere-but-home-4e9a1074d0999.png","likes":"0","disc":"1","size":"1000"}]},"eab92048-3e05-3e0f-bc16-0780f5481b83":{"albumcover":[{"id":"3400","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/3400/origin-4ddfdc3de0e2e.jpg","likes":"0"}],"cdart":[{"id":"5354","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/5354/origin-4df836629a2c0.png","likes":"0","disc":"1","size":"1000"}]},"a35bcaf6-8e4a-3087-9b3b-d1295a2d4dbb":{"cdart":[{"id":"5353","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/5353/bring-me-to-life-4df8360027bb3.png","likes":"0","disc":"1","size":"1000"}],"albumcover":[{"id":"5355","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/5355/bring-me-to-life-4df8379964b33.jpg","likes":"0"}]},"bf18a287-fdec-3e65-b9f2-460b82790a16":{"albumcover":[{"id":"5356","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/5356/not-for-your-ears-4df83799656ec.jpg","likes":"0"}]},"e1c522d0-2746-3845-9b1c-975632f496bc":{"albumcover":[{"id":"5357","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/5357/beauty-in-darkness-b-sides-and-rarities-disc-2-4df837996c834.jpg","likes":"0"}],"cdart":[{"id":"12422","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/12422/beauty-in-darkness-b-sides-and-rarities-4e9a1074d8e6a.png","likes":"0","disc":"1","size":"1000"}]},"902331d8-67aa-3b3c-bb2a-786d6a66c823":{"albumcover":[{"id":"12417","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/12417/evanescence-4e9a100d800dd.jpg","likes":"0"},{"id":"14168","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/albumcover/14168/evanescence-4ec7fc1c16d26.jpg","likes":"0"}],"cdart":[{"id":"12419","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/12419/evanescence-4e9a1074cfde2.png","likes":"0","disc":"1","size":"1000"}]},"8866d307-29d3-32d5-8b1b-16d8c10a85b5":{"cdart":[{"id":"12418","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/12418/special-2004-4e9a1074c6589.png","likes":"0","disc":"1","size":"1000"}]},"a23c8be0-4aa9-3f6c-b1bc-af543a1da73d":{"cdart":[{"id":"12421","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/12421/ultra-rare-trax-volume-1-4e9a1074d82b2.png","likes":"0","disc":"1","size":"1000"}]},"b1f3d25e-80ba-47f6-b0b8-7310e0dfe3e2":{"cdart":[{"id":"14485","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/cdart/14485/evanescence-4ff862566d408.png","likes":"0","disc":"1","size":"1000"}]}},"hdmusiclogo":[{"id":"50850","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/hdmusiclogo/50850/evanescence-5049ce8bbe373.png","likes":"0"}],"musicbanner":[{"id":"56733","url":"http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/musicbanner/56733/evanescence-507beae754bf6.jpg","likes":"0"}]}}
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'fakeweb'
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+ require 'minitest/unit'
12
+
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
+ require 'fanart_tv'
16
+
17
+ FanartTv.configure do |c|
18
+ c.app_name = "FanartTvGemTestSuite"
19
+ c.app_version = FanartTv::VERSION
20
+ c.contact = "https://github.com/egze/fanart_tv"
21
+ c.perform_caching = true
22
+ c.api_key = "dummy_api_key"
23
+ end
24
+
25
+ FakeWeb.allow_net_connect = false
26
+
27
+ class MiniTest::Unit::TestCase
28
+ end
29
+
30
+ MiniTest::Unit.autorun
@@ -0,0 +1,26 @@
1
+ require 'helper'
2
+
3
+ class TestArtist < MiniTest::Unit::TestCase
4
+
5
+ def test_find_artist
6
+ FakeWeb.register_uri(:any, %r|http://api.fanart.tv/|, :body => File.read(File.dirname(__FILE__) + "/fixtures/artist.json"))
7
+
8
+ mbid_id = "f4a31f0a-51dd-4fa7-986d-3095c40c5ed9"
9
+ artist = FanartTv::Artist.find(mbid_id)
10
+ assert_equal mbid_id, artist.mbid_id
11
+ assert_equal 5474, artist.musiclogo.first.id
12
+ assert_equal "http://fanart.tv/fanart/music/f4a31f0a-51dd-4fa7-986d-3095c40c5ed9/artistbackground/6/evanescence-4dc7198199ccd.jpg", artist.artistbackground.first.url
13
+ assert_equal 1, artist.artistthumb.first.likes
14
+ assert_equal "2187d248-1a3b-35d0-a4ec-bead586ff547", artist.albums.first.mbid_id
15
+ assert_equal 43, artist.albums.first.albumcover.first.id
16
+ end
17
+
18
+ def test_find_artist_should_return_nil_if_nothing_found
19
+ FakeWeb.register_uri(:any, %r|http://api.fanart.tv/|, :body => "null")
20
+
21
+ mbid_id = "f4a31f0a-51dd-4fa7-986d-3095c40c5ed9"
22
+ artist = FanartTv::Artist.find(mbid_id)
23
+ assert_nil artist
24
+ end
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fanart_tv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aleksandr Lossenko
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: faraday_middleware
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: json
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: minitest
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rdoc
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: bundler
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: jeweler
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: fakeweb
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: A ruby wrapper for fanart.tv API.
143
+ email: aleksandr.lossenko@gmail.com
144
+ executables: []
145
+ extensions: []
146
+ extra_rdoc_files:
147
+ - LICENSE.txt
148
+ - README.rdoc
149
+ files:
150
+ - .document
151
+ - .rvmrc
152
+ - Gemfile
153
+ - Gemfile.lock
154
+ - LICENSE.txt
155
+ - README.rdoc
156
+ - Rakefile
157
+ - VERSION
158
+ - fanart_tv.gemspec
159
+ - lib/fanart_tv.rb
160
+ - lib/fanart_tv/bindings/artist.rb
161
+ - lib/fanart_tv/client.rb
162
+ - lib/fanart_tv/client_modules/transparent_proxy.rb
163
+ - lib/fanart_tv/configuration.rb
164
+ - lib/fanart_tv/models/album.rb
165
+ - lib/fanart_tv/models/artist.rb
166
+ - lib/fanart_tv/models/base_model.rb
167
+ - lib/fanart_tv/models/photo.rb
168
+ - lib/fanart_tv/version.rb
169
+ - test/fixtures/artist.json
170
+ - test/helper.rb
171
+ - test/test_artist.rb
172
+ homepage: http://github.com/egze/fanart_tv
173
+ licenses:
174
+ - MIT
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ none: false
181
+ requirements:
182
+ - - ! '>='
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ segments:
186
+ - 0
187
+ hash: 1569364256116675967
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 1.8.24
197
+ signing_key:
198
+ specification_version: 3
199
+ summary: A ruby wrapper for fanart.tv API.
200
+ test_files: []