beatport 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +5 -2
  3. data/README.rdoc +11 -1
  4. data/VERSION +1 -1
  5. data/beatport.gemspec +22 -36
  6. data/lib/beatport/catalog.rb +1 -0
  7. data/lib/beatport/catalog/artist.rb +12 -6
  8. data/lib/beatport/catalog/label.rb +16 -10
  9. data/lib/beatport/catalog/mix.rb +7 -0
  10. data/lib/beatport/item.rb +18 -0
  11. data/spec/catalog/account_type_spec.rb +11 -9
  12. data/spec/catalog/artist_spec.rb +56 -57
  13. data/spec/catalog/audio_format_spec.rb +12 -12
  14. data/spec/catalog/autocomplete_spec.rb +11 -9
  15. data/spec/catalog/chart_overview_spec.rb +14 -5
  16. data/spec/catalog/chart_spec.rb +11 -7
  17. data/spec/catalog/country_spec.rb +9 -3
  18. data/spec/catalog/currency_spec.rb +9 -3
  19. data/spec/catalog/genre_spec.rb +18 -21
  20. data/spec/catalog/item_type_spec.rb +8 -0
  21. data/spec/catalog/label_spec.rb +22 -12
  22. data/spec/catalog/mixed_spec.rb +9 -1
  23. data/spec/catalog/release_spec.rb +14 -9
  24. data/spec/catalog/search_spec.rb +21 -23
  25. data/spec/catalog/source_type_spec.rb +9 -3
  26. data/spec/catalog/track_spec.rb +9 -3
  27. data/spec/fixtures/{account_type_all.yml → account_type.yml} +38 -3
  28. data/spec/fixtures/artist.yml +555 -0
  29. data/spec/fixtures/{audio_format_all.yml → audio_format.yml} +73 -3
  30. data/spec/fixtures/autocomplete.yml +77 -0
  31. data/spec/fixtures/chart.yml +579 -0
  32. data/spec/fixtures/chart_overview.yml +41 -0
  33. data/spec/fixtures/{country_au.yml → country.yml} +3 -3
  34. data/spec/fixtures/{currency_all.yml → currency.yml} +3 -3
  35. data/spec/fixtures/genre.yml +273 -0
  36. data/spec/fixtures/item_type.yml +43 -0
  37. data/spec/fixtures/label.yml +372 -0
  38. data/spec/fixtures/mixed.yml +89 -0
  39. data/spec/fixtures/release.yml +1251 -0
  40. data/spec/fixtures/search.yml +315 -0
  41. data/spec/fixtures/{source_type_all.yml → source_type.yml} +4 -4
  42. data/spec/fixtures/track.yml +1124 -0
  43. data/spec/spec_helper.rb +7 -1
  44. metadata +24 -38
  45. data/spec/fixtures/account_type_visa.yml +0 -38
  46. data/spec/fixtures/artist_7181.yml +0 -43
  47. data/spec/fixtures/artist_7181_7182.yml +0 -44
  48. data/spec/fixtures/artist_7181_top_downloads.yml +0 -105
  49. data/spec/fixtures/artist_all.yml +0 -64
  50. data/spec/fixtures/artist_all_5_per_page.yml +0 -53
  51. data/spec/fixtures/artist_all_for_facets.yml +0 -38
  52. data/spec/fixtures/artist_all_return_facets.yml +0 -144
  53. data/spec/fixtures/artist_all_sorted.yml +0 -44
  54. data/spec/fixtures/audio_format_2.yml +0 -38
  55. data/spec/fixtures/audio_format_wav.yml +0 -38
  56. data/spec/fixtures/autocomplete_lutzen.yml +0 -41
  57. data/spec/fixtures/autocomplete_lutzen_page_3.yml +0 -39
  58. data/spec/fixtures/chart_15722.yml +0 -39
  59. data/spec/fixtures/genre_7.yml +0 -38
  60. data/spec/fixtures/genre_all.yml +0 -47
  61. data/spec/fixtures/genre_all_with_subgenres.yml +0 -62
  62. data/spec/fixtures/genre_invalid.yml +0 -38
  63. data/spec/fixtures/label_1390.yml +0 -43
  64. data/spec/fixtures/label_all.yml +0 -76
  65. data/spec/fixtures/release_164808.yml +0 -55
  66. data/spec/fixtures/search_ANJCDCO011D.yml +0 -38
  67. data/spec/fixtures/search_anjunadeep_genre_trance.yml +0 -101
  68. data/spec/fixtures/search_archipel.yml +0 -102
  69. data/spec/fixtures/search_believe_2004.yml +0 -220
  70. data/spec/fixtures/track_1217790.yml +0 -45
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ gem 'money' # https://github.com/aflatter/money
11
11
  group :development do
