7digital 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -7
- data/lib/sevendigital.rb +54 -53
- data/lib/sevendigital/api_operator.rb +33 -30
- data/lib/sevendigital/api_operator_cached.rb +23 -23
- data/lib/sevendigital/api_request.rb +23 -23
- data/lib/sevendigital/client.rb +136 -124
- data/lib/sevendigital/default_configuration.yml +2 -2
- data/lib/sevendigital/digestion_tract/api_response_digestor.rb +52 -52
- data/lib/sevendigital/digestion_tract/artist_digestor.rb +31 -31
- data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +27 -27
- data/lib/sevendigital/digestion_tract/digestor.rb +66 -66
- data/lib/sevendigital/digestion_tract/format_digestor.rb +21 -21
- data/lib/sevendigital/digestion_tract/label_digestor.rb +19 -19
- data/lib/sevendigital/digestion_tract/pager_digestor.rb +23 -23
- data/lib/sevendigital/digestion_tract/price_digestor.rb +24 -24
- data/lib/sevendigital/digestion_tract/release_digestor.rb +52 -52
- data/lib/sevendigital/digestion_tract/track_digestor.rb +37 -37
- data/lib/sevendigital/management/artist_manager.rb +45 -39
- data/lib/sevendigital/management/manager.rb +11 -11
- data/lib/sevendigital/management/release_manager.rb +57 -50
- data/lib/sevendigital/management/track_manager.rb +28 -17
- data/lib/sevendigital/model/api_response.rb +24 -12
- data/lib/sevendigital/model/artist.rb +46 -36
- data/lib/sevendigital/model/chart_item.rb +9 -9
- data/lib/sevendigital/model/format.rb +9 -9
- data/lib/sevendigital/model/label.rb +9 -9
- data/lib/sevendigital/model/price.rb +11 -11
- data/lib/sevendigital/model/release.rb +33 -33
- data/lib/sevendigital/model/sevendigital_error.rb +3 -3
- data/lib/sevendigital/model/sevendigital_object.rb +51 -51
- data/lib/sevendigital/model/track.rb +28 -7
- data/lib/sevendigital/pager.rb +16 -16
- data/lib/sevendigital/peachy_patch.rb +19 -0
- data/lib/sevendigital/proxy_police.rb +23 -23
- data/spec/api_operator_cached_spec.rb +47 -46
- data/spec/api_operator_spec.rb +114 -107
- data/spec/api_request_spec.rb +26 -27
- data/spec/client_spec.rb +75 -45
- data/spec/data/config/sevendigital.yml +5 -5
- data/spec/data/configuration_env_override.yml +5 -5
- data/spec/digestion_tract/api_response_digestor_spec.rb +78 -74
- data/spec/digestion_tract/artist_digestor_spec.rb +81 -82
- data/spec/digestion_tract/chart_digestor_spec.rb +52 -53
- data/spec/digestion_tract/format_digestor_spec.rb +38 -39
- data/spec/digestion_tract/label_digestor_spec.rb +33 -34
- data/spec/digestion_tract/pager_digestor_spec.rb +50 -51
- data/spec/digestion_tract/price_digestor_spec.rb +57 -57
- data/spec/digestion_tract/release_digestor_spec.rb +101 -102
- data/spec/digestion_tract/track_digestor_spec.rb +104 -106
- data/spec/management/artist_manager_spec.rb +128 -107
- data/spec/management/release_manager_spec.rb +222 -178
- data/spec/management/track_manager_spec.rb +88 -52
- data/spec/model/api_response_spec.rb +44 -31
- data/spec/model/artist_spec.rb +166 -121
- data/spec/model/release_spec.rb +109 -110
- data/spec/model/track_spec.rb +140 -0
- data/spec/pager_spec.rb +7 -8
- data/spec/peachy_spec_helper_patch.rb +7 -0
- data/spec/proxy_police_spec.rb +47 -48
- data/spec/spec_helper.rb +52 -48
- data/spec/test-xml/methods/artist/byTag/top.xml +50 -50
- data/spec/test-xml/methods/artist/details.xml +9 -9
- data/spec/test-xml/methods/artist/releases.xml +544 -544
- data/spec/test-xml/methods/artist/search.xml +19 -0
- data/spec/test-xml/methods/artist/similar.xml +39 -39
- data/spec/test-xml/methods/artist/toptracks.xml +279 -279
- data/spec/test-xml/methods/release/bydate.xml +173 -173
- data/spec/test-xml/methods/release/bytag/top.xml +150 -150
- data/spec/test-xml/methods/release/chart.xml +181 -181
- data/spec/test-xml/methods/release/details.xml +48 -48
- data/spec/test-xml/methods/release/recommend.xml +89 -89
- data/spec/test-xml/methods/release/search.xml +195 -0
- data/spec/test-xml/methods/release/tracks.xml +28 -28
- data/spec/test-xml/methods/track/chart.xml +149 -149
- data/spec/test-xml/methods/track/details.xml +30 -30
- data/spec/test-xml/methods/track/search.xml +160 -0
- data/spec/test-xml/objects/artist.xml +6 -6
- data/spec/test-xml/objects/artist_chart_item.xml +7 -7
- data/spec/test-xml/objects/artist_list.xml +22 -22
- data/spec/test-xml/objects/artist_list_empty.xml +4 -4
- data/spec/test-xml/objects/price.xml +7 -7
- data/spec/test-xml/objects/release.xml +40 -40
- data/spec/test-xml/objects/release_chart_item.xml +39 -34
- data/spec/test-xml/objects/release_list.xml +18 -18
- data/spec/test-xml/objects/release_list_empty.xml +4 -4
- data/spec/test-xml/objects/response.xml +39 -0
- data/spec/test-xml/objects/track.xml +33 -33
- data/spec/test-xml/objects/track_chart_item.xml +27 -27
- metadata +10 -5
- data/lib/peachy_patchy.rb +0 -14
- data/lib/sevendigital/version.rb +0 -3
data/spec/model/release_spec.rb
CHANGED
@@ -1,111 +1,110 @@
|
|
1
|
-
require "
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
@release =
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@release.
|
28
|
-
@release.
|
29
|
-
@release.
|
30
|
-
@release.
|
31
|
-
@release.
|
32
|
-
@release.
|
33
|
-
@release.
|
34
|
-
@release.
|
35
|
-
@release.
|
36
|
-
@release.
|
37
|
-
@release.
|
38
|
-
@release.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
releases
|
82
|
-
releases << Sevendigital::Release.new(@client)
|
83
|
-
releases
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
tracks
|
89
|
-
tracks << Sevendigital::Track.new(@client)
|
90
|
-
tracks
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
release =
|
96
|
-
release.
|
97
|
-
release.
|
98
|
-
release.
|
99
|
-
release.
|
100
|
-
release.
|
101
|
-
release.
|
102
|
-
release.
|
103
|
-
release.
|
104
|
-
release.
|
105
|
-
release.
|
106
|
-
release.
|
107
|
-
release.
|
108
|
-
release
|
109
|
-
|
110
|
-
end
|
1
|
+
require "date"
|
2
|
+
require File.join(File.dirname(__FILE__), %w[../spec_helper])
|
3
|
+
|
4
|
+
describe "Release" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = stub(Sevendigital::Client)
|
8
|
+
@release_manager = mock(Sevendigital::ReleaseManager)
|
9
|
+
@client.stub!(:release).and_return @release_manager
|
10
|
+
|
11
|
+
@release = Sevendigital::Release.new(@client)
|
12
|
+
@release.id = 1234
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should get its basic details from manager" do
|
16
|
+
expected_options = {:page => 2}
|
17
|
+
fresh_release = fake_release_with_details
|
18
|
+
|
19
|
+
@release_manager.should_receive(:get_details) { |release_id, options|
|
20
|
+
release_id.should == @release.id
|
21
|
+
(options.keys & expected_options.keys).should == expected_options.keys
|
22
|
+
fresh_release
|
23
|
+
}
|
24
|
+
@release.get_details(expected_options)
|
25
|
+
|
26
|
+
@release.version.should == fresh_release.version
|
27
|
+
@release.type.should == fresh_release.type
|
28
|
+
@release.artist.should == fresh_release.artist
|
29
|
+
@release.image.should == fresh_release.image
|
30
|
+
@release.url.should == fresh_release.url
|
31
|
+
@release.release_date.should == fresh_release.release_date
|
32
|
+
@release.added_date.should == fresh_release.added_date
|
33
|
+
@release.barcode.should == fresh_release.barcode
|
34
|
+
@release.year.should == fresh_release.year
|
35
|
+
@release.explicit_content.should == fresh_release.explicit_content
|
36
|
+
@release.formats.should == fresh_release.formats
|
37
|
+
@release.label.should == fresh_release.label
|
38
|
+
@release.price.should == fresh_release.price
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
it "get_tracks should get tracks from manager" do
|
43
|
+
expected_options = {:page => 2}
|
44
|
+
|
45
|
+
@release_manager.should_receive(:get_tracks) { |release_id, options|
|
46
|
+
release_id.should == @release.id
|
47
|
+
(options.keys & expected_options.keys).should == expected_options.keys
|
48
|
+
fake_track_list
|
49
|
+
}
|
50
|
+
@release.get_tracks(expected_options)
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
it "get_tracks should link all tracks back to release itself" do
|
55
|
+
|
56
|
+
@release_manager.should_receive(:get_tracks) { |release_id, options|
|
57
|
+
release_id.should == @release.id
|
58
|
+
fake_track_list
|
59
|
+
}
|
60
|
+
|
61
|
+
tracks = @release.get_tracks()
|
62
|
+
|
63
|
+
tracks.all?{|track| track.release == @release}.should == true
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
it "get_recommendations should get recommendations from manager" do
|
68
|
+
expected_options = {:page => 2}
|
69
|
+
|
70
|
+
@release_manager.should_receive(:get_recommendations) { |release_id, options|
|
71
|
+
release_id.should == @release.id
|
72
|
+
(options.keys & expected_options.keys).should == expected_options.keys
|
73
|
+
fake_releases_list
|
74
|
+
}
|
75
|
+
@release.get_recommendations(expected_options)
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def fake_releases_list
|
80
|
+
releases = Array.new
|
81
|
+
releases << Sevendigital::Release.new(@client)
|
82
|
+
releases << Sevendigital::Release.new(@client)
|
83
|
+
releases
|
84
|
+
end
|
85
|
+
|
86
|
+
def fake_track_list
|
87
|
+
tracks = Array.new
|
88
|
+
tracks << Sevendigital::Track.new(@client)
|
89
|
+
tracks << Sevendigital::Track.new(@client)
|
90
|
+
tracks
|
91
|
+
end
|
92
|
+
|
93
|
+
def fake_release_with_details
|
94
|
+
release = Sevendigital::Release.new(@client)
|
95
|
+
release.version = "(release version)"
|
96
|
+
release.type = :album
|
97
|
+
release.artist = Sevendigital::Artist.new(@client)
|
98
|
+
release.image = "image"
|
99
|
+
release.url = "url"
|
100
|
+
release.release_date = DateTime.new(2010, 1, 1)
|
101
|
+
release.added_date = DateTime.new(2000, 1, 1)
|
102
|
+
release.barcode = "AAA"
|
103
|
+
release.year = 1999
|
104
|
+
release.explicit_content = true
|
105
|
+
release.formats = []
|
106
|
+
release.label = Sevendigital::Label.new
|
107
|
+
release.price = Sevendigital::Price.new
|
108
|
+
release
|
109
|
+
end
|
111
110
|
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require "date"
|
2
|
+
require File.join(File.dirname(__FILE__), %w[../spec_helper])
|
3
|
+
|
4
|
+
describe "Track" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = stub(Sevendigital::Client)
|
8
|
+
@track_manager = mock(Sevendigital::TrackManager)
|
9
|
+
@client.stub!(:track).and_return @track_manager
|
10
|
+
|
11
|
+
@track = Sevendigital::Track.new(@client)
|
12
|
+
@track.id = 1234
|
13
|
+
end
|
14
|
+
|
15
|
+
it "get_details should get track's basic details from manager" do
|
16
|
+
expected_options = {:page => 2}
|
17
|
+
fresh_track = fake_track_with_details
|
18
|
+
|
19
|
+
@track_manager.should_receive(:get_details) { |track_id, options|
|
20
|
+
track_id.should == @track.id
|
21
|
+
(options.keys & expected_options.keys).should == expected_options.keys
|
22
|
+
fresh_track
|
23
|
+
}
|
24
|
+
@track.get_details(expected_options)
|
25
|
+
|
26
|
+
@track.track_number.should == fresh_track.track_number
|
27
|
+
@track.duration.should == fresh_track.duration
|
28
|
+
@track.explicit_content.should == fresh_track.explicit_content
|
29
|
+
@track.isrc.should == fresh_track.isrc
|
30
|
+
@track.release.should == fresh_track.release
|
31
|
+
@track.url.should == fresh_track.url
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
it "preview_url should get preview URL from manager" do
|
36
|
+
expected_options = {:country => "mx"}
|
37
|
+
fake_preview_url = "http://preview.com/trackid/123456"
|
38
|
+
|
39
|
+
@track_manager.should_receive(:build_preview_url) { |track_id, options|
|
40
|
+
track_id.should == @track.id
|
41
|
+
(options.keys & expected_options.keys).should == expected_options.keys
|
42
|
+
fake_preview_url
|
43
|
+
}
|
44
|
+
|
45
|
+
@track.preview_url(expected_options).should == fake_preview_url
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should have a short title without any version in brackets" do
|
50
|
+
|
51
|
+
@track.title = "Girl With One Eye (Bayou Percussion Version)"
|
52
|
+
@track.short_title.should == "Girl With One Eye"
|
53
|
+
|
54
|
+
@track.title = "The Thing I Like Best About Him Is His Girlfriend (Gr's Man-Made Island Edition)"
|
55
|
+
@track.short_title.should == "The Thing I Like Best About Him Is His Girlfriend"
|
56
|
+
|
57
|
+
@track.title = "Your Head to Your Toes (Live at the BBC)"
|
58
|
+
@track.short_title.should == "Your Head to Your Toes"
|
59
|
+
|
60
|
+
@track.title = "Welcome To The World of The Plastic Beach (Feat. Snoop Dogg and Hypnotic Brass Ensemble)"
|
61
|
+
@track.short_title.should == "Welcome To The World of The Plastic Beach"
|
62
|
+
|
63
|
+
@track.title = "(lp version)"
|
64
|
+
@track.short_title.should == "(lp version)"
|
65
|
+
|
66
|
+
@track.title = "What's the Story (Morning Glory)"
|
67
|
+
@track.short_title.should == "What's the Story (Morning Glory)"
|
68
|
+
|
69
|
+
@track.title = "track 1 (something else)"
|
70
|
+
@track.short_title.should == "track 1 (something else)"
|
71
|
+
|
72
|
+
@track.title = "track 1 (dj remix)"
|
73
|
+
@track.short_title.should == "track 1"
|
74
|
+
|
75
|
+
@track.title = "track 1 ( dj mix )"
|
76
|
+
@track.short_title.should == "track 1"
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "alternate_version?" do
|
80
|
+
|
81
|
+
before do
|
82
|
+
@artist1 = Sevendigital::Artist.new(@client)
|
83
|
+
@artist2 = Sevendigital::Artist.new(@client)
|
84
|
+
@track1 = Sevendigital::Track.new(@client)
|
85
|
+
@track1.artist = @artist1
|
86
|
+
@track2 = Sevendigital::Track.new(@client)
|
87
|
+
@track2.artist = @artist2
|
88
|
+
|
89
|
+
@artist1.name = "artist 1"
|
90
|
+
@track1.title = "track 1"
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should be considered alternate version if artist names and titles match" do
|
95
|
+
@artist2.name = "Artist 1"
|
96
|
+
@track2.title = "Track 1"
|
97
|
+
|
98
|
+
@track1.alternate_version_of?(@track2).should == true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should be considered alternate version if artist names and short titles match" do
|
102
|
+
@track1.title = "track 1 (uk version)"
|
103
|
+
|
104
|
+
@artist2.name = "Artist 1"
|
105
|
+
@track2.title = "TRACK 1 (us remix)"
|
106
|
+
|
107
|
+
@track1.alternate_version_of?(@track2).should == true
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should not be considered alternate version if artist names don't match" do
|
111
|
+
@artist2.name = "artist 2"
|
112
|
+
@track2.title = "track 1"
|
113
|
+
|
114
|
+
@track1.alternate_version_of?(@track2).should == false
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should not be considered alternate version if short titles don't match" do
|
118
|
+
@artist2.name = "artist 1"
|
119
|
+
@track2.title = "track 2"
|
120
|
+
|
121
|
+
@track1.alternate_version_of?(@track2).should == false
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
def fake_track_with_details
|
128
|
+
track = Sevendigital::Track.new(@client)
|
129
|
+
track.title = "Song 1"
|
130
|
+
track.version = "Version 2"
|
131
|
+
track.artist = Sevendigital::Artist.new(@client)
|
132
|
+
track.track_number = 7
|
133
|
+
track.duration = 77
|
134
|
+
track.explicit_content = true
|
135
|
+
track.isrc = "7D"
|
136
|
+
track.release = Sevendigital::Release.new(@client)
|
137
|
+
track.url = "http://aaa.bbb.ccc/"
|
138
|
+
track
|
139
|
+
end
|
140
|
+
end
|
data/spec/pager_spec.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
+
|
3
|
+
describe "Pager" do
|
4
|
+
|
5
|
+
it "should paginate list"
|
6
|
+
|
7
|
+
end
|
data/spec/proxy_police_spec.rb
CHANGED
@@ -1,49 +1,48 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require '
|
3
|
-
require
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
proxy
|
17
|
-
proxy.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
proxy
|
30
|
-
proxy.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
proxy
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'date'
|
3
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
4
|
+
|
5
|
+
describe "Proxy Police" do
|
6
|
+
|
7
|
+
it "should create a Peachy proxy from xml string with root element with given name" do
|
8
|
+
|
9
|
+
xml = <<XML
|
10
|
+
<rootElement id="123">
|
11
|
+
<subElement>expected value</subElement>
|
12
|
+
</rootElement>
|
13
|
+
XML
|
14
|
+
|
15
|
+
proxy = Sevendigital::ProxyPolice.create_release_proxy(xml, :root_element)
|
16
|
+
proxy.kind_of?(Peachy::Proxy).should == true
|
17
|
+
proxy.sub_element.value.should == "expected value"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should create a Peachy proxy from root of the xml string if no element name given" do
|
21
|
+
|
22
|
+
xml = <<XML
|
23
|
+
<rootElement id="123">
|
24
|
+
<subElement>expected value</subElement>
|
25
|
+
</rootElement>
|
26
|
+
XML
|
27
|
+
|
28
|
+
proxy = Sevendigital::ProxyPolice.create_release_proxy(xml, nil)
|
29
|
+
proxy.kind_of?(Peachy::Proxy).should == true
|
30
|
+
proxy.root_element.sub_element.value.should == "expected value"
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not create a Peachy proxy from xml string without root element with given name" do
|
35
|
+
|
36
|
+
xml = <<XML
|
37
|
+
<rootElement id="123">
|
38
|
+
<subElement>expected value</subElement>
|
39
|
+
</rootElement>
|
40
|
+
XML
|
41
|
+
|
42
|
+
proxy = Sevendigital::ProxyPolice.create_release_proxy(xml, :different_element)
|
43
|
+
proxy.should == nil
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
49
48
|
end
|