meta-spotify 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ Gemfile.lock
21
+
22
+ ## PROJECT::SPECIFIC
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/HISTORY CHANGED
@@ -1,13 +1,27 @@
1
+ === 0.2.0 / 2012-08-31
2
+
3
+ * 1 major update
4
+
5
+ * Updated to use Httparty > 0.8
6
+
7
+ Also removed Jeweler and dependency on Crack.
8
+
9
+ === 0.1.6 / 2012-03-12
10
+
11
+ * 1 bug fix
12
+
13
+ * restricted Httparty to < 0.8
14
+
1
15
  === 0.1.5 / 2009-12-19
2
16
 
3
17
  * 1 minor enhancement
4
-
18
+
5
19
  * Added access to musicbrainz and allmusic ids for tracks
6
20
 
7
21
  === 0.1.4 / 2009-11-19
8
22
 
9
23
  * 2 minor enhancements
10
-
24
+
11
25
  * Now stores the URI of the original object looked up
12
26
  * Tests for an album lookup with track details
13
27
 
@@ -16,11 +30,11 @@
16
30
  * 1 minor enhancement
17
31
 
18
32
  * Added popularity to artists and albums when they are a result of a search
19
-
33
+
20
34
  * 1 bug fix
21
35
 
22
36
  * Search results with only one result were failing
23
-
37
+
24
38
  === 0.1.2 / 2009-11-15
25
39
 
26
40
  * 2 minor enhancements
@@ -19,6 +19,7 @@ To look up an artist, album or track, simply call:
19
19
  MetaSpotify::Artist.lookup(spotify_uri)
20
20
  MetaSpotify::Album.lookup(spotify_uri)
21
21
  or
22
+
22
23
  MetaSpotify::Track.lookup(spotify_uri)
23
24
 
24
25
  e.g.
data/Rakefile CHANGED
@@ -1,55 +1,11 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "meta-spotify"
8
- gem.summary = %Q{A ruby wrapper for the Spotify Metadata API}
9
- gem.email = "philnash@gmail.com"
10
- gem.homepage = "http://github.com/philnash/meta-spotify"
11
- gem.authors = ["Phil Nash"]
12
- gem.add_dependency 'httparty', [">= 0.4.5", "< 0.8"]
13
- gem.add_dependency 'crack', ">= 0.1.4"
14
- gem.add_development_dependency "shoulda", ">= 2.10.2"
15
- gem.add_development_dependency "fakeweb", ">= 1.2.4"
16
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
- end
18
- Jeweler::GemcutterTasks.new
19
- rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
- end
22
-
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
23
3
  require 'rake/testtask'
4
+
24
5
  Rake::TestTask.new(:test) do |test|
25
6
  test.libs << 'lib' << 'test'
26
7
  test.pattern = 'test/**/test_*.rb'
27
8
  test.verbose = true
28
9
  end
29
10
 
30
- begin
31
- require 'rcov/rcovtask'
32
- Rcov::RcovTask.new do |test|
33
- test.libs << 'test'
34
- test.pattern = 'test/**/test_*.rb'
35
- test.verbose = true
36
- end
37
- rescue LoadError
38
- task :rcov do
39
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
- end
41
- end
42
-
43
- task :test => :check_dependencies
44
-
45
11
  task :default => :test
46
-
47
- require 'rake/rdoctask'
48
- Rake::RDocTask.new do |rdoc|
49
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
-
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = "meta-spotify #{version}"
53
- rdoc.rdoc_files.include('README*')
54
- rdoc.rdoc_files.include('lib/**/*.rb')
55
- end
@@ -3,15 +3,15 @@ $:.unshift File.dirname(__FILE__)
3
3
  require 'httparty'
4
4
 
5
5
  module MetaSpotify
6
-
6
+
7
7
  API_VERSION = '1'
8
-
8
+
9
9
  class Base
10
10
  include HTTParty
11
11
  base_uri 'http://ws.spotify.com'
12
-
12
+
13
13
  attr_reader :name, :uri, :popularity
14
-
14
+
15
15
  def self.search(string, opts={})