12
12
  gem 'bundler'
13
13
  gem 'fakeweb'
14
- gem 'jeweler', '~> 1.6.3'
14
+ gem 'jeweler'
15
15
  #gem "rcov", ">= 0"
16
16
  gem 'log_buddy'
17
17
  gem 'rspec', '>= 0'
@@ -8,10 +8,11 @@ GEM
8
8
  multi_json (~> 1.0)
9
9
  multi_xml
10
10
  i18n (0.6.1)
11
- jeweler (1.6.4)
11
+ jeweler (1.8.4)
12
12
  bundler (~> 1.0)
13
13
  git (>= 1.2.5)
14
14
  rake
15
+ rdoc
15
16
  json (1.7.5)
16
17
  log_buddy (0.7.0)
17
18
  money (5.0.0)
@@ -20,6 +21,8 @@ GEM
20
21
  multi_json (1.3.6)
21
22
  multi_xml (0.5.1)
22
23
  rake (0.9.2.2)
24
+ rdoc (3.12)
25
+ json (~> 1.4)
23
26
  rspec (2.11.0)
24
27
  rspec-core (~> 2.11.0)
25
28
  rspec-expectations (~> 2.11.0)
@@ -38,7 +41,7 @@ DEPENDENCIES
38
41
  bundler
39
42
  fakeweb
40
43
  httparty
41
- jeweler (~> 1.6.3)
44
+ jeweler
42
45
  log_buddy
43
46
  money
44
47
  rspec
@@ -4,7 +4,17 @@ A ruby gem for accessing the Beatport API
4
4
 
5
5
  http://api.beatport.com
6
6
 
