rspotify 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e29fb708a1a147c1715b3646fbf79c7a022ddf9
4
+ data.tar.gz: cbaaf10af09720731340c646bad0b1f481c4ef83
5
+ SHA512:
6
+ metadata.gz: 10b5fbf40e3c113b08e31c35c561be7ca51380d68b01df66967ae464a9079e429789ac933549dcfdce7b19ea4df0d9edf1c418f833d66980a4980450b75a61ca
7
+ data.tar.gz: dabf5f86a86e0ea21b1a627a60f7b2b167b385cde6c6dcd63dfb5a75c4d57ab81dfbe7ebfb32efa04c8bace37e37333c1fd7c78e8421a0cbe09ea5eb9138b9e8
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .bundle
2
+ pkg
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 GuilhermeSad
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # RSpotify
2
+
3
+ This is a ruby wrapper for the [new Spotify Web API](https://developer.spotify.com/web-api), released in June 17, 2014.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rspotify'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rspotify
18
+
19
+ ## Usage
20
+
21
+ This gem is pretty new and authentication has not yet been implemented. So far you can access public data such as albums, tracks and artists:
22
+
23
+ ```ruby
24
+ tracks = RSpotify::Track.search('Paranoid')
25
+
26
+ tracks.first.name #=> "Paranoid"
27
+ tracks.first.popularity #=> 68
28
+
29
+ album = tracks.first.album
30
+ album.name #=> "Paranoid (Remastered)"
31
+ album.images #=> (Image array)
32
+
33
+ artists = tracks.first.artists
34
+ artists.first.name #=> "Black Sabbath"
35
+ artists.first.uri #=> "spotify:artist:5M52tdBnJaKSvOpJGz8mfZ"
36
+ ```
37
+ More documentation will follow
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/guilhermesad/rspotify/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/lib/rspotify.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'rspotify/version'
2
+
3
+ require 'json'
4
+ require 'restclient'
5
+
6
+ module RSpotify
7
+
8
+ BASE_URI = 'https://api.spotify.com/v1/'
9
+ VERBS = %w(get post put delete)
10
+
11
+ autoload :Base, 'rspotify/base'
12
+ autoload :Artist, 'rspotify/artist'
13
+ autoload :Album, 'rspotify/album'
14
+ autoload :Track, 'rspotify/track'
15
+
16
+ VERBS.each do |verb|
17
+ define_singleton_method verb do |path, *params|
18
+ url = BASE_URI + path
19
+ response = RestClient.send(verb, url, *params)
20
+ JSON.parse response
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module RSpotify
2
+
3
+ class Album < Base
4
+
5
+ attr_accessor :album_type, :images
6
+
7
+ def self.search(query, limit = 20, offset = 0)
8
+ super(query, 'album', limit, offset)
9
+ end
10
+
11
+ def initialize(options = {})
12
+ @album_type = options['album_type']
13
+ @images = options['images']
14
+
15
+ super(options)
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ module RSpotify
2
+
3
+ class Artist < Base
4
+
5
+ attr_accessor :genres, :images, :popularity
6
+
7
+ def self.search(query, limit = 20, offset = 0)
8
+ super(query, 'artist', limit, offset)
9
+ end
10
+
11
+ def initialize(options = {})
12
+ @genres = options['genres']
13
+ @images = options['images']
14
+ @popularity = options['popularity']
15
+
16
+ super(options)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ module RSpotify
2
+
3
+ class Base
4
+
5
+ attr_accessor :external_urls, :href, :id, :name, :type, :uri
6
+
7
+ def self.find(id)
8
+ #TODO
9
+ end
10
+
11
+ def self.search(query, type, limit = 20, offset = 0)
12
+ pluralized_type = "#{type}s"
13
+ type_class = eval type.capitalize
14
+
15
+ json = RSpotify.get 'search',
16
+ params: {
17
+ q: query,
18
+ type: type,
19
+ limit: limit,
20
+ offset: offset
21
+ }
22
+
23
+ items = json[pluralized_type]['items']
24
+ items.map { |item| type_class.new item }
25
+ end
26
+
27
+ def initialize(options = {})
28
+ @external_urls = options['external_urls']
29
+ @href = options['href']
30
+ @id = options['id']
31
+ @name = options['name']
32
+ @type = options['type']
33
+ @uri = options['uri']
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,28 @@
1
+ module RSpotify
2
+
3
+ class Track < Base
4
+
5
+ attr_accessor :album, :artists, :available_markets, :disc_number, :duration_ms,
6
+ :explicit, :external_ids, :popularity, :preview_url, :track_number
7
+
8
+ def self.search(query, limit = 20, offset = 0)
9
+ super(query, 'track', limit, offset)
10
+ end
11
+
12
+ def initialize(options = {})
13
+ @album = Album.new options['album']
14
+ @artists = options['artists'].map { |a| Artist.new a }
15
+ @available_markets = options['available_markets']
16
+ @disc_number = options['disc_number']
17
+ @duration_ms = options['duration_ms']
18
+ @explicit = options['explicit']
19
+ @external_ids = options['external_ids']
20
+ @popularity = options['popularity']
21
+ @preview_url = options['preview_url']
22
+ @track_number = options['track_number']
23
+
24
+ super(options)
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module RSpotify
2
+ VERSION = '0.0.1'
3
+ end
data/rspotify.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspotify/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rspotify'
8
+ spec.version = RSpotify::VERSION
9
+ spec.authors = ['Guilherme Sad']
10
+ spec.email = ['gorgulhoguilherme@gmail.com']
11
+ spec.summary = %q{A ruby wrapper for the Spotify Web API}
12
+ spec.homepage = 'http://rubygems.org/gems/rspotify'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.test_files = spec.files.grep(/^spec\//)
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'rest_client', '~> 1.7'
20
+
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rspec'
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'fakeweb', '~> 1.3'
25
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspotify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Guilherme Sad
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest_client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fakeweb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ description:
84
+ email:
85
+ - gorgulhoguilherme@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/rspotify.rb
96
+ - lib/rspotify/album.rb
97
+ - lib/rspotify/artist.rb
98
+ - lib/rspotify/base.rb
99
+ - lib/rspotify/track.rb
100
+ - lib/rspotify/version.rb
101
+ - rspotify.gemspec
102
+ homepage: http://rubygems.org/gems/rspotify
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.2.2
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: A ruby wrapper for the Spotify Web API
126
+ test_files: []