ruby_deezer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,10 +8,63 @@ RubyDeezer is a ruby wrapper for the Deezer APIs ( http://www.deezer.com/en/#dev
8
8
 
9
9
  == Usage
10
10
 
11
- RubyDeezer::Artist.find(13)
12
- RubyDeezer::Artist.search("eminem", {:per_page => 10, :page => 1}) # options can be skipped, default is 10 per page
11
+ require "ruby_deezer"
12
+
13
+ artist = RubyDeezer::Artist.find(13, ["similar_artists", "discography", "discography_details"]) # array option is optional
14
+
15
+ >> artist.name
16
+ "Eminem"
17
+ >> artist.url
18
+ "http://www.deezer.com/en/music/eminem"
19
+ >> artist.image
20
+ "http://cdn-images.deezer.com/images/artist/cb286a88a55a10847d1ac0f47798380c/90x90-000000-80-0-0.jpg"
21
+ >> artist.id
22
+ 13
23
+ >> artist.similar_artists.map(&:name)
24
+ [
25
+ [0] "50 Cent",
26
+ [1] "Obie Trice",
27
+ [2] "Stat Quo",
28
+ [3] "Benzino",
29
+ [4] "Dr. Dre",
30
+ [5] "Proof",
31
+ [6] "2Pac",
32
+ [7] "Cashis",
33
+ [8] "Bizarre",
34
+ [9] "Xzibit"
35
+ ]
36
+ >> artist.albums.map(&:name)
37
+ [
38
+ [0] "Recovery (2010)",
39
+ [1] "Relapse: Refill (2009)",
40
+ [2] "Relapse (2009)",
41
+ [3] "Eminem Presents The Re-Up (2006)",
42
+ [4] "Curtain Call (2005)",
43
+ [5] "Encore (2004)",
44
+ [6] "Intl Singles Box Set (2003)",
45
+ [7] "Oyun Senin (2003)",
46
+ [8] "The Eminem Show (2002)",
47
+ [9] "The Eminem Show (Deluxe Ed.) (2002)"
48
+ ]
49
+
50
+ artists = RubyDeezer::Artist.search("eminem", {:per_page => 10, :page => 1}) # options can be skipped, default is 10 per page
51
+
52
+ >> artists.map(&:name)
53
+ [
54
+ [0] "Eminem",
55
+ [1] "Various Artists - Eminem Tribute",
56
+ [2] "Dr. Dre, 50 Cent, Eminem",
57
+ [3] "Xzibit Featuring Eminem & Nate Dogg",
58
+ [4] "Drake, Eminem, Kanye West, Lil Wayne",
59
+ [5] "Dr. Dre, Eminem, 50 Cent",
60
+ [6] "Eminem, Cashis, 50 Cent, Lloyd Banks",
61
+ [7] "Dmx, Obie Trice, Eminem",
62
+ [8] "Missy Elliott / Eminem",
63
+ [9] "Lil Wayne, Drake, Kanye West, Eminem"
64
+ ]
65
+
13
66
 
14
- RubyDeezer::Album.find(13)
67
+ RubyDeezer::Album.find(13, ["tracks"]) # array option is optional
15
68
  RubyDeezer::Album.search("eminem", {:per_page => 10, :page => 1}) # options can be skipped, default is 10 per page
16
69
 
17
70
  RubyDeezer::Track.find(13)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -31,7 +31,8 @@ module RubyDeezer
31
31
 
32
32
  def self.init_from_hash(hash)
33
33
  return nil unless hash.is_a?(Hash)
34
- tracks = hash["tracks"] || []
34
+ tracks = hash["tracks"] || {}
35
+ tracks_array = tracks["track"] || []
35
36
  artist = hash["artist"] || {}
36
37
  Album.new.tap do |album|
37
38
  album.id = hash["id"].to_i
@@ -41,7 +42,7 @@ module RubyDeezer
41
42
  album.nb_tracks = hash["nb_tracks"].to_i
42
43
  album.nb_disks = hash["nb_disks"].to_i
43
44
  album.year = hash["year"].to_i
44
- album.tracks = tracks.inject([]) {|arr, track| arr << Track.init_from_hash(track); arr}
45
+ album.tracks = tracks_array.inject([]) {|arr, track| arr << Track.init_from_hash(track); arr}
45
46
  album.artist = Artist.init_from_hash(artist)
46
47
  end
47
48
  end
Binary file
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby_deezer}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aleksandr Lossenko"]
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "lib/ruby_deezer/artist.rb",
29
29
  "lib/ruby_deezer/track.rb",
30
30
  "pkg/ruby_deezer-0.1.0.gem",
31
+ "pkg/ruby_deezer-0.1.1.gem",
31
32
  "ruby_deezer.gemspec",
32
33
  "test/fixtures/album.json",
33
34
  "test/fixtures/albums.json",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aleksandr Lossenko
@@ -120,6 +120,7 @@ files:
120
120
  - lib/ruby_deezer/artist.rb
121
121
  - lib/ruby_deezer/track.rb
122
122
  - pkg/ruby_deezer-0.1.0.gem
123
+ - pkg/ruby_deezer-0.1.1.gem
123
124
  - ruby_deezer.gemspec
124
125
  - test/fixtures/album.json
125
126
  - test/fixtures/albums.json