16
16
  item_name = self.name.downcase.gsub(/^.*::/,'')
17
17
  query = {:q => string}
@@ -31,16 +31,16 @@ module MetaSpotify
31
31
  end
32
32
  return { (item_name+'s').to_sym => items,
33
33
  :query => {
34
- :start_page => result["opensearch:Query"]["startPage"].to_i,
35
- :role => result["opensearch:Query"]["role"],
36
- :search_terms => result["opensearch:Query"]["searchTerms"]
34
+ :start_page => result["Query"]["startPage"].to_i,
35
+ :role => result["Query"]["role"],
36
+ :search_terms => result["Query"]["searchTerms"]
37
37
  },
38
- :items_per_page => result["opensearch:itemsPerPage"].to_i,
39
- :start_index => result["opensearch:startIndex"].to_i,
40
- :total_results => result["opensearch:totalResults"].to_i
38
+ :items_per_page => result["itemsPerPage"].to_i,
39
+ :start_index => result["startIndex"].to_i,
40
+ :total_results => result["totalResults"].to_i
41
41
  }
42
42
  end
43
-
43
+
44
44
  def self.lookup(uri, opts={})
45
45
  uri = uri.strip
46
46
  raise URIError.new("Spotify URI not in the correct syntax") unless self::URI_REGEX.match(uri)
@@ -55,14 +55,14 @@ module MetaSpotify
55
55
  return Artist.new(v)
56
56
  when "album"
57
57
  return Album.new(v)
58
- when "track"
58
+ when "track"
59
59
  return Track.new(v)
60
60
  end
61
61
  end
62
62
  end
63
-
63
+
64
64
  private
65
-
65
+
66
66
  def self.raise_errors(response)
67
67
  case response.code
68
68
  when 400
@@ -79,12 +79,12 @@ module MetaSpotify
79
79
  raise ServerError.new('503 - The API is temporarily unavailable')
80
80
  end
81
81
  end
82
-
82
+
83
83
  end
84
-
84
+
85
85
  class MetaSpotifyError < StandardError
86
86
  attr_reader :data
87
-
87
+
88
88
  def initialize(data)
89
89
  @data = data
90
90
  super
@@ -99,4 +99,5 @@ end
99
99
 
100
100
  require 'meta-spotify/artist'
101
101
  require 'meta-spotify/track'
102
- require 'meta-spotify/album'
102
+ require 'meta-spotify/album'
103
+ require 'meta-spotify/version'
@@ -31,15 +31,15 @@ module MetaSpotify
31
31
  if hash['id'].is_a? Array
32
32
 
33
33
  hash['id'].each do |id|
34
- case id.attributes['type']
34
+ case id['type']
35
35
  when 'upc' then
36
- @upc = id
36
+ @upc = id['__content__']
37
37
  when 'mbid' then
38
- @musicbrainz_id = id
39
- @musicbrainz_uri = id.attributes['href']
38
+ @musicbrainz_id = id['__content__']
39
+ @musicbrainz_uri = id['href']
40
40
  when 'amgid' then
41
- @allmusic_id = id
42
- @allmusic_uri = id.attributes['href']
41
+ @allmusic_id = id['__content__']
42
+ @allmusic_uri = id['href']
43
43
  end
44
44
  end
45
45
  end
@@ -59,4 +59,4 @@ module MetaSpotify
59
59
  !is_available_in?(territory)
60
60
  end
61
61
  end
62
- end
62
+ end
@@ -25,16 +25,16 @@ module MetaSpotify
25
25
  if hash['id'].is_a? Array
26
26
 
27
27
  hash['id'].each do |id|
28
- case id.attributes['type']
28
+ case id['type']
29
29
  when 'mbid' then
30
- @musicbrainz_id = id
31
- @musicbrainz_uri = id.attributes['href']
30
+ @musicbrainz_id = id['__content__']
31
+ @musicbrainz_uri = id['href']
32
32
  when 'amgid' then
33
33
  @allmusic_id = id
34
- @allmusic_uri = id.attributes['href']
34
+ @allmusic_uri = id['href']
35
35
  end
