discogs-wrapper 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/discogs.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = "discogs-wrapper"
4
- s.version = "1.1.0"
5
- s.date = "2011-10-22"
4
+ s.version = "1.1.1"
5
+ s.date = "2011-10-23"
6
6
  s.summary = "Discogs::Wrapper is a full wrapper for the http://www.discogs.com API V2"
7
7
  s.homepage = "http://www.github.com/buntine/discogs"
8
8
  s.email = "info@andrewbuntine.com"
@@ -10,9 +10,9 @@ Gem::Specification.new do |s|
10
10
 
11
11
  s.description = "Discogs::Wrapper is a full wrapper for the http://www.discogs.com API V2"
12
12
 
13
- s.files = ["lib/wrapper", "lib/wrapper/resource_mappings.rb", "lib/wrapper/wrapper.rb", "lib/wrapper/resource.rb", "lib/wrapper/resources", "lib/wrapper/resources/format.rb", "lib/wrapper/resources/search.rb", "lib/wrapper/resources/label_release.rb", "lib/wrapper/resources/artist.rb", "lib/wrapper/resources/release_artist.rb", "lib/wrapper/resources/artist_release.rb", "lib/wrapper/resources/release_label.rb", "lib/wrapper/resources/generic_list.rb", "lib/wrapper/resources/search_result.rb", "lib/wrapper/resources/label.rb", "lib/wrapper/resources/image.rb", "lib/wrapper/resources/track.rb", "lib/wrapper/resources/release.rb", "lib/discogs.rb", "Rakefile", "README.markdown", "discogs.gemspec"]
13
+ s.files = ["lib/wrapper", "lib/wrapper/resource_mappings.rb", "lib/wrapper/wrapper.rb", "lib/wrapper/resource.rb", "lib/wrapper/resources", "lib/wrapper/resources/format.rb", "lib/wrapper/resources/search.rb", "lib/wrapper/resources/label_release.rb", "lib/wrapper/resources/artist.rb", "lib/wrapper/resources/release_artist.rb", "lib/wrapper/resources/artist_release.rb", "lib/wrapper/resources/release_label.rb", "lib/wrapper/resources/generic_list.rb", "lib/wrapper/resources/search_result.rb", "lib/wrapper/resources/label.rb", "lib/wrapper/resources/image.rb", "lib/wrapper/resources/track.rb", "lib/wrapper/resources/release.rb", "lib/wrapper/resources/master_release.rb", "lib/wrapper/resources/video.rb", "lib/discogs.rb", "Rakefile", "README.markdown", "discogs.gemspec"]
14
14
 
15
- s.test_files = ["spec/wrapper_methods/get_release_spec.rb", "spec/wrapper_methods/search_spec.rb", "spec/wrapper_methods/get_artist_spec.rb", "spec/wrapper_methods/get_label_spec.rb", "spec/resource_spec.rb", "spec/resources/label_spec.rb", "spec/resources/generic_list_spec.rb", "spec/resources/artist_release_spec.rb", "spec/resources/artist_spec.rb", "spec/resources/release_artist_spec.rb", "spec/resources/search_spec.rb", "spec/resources/label_release_spec.rb", "spec/resources/release_label_spec.rb", "spec/resources/release_spec.rb", "spec/resources/search_result_spec.rb", "spec/resources/image_spec.rb", "spec/resources/track_spec.rb", "spec/resources/format_spec.rb", "spec/wrapper_spec.rb", "spec/spec_helper.rb"]
15
+ s.test_files = ["spec/wrapper_methods/get_release_spec.rb", "spec/wrapper_methods/get_master_release_spec.rb", "spec/wrapper_methods/search_spec.rb", "spec/wrapper_methods/get_artist_spec.rb", "spec/wrapper_methods/get_label_spec.rb", "spec/resource_spec.rb", "spec/resources/label_spec.rb", "spec/resources/generic_list_spec.rb", "spec/resources/artist_release_spec.rb", "spec/resources/artist_spec.rb", "spec/resources/release_artist_spec.rb", "spec/resources/search_spec.rb", "spec/resources/label_release_spec.rb", "spec/resources/release_label_spec.rb", "spec/resources/release_spec.rb", "spec/resources/master_release_spec.rb", "spec/resources/video_spec.rb", "spec/resources/search_result_spec.rb", "spec/resources/image_spec.rb", "spec/resources/track_spec.rb", "spec/resources/format_spec.rb", "spec/wrapper_spec.rb", "spec/spec_helper.rb"]
16
16
 
