beatport 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README.md +12 -8
- data/VERSION +1 -1
- data/beatport.gemspec +9 -2
- data/lib/beatport/catalog.rb +18 -16
- data/lib/beatport/catalog/artist.rb +4 -2
- data/lib/beatport/catalog/dynamic_image.rb +11 -0
- data/lib/beatport/catalog/dynamic_images.rb +13 -0
- data/lib/beatport/catalog/images.rb +2 -2
- data/lib/beatport/catalog/label.rb +4 -2
- data/lib/beatport/catalog/release.rb +5 -4
- data/lib/beatport/catalog/track.rb +12 -9
- data/lib/beatport/client.rb +17 -9
- data/lib/beatport/item.rb +18 -18
- data/lib/beatport/support.rb +2 -0
- data/lib/beatport/support/middleware.rb +14 -0
- data/lib/beatport/support/url.rb +9 -0
- data/spec/catalog/artist_spec.rb +21 -20
- data/spec/catalog/country_spec.rb +5 -5
- data/spec/catalog/label_spec.rb +22 -21
- data/spec/catalog/release_spec.rb +27 -26
- data/spec/catalog/track_spec.rb +33 -26
- metadata +23 -3
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# Beatport
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
http://api.beatport.com
|
3
|
+
[![Dependency Status](https://gemnasium.com/mateomurphy/beatport.png)](https://gemnasium.com/mateomurphy/beatport)
|
6
4
|
|
7
|
-
|
5
|
+
A ruby gem for accessing the Beatport API; currently incomplete and only supports the Catalog API, but under development.
|
8
6
|
|
9
|
-
|
7
|
+
https://oauth-api.beatport.com/docs/
|
10
8
|
|
11
9
|
## Oauth
|
12
10
|
|
13
11
|
Beatport's api now requires authentication via Oauth. This means you now need to provide the gem
|
14
|
-
|
12
|
+
your oauth credentials to make requests, for example in a rails initializer:
|
15
13
|
|
16
14
|
Beatport.consumer_key = 'consumer_key'
|
17
15
|
Beatport.consumer_secret = 'consumer_secret'
|
18
16
|
Beatport.access_token_key = 'access_token_key'
|
19
17
|
Beatport.access_token_secret = 'access_token_secret'
|
20
18
|
|
19
|
+
Your consumer key and secret are found in the API Keys section of your beatbort account, whereas the access token key and secret can be generated at the docs page.
|
20
|
+
|
21
21
|
## Facets
|
22
22
|
|
23
23
|
Many queries to beatport support facets, but they aren't properly documentated on their site. These are the ones I've found so far:
|
@@ -42,8 +42,7 @@ Many queries to beatport support facets, but they aren't properly documentated o
|
|
42
42
|
query[1].class # => second result is a Beatport.Catalog::Chart object
|
43
43
|
query[1].publish_date # => returns the published date of the Chart
|
44
44
|
|
45
|
-
# Note that search results change frequently, so first result may not
|
46
|
-
necessarily be a Beatport::Catalog::Artist object
|
45
|
+
# Note that search results change frequently, so first result may not necessarily be a Beatport::Catalog::Artist object
|
47
46
|
|
48
47
|
# Find top downloads for a given genre
|
49
48
|
genres = Beatport::Catalog::Genre.all # => list all genres
|
@@ -67,6 +66,11 @@ Many queries to beatport support facets, but they aren't properly documentated o
|
|
67
66
|
trance_genre = Beatport::Catalog::Genre.find(7) # => returns a Trance Genre object
|
68
67
|
```
|
69
68
|
|
69
|
+
## Running specs
|
70
|
+
|
71
|
+
To run specs, you'll need to create a file with your oauth credentials in `spec/config.rb`, which
|
72
|
+
will be loaded by `spec/spec_helper.rb`
|
73
|
+
|
70
74
|
## Contributing to beatport
|
71
75
|
|
72
76
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/beatport.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "beatport"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
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 = "2013-
|
12
|
+
s.date = "2013-11-20"
|
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 = [
|
@@ -37,6 +37,8 @@ Gem::Specification.new do |s|
|
|
37
37
|
"lib/beatport/catalog/country.rb",
|
38
38
|
"lib/beatport/catalog/currency.rb",
|
39
39
|
"lib/beatport/catalog/djprofile.rb",
|
40
|
+
"lib/beatport/catalog/dynamic_image.rb",
|
41
|
+
"lib/beatport/catalog/dynamic_images.rb",
|
40
42
|
"lib/beatport/catalog/feature.rb",
|
41
43
|
"lib/beatport/catalog/genre.rb",
|
42
44
|
"lib/beatport/catalog/home.rb",
|
@@ -66,8 +68,10 @@ Gem::Specification.new do |s|
|
|
66
68
|
"lib/beatport/price.rb",
|
67
69
|
"lib/beatport/support.rb",
|
68
70
|
"lib/beatport/support/inflector.rb",
|
71
|
+
"lib/beatport/support/middleware.rb",
|
69
72
|
"lib/beatport/support/parser.rb",
|
70
73
|
"lib/beatport/support/query_builder.rb",
|
74
|
+
"lib/beatport/support/url.rb",
|
71
75
|
"spec/beatport_spec.rb",
|
72
76
|
"spec/catalog/account_type_spec.rb",
|
73
77
|
"spec/catalog/artist_spec.rb",
|
@@ -106,6 +110,7 @@ Gem::Specification.new do |s|
|
|
106
110
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
107
111
|
s.add_runtime_dependency(%q<addressable>, [">= 0"])
|
108
112
|
s.add_runtime_dependency(%q<signet>, [">= 0"])
|
113
|
+
s.add_runtime_dependency(%q<faraday>, ["~> 0.8.8"])
|
109
114
|
s.add_runtime_dependency(%q<money>, ["~> 5.1.1"])
|
110
115
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
111
116
|
s.add_development_dependency(%q<webmock>, [">= 0"])
|
@@ -117,6 +122,7 @@ Gem::Specification.new do |s|
|
|
117
122
|
else
|
118
123
|
s.add_dependency(%q<addressable>, [">= 0"])
|
119
124
|
s.add_dependency(%q<signet>, [">= 0"])
|
125
|
+
s.add_dependency(%q<faraday>, ["~> 0.8.8"])
|
120
126
|
s.add_dependency(%q<money>, ["~> 5.1.1"])
|
121
127
|
s.add_dependency(%q<bundler>, [">= 0"])
|
122
128
|
s.add_dependency(%q<webmock>, [">= 0"])
|
@@ -129,6 +135,7 @@ Gem::Specification.new do |s|
|
|
129
135
|
else
|
130
136
|
s.add_dependency(%q<addressable>, [">= 0"])
|
131
137
|
s.add_dependency(%q<signet>, [">= 0"])
|
138
|
+
s.add_dependency(%q<faraday>, ["~> 0.8.8"])
|
132
139
|
s.add_dependency(%q<money>, ["~> 5.1.1"])
|
133
140
|
s.add_dependency(%q<bundler>, [">= 0"])
|
134
141
|
s.add_dependency(%q<webmock>, [">= 0"])
|
data/lib/beatport/catalog.rb
CHANGED
@@ -10,12 +10,14 @@ module Beatport
|
|
10
10
|
autoload :Country, 'beatport/catalog/country'
|
11
11
|
autoload :Currency, 'beatport/catalog/currency'
|
12
12
|
autoload :Djprofile, 'beatport/catalog/djprofile'
|
13
|
-
autoload :
|
13
|
+
autoload :DynamicImage, 'beatport/catalog/dynamic_image'
|
14
|
+
autoload :DynamicImages, 'beatport/catalog/dynamic_images'
|
15
|
+
autoload :Feature, 'beatport/catalog/feature'
|
14
16
|
autoload :Genre, 'beatport/catalog/genre'
|
15
17
|
autoload :Home, 'beatport/catalog/home'
|
16
18
|
autoload :ItemType, 'beatport/catalog/item_type'
|
17
19
|
autoload :Image, 'beatport/catalog/image'
|
18
|
-
autoload :Images, 'beatport/catalog/images'
|
20
|
+
autoload :Images, 'beatport/catalog/images'
|
19
21
|
autoload :Key, 'beatport/catalog/key'
|
20
22
|
autoload :Keys, 'beatport/catalog/keys'
|
21
23
|
autoload :Label, 'beatport/catalog/label'
|
@@ -30,36 +32,36 @@ module Beatport
|
|
30
32
|
autoload :Slide, 'beatport/catalog/slide'
|
31
33
|
autoload :Slideshow, 'beatport/catalog/slideshow'
|
32
34
|
autoload :SourceType, 'beatport/catalog/source_type'
|
33
|
-
autoload :Track, 'beatport/catalog/track'
|
34
|
-
|
35
|
+
autoload :Track, 'beatport/catalog/track'
|
36
|
+
|
35
37
|
def self.artist(id)
|
36
38
|
Artist.find(id)
|
37
39
|
end
|
38
|
-
|
40
|
+
|
39
41
|
def self.artists(*args)
|
40
42
|
Artist.all(*args)
|
41
43
|
end
|
42
|
-
|
44
|
+
|
43
45
|
def self.chart(id)
|
44
46
|
Chart.find(id)
|
45
47
|
end
|
46
|
-
|
48
|
+
|
47
49
|
def self.chart_overview(*args)
|
48
50
|
ChartOverview.get
|
49
51
|
end
|
50
|
-
|
52
|
+
|
51
53
|
def self.charts(*args)
|
52
54
|
Chart.all
|
53
55
|
end
|
54
|
-
|
56
|
+
|
55
57
|
def self.genre(key)
|
56
58
|
Genre.find(key)
|
57
59
|
end
|
58
|
-
|
60
|
+
|
59
61
|
def self.genre_overview
|
60
62
|
Genre.overview
|
61
63
|
end
|
62
|
-
|
64
|
+
|
63
65
|
def self.genres(*args)
|
64
66
|
Genre.all(*args)
|
65
67
|
end
|
@@ -83,14 +85,14 @@ module Beatport
|
|
83
85
|
def self.releases(*args)
|
84
86
|
Release.all(*args)
|
85
87
|
end
|
86
|
-
|
88
|
+
|
87
89
|
def self.track(id)
|
88
90
|
Track.find(id)
|
89
91
|
end
|
90
|
-
|
92
|
+
|
91
93
|
def self.tracks(*args)
|
92
94
|
Track.all(*args)
|
93
|
-
end
|
94
|
-
|
95
|
+
end
|
96
|
+
|
95
97
|
end
|
96
|
-
end
|
98
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Beatport
|
2
2
|
module Catalog
|
3
3
|
class Artist < Item
|
4
|
+
include Support::Url
|
5
|
+
|
4
6
|
has_many :genres, Genre
|
5
7
|
has_many :subgenres, Genre
|
6
8
|
has_one :images, Images
|
@@ -20,10 +22,10 @@ module Beatport
|
|
20
22
|
:artist_name
|
21
23
|
end
|
22
24
|
end
|
23
|
-
|
25
|
+
|
24
26
|
def top_downloads(options = {})
|
25
27
|
Track.most_popular_for_artist(id, options)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
29
|
-
end
|
31
|
+
end
|
@@ -2,7 +2,7 @@ module Beatport
|
|
2
2
|
module Catalog
|
3
3
|
class Images
|
4
4
|
attr_reader :small, :medium, :large, :waveform, :banner
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(images)
|
7
7
|
images.each do |format, data|
|
8
8
|
instance_variable_set(:"@#{format}", Image.new(data))
|
@@ -10,4 +10,4 @@ module Beatport
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Beatport
|
2
2
|
module Catalog
|
3
3
|
class Label < Item
|
4
|
+
include Support::Url
|
5
|
+
|
4
6
|
has_many :genres, Genre
|
5
7
|
has_many :subgenres, Genre
|
6
8
|
has_many :top_downloads, Track
|
7
9
|
has_many :featured_releases, Release
|
8
10
|
has_many :most_popular_releases, Release
|
9
11
|
has_one :images, Images
|
10
|
-
|
12
|
+
|
11
13
|
class << self
|
12
14
|
def all(options = {})
|
13
15
|
Client.retrieve 'labels', Label, options
|
@@ -32,4 +34,4 @@ module Beatport
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
35
|
-
end
|
37
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Beatport
|
2
2
|
module Catalog
|
3
3
|
class Release < Item
|
4
|
+
include Support::Url
|
5
|
+
|
4
6
|
has_many :artists, Artist
|
5
7
|
has_one :audio_format_fee, AudioFormatFee
|
6
8
|
has_many :genres, Genre
|
@@ -14,15 +16,15 @@ module Beatport
|
|
14
16
|
def discount
|
15
17
|
tracks_price - price
|
16
18
|
end
|
17
|
-
|
19
|
+
|
18
20
|
def self.find(*args)
|
19
21
|
Client.retrieve 'releases', Release, *args
|
20
22
|
end
|
21
23
|
|
22
24
|
def self.all(options={})
|
23
25
|
Client.retrieve 'releases', Release, options
|
24
|
-
end
|
25
|
-
|
26
|
+
end
|
27
|
+
|
26
28
|
def self.featured(*args)
|
27
29
|
Client.retrieve 'featured/releases', Release, *args
|
28
30
|
end
|
@@ -34,4 +36,3 @@ module Beatport
|
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
37
|
-
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Beatport
|
2
|
-
module Catalog
|
2
|
+
module Catalog
|
3
3
|
class Track < Item
|
4
|
+
include Support::Url
|
5
|
+
|
4
6
|
has_many :genres, Genre
|
5
7
|
has_many :sub_genres, Genre
|
6
8
|
has_many :artists, Artist
|
@@ -9,29 +11,30 @@ module Beatport
|
|
9
11
|
has_one :label, Label
|
10
12
|
has_one :price, Price
|
11
13
|
has_one :images, Images
|
14
|
+
has_one :dynamic_images, DynamicImages
|
12
15
|
has_one :audio_format_fee, AudioFormatFee
|
13
16
|
has_one :key, Keys
|
14
|
-
|
17
|
+
|
15
18
|
# Returns the track with the given id
|
16
19
|
def self.find(key)
|
17
20
|
Client.retrieve 'tracks', Track, :key => key
|
18
21
|
end
|
19
|
-
|
22
|
+
|
20
23
|
# Returns all the tracks matching the criterea
|
21
24
|
def self.all(options = {})
|
22
25
|
Client.retrieve 'tracks', Track, options
|
23
|
-
end
|
24
|
-
|
26
|
+
end
|
27
|
+
|
25
28
|
def self.most_popular(options = {})
|
26
29
|
Client.retrieve 'most-popular', Track, options
|
27
30
|
end
|
28
|
-
|
31
|
+
|
29
32
|
def self.most_popular_for_genre(id, options = {})
|
30
33
|
options[:id] = id
|
31
34
|
options[:collection] = true
|
32
35
|
Client.retrieve "most-popular/genre", Track, options
|
33
36
|
end
|
34
|
-
|
37
|
+
|
35
38
|
def self.most_popular_for_artist(id, options = {})
|
36
39
|
options[:id] = id
|
37
40
|
options[:collection] = true
|
@@ -43,7 +46,7 @@ module Beatport
|
|
43
46
|
options[:collection] = true
|
44
47
|
Client.retrieve "most-popular/label", Track, options
|
45
48
|
end
|
46
|
-
|
49
|
+
|
47
50
|
end
|
48
51
|
end
|
49
|
-
end
|
52
|
+
end
|
data/lib/beatport/client.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
module Beatport
|
2
2
|
module Client
|
3
|
+
def self.connection
|
4
|
+
@connection ||= Faraday.new do |conn|
|
5
|
+
conn.use Support::Middleware
|
6
|
+
conn.adapter Faraday.default_adapter # make requests with Net::HTTP
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
3
10
|
def self.client
|
4
11
|
@client ||= Signet::OAuth1::Client.new(
|
5
12
|
:client_credential_key => Beatport.consumer_key,
|
@@ -13,19 +20,20 @@ module Beatport
|
|
13
20
|
@builder ||= Support::QueryBuilder.new
|
14
21
|
end
|
15
22
|
|
16
|
-
def self.
|
17
|
-
|
23
|
+
def self.uri(path, args)
|
24
|
+
Addressable::URI.new(
|
18
25
|
:scheme => 'https',
|
19
26
|
:host => 'api.beatport.com',
|
20
27
|
:path => "/catalog/3/#{path}",
|
21
28
|
:query_values => builder.process(*args)
|
22
|
-
)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.retrieve(path, klass, *args)
|
33
|
+
result = client.fetch_protected_resource(
|
34
|
+
:connection => connection,
|
35
|
+
:uri => uri(path, args).to_s
|
36
|
+
).body
|
29
37
|
|
30
38
|
if result['metadata']['error']
|
31
39
|
raise Error.new("#{result['metadata']['error']}: #{result['metadata']['message']}")
|
data/lib/beatport/item.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
module Beatport
|
2
|
-
|
2
|
+
|
3
3
|
class Item < OpenStruct
|
4
4
|
class << self
|
5
5
|
def associations
|
6
6
|
@associations ||= {}
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def has_one(var, klass)
|
10
10
|
lazy_accessor(var)
|
11
11
|
self.associations[var] = {:list => false, :klass => klass}
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def has_many(var, klass)
|
15
15
|
lazy_accessor(var)
|
16
16
|
self.associations[var] = {:list => true, :klass => klass}
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def lazy_accessor(var)
|
20
20
|
return if respond_to?(var)
|
21
21
|
class_eval "def #{var}; @#{var}; end"
|
@@ -39,25 +39,25 @@ module Beatport
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def initialize(data = {})
|
44
44
|
raise ArgumentError, "Invalid data passed to Item.new: #{data.inspect}" unless data.is_a?(Hash)
|
45
|
-
|
45
|
+
|
46
46
|
# OpenStruct doesn't like id or type, so we store them after the call to super
|
47
47
|
id = data.delete('id')
|
48
48
|
type = data.delete('type')
|
49
|
-
|
49
|
+
|
50
50
|
self.class.associations.each do |k, v|
|
51
51
|
associate(data, k, v[:list], v[:klass])
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
super(data)
|
55
55
|
|
56
56
|
data.each do |k, v|
|
57
57
|
@table[k.to_sym] = Date.parse(v) if k =~ /_date$/
|
58
58
|
@table[k.to_sym] = Regexp.new(v.to_s) if k =~ /_regex$/
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
@table['id'] = id if id
|
62
62
|
@table['type'] = type if type
|
63
63
|
end
|
@@ -65,21 +65,21 @@ module Beatport
|
|
65
65
|
def id
|
66
66
|
@table['id']
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def type
|
70
70
|
@table['type']
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
# Allow treating the item as a hash
|
74
74
|
def [](key)
|
75
75
|
send(key) if respond_to?(key)
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def associate(data, var, collection = false, klass = Item)
|
79
79
|
a = data.delete(var.to_s)
|
80
|
-
|
80
|
+
|
81
81
|
return unless a
|
82
|
-
|
82
|
+
|
83
83
|
if collection && a.is_a?(Array)
|
84
84
|
a = a.compact.map { |g| klass.new(g) }
|
85
85
|
elsif !collection && a.is_a?(Hash)
|
@@ -90,10 +90,10 @@ module Beatport
|
|
90
90
|
else
|
91
91
|
raise ArgumentError, "Invalid data for association: '#{var}' = #{a.inspect}"
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
instance_variable_set(:"@#{var}", a)
|
95
95
|
end
|
96
|
-
|
97
|
-
|
96
|
+
|
97
|
+
|
98
98
|
end
|
99
|
-
end
|
99
|
+
end
|
data/lib/beatport/support.rb
CHANGED
@@ -3,5 +3,7 @@ module Beatport
|
|
3
3
|
autoload :Inflector, 'beatport/support/inflector'
|
4
4
|
autoload :Parser, 'beatport/support/parser'
|
5
5
|
autoload :QueryBuilder, 'beatport/support/query_builder'
|
6
|
+
autoload :Middleware, 'beatport/support/middleware'
|
7
|
+
autoload :Url, 'beatport/support/url'
|
6
8
|
end
|
7
9
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Beatport
|
2
|
+
module Support
|
3
|
+
class Middleware < Faraday::Response::Middleware
|
4
|
+
def parse(body)
|
5
|
+
body = jsonify(body)
|
6
|
+
end
|
7
|
+
|
8
|
+
def jsonify(body)
|
9
|
+
body = ::JSON.parse(body)
|
10
|
+
body = Support::Inflector.process_keys(body) { |k| Support::Inflector.underscore(k) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/catalog/artist_spec.rb
CHANGED
@@ -12,12 +12,13 @@ module Beatport::Catalog
|
|
12
12
|
|
13
13
|
describe 'structure' do
|
14
14
|
subject { Artist.find(7181) }
|
15
|
-
|
15
|
+
|
16
16
|
it { should be_an(Artist) }
|
17
17
|
its (:id) { should == 7181 }
|
18
18
|
its (:type) { should == "artist" }
|
19
19
|
its (:name) { should == "Above & Beyond" }
|
20
20
|
its (:slug) { should == "above-and-beyond" }
|
21
|
+
its (:url) { should == "http://www.beatport.com/artist/above-and-beyond/7181" }
|
21
22
|
its (:last_publish_date) { should >= Date.new(2011, 12, 15)}
|
22
23
|
its (:biography) { should == "" }
|
23
24
|
its (:'genres.length') { should be > 1 }
|
@@ -28,18 +29,18 @@ module Beatport::Catalog
|
|
28
29
|
its (:'images.large.url') { should == "http://geo-media.beatport.com/image/4686424.jpg" }
|
29
30
|
# its (:'featured_releases.length') { should be > 1 }
|
30
31
|
end
|
31
|
-
|
32
|
+
|
32
33
|
describe '.find' do
|
33
34
|
context 'with a single id' do
|
34
35
|
subject { Artist.find(7181) }
|
35
|
-
|
36
|
+
|
36
37
|
it { should be_an(Artist) }
|
37
38
|
its (:id) { should == 7181 }
|
38
39
|
end
|
39
40
|
|
40
41
|
context 'with multiple ids' do
|
41
42
|
subject { Artist.find(7181, 7182) }
|
42
|
-
|
43
|
+
|
43
44
|
# it { should be_a(Collection) }
|
44
45
|
its (:length) { should == 2 }
|
45
46
|
it "returns the requested artists" do
|
@@ -49,18 +50,18 @@ module Beatport::Catalog
|
|
49
50
|
|
50
51
|
context 'with an array of ids' do
|
51
52
|
subject { Artist.find([7181, 7182]) }
|
52
|
-
|
53
|
+
|
53
54
|
# it { should be_a(Collection) }
|
54
55
|
its (:length) { should == 2 }
|
55
56
|
it "returns the requested artists" do
|
56
57
|
subject.map(&:id).should == [7181, 7182]
|
57
58
|
end
|
58
59
|
end
|
59
|
-
end
|
60
|
-
|
60
|
+
end
|
61
|
+
|
61
62
|
describe '.find_by_name' do
|
62
63
|
subject { Artist.find_by_name('Above & Beyond') }
|
63
|
-
|
64
|
+
|
64
65
|
it { should be_an(Artist) }
|
65
66
|
its (:id) { should == 7181 }
|
66
67
|
end
|
@@ -70,39 +71,39 @@ module Beatport::Catalog
|
|
70
71
|
artists = Artist.all
|
71
72
|
artists.length.should == 10
|
72
73
|
end
|
73
|
-
|
74
|
+
|
74
75
|
it "should get the first page with 5 artists per page" do
|
75
76
|
artists = Artist.all :per_page => 5, :page => 1
|
76
77
|
artists.length.should == 5
|
77
78
|
artists.page.should == 1
|
78
79
|
artists.per_page.should == 5
|
79
80
|
end
|
80
|
-
|
81
|
+
|
81
82
|
it "should get the first page with 5 artists per page, sorted by publish date and artist id, for the House genre" do
|
82
83
|
artists = Artist.all(:sort_by=> { :publish_date => 'asc', :artist_id => 'asc' }, :genre_id=> 5, :per_page=>5, :page=>1)
|
83
84
|
artists.length.should == 5
|
84
|
-
|
85
|
+
|
85
86
|
old_id = nil
|
86
87
|
old_date = artists.first.last_publish_date
|
87
|
-
|
88
|
+
|
88
89
|
artists.each do |artist|
|
89
90
|
old_id = nil if old_date.to_s != artist.last_publish_date.to_s
|
90
|
-
|
91
|
+
|
91
92
|
# beatport has some bad genre data?
|
92
93
|
# artist.genres.map(&:id).should include(5)
|
93
94
|
artist.id.should be >= old_id if old_id
|
94
95
|
artist.last_publish_date.should be >= old_date if old_date
|
95
|
-
|
96
|
+
|
96
97
|
old_id = artist.id
|
97
98
|
old_date = artist.publish_date
|
98
99
|
end
|
99
100
|
end
|
100
|
-
|
101
|
+
|
101
102
|
it "should get arbitrary artists with filter metadata for all genre names and artist names" do
|
102
103
|
artists = Artist.all :return_facets => ['genre_name', 'performer_name']
|
103
|
-
|
104
|
+
|
104
105
|
artists.facets['fields']['performer_name'].count.should be > 1
|
105
|
-
artists.facets['fields']['genre_name'].count.should be > 1
|
106
|
+
artists.facets['fields']['genre_name'].count.should be > 1
|
106
107
|
|
107
108
|
end
|
108
109
|
|
@@ -110,11 +111,11 @@ module Beatport::Catalog
|
|
110
111
|
pending "Request doesn't return any results"
|
111
112
|
|
112
113
|
artists = Artist.all :facets => {:genre_name => ['Trance', 'Progessive House']}
|
113
|
-
|
114
|
+
|
114
115
|
artists.each do |artist|
|
115
116
|
artists = artist['artists'].map { |a| a['name'] }
|
116
117
|
artists.should include("Above & Beyond")
|
117
|
-
|
118
|
+
|
118
119
|
genres = artist['genres'].map { |a| a['name'] }
|
119
120
|
genres.should include('Trance')
|
120
121
|
end
|
@@ -122,4 +123,4 @@ module Beatport::Catalog
|
|
122
123
|
|
123
124
|
end
|
124
125
|
end
|
125
|
-
end
|
126
|
+
end
|
@@ -12,7 +12,7 @@ module Beatport::Catalog
|
|
12
12
|
|
13
13
|
describe 'structure' do
|
14
14
|
subject { Country.find('au') }
|
15
|
-
|
15
|
+
|
16
16
|
it { should be_a(Country) }
|
17
17
|
its (:id) { should == 5 }
|
18
18
|
its (:code) { should == "AUS" }
|
@@ -22,11 +22,11 @@ module Beatport::Catalog
|
|
22
22
|
its (:vat_rate) { should == 0 }
|
23
23
|
its (:iso3166_3) { should == "AUS" }
|
24
24
|
its (:iso3166_2) { should == "AU" }
|
25
|
-
its (:'currency.code') { should == "
|
26
|
-
its (:'currency.name') { should == "Dollar" }
|
25
|
+
its (:'currency.code') { should == "AUD" }
|
26
|
+
its (:'currency.name') { should == "Australian Dollar" }
|
27
27
|
its (:'states.first.code') { should == 'ACT' }
|
28
|
-
its (:'states.first.type') { should == 'territory' }
|
28
|
+
its (:'states.first.type') { should == 'territory' }
|
29
29
|
its (:'states.first.name') { should == "Australian Capital Territory" }
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
data/spec/catalog/label_spec.rb
CHANGED
@@ -12,36 +12,37 @@ module Beatport::Catalog
|
|
12
12
|
|
13
13
|
describe 'structure' do
|
14
14
|
subject { Label.find(1390) }
|
15
|
-
|
15
|
+
|
16
16
|
it { should be_a(Label) }
|
17
17
|
its (:id) { should == 1390 }
|
18
18
|
its (:type) { should == "label" }
|
19
19
|
its (:name) { should == "Anjunadeep" }
|
20
|
-
its (:slug) { should == "anjunadeep" }
|
20
|
+
its (:slug) { should == "anjunadeep" }
|
21
|
+
its (:url) { should == "http://www.beatport.com/label/anjunadeep/1390" }
|
21
22
|
pending "source type is no longer returned?"
|
22
23
|
#its (:source_type) { should == ["store", "mobile", "sushi"] }
|
23
24
|
|
24
25
|
its (:last_publish_date) { should > Date.new(2012, 9, 10) }
|
25
26
|
its (:biography) { should == "" }
|
26
27
|
its (:'genres.length') { should be > 1 }
|
27
|
-
its (:'sub_genres.length') { should be > 0 }
|
28
|
+
its (:'sub_genres.length') { should be > 0 }
|
28
29
|
# its (:display_level) { should == 1 }
|
29
30
|
its (:'images.small.url') { should == "http://geo-media.beatport.com/image/3406.jpg"}
|
30
31
|
its (:'images.medium.url') { should == "http://geo-media.beatport.com/image/1191.jpg"}
|
31
|
-
its (:'images.banner.url') { should == "http://geo-media.beatport.com/image/345152.jpg"}
|
32
|
+
its (:'images.banner.url') { should == "http://geo-media.beatport.com/image/345152.jpg"}
|
32
33
|
# its (:'top_downloads.length') { should be > 1 }
|
33
34
|
# its (:'featured_releases.length') { should be > 1 }
|
34
35
|
# its (:'most_popular_releases.length') { should be > 1 }
|
35
36
|
|
36
37
|
end
|
37
|
-
|
38
|
+
|
38
39
|
describe '.find' do
|
39
40
|
it "should get Anjunadeep give id 1390" do
|
40
41
|
label = Label.find(1390)
|
41
42
|
label.id.should == 1390
|
42
43
|
end
|
43
44
|
end
|
44
|
-
|
45
|
+
|
45
46
|
describe '.find_by_name' do
|
46
47
|
it 'returns Anjunadeep' do
|
47
48
|
label = Label.find_by_name('Anjunadeep')
|
@@ -54,55 +55,55 @@ module Beatport::Catalog
|
|
54
55
|
labels = Label.all
|
55
56
|
labels.length.should == 10
|
56
57
|
end
|
57
|
-
|
58
|
+
|
58
59
|
it "should get the first page with 5 labels per page" do
|
59
60
|
labels = Label.all :per_page => 5, :page => 1
|
60
61
|
labels.length.should == 5
|
61
62
|
labels.page.should == 1
|
62
63
|
labels.per_page.should == 5
|
63
64
|
end
|
64
|
-
|
65
|
+
|
65
66
|
it "should get the first page with 5 labels per page, sorted by publish date and label id, for the House genre" do
|
66
67
|
labels = Label.all(:sort_by=> ['publishDate asc', 'labelId asc'], :genre_id=> 5, :per_page=>5, :page=>1)
|
67
68
|
labels.length.should == 5
|
68
|
-
|
69
|
+
|
69
70
|
old_id = nil
|
70
71
|
old_date = labels.first.last_publish_date
|
71
|
-
|
72
|
+
|
72
73
|
labels.each do |label|
|
73
74
|
old_id = nil if old_date.to_s != label.last_publish_date.to_s
|
74
|
-
|
75
|
+
|
75
76
|
# beatport has some bad genre data?
|
76
77
|
# label.genres.map(&:id)) { should include(5)
|
77
78
|
label.id.should be >= old_id if old_id
|
78
79
|
label.last_publish_date.should be >= old_date if old_date
|
79
|
-
|
80
|
+
|
80
81
|
old_id = label.id
|
81
82
|
old_date = label.last_publish_date
|
82
83
|
end
|
83
84
|
end
|
84
|
-
|
85
|
+
|
85
86
|
it "should get arbitrary labels with filter metadata for all genre names and label names" do
|
86
87
|
labels = Label.all :return_facets => ['genre_name', 'performer_name']
|
87
|
-
|
88
|
+
|
88
89
|
# no worky
|
89
90
|
# labels.facets['fields']['performer_name'].count) { should be > 1
|
90
|
-
labels.facets['fields']['genre_name'].count.should be > 1
|
91
|
+
labels.facets['fields']['genre_name'].count.should be > 1
|
91
92
|
end
|
92
93
|
|
93
94
|
it "should get all trance labels for above & beyond" do
|
94
95
|
labels = Label.all :facets => {:genre_name => ['Trance', 'Progessive House']}
|
95
|
-
|
96
|
+
|
96
97
|
labels.each do |label|
|
97
98
|
labels = label['labels'].map { |a| a['name'] }
|
98
99
|
labels.should include("Above & Beyond")
|
99
|
-
|
100
|
+
|
100
101
|
genres = label['genres'].map { |a| a['name'] }
|
101
102
|
genres.should include('Trance')
|
102
103
|
end
|
103
104
|
end
|
104
105
|
end
|
105
|
-
|
106
|
+
|
106
107
|
describe '.featured' do
|
107
108
|
it "should get the featured labels for the Home page" do
|
108
109
|
pending "deprecated?"
|
@@ -110,10 +111,10 @@ module Beatport::Catalog
|
|
110
111
|
labels = Label.featured
|
111
112
|
labels.length.should be > 1
|
112
113
|
end
|
113
|
-
|
114
|
+
|
114
115
|
it "should get the featured labels for the Trance page" do
|
115
116
|
pending "deprecated?"
|
116
|
-
|
117
|
+
|
117
118
|
labels = Label.featured :genre_id => 7
|
118
119
|
labels.length.should be > 1
|
119
120
|
labels.each do |label|
|
@@ -122,4 +123,4 @@ module Beatport::Catalog
|
|
122
123
|
end
|
123
124
|
end
|
124
125
|
end
|
125
|
-
end
|
126
|
+
end
|
@@ -12,7 +12,7 @@ module Beatport::Catalog
|
|
12
12
|
|
13
13
|
describe 'structure' do
|
14
14
|
subject { Release.find(164808) }
|
15
|
-
|
15
|
+
|
16
16
|
it { should be_a(Release) }
|
17
17
|
its (:id) { should == 164808 }
|
18
18
|
its (:type) { should == 'release' }
|
@@ -25,6 +25,7 @@ module Beatport::Catalog
|
|
25
25
|
its (:current_status) { should == "General Content"}
|
26
26
|
its (:catalog_number) { should == "ANJCDCO011D"}
|
27
27
|
its (:purchasable) { should == true }
|
28
|
+
its (:url) { should == "http://www.beatport.com/release/anjunabeats-volume-6-unmixed-dj-ready/164808" }
|
28
29
|
its (:'price.to_s') { should == "9.99" }
|
29
30
|
its (:'tracks_price.to_s') { should == "43.21" }
|
30
31
|
its (:'audio_format_fee.wav.to_s') { should == '21.75'}
|
@@ -34,64 +35,64 @@ module Beatport::Catalog
|
|
34
35
|
specify { subject.genres.map(&:name).sort.should == ["Progressive House", "Trance"] }
|
35
36
|
its (:'images.small.url') { should == "http://geo-media.beatport.com/image/392699.jpg" }
|
36
37
|
its (:'images.medium.url') { should == "http://geo-media.beatport.com/image/392700.jpg" }
|
37
|
-
its (:'images.large.url') { should == "http://geo-media.beatport.com/image/392701.jpg" }
|
38
|
+
its (:'images.large.url') { should == "http://geo-media.beatport.com/image/392701.jpg" }
|
38
39
|
its (:'discount.to_s') { should == "33.22" }
|
39
40
|
# its (:'recommendations.releases.length') { should > 1 }
|
40
41
|
end
|
41
|
-
|
42
|
+
|
42
43
|
describe '.find' do
|
43
44
|
it "should get Anjunabeats Volume 6 when given id 164808" do
|
44
45
|
release = Release.find(164808)
|
45
46
|
release.id.should == 164808
|
46
47
|
end
|
47
48
|
end
|
48
|
-
|
49
|
+
|
49
50
|
describe '.all' do
|
50
51
|
it "should get arbitrary releases" do
|
51
52
|
releases = Release.all
|
52
53
|
releases.length.should == 10
|
53
54
|
end
|
54
|
-
|
55
|
+
|
55
56
|
it "should get the first page with 5 releases per page" do
|
56
57
|
releases = Release.all :per_page => 5, :page => 1
|
57
58
|
releases.length.should == 5
|
58
59
|
releases.page.should == 1
|
59
60
|
releases.per_page.should == 5
|
60
61
|
end
|
61
|
-
|
62
|
+
|
62
63
|
it "should get the first page with 5 releases per page, sorted by publish date and release id, for the House genre" do
|
63
64
|
releases = Release.all(:sort_by=> ['publishDate asc', 'releaseId asc'], :genre_id=> 5, :per_page=>5, :page=>1)
|
64
65
|
releases.length.should == 5
|
65
|
-
|
66
|
+
|
66
67
|
old_id = nil
|
67
68
|
old_date = releases.first.publish_date
|
68
|
-
|
69
|
+
|
69
70
|
releases.each do |release|
|
70
71
|
old_id = nil if old_date.to_s != release.publish_date.to_s
|
71
|
-
|
72
|
+
|
72
73
|
release.genres.first.id.should == 5
|
73
74
|
release.id.should be >= old_id if old_id
|
74
75
|
release.publish_date.should be >= old_date if old_date
|
75
|
-
|
76
|
+
|
76
77
|
old_id = release.id
|
77
78
|
old_date = release.publish_date
|
78
79
|
end
|
79
80
|
end
|
80
|
-
|
81
|
+
|
81
82
|
it "should get arbitrary releases with filter metadata for all genre names and artist names" do
|
82
83
|
releases = Release.all :return_facets => ['genre_name', 'performer_name']
|
83
|
-
|
84
|
+
|
84
85
|
releases.facets['fields']['performer_name'].count.should be > 1
|
85
|
-
releases.facets['fields']['genre_name'].count.should be > 1
|
86
|
+
releases.facets['fields']['genre_name'].count.should be > 1
|
86
87
|
end
|
87
88
|
|
88
89
|
it "should get all trance releases for above & beyond" do
|
89
90
|
releases = Release.all :facets => {:genre_name => 'Trance', :performer_name => 'Above & Beyond'}
|
90
|
-
|
91
|
+
|
91
92
|
releases.each do |release|
|
92
93
|
artists = release['artists'].map { |a| a['name'] }
|
93
94
|
artists.should include("Above & Beyond")
|
94
|
-
|
95
|
+
|
95
96
|
genres = release['genres'].map { |a| a['name'] }
|
96
97
|
genres.should include('Trance')
|
97
98
|
end
|
@@ -103,29 +104,29 @@ module Beatport::Catalog
|
|
103
104
|
releases = Release.featured
|
104
105
|
releases.length.should be > 1
|
105
106
|
end
|
106
|
-
|
107
|
+
|
107
108
|
it "should get the featured releases for the Trance page" do
|
108
109
|
releases = Release.featured :genre_id => 7
|
109
110
|
releases.length.should be > 1
|
110
111
|
releases.each do |release|
|
111
112
|
release.genres.map(&:id).should include(7)
|
112
|
-
end
|
113
|
+
end
|
113
114
|
end
|
114
|
-
|
115
|
+
|
115
116
|
it "should get 'Just Added' featured releases for the Trance page" do
|
116
117
|
releases = Release.featured :genre_id => 7, :just_added => true
|
117
118
|
releases.length.should be > 1
|
118
119
|
releases.each do |release|
|
119
120
|
release.genres.map(&:id).should include(7)
|
120
|
-
end
|
121
|
+
end
|
121
122
|
end
|
122
|
-
|
123
|
+
|
123
124
|
it "should not give the same releases with justAdded true and false" do
|
124
125
|
pending "test will not give consistent results, revisit"
|
125
|
-
|
126
|
+
|
126
127
|
featured = Release.featured :genre_id => 7
|
127
128
|
just_added = Release.featured :genre_id => 7, :just_added => true
|
128
|
-
|
129
|
+
|
129
130
|
featured.map(&:id).should_not == just_added.map(&:id)
|
130
131
|
end
|
131
132
|
end
|
@@ -135,15 +136,15 @@ module Beatport::Catalog
|
|
135
136
|
release = Release.find(164808)
|
136
137
|
release.tracks
|
137
138
|
end
|
138
|
-
|
139
|
+
|
139
140
|
it "should return all 29 tracks for Anjunabeats Volume 6" do
|
140
141
|
subject.count.should == 29
|
141
142
|
end
|
142
|
-
|
143
|
+
|
143
144
|
it "should return paper jet as the first track" do
|
144
145
|
subject.first.name.should == "Paper Jet"
|
145
146
|
end
|
146
|
-
|
147
|
+
|
147
148
|
end
|
148
149
|
end
|
149
|
-
end
|
150
|
+
end
|
data/spec/catalog/track_spec.rb
CHANGED
@@ -19,7 +19,7 @@ module Beatport::Catalog
|
|
19
19
|
|
20
20
|
describe 'structure' do
|
21
21
|
subject { Track.find(1217790) }
|
22
|
-
|
22
|
+
|
23
23
|
it { should be_a(Track) }
|
24
24
|
its (:id) { should == 1217790 }
|
25
25
|
its (:type) { should == 'track' }
|
@@ -29,9 +29,10 @@ module Beatport::Catalog
|
|
29
29
|
its (:title) { should == "Tonight (IMS Anthem 2009) (Above & Beyond Remix)"}
|
30
30
|
its (:release_date) { should == Date.new(2010,05,17) }
|
31
31
|
its (:publish_date) { should == Date.new(2010,05,17) }
|
32
|
-
its (:sample_url) { should == 'http://geo-samples.beatport.com/lofi/1217790.LOFI.mp3' }
|
33
|
-
its (:rtmp_stream_url) { should == 'rtmp://geo-rtmp-samples.beatport.com/beatport/_definst_/mp3:lofi_samples/items/volumes/volume7/items/1000000/200000/10000/7000/700/90/1217790.LOFI'}
|
32
|
+
#its (:sample_url) { should == 'http://geo-samples.beatport.com/lofi/1217790.LOFI.mp3' }
|
33
|
+
#its (:rtmp_stream_url) { should == 'rtmp://geo-rtmp-samples.beatport.com/beatport/_definst_/mp3:lofi_samples/items/volumes/volume7/items/1000000/200000/10000/7000/700/90/1217790.LOFI'}
|
34
34
|
its (:exclusive) { should be_false }
|
35
|
+
its (:url) { should == "http://www.beatport.com/track/tonight-ims-anthem-2009-above-and-beyond-remix/1217790" }
|
35
36
|
its (:'price.to_s') { should == "1.49" }
|
36
37
|
its (:'audio_format_fee.wav.to_s') { should == "0.75" }
|
37
38
|
its (:'audio_format_fee.aiff.to_s') { should == "0.75" }
|
@@ -50,59 +51,65 @@ module Beatport::Catalog
|
|
50
51
|
its (:'images.small.url') { should == 'http://geo-media.beatport.com/image/674759.jpg' }
|
51
52
|
its (:'images.medium.url') { should == 'http://geo-media.beatport.com/image/674760.jpg' }
|
52
53
|
its (:'images.large.url') { should == 'http://geo-media.beatport.com/image/674761.jpg' }
|
53
|
-
its (:'images.waveform.url') { should == 'http://geo-media.beatport.com/image/1268229.png' }
|
54
|
+
its (:'images.waveform.url') { should == 'http://geo-media.beatport.com/image/1268229.png' }
|
55
|
+
its (:'dynamic_images.main.url') { should == '//geo-media.beatport.com/image_size{hq}/{w}x{h}/674761.jpg' }
|
56
|
+
|
57
|
+
it "should render a dynamic url of the right size" do
|
58
|
+
subject.dynamic_images.main.dynamic_url(w: 120, h: 120).should == '//geo-media.beatport.com/image_size/120x120/674761.jpg'
|
59
|
+
end
|
60
|
+
|
54
61
|
end
|
55
|
-
|
62
|
+
|
56
63
|
describe '.find' do
|
57
64
|
it "should find the track with the id 1217790" do
|
58
65
|
track = Track.find(1217790)
|
59
66
|
track.id.should == 1217790
|
60
67
|
end
|
61
68
|
end
|
62
|
-
|
69
|
+
|
63
70
|
describe '.all' do
|
64
71
|
it "should get arbitrary" do
|
65
72
|
Track.all.length.should be > 1
|
66
73
|
end
|
67
|
-
|
74
|
+
|
68
75
|
it "should get the first page with 5 tracks per page" do
|
69
76
|
tracks = Track.all(:per_page => 5, :page => 1)
|
70
77
|
tracks.length.should == 5
|
71
78
|
tracks.page.should == 1
|
72
79
|
tracks.per_page.should == 5
|
73
80
|
end
|
74
|
-
|
81
|
+
|
75
82
|
it "should get the first page with 5 tracks per page, sorted by publish date and release if, for the House genre" do
|
76
83
|
tracks = Track.all(:sort_by=> ['publishDate asc', 'releaseId asc'], :genre_id=> 5, :per_page=>5, :page=>1)
|
77
84
|
tracks.length.should == 5
|
78
|
-
|
85
|
+
|
79
86
|
old_id = tracks.first.id
|
80
87
|
old_date = tracks.first.publish_date
|
81
|
-
|
88
|
+
|
82
89
|
tracks.each do |track|
|
83
90
|
track.genres.first.id.should == 5
|
84
91
|
track.id.should be >= old_id
|
85
92
|
track.publish_date.should be >= old_date
|
86
|
-
|
93
|
+
|
87
94
|
old_id = track.id
|
88
95
|
old_date = track.publish_date
|
89
96
|
end
|
90
97
|
end
|
91
|
-
|
98
|
+
|
92
99
|
it "should get arbitrary tracks with filter metadata for all genre names and artist names" do
|
93
100
|
tracks = Track.all :return_facets => ['genre_name', 'performer_name']
|
94
|
-
|
101
|
+
|
95
102
|
tracks.facets['fields']['performer_name'].count.should be > 1
|
96
|
-
tracks.facets['fields']['genre_name'].count.should be > 1
|
103
|
+
tracks.facets['fields']['genre_name'].count.should be > 1
|
97
104
|
end
|
98
105
|
|
99
106
|
it "should get all trance tracks for above & beyond" do
|
100
107
|
tracks = Track.all :facets => {:genre_name => 'Trance', :performer_name => 'Above & Beyond'}
|
101
|
-
|
108
|
+
|
102
109
|
tracks.each do |track|
|
103
110
|
artists = track['artists'].map { |a| a['name'] }
|
104
111
|
artists.should include("Above & Beyond")
|
105
|
-
|
112
|
+
|
106
113
|
genres = track['genres'].map { |a| a['name'] }
|
107
114
|
genres.should include('Trance')
|
108
115
|
end
|
@@ -115,7 +122,7 @@ module Beatport::Catalog
|
|
115
122
|
tracks.count.should == 100
|
116
123
|
tracks.length.should == 10
|
117
124
|
end
|
118
|
-
|
125
|
+
|
119
126
|
it "should get the top classics for the home page" do
|
120
127
|
tracks = Track.most_popular :status => 5
|
121
128
|
tracks.count.should == 100
|
@@ -125,15 +132,15 @@ module Beatport::Catalog
|
|
125
132
|
it "should not return the same results for most_popular and classics" do
|
126
133
|
popular = Track.most_popular
|
127
134
|
classics = Track.most_popular :status => 5
|
128
|
-
|
135
|
+
|
129
136
|
popular.map(&:id).should_not == classics.map(&:id)
|
130
137
|
end
|
131
138
|
end
|
132
|
-
|
139
|
+
|
133
140
|
describe '.most_popular_for_genre' do
|
134
141
|
it "should get the top download for the trance page" do
|
135
142
|
tracks = Track.most_popular_for_genre 7
|
136
|
-
|
143
|
+
|
137
144
|
tracks.count.should == 100
|
138
145
|
tracks.length.should == 10
|
139
146
|
tracks.each do |track|
|
@@ -143,19 +150,19 @@ module Beatport::Catalog
|
|
143
150
|
|
144
151
|
it "should get the top classics for the trance page" do
|
145
152
|
tracks = Track.most_popular_for_genre 7, :status => 5
|
146
|
-
|
153
|
+
|
147
154
|
tracks.each do |track|
|
148
155
|
track.genres.map(&:id).should include(7)
|
149
156
|
end
|
150
157
|
end
|
151
|
-
|
158
|
+
|
152
159
|
it "should not return the same results for most_popular and classics" do
|
153
160
|
popular = Track.most_popular_for_genre 7
|
154
161
|
classics = Track.most_popular_for_genre 7, :status => 5
|
155
|
-
|
162
|
+
|
156
163
|
popular.map(&:id).should_not == classics.map(&:id)
|
157
|
-
end
|
158
|
-
|
164
|
+
end
|
165
|
+
|
159
166
|
end
|
160
167
|
|
161
168
|
describe '.most_popular_for_artist' do
|
@@ -175,7 +182,7 @@ module Beatport::Catalog
|
|
175
182
|
tracks.each do |track|
|
176
183
|
track.label.id.should == 804
|
177
184
|
end
|
178
|
-
end
|
185
|
+
end
|
179
186
|
end
|
180
187
|
end
|
181
188
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beatport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: faraday
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.8.8
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.8
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: money
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,6 +215,8 @@ files:
|
|
199
215
|
- lib/beatport/catalog/country.rb
|
200
216
|
- lib/beatport/catalog/currency.rb
|
201
217
|
- lib/beatport/catalog/djprofile.rb
|
218
|
+
- lib/beatport/catalog/dynamic_image.rb
|
219
|
+
- lib/beatport/catalog/dynamic_images.rb
|
202
220
|
- lib/beatport/catalog/feature.rb
|
203
221
|
- lib/beatport/catalog/genre.rb
|
204
222
|
- lib/beatport/catalog/home.rb
|
@@ -228,8 +246,10 @@ files:
|
|
228
246
|
- lib/beatport/price.rb
|
229
247
|
- lib/beatport/support.rb
|
230
248
|
- lib/beatport/support/inflector.rb
|
249
|
+
- lib/beatport/support/middleware.rb
|
231
250
|
- lib/beatport/support/parser.rb
|
232
251
|
- lib/beatport/support/query_builder.rb
|
252
|
+
- lib/beatport/support/url.rb
|
233
253
|
- spec/beatport_spec.rb
|
234
254
|
- spec/catalog/account_type_spec.rb
|
235
255
|
- spec/catalog/artist_spec.rb
|
@@ -270,7 +290,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
270
290
|
version: '0'
|
271
291
|
segments:
|
272
292
|
- 0
|
273
|
-
hash:
|
293
|
+
hash: 746907513197344592
|
274
294
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
275
295
|
none: false
|
276
296
|
requirements:
|