coverart 0.0.4

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c27208a52cad6e750a836f14369e2fc289f74b81
4
+ data.tar.gz: 3dc1a9c30d07979258416c6ab03941d727ba4a51
5
+ SHA512:
6
+ metadata.gz: ae64811fd4d7ab482de42357c3f2f277e4577ab8ebcb6d1fec95fd55cc355ced5cc22dfc221334b3d8be5b37a5087548bd6bf8442ed3006009ab994d4d4175b7
7
+ data.tar.gz: 11f8a3045447a36c209482a66558b00e9d5d4c116fa43c09d0bcc9080a11b1335721b90f5feff58c1d8cc0f4f201a1e2930575a9c799f61a2658254d47d09e61
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'rspec'
5
+ gem 'webmock'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Savater Sebastien
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Cover Art
2
+
3
+ A tiny client for the [Cover Art Archive](http://coverartarchive.org) web service.
4
+
5
+ It works great with the [Musicbrainz clien](https://github.com/inkstak/coverart).
6
+
7
+ [![Build Status](https://travis-ci.org/inkstak/coverart.svg)](https://travis-ci.org/inkstak/coverart)
8
+ [![Gem Version](https://badge.fury.io/rb/coverart.png)](http://badge.fury.io/rb/coverart)
9
+
10
+ ### Ruby Version
11
+
12
+ Ruby version 1.9.0+ required.
13
+
14
+ ### Installation
15
+
16
+ Is this really necessary to explain ?
17
+
18
+ gem install coverart
19
+
20
+
21
+ ### Usage
22
+
23
+ Read the [JSON API manual](http://wiki.musicbrainz.org/Cover_Art_Archive/API)
24
+
25
+ require 'coverart'
26
+ api = CoverArt::Client.new
27
+ api.get '/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd'
28
+
29
+
30
+ You can also use shortcuts :
31
+
32
+ # Get the front image URL
33
+ api.front '76df3287-6cda-33eb-8e9a-044b5e15ffdd'
34
+
35
+ # Get the back image URL
36
+ api.back '99b09d02-9cc9-3fed-8431-f162165a9371'
37
+
38
+ # Get the front image URL for a release group
39
+ api.group '76df3287-6cda-33eb-8e9a-044b5e15ffdd'
40
+
41
+
42
+ ### Caching & middlewares
43
+
44
+ In order to perform caching, you can use [faraday_middleware](http://github.com/lostisland/faraday_middleware)
45
+ or your own middlewares:
46
+
47
+ # Please note that faraday_middleware and active_support are not included as dependencies
48
+ # you may install them
49
+
50
+ require 'coverart'
51
+ require 'faraday_middleware'
52
+ require 'active_support'
53
+
54
+ api = CoverArt::Client.new do |f|
55
+ f.response :caching do
56
+ ActiveSupport::Cache.lookup_store :file_store, './tmp/cache', namespace: 'covertart', expires_in: 3600
57
+ end
58
+ end
59
+
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
data/coverart.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../lib/coverart/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'coverart'
5
+ s.version = CoverArt::VERSION
6
+
7
+ s.authors = ['Savater Sebastien']
8
+ s.email = 'savater.sebastien@gmail.com'
9
+
10
+ s.homepage = 'http://github.com/inkstak/coverart'
11
+ s.summary = 'A tiny client for the Cover Art Archive web service'
12
+ s.license = 'MIT'
13
+
14
+ s.files = %w(Gemfile LICENSE README.md coverart.gemspec)
15
+ s.files += Dir.glob('lib/**/*')
16
+
17
+ s.add_dependency 'faraday'
18
+ end
@@ -0,0 +1,43 @@
1
+ module CoverArt
2
+ class Client
3
+ ENDPOINT = 'http://coverartarchive.org'
4
+
5
+ attr_reader :http
6
+
7
+ def initialize &block
8
+ @http ||= Faraday.new url: ENDPOINT do |f|
9
+ yield f if block_given?
10
+ f.adapter Faraday.default_adapter
11
+ end
12
+ end
13
+
14
+ def get url
15
+ response = http.get url
16
+
17
+ case response.status
18
+ when 404 then nil
19
+ when 200 then JSON.parse response.body
20
+ when 300..310
21
+ if response.headers[:location].match /\.(jpg|jpeg|png|gif)/
22
+ response.headers[:location]
23
+ else
24
+ get response.headers[:location]
25
+ end
26
+ else
27
+ raise "Unexpected response (#{ response.status }) at #{ url }"
28
+ end
29
+ end
30
+
31
+ def front mbid
32
+ get "/release/#{ mbid }/front"
33
+ end
34
+
35
+ def back mbid
36
+ get "/release/#{ mbid }/back"
37
+ end
38
+
39
+ def group mbid
40
+ get "/release-group/#{ mbid }/front"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module CoverArt
2
+ VERSION = '0.0.4'
3
+ end
data/lib/coverart.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'coverart/client'
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coverart
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Savater Sebastien
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email: savater.sebastien@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - coverart.gemspec
37
+ - lib/coverart.rb
38
+ - lib/coverart/client.rb
39
+ - lib/coverart/version.rb
40
+ homepage: http://github.com/inkstak/coverart
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.2.2
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: A tiny client for the Cover Art Archive web service
64
+ test_files: []