17
17
  s.platform = Gem::Platform::RUBY
18
18
 
@@ -0,0 +1,19 @@
1
+ # Represents a master release in the Discogs API.
2
+
3
+ class Discogs::MasterRelease < Discogs::Resource
4
+
5
+ no_mapping
6
+
7
+ attr_accessor :id,
8
+ :styles,
9
+ :genres,
10
+ :main_release,
11
+ :notes,
12
+ :year,
13
+ :images,
14
+ :videos,
15
+ :tracklist,
16
+ :artists
17
+ #:versions,
18
+ #:videos
19
+ end
@@ -0,0 +1,11 @@
1
+ # Represents an video in the Discogs API.
2
+
3
+ class Discogs::Video < Discogs::Resource
4
+
5
+ attr_accessor :uri,
6
+ :duration,
7
+ :embed,
8
+ :description,
9
+ :title
10
+
11
+ end
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe Discogs::MasterRelease do
4
+
5
+ it "should map to empty array" do
6
+ Discogs::Release.element_names.should == []
7
+ end
8
+
9
+ it "should map plural to empty array" do
10
+ Discogs::Release.plural_element_names.should == []
11
+ end
12
+
13
+ ## See ./spec/wrapper_methods/get_master_release_spec.rb for extensive tests of this class.
14
+
15
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe Discogs::Video do
4
+
5
+ it "should map to video" do
6
+ Discogs::Video.element_names.should == [ :video ]
7
+ end
8
+
9
+ it "should map to plural videos" do
10
+ Discogs::Video.plural_element_names.should == [ :videos ]
11
+ end
12
+
13
+ describe "when asking for video information" do
14
+
15
+ before do
16
+ data = File.read(File.join(File.dirname(__FILE__), "..", "samples", "valid_video.xml"))
17
+ @video = Discogs::Video.new(data)
18
+ @video.build!
19
+ end
20
+
21
+ it "should have a duration attribute" do
22
+ @video.duration.should == "334"
23
+ end
24
+
25
+ it "should have a embed attribute" do
26
+ @video.embed.should == "true"
27
+ end
28
+
29
+ it "should have a description attribute" do
30
+ @video.description.should == "The Persuader-Stockholm-Sodermalm"
31
+ end
32
+
33
+ it "should have a uri attribute" do
34
+ @video.uri.should == "http://www.youtube.com/watch?v=QVdDhOnoR8k"
35
+ end
36
+
37
+ it "should have a title attribute" do
38
+ @video.title.should == "The Persuader"
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,91 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe Discogs::Wrapper do
4
+
5
+ before do
6
+ @wrapper = Discogs::Wrapper.new("some_user_agent")
7
+ @master_release_id = "666666"
8
+ end
9
+
10
+ describe "when asking for master_release information" do
11
+
12
+ before do
13
+ @http_request = mock(Net::HTTP)
14
+ @http_response = mock(Net::HTTPResponse, :code => "200", :body => valid_master_release_xml)
15
+ @http_response_as_file = mock(StringIO, :read => valid_master_release_xml)
16
+ Zlib::GzipReader.should_receive(:new).and_return(@http_response_as_file)
17
+ @http_request.should_receive(:start).and_return(@http_response)
18
+ Net::HTTP.should_receive(:new).and_return(@http_request)
19
+
20
+ @master_release = @wrapper.get_master_release(@master_release_id)
21
+ end
22
+
23
+ describe "when calling simple master_release attributes" do
24
+
25
+ it "should have an ID attribute" do
26
+ @master_release.id.should == "6119"
27
+ end
28
+
29
+ it "should have a main_release attribute" do
30
+ @master_release.main_release.should == "1025"
31
+ end
32
+
33
+ it "should have one or more tracks" do
34
+ @master_release.tracklist.should be_instance_of(Array)
35
+ @master_release.tracklist[0].should be_instance_of(Discogs::MasterRelease::Track)
36
+ end
37
+
38
+ it "should have one or more genres" do
39
+ @master_release.genres.should be_instance_of(Array)
40
+ @master_release.genres[0].should == "Electronic"
41
+ end
42
+
43
+ it "should have one or more images" do
44
+ @master_release.images.should be_instance_of(Array)
45
+ @master_release.images[0].should be_instance_of(Discogs::Image)
46
+ end
47
+
48
+ end
49
+
50
+ describe "when calling complex master_release attributes" do
51
+
52
+ it "should have a duration for the first track" do
53
+ @master_release.tracklist[0].duration.should == "4:42"
54
+ end
55
+
56
+ it "should have specifications for each image" do
57
+ specs = [ [ '600', '590', 'primary' ], [ '600', '594', 'secondary' ], [ '600', '297', 'secondary' ], [ '600', '601', 'secondary' ], [ '600', '600', 'secondary' ] ]
58
+ @master_release.images.each_with_index do |image, index|
59
+ image.width.should == specs[index][0]
60
+ image.height.should == specs[index][1]
61
+ image.type.should == specs[index][2]
62
+ end
63
+ end
64
+
65
+ it "should have a traversible list of styles" do
66
+ @master_release.styles.should be_instance_of(Array)
67
+ @master_release.styles[0].should == "Deep House"
68
+ end
69
+
70
+ it "should have an artist associated to the second track" do
71
+ @master_release.tracklist[1].artists.should be_instance_of(Array)
72
+ @master_release.tracklist[1].artists[0].should be_instance_of(Discogs::MasterRelease::Track::Artist)
73
+ @master_release.tracklist[1].artists[0].name.should == "Arakain"
74
+ end
75
+
76
+ it "should have an extra artist associated to the second track" do
77
+ @master_release.tracklist[1].extraartists.should be_instance_of(Array)
78
+ @master_release.tracklist[1].extraartists[0].should be_instance_of(Discogs::MasterRelease::Track::Artist)
79
+ @master_release.tracklist[1].extraartists[0].name.should == "Debustrol"
80
+ @master_release.tracklist[1].extraartists[0].role.should == "Sadism"
81
+ end
82
+
83
+ it "should have no artist associated to the third track" do
84
+ @master_release.tracklist[2].artists.should be_nil
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+
91
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discogs-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Buntine
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-22 00:00:00 +11:00
19
+ date: 2011-10-23 00:00:00 +11:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -45,11 +45,14 @@ files:
45
45
  - lib/wrapper/resources/image.rb