36
36
  end
37
37
  end
38
38
  end
39
39
  end
40
- end
40
+ end
@@ -0,0 +1,3 @@
1
+ module MetaSpotify
2
+ VERSION = "0.2.0"
3
+ end
@@ -1,81 +1,25 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/meta-spotify/version', __FILE__)
5
3
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{meta-spotify}
8
- s.version = "0.1.5"
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "meta-spotify"
6
+ gem.authors = ["Phil Nash"]
7
+ gem.email = ["philnash@gmail.com"]
8
+ gem.description = %q{A ruby wrapper for the Spotify Metadata API.
9
+ See https://developer.spotify.com/technologies/web-api/
10
+ for API documentation.}
11
+ gem.summary = %q{A ruby wrapper for the Spotify Metadata API}
12
+ gem.homepage = "http://github.com/philnash/meta-spotify"
9
13
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Phil Nash"]
12
- s.date = %q{2009-12-19}
13
- s.email = %q{philnash@gmail.com}
14
- s.extra_rdoc_files = [
15
- "LICENSE",
16
- "README.markdown"
17
- ]
18
- s.files = [
19
- ".document",
20
- ".gitignore",
21
- "HISTORY",
22
- "LICENSE",
23
- "README.markdown",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/meta-spotify.rb",
27
- "lib/meta-spotify/album.rb",
28
- "lib/meta-spotify/artist.rb",
29
- "lib/meta-spotify/track.rb",
30
- "meta-spotify.gemspec",
31
- "test/fixtures/album.xml",
32
- "test/fixtures/album_search.xml",
33
- "test/fixtures/album_with_trackdetail.xml",
34
- "test/fixtures/artist.xml",
35
- "test/fixtures/artist_search.xml",
36
- "test/fixtures/artist_search_one_result.xml",
37
- "test/fixtures/artist_with_albumdetail.xml",
38
- "test/fixtures/track.xml",
39
- "test/fixtures/track_search.xml",
40
- "test/fixtures/track_search_page_2.xml",
41
- "test/helper.rb",
42
- "test/test_album.rb",
43
- "test/test_artist.rb",
44
- "test/test_track.rb"
45
- ]
46
- s.homepage = %q{http://github.com/philnash/meta-spotify}
47
- s.rdoc_options = ["--charset=UTF-8"]
48
- s.require_paths = ["lib"]
49
- s.rubyforge_project = %q{meta-spotify}
50
- s.rubygems_version = %q{1.3.5}
51
- s.summary = %q{A ruby wrapper for the Spotify Metadata API}
52
- s.test_files = [
53
- "test/helper.rb",
54
- "test/test_album.rb",
55
- "test/test_artist.rb",
56
- "test/test_track.rb"
57
- ]
14
+ gem.files = `git ls-files`.split($\)
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.require_paths = ["lib"]
17
+ gem.version = MetaSpotify::VERSION
58
18
 
59
- if s.respond_to? :specification_version then
60
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
- s.specification_version = 3
19
+ gem.add_dependency 'httparty', '> 0.8'
20
+
21
+ gem.add_development_dependency 'shoulda', '>= 2.10.2'
22
+ gem.add_development_dependency 'fakeweb', '>= 1.2.4'
62
23
 
63
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
64
- s.add_runtime_dependency(%q<httparty>, [">= 0.4.5"])
65
- s.add_runtime_dependency(%q<crack>, [">= 0.1.4"])
66
- s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
67
- s.add_development_dependency(%q<fakeweb>, [">= 1.2.4"])
68
- else
69
- s.add_dependency(%q<httparty>, [">= 0.4.5"])
70
- s.add_dependency(%q<crack>, [">= 0.1.4"])
71
- s.add_dependency(%q<shoulda>, [">= 2.10.2"])
72
- s.add_dependency(%q<fakeweb>, [">= 1.2.4"])
73
- end
74
- else
75
- s.add_dependency(%q<httparty>, [">= 0.4.5"])
76
- s.add_dependency(%q<crack>, [">= 0.1.4"])
77
- s.add_dependency(%q<shoulda>, [">= 2.10.2"])
78
- s.add_dependency(%q<fakeweb>, [">= 1.2.4"])
79
- end
80
24
  end
81
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta-spotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,36 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-11 00:00:00.000000000Z
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &2152533500 !ruby/object:Gem::Requirement
16
+ requirement: &70293660427780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - <
19
+ - - ! '>'
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0.8'
22
- - - ! '>='
23
- - !ruby/object:Gem::Version
24
- version: 0.4.5
25
22
  type: :runtime
26
23
  prerelease: false
27
- version_requirements: *2152533500
28
- - !ruby/object:Gem::Dependency
29
- name: crack
30
- requirement: &2152532300 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ! '>='
34
- - !ruby/object:Gem::Version
35
- version: 0.1.4
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: *2152532300
24
+ version_requirements: *70293660427780
39
25
  - !ruby/object:Gem::Dependency
40
26
  name: shoulda
41
- requirement: &2152531620 !ruby/object:Gem::Requirement
27
+ requirement: &70293660427280 !ruby/object:Gem::Requirement
42
28
  none: false
43
29
  requirements:
44
30
  - - ! '>='
@@ -46,10 +32,10 @@ dependencies:
46
32
  version: 2.10.2
47
33
  type: :development
48
34
  prerelease: false
49
- version_requirements: *2152531620
35
+ version_requirements: *70293660427280
50
36
  - !ruby/object:Gem::Dependency
51
37
  name: fakeweb
52
- requirement: &2152530980 !ruby/object:Gem::Requirement
38
+ requirement: &70293660426760 !ruby/object:Gem::Requirement
53
39
  none: false
54
40
  requirements:
55
41
  - - ! '>='
@@ -57,25 +43,27 @@ dependencies:
57
43
  version: 1.2.4
58
44
  type: :development
59
45
  prerelease: false
60
- version_requirements: *2152530980
61
- description:
62
- email: philnash@gmail.com
46
+ version_requirements: *70293660426760
47
+ description: ! "A ruby wrapper for the Spotify Metadata API.\n See
48
+ https://developer.spotify.com/technologies/web-api/\n for
49
+ API documentation."
50
+ email:
51
+ - philnash@gmail.com
63
52
  executables: []
64
53
  extensions: []
65
- extra_rdoc_files:
66
- - LICENSE
67
- - README.markdown
54
+ extra_rdoc_files: []
68
55
  files:
69
- - .document
56
+ - .gitignore
57
+ - Gemfile
70
58
  - HISTORY
71
59
  - LICENSE
72
60
  - README.markdown
73
61
  - Rakefile
74
- - VERSION
75
62
  - lib/meta-spotify.rb
76
63
  - lib/meta-spotify/album.rb
77
64
  - lib/meta-spotify/artist.rb
78
65
  - lib/meta-spotify/track.rb
66
+ - lib/meta-spotify/version.rb
79
67
  - meta-spotify.gemspec
80
68
  - test/fixtures/album.xml
81
69
  - test/fixtures/album_search.xml
@@ -111,8 +99,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
99
  version: '0'
112
100
  requirements: []
113
101
  rubyforge_project:
114
- rubygems_version: 1.8.6
102
+ rubygems_version: 1.8.11
115
103
  signing_key:
116
104
  specification_version: 3
117
105
  summary: A ruby wrapper for the Spotify Metadata API
118
- test_files: []
106
+ test_files:
107
+ - test/fixtures/album.xml
108
+ - test/fixtures/album_search.xml
109
+ - test/fixtures/album_with_trackdetail.xml
110
+ - test/fixtures/artist.xml
111
+ - test/fixtures/artist_search.xml
112
+ - test/fixtures/artist_search_one_result.xml
113
+ - test/fixtures/artist_with_albumdetail.xml
114
+ - test/fixtures/track.xml
115
+ - test/fixtures/track_search.xml
116
+ - test/fixtures/track_search_page_2.xml
117
+ - test/helper.rb
118
+ - test/test_album.rb
119
+ - test/test_artist.rb
120
+ - test/test_track.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.6