spotifiery 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -28,13 +28,13 @@ There are three "searchable items":
28
28
 
29
29
  To search for a track you can do:
30
30
 
31
- Spotifiery::Searchable::Track.find(:q => 'Stairway to Heaven')
31
+ $ Spotifiery::Searchable::Track.find(:q => 'Stairway to Heaven')
32
32
 
33
33
  Which will return a SearchResult containing tracks called "Stairway to Heaven".
34
34
 
35
35
  It accepts the same params as the spotify API so if you want to look for the page 2 of search results you should do:
36
36
 
37
- Spotifiery::Searchable::Track.find(:q => 'Stairway to Heaven', :page => 2)
37
+ $ Spotifiery::Searchable::Track.find(:q => 'Stairway to Heaven', :page => 2)
38
38
 
39
39
  A find will return a SearchResult object which contains metadata about the query performed like "num_results", "limit", "offset", "page"... and of course the result set, which can be accessed via the results method (if you've searched for tracks you can use the tracks method too, the same applies to albums or artists).
40
40
 
@@ -8,13 +8,13 @@ module Spotifiery
8
8
 
9
9
  class Base
10
10
 
11
- def initialize response
11
+ def initialize response, response_class = nil
12
12
 
13
13
  response_hash = HashWithIndifferentAccess.new response
14
14
 
15
15
  @info = response_hash[:info]
16
16
  response_results = response_hash[ ActiveSupport::Inflector.pluralize(@info[:type]) ]
17
- response_class = ActiveSupport::Inflector.constantize( "Spotifiery::Searchable::" + ActiveSupport::Inflector.titleize(@info[:type]))
17
+ response_class = ActiveSupport::Inflector.constantize( "Spotifiery::Searchable::" + ActiveSupport::Inflector.titleize(@info[:type])) if response_class.blank?
18
18
  @results = response_results.map{|result_hash| response_class.new(result_hash) }
19
19
  end
20
20
 
@@ -7,6 +7,10 @@ module Spotifiery
7
7
  LOOKUPS = ['artist' , 'track']
8
8
  QUERY_EXTRA_DEFAULT = 'trackdetail'
9
9
 
10
+ def self.base_name
11
+ 'album'
12
+ end
13
+
10
14
  private
11
15
 
12
16
  # Spotify messed it up with albums and artists.
@@ -6,6 +6,11 @@ module Spotifiery
6
6
  include Base
7
7
  LOOKUPS = ['album']
8
8
  QUERY_EXTRA_DEFAULT = 'albumdetail'
9
+
10
+ def self.base_name
11
+ 'artist'
12
+ end
13
+
9
14
  end
10
15
 
11
16
  end
@@ -24,14 +24,14 @@ module Spotifiery
24
24
  # Accept the same params as spotify search API
25
25
  def find opts = {}
26
26
  parsed_response = ask_spotify opts
27
- Spotifiery::SearchResult::Base.new parsed_response
27
+ Spotifiery::SearchResult::Base.new parsed_response, self
28
28
  end
29
29
 
30
30
  private
31
31
 
32
32
  def ask_spotify opts = {}
33
33
  opts = {:q => '', :page => '1'}.merge opts
34
- self.get("/#{name.demodulize.downcase}.json" , :query => opts.to_param ).parsed_response
34
+ self.get("/#{base_name.demodulize.downcase}.json" , :query => opts.to_param ).parsed_response
35
35
  end
36
36
  end
37
37
 
@@ -96,7 +96,7 @@ module Spotifiery
96
96
 
97
97
  # Define base attribute methods from an Spotify lookup
98
98
  def set_base_attributes_by_lookup attributes_hash
99
- searchable_type = self.class.name.demodulize.downcase
99
+ searchable_type = self.class.base_name.demodulize.downcase
100
100
  initialize_base_attributes_getters attributes_hash[ searchable_type ]
101
101
  end
102
102
 
@@ -6,6 +6,11 @@ module Spotifiery
6
6
  include Base
7
7
  LOOKUPS = ['artist' , 'album']
8
8
  QUERY_EXTRA_DEFAULT = nil
9
+
10
+ def self.base_name
11
+ 'track'
12
+ end
13
+
9
14
  end
10
15
 
11
16
  end
@@ -1,3 +1,3 @@
1
1
  module Spotifiery
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spotifiery.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Spotifiery::VERSION
17
17
 
18
18
  gem.add_dependency "httparty", ">= 0.9.0"
19
- gem.add_dependency %q<active_support>, ">= 3.0"
19
+ gem.add_dependency %q<activesupport>, ">= 3.0"
20
20
 
21
21
  gem.add_development_dependency "rspec", "~> 2.11.0"
22
22
  gem.add_development_dependency "webmock", "< 1.9.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotifiery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2012-12-13 00:00:00.000000000 Z
12
+ date: 2013-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -28,7 +28,7 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.9.0
30
30
  - !ruby/object:Gem::Dependency
31
- name: active_support
31
+ name: activesupport
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 1.8.24
151
+ rubygems_version: 1.8.25
152
152
  signing_key:
153
153
  specification_version: 3
154
154
  summary: This gem provides an API wrapper for the spotify Web search API