46
46
  - lib/wrapper/resources/track.rb
47
47
  - lib/wrapper/resources/release.rb
48
+ - lib/wrapper/resources/master_release.rb
49
+ - lib/wrapper/resources/video.rb
48
50
  - lib/discogs.rb
49
51
  - Rakefile
50
52
  - README.markdown
51
53
  - discogs.gemspec
52
54
  - spec/wrapper_methods/get_release_spec.rb
55
+ - spec/wrapper_methods/get_master_release_spec.rb
53
56
  - spec/wrapper_methods/search_spec.rb
54
57
  - spec/wrapper_methods/get_artist_spec.rb
55
58
  - spec/wrapper_methods/get_label_spec.rb
@@ -63,6 +66,8 @@ files:
63
66
  - spec/resources/label_release_spec.rb
64
67
  - spec/resources/release_label_spec.rb
65
68
  - spec/resources/release_spec.rb
69
+ - spec/resources/master_release_spec.rb
70
+ - spec/resources/video_spec.rb
66
71
  - spec/resources/search_result_spec.rb
67
72
  - spec/resources/image_spec.rb
68
73
  - spec/resources/track_spec.rb
@@ -105,6 +110,7 @@ specification_version: 3
105
110
  summary: Discogs::Wrapper is a full wrapper for the http://www.discogs.com API V2
106
111
  test_files:
107
112
  - spec/wrapper_methods/get_release_spec.rb
113
+ - spec/wrapper_methods/get_master_release_spec.rb
108
114
  - spec/wrapper_methods/search_spec.rb
109
115
  - spec/wrapper_methods/get_artist_spec.rb
110
116
  - spec/wrapper_methods/get_label_spec.rb
@@ -118,6 +124,8 @@ test_files:
118
124
  - spec/resources/label_release_spec.rb
119
125
  - spec/resources/release_label_spec.rb
120
126
  - spec/resources/release_spec.rb
127
+ - spec/resources/master_release_spec.rb
128
+ - spec/resources/video_spec.rb
121
129
  - spec/resources/search_result_spec.rb
122
130
  - spec/resources/image_spec.rb
123
131
  - spec/resources/track_spec.rb