sandro-metamuse 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/metamuse/album.rb +7 -3
- data/lib/metamuse/artist.rb +8 -0
- data/metamuse.gemspec +2 -2
- data/spec/metamuse/album_spec.rb +31 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/metamuse/album.rb
CHANGED
@@ -7,10 +7,14 @@ module Metamuse
|
|
7
7
|
attr_accessor :name, :release_date, :freebase_id, :mbid, :rank, :images
|
8
8
|
|
9
9
|
def <=>(other)
|
10
|
-
if rank
|
11
|
-
rank <=> other.rank
|
10
|
+
if rank && other.rank
|
11
|
+
rank.to_i <=> other.rank.to_i
|
12
|
+
elsif rank
|
13
|
+
-1
|
14
|
+
elsif other.rank
|
15
|
+
1
|
12
16
|
else
|
13
|
-
|
17
|
+
0
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
data/lib/metamuse/artist.rb
CHANGED
@@ -34,8 +34,16 @@ module Metamuse
|
|
34
34
|
self.albums = artist.albums
|
35
35
|
end
|
36
36
|
|
37
|
+
def inspect
|
38
|
+
"#<#{self.class.inspect}:#{object_id.inspect}, name: #{name.inspect}, echonest_id: #{echonest_id.inspect}, freebase_guid: #{freebase_guid.inspect}, mbid: #{mbid.inspect}, albums: #{album_names.inspect}>"
|
39
|
+
end
|
40
|
+
|
37
41
|
private
|
38
42
|
|
43
|
+
def album_names
|
44
|
+
@album_names ||= albums.map {|a| a.name}
|
45
|
+
end
|
46
|
+
|
39
47
|
def lastfm_albums
|
40
48
|
@lastfm_albums ||= Services::Lastfm.top_albums(name)
|
41
49
|
end
|
data/metamuse.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{metamuse}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sandro Turriate"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-24}
|
10
10
|
s.email = %q{sandro.turriate@gmail.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"README.rdoc"
|
data/spec/metamuse/album_spec.rb
CHANGED
@@ -1,4 +1,35 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe Metamuse::Album do
|
4
|
+
describe "#<=>" do
|
5
|
+
context "comparing nil ranks" do
|
6
|
+
before do
|
7
|
+
@nil1 = Metamuse::Album.new :rank => nil
|
8
|
+
@nil2 = Metamuse::Album.new :rank => nil
|
9
|
+
@album1 = Metamuse::Album.new(:rank => 1)
|
10
|
+
@album3 = Metamuse::Album.new(:rank => 3)
|
11
|
+
@album5 = Metamuse::Album.new(:rank => 5)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "moves the nil from the beginning to the end" do
|
15
|
+
collection = [@nil1, @album5, @album1, @album3]
|
16
|
+
collection.sort.should == [@album1, @album3, @album5, @nil1]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "leaves the nil at the end" do
|
20
|
+
collection = [@album5, @album1, @album3, @nil1]
|
21
|
+
collection.sort.should == [@album1, @album3, @album5, @nil1]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "moves the nil from the middle to the end" do
|
25
|
+
collection = [@album5, @album1, @nil1, @album3]
|
26
|
+
collection.sort.should == [@album1, @album3, @album5, @nil1]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "moves both nils to the end" do
|
30
|
+
collection = [@nil2, @album5, @album1, @nil1, @album3]
|
31
|
+
collection.sort.should == [@album1, @album3, @album5, @nil1, @nil2]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
4
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandro-metamuse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Turriate
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|