7
- Currently incomplete, but under active development.
7
+ Currently incomplete, but under development.
8
+
9
+ {<img src="https://secure.travis-ci.org/mateomurphy/beatport.png" alt="Build Status" />}[http://travis-ci.org/mateomurphy/beatport]
10
+
11
+ == Facets
12
+
13
+ Many queries to beatport support facets, but they aren't properly documentated on their site. These are the ones I've found so far:
14
+
15
+ * genreName
16
+ * artistName (and not performerName)
17
+ * labelName
8
18
 
9
19
  == Contributing to beatport
10
20
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "beatport"
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mateo Murphy"]
12
- s.date = "2012-10-10"
12
+ s.date = "2012-11-11"
13
13
  s.description = "A ruby gem for accessing the beatport api"
14
14
  s.email = "mateo.murphy@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -48,6 +48,7 @@ Gem::Specification.new do |s|
48
48
  "lib/beatport/catalog/keys.rb",
49
49
  "lib/beatport/catalog/label.rb",
50
50
  "lib/beatport/catalog/list.rb",
51
+ "lib/beatport/catalog/mix.rb",
51
52
  "lib/beatport/catalog/mixed.rb",
52
53
  "lib/beatport/catalog/part.rb",
53
54
  "lib/beatport/catalog/recommendations.rb",
@@ -86,37 +87,22 @@ Gem::Specification.new do |s|
86
87
  "spec/catalog/source_type_spec.rb",
87
88
  "spec/catalog/track_spec.rb",
88
89
  "spec/collection_spec.rb",
89
- "spec/fixtures/account_type_all.yml",
90
- "spec/fixtures/account_type_visa.yml",
91
- "spec/fixtures/artist_7181.yml",
92
- "spec/fixtures/artist_7181_7182.yml",
93
- "spec/fixtures/artist_7181_top_downloads.yml",
94
- "spec/fixtures/artist_all.yml",
95
- "spec/fixtures/artist_all_5_per_page.yml",
96
- "spec/fixtures/artist_all_for_facets.yml",
97
- "spec/fixtures/artist_all_return_facets.yml",
98
- "spec/fixtures/artist_all_sorted.yml",
99
- "spec/fixtures/audio_format_2.yml",
100
- "spec/fixtures/audio_format_all.yml",
101
- "spec/fixtures/audio_format_wav.yml",
102
- "spec/fixtures/autocomplete_lutzen.yml",
103
- "spec/fixtures/autocomplete_lutzen_page_3.yml",
104
- "spec/fixtures/chart_15722.yml",
105
- "spec/fixtures/country_au.yml",
106
- "spec/fixtures/currency_all.yml",
107
- "spec/fixtures/genre_7.yml",
108
- "spec/fixtures/genre_all.yml",
109
- "spec/fixtures/genre_all_with_subgenres.yml",
110
- "spec/fixtures/genre_invalid.yml",
111
- "spec/fixtures/label_1390.yml",
112
- "spec/fixtures/label_all.yml",
113
- "spec/fixtures/release_164808.yml",
114
- "spec/fixtures/search_ANJCDCO011D.yml",
115
- "spec/fixtures/search_anjunadeep_genre_trance.yml",
116
- "spec/fixtures/search_archipel.yml",
117
- "spec/fixtures/search_believe_2004.yml",
118
- "spec/fixtures/source_type_all.yml",
119
- "spec/fixtures/track_1217790.yml",
90
+ "spec/fixtures/account_type.yml",
91
+ "spec/fixtures/artist.yml",
92
+ "spec/fixtures/audio_format.yml",
93
+ "spec/fixtures/autocomplete.yml",
94
+ "spec/fixtures/chart.yml",
95
+ "spec/fixtures/chart_overview.yml",
96
+ "spec/fixtures/country.yml",
97
+ "spec/fixtures/currency.yml",
98
+ "spec/fixtures/genre.yml",
99
+ "spec/fixtures/item_type.yml",
100
+ "spec/fixtures/label.yml",
101
+ "spec/fixtures/mixed.yml",
102
+ "spec/fixtures/release.yml",
103
+ "spec/fixtures/search.yml",
104
+ "spec/fixtures/source_type.yml",
105
+ "spec/fixtures/track.yml",
120
106
  "spec/item_spec.rb",
121
107
  "spec/spec_helper.rb",
122
108
  "spec/support/inflector_spec.rb",
@@ -136,7 +122,7 @@ Gem::Specification.new do |s|
136
122
  s.add_runtime_dependency(%q<money>, [">= 0"])
137
123
  s.add_development_dependency(%q<bundler>, [">= 0"])
138
124
  s.add_development_dependency(%q<fakeweb>, [">= 0"])
139
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
125
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
140
126
  s.add_development_dependency(%q<log_buddy>, [">= 0"])
141
127
  s.add_development_dependency(%q<rspec>, [">= 0"])
142
128
  s.add_development_dependency(%q<yard>, [">= 0"])
@@ -146,7 +132,7 @@ Gem::Specification.new do |s|
146
132
  s.add_dependency(%q<money>, [">= 0"])
147
133
  s.add_dependency(%q<bundler>, [">= 0"])
148
134
  s.add_dependency(%q<fakeweb>, [">= 0"])
149
- s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
135
+ s.add_dependency(%q<jeweler>, [">= 0"])
150
136
  s.add_dependency(%q<log_buddy>, [">= 0"])
151
137
  s.add_dependency(%q<rspec>, [">= 0"])
152
138
  s.add_dependency(%q<yard>, [">= 0"])
@@ -157,7 +143,7 @@ Gem::Specification.new do |s|
157
143
  s.add_dependency(%q<money>, [">= 0"])
158
144
  s.add_dependency(%q<bundler>, [">= 0"])
159
145
  s.add_dependency(%q<fakeweb>, [">= 0"])
160
- s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
146
+ s.add_dependency(%q<jeweler>, [">= 0"])
161
147
  s.add_dependency(%q<log_buddy>, [">= 0"])
162
148
  s.add_dependency(%q<rspec>, [">= 0"])
163
149
  s.add_dependency(%q<yard>, [">= 0"])
@@ -20,6 +20,7 @@ module Beatport
20
20
  autoload :Keys, 'beatport/catalog/keys'
21
21
  autoload :Label, 'beatport/catalog/label'
22
22
  autoload :List, 'beatport/catalog/list'
23
+ autoload :Mix, 'beatport/catalog/mix'
23
24
  autoload :Mixed, 'beatport/catalog/mixed'
24
25
  autoload :Part, 'beatport/catalog/part'
25
26
  autoload :Recommendations, 'beatport/catalog/recommendations'
@@ -6,13 +6,19 @@ module Beatport
6
6
  has_one :images, Images
7
7
  has_many :top_downloads, Track
8
8
  # has_many :featured_releases, Release
9
-
10
- def self.find(*args)
11
- Client.retrieve 'artists', Artist, *args
12
- end
13
9
 
14
- def self.all(options = {})
15
- Client.retrieve 'artists', Artist, options
10
+ class << self
11
+ def all(options = {})
12
+ Client.retrieve 'artists', Artist, options
13
+ end
14
+
15
+ def find(*args)
16
+ Client.retrieve 'artists', Artist, *args
17
+ end
18
+
19
+ def name_facet
20
+ :artist_name
21
+ end
16
22
  end
17
23
 
18
24
  def top_downloads(options = {})
@@ -8,18 +8,24 @@ module Beatport
8
8
  has_many :most_popular_releases, Release
9
9
  has_one :images, Images
10
10
 
11
- def self.find(*args)
12
- Client.retrieve 'labels', Label, *args
13
- end
11
+ class << self
12
+ def all(options = {})
13
+ Client.retrieve 'labels', Label, options
14
+ end
15
+
16
+ def featured(*args)
17
+ Client.retrieve 'featured/labels', Label, *args
18
+ end
14
19
 
15
- def self.all(options = {})
16
- Client.retrieve 'labels', Label, options
20
+ def find(*args)
21
+ Client.retrieve 'labels', Label, *args
22
+ end
23
+
24
+ def name_facet
25
+ :label_name
26
+ end
17
27
  end
18
-
19
- def self.featured(*args)
20
- Client.retrieve 'featured/labels', Label, *args
21
- end
22
-
28
+
23
29
  def releases(options)
24
30
  options[:label_id] = id
25
31
  Release.all(options)
@@ -0,0 +1,7 @@
1
+ module Beatport
2
+ module Catalog
3
+ class Mix < Item
4
+
5
+ end
6
+ end
7
+ end
@@ -20,6 +20,24 @@ module Beatport
20
20
  return if respond_to?(var)
21
21
  class_eval "def #{var}; @#{var}; end"
22
22
  end
23
+
24
+ def find_by_name(name, *args)
25
+ raise "finding by name is not supported" unless respond_to?(:name_facet)
26
+
27
+ options = args.last || {}
28
+ options[:facets] ||= {}
29
+ options[:facets][name_facet] = name
30
+ results = find(options)
31
+
32
+ case results.length
33
+ when 0
34
+ nil
35
+ when 1
36
+ results.first
37
+ else
38
+ raise "find_by_name returned multiple results"
39
+ end
40
+ end
23
41
  end
24
42
 
25
43
  def initialize(data = {})
@@ -2,11 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  module Beatport::Catalog
4
4
  describe AccountType do
5
+ before :each do
6
+ VCR.insert_cassette 'account_type'
7
+ end
8
+
9
+ after :each do
10
+ VCR.eject_cassette
11
+ end
12
+
5
13
  describe 'structure' do
6
14
  subject do
7
- VCR.use_cassette "account_type_all" do
8
- AccountType.all.first
9
- end
15
+ AccountType.all.first
10
16
  end
11
17
 
12
18
  it { should be_an(AccountType) }
@@ -21,9 +27,7 @@ module Beatport::Catalog
21
27
 
22
28
  describe '.all' do
23
29
  subject do
24
- VCR.use_cassette "account_type_all" do
25
- AccountType.all
26
- end
30
+ AccountType.all
27
31
  end
28
32
 
29
33
  its (:length) { should be > 1 }
@@ -38,9 +42,7 @@ module Beatport::Catalog
38
42
 
39
43
  context "by name" do
40
44
  subject do
41
- VCR.use_cassette "account_type_visa" do
42
- AccountType.find('Visa')
43
- end
45
+ AccountType.find('Visa')
44
46
  end
45
47
 
46
48
  its (:name) { should == "Visa" }
@@ -2,10 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  module Beatport::Catalog
4
4
  describe Artist do
5
+ before :each do
6
+ VCR.insert_cassette 'artist'
7
+ end
8
+
9
+ after :each do
10
+ VCR.eject_cassette
11
+ end
12
+
5
13
  describe 'structure' do
6
- subject do
7
- VCR.use_cassette('artist_7181') { Artist.find(7181) }
8
- end
14
+ subject { Artist.find(7181) }
9
15
 
10
16
  it { should be_an(Artist) }
11
17
  its (:id) { should == 7181 }
@@ -16,7 +22,7 @@ module Beatport::Catalog
16
22
  its (:biography) { should == "" }
17
23
  its (:'genres.length') { should be > 1 }
18
24
  its (:'sub_genres.length') { should be > 1 }
19
- its (:'top_downloads.length') { VCR.use_cassette('artist_7181_top_downloads') { should be > 1 } }
25
+ its (:'top_downloads.length') { should be > 1 }
20
26
  its (:'images.small.url') { should == "http://geo-media.beatport.com/image/491527.jpg" }
21
27
  its (:'images.medium.url') { should == "http://geo-media.beatport.com/image/491530.jpg" }
22
28
  its (:'images.large.url') { should == "http://geo-media.beatport.com/image/4686424.jpg" }
@@ -25,20 +31,16 @@ module Beatport::Catalog
25
31
 
26
32
  describe '.find' do
27
33
  context 'with a single id' do
28
- subject do
29
- VCR.use_cassette('artist_7181') { Artist.find(7181) }
30
- end
34
+ subject { Artist.find(7181) }
31
35
 
32
36
  it { should be_an(Artist) }
33
37
  its (:id) { should == 7181 }
34
38
  end
35
39
 
36
40
  context 'with multiple ids' do
37
- subject do
38
- VCR.use_cassette('artist_7181_7182') { Artist.find(7181, 7182) }
39
- end
41
+ subject { Artist.find(7181, 7182) }
40
42
 
41
- # it { should be_a(Collection) }
43
+ # it { should be_a(Collection) }
42
44
  its (:length) { should == 2 }
43
45
  it "returns the requested artists" do
44
46
  subject.map(&:id).should == [7181, 7182]
@@ -46,11 +48,9 @@ module Beatport::Catalog
46
48
  end
47
49
 
48
50
  context 'with an array of ids' do
49
- subject do
50
- VCR.use_cassette('artist_7181_7182') { Artist.find(7181, 7182) }
51
- end
51
+ subject { Artist.find(7181, 7182) }
52
52
 
53
- # it { should be_a(Collection) }
53
+ # it { should be_a(Collection) }
54
54
  its (:length) { should == 2 }
55
55
  it "returns the requested artists" do
56
56
  subject.map(&:id).should == [7181, 7182]
@@ -58,69 +58,68 @@ module Beatport::Catalog
58
58
  end
59
59
  end
60
60
 
61
+ describe '.find_by_name' do
62
+ subject { Artist.find_by_name('Above & Beyond') }
63
+
64
+ it { should be_an(Artist) }
65
+ its (:id) { should == 7181 }
66
+ end
67
+
61
68
  describe '.all' do
62
69
  it "should get arbitrary artists" do
63
- VCR.use_cassette('artist_all') do
64
- artists = Artist.all
65
- artists.length.should == 10
66
- end
70
+ artists = Artist.all
71
+ artists.length.should == 10
67
72
  end
68
73
 
69
74
  it "should get the first page with 5 artists per page" do
70
- VCR.use_cassette('artist_all_5_per_page') do
71
- artists = Artist.all :per_page => 5, :page => 1
72
- artists.length.should == 5
73
- artists.page.should == 1
74
- artists.per_page.should == 5
75
- end
75
+ artists = Artist.all :per_page => 5, :page => 1
76
+ artists.length.should == 5
77
+ artists.page.should == 1
78
+ artists.per_page.should == 5
76
79
  end
77
80
 
78
81
  it "should get the first page with 5 artists per page, sorted by publish date and artist id, for the House genre" do
79
- VCR.use_cassette('artist_all_sorted') do
80
- artists = Artist.all(:sort_by=> { :publish_date => 'asc', :artist_id => 'asc' }, :genre_id=> 5, :per_page=>5, :page=>1)
81
- artists.length.should == 5
82
+ artists = Artist.all(:sort_by=> { :publish_date => 'asc', :artist_id => 'asc' }, :genre_id=> 5, :per_page=>5, :page=>1)
83
+ artists.length.should == 5
84
+
85
+ old_id = nil
86
+ old_date = artists.first.last_publish_date
87
+
88
+ artists.each do |artist|
89
+ old_id = nil if old_date.to_s != artist.last_publish_date.to_s
82
90
 
83
- old_id = nil
84
- old_date = artists.first.last_publish_date
91
+ # beatport has some bad genre data?
92
+ # artist.genres.map(&:id).should include(5)
93
+ artist.id.should be >= old_id if old_id
94
+ artist.last_publish_date.should be >= old_date if old_date
85
95
 
86
- artists.each do |artist|
87
- old_id = nil if old_date.to_s != artist.last_publish_date.to_s
88
-
89
- # beatport has some bad genre data?
90
- # artist.genres.map(&:id).should include(5)
91
- artist.id.should be >= old_id if old_id
92
- artist.last_publish_date.should be >= old_date if old_date
93
-
94
- old_id = artist.id
95
- old_date = artist.publish_date
96
- end
96
+ old_id = artist.id
97
+ old_date = artist.publish_date
97
98
  end
98
99
  end
99
100
 
100
101
  it "should get arbitrary artists with filter metadata for all genre names and artist names" do
101
- VCR.use_cassette('artist_all_return_facets') do
102
- artists = Artist.all :return_facets => ['genre_name', 'performer_name']
103
-
104
- artists.facets['fields']['performer_name'].count.should be > 1
105
- artists.facets['fields']['genre_name'].count.should be > 1
106
- end
102
+ artists = Artist.all :return_facets => ['genre_name', 'performer_name']
103
+
104
+ artists.facets['fields']['performer_name'].count.should be > 1
105
+ artists.facets['fields']['genre_name'].count.should be > 1
106
+
107
107
  end
108
108
 
109
109
  it "should get all trance artists for above & beyond" do
110
110
  pending "Request doesn't return any results"
111
111
 
112
- VCR.use_cassette('artist_all_for_facets') do
113
- artists = Artist.all :facets => {:genre_name => ['Trance', 'Progessive House']}
114
-
115
- artists.each do |artist|
116
- artists = artist['artists'].map { |a| a['name'] }
117
- artists.should include("Above & Beyond")
118
-
119
- genres = artist['genres'].map { |a| a['name'] }
120
- genres.should include('Trance')
121
- end
112
+ artists = Artist.all :facets => {:genre_name => ['Trance', 'Progessive House']}
113
+
114
+ artists.each do |artist|
115
+ artists = artist['artists'].map { |a| a['name'] }
116
+ artists.should include("Above & Beyond")
117
+
118
+ genres = artist['genres'].map { |a| a['name'] }
119
+ genres.should include('Trance')
122
120
  end
123
121
  end
122
+
124
123
  end
125
124
  end
126
125
  end