Permalink
Browse files

adjust urls for artist and release image sizes "on the fly"

  • Loading branch information...
1 parent 3b4cca0 commit 53fb8cd601502ed5eb9a8833436667629afaddea filip committed Sep 20, 2012
View
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = ["README.rdoc"]
s.add_dependency('oauth', '>= 0.4.5')
s.add_dependency('nokogiri', '>= 1.5.0')
- s.add_dependency('will_paginate', '>= 2.3.15')
+ s.add_development_dependency('will_paginate', '>= 2.3.15')
s.add_development_dependency('yard', '>= 0.6.0')
s.homepage = "http://github.com/filip7d/7digital"
s.rdoc_options = ["--main", "README.rdoc"]
View
@@ -4,22 +4,29 @@ This is a ruby wrapper for the 7digital API.
==About 7digital
-7digital.com is an online music store operating in over 16 countries and offering more than 11 million high quality DRM free MP3s (320kbps) from all major labels and wide range of idependent labels and distributors. 7digital API will give you access to the full catalogue including high quality album art, 30s preview clips for all tracks, commissions on sales, integrated purchasing and full length streaming. More details at http://developer.7digital.net
+7digital.com is an online music store operating in over 30 countries and offering more than 20 million high quality DRM free MP3s (320kbps) from all major labels and wide range of idependent labels and distributors. 7digital API will give you access to the full catalogue including high quality album art, 30s preview clips for all tracks, commissions on sales, integrated purchasing and full length streaming. More details at http://developer.7digital.net
==Installation
gem install 7digital
+
==Quick start example
require "sevendigital"
+
api_client = Sevendigital::Client.new(:oauth_consumer_key => "YOUR_KEY_HERE", :country => "GB")
+
an_artist = api_client.artist.search("radiohead").first
+
a_release = an_artist.releases(:page_size=>100).sort_by{|release| release.year}.last
+
puts "the latest #{an_artist.name} release is #{a_release.title} from #{a_release.year}"
+
puts "go and buy it at #{a_release.url} !"
+
==Usage details
===Initializing & configuring an API Client
@@ -52,6 +52,11 @@ class Artist < SevendigitalObject
#@return [Array<Artist>] similar
sevendigital_extended_property :tags
+ def image(image_size = nil)
+ return @image.gsub(/_\d+\.jpg/, "_#{image_size}.jpg") if image_size
+ @image
+ end
+
#populates all available details on artist by calling *artist/details* API method
#@return [Artist]
def get_details(options={})
@@ -17,6 +17,11 @@ def get_details(options={})
@price = release_with_details.instance_variable_get("@price")
release_with_details
end
+
+ def image(image_size = nil)
+ return @image.gsub(/_\d+\.jpg/, "_#{image_size}.jpg") if image_size
+ @image
+ end
def get_tracks(options={})
@api_client.release.get_tracks(@id, options)
View
@@ -122,7 +122,15 @@
end
+ it "image should return link to image with specified image size" do
+ release = fake_release_with_details
+ release.image(333).should == "http://cdn.7static.com/static/img/artistimages/00/000/000/0000000001_333.jpg"
+ end
+ it "image should return link to image with returned image size" do
+ release = fake_release_with_details
+ release.image.should == "http://cdn.7static.com/static/img/artistimages/00/000/000/0000000001_300.jpg"
+ end
def fake_track_list
tracks = Array.new
@@ -148,7 +156,7 @@ def fake_artist_list
def fake_artist_with_details
artist = Sevendigital::Artist.new(@client)
artist.sort_name = "The, The"
- artist.image = "image"
+ artist.image = "http://cdn.7static.com/static/img/artistimages/00/000/000/0000000001_300.jpg"
artist.url = "url"
artist
end
View
@@ -85,8 +85,19 @@
}
@release.get_tags(expected_options)
+ end
+
+ it "image should return link to image with specified image size" do
+ release = fake_release_with_details
+ release.image(333).should == "http://cdn.7static.com/static/img/sleeveart/00/008/097/0000809794_333.jpg"
+ end
+
+ it "image should return link to image with returned image size" do
+ release = fake_release_with_details
+ release.image(333).should == "http://cdn.7static.com/static/img/sleeveart/00/008/097/0000809794_100.jpg"
end
+
def fake_releases_list
releases = Array.new
releases << Sevendigital::Release.new(@client)
@@ -106,7 +117,7 @@ def fake_release_with_details
release.version = "(release version)"
release.type = :album
release.artist = Sevendigital::Artist.new(@client)
- release.image = "image"
+ release.image = "http://cdn.7static.com/static/img/sleeveart/00/008/097/0000809794_100.jpg"
release.url = "url"
release.release_date = DateTime.new(2010, 1, 1)
release.added_date = DateTime.new(2000, 1, 1)

0 comments on commit 53fb8cd

Please sign in to comment.