rhapsody 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.
- checksums.yaml +7 -0
- data/.gitignore +26 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/lib/rhapsody.rb +3 -34
- data/lib/rhapsody/models/client.rb +47 -0
- data/lib/rhapsody/version.rb +3 -0
- data/rhapsody.gemspec +23 -0
- data/spec/app/rhapsody_spec.rb +16 -0
- data/spec/config_helper.rb +14 -0
- data/spec/factories/clients.rb +12 -0
- data/spec/models/client_spec.rb +6 -0
- data/spec/spec_helper.rb +13 -0
- metadata +62 -16
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6414e079fd2e245077332cbff0c57cb274508f88
|
|
4
|
+
data.tar.gz: cf1f85894d98676fd6ed134fc3262c20510c0d14
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7af62420f8e0c6b09f6a60807eca9e01bb0c0d47bf14b4112409d3761f987961292355ecf18c93201eb1ba5a46a0e13ccfc4323d45678b7f0deca46b93c1f284
|
|
7
|
+
data.tar.gz: 0fa41ec5a4d3b7a54dc182d1f1878bb3946914bc9b7f4106d5a09e13868477e8dc9a44deef6cc6a0289f47d487bf49d74408ee3bd71a3a0517fc0ad2952bb372
|
data/.gitignore
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
*.bundle
|
|
19
|
+
*.so
|
|
20
|
+
*.o
|
|
21
|
+
*.a
|
|
22
|
+
mkmf.log
|
|
23
|
+
|
|
24
|
+
# custom
|
|
25
|
+
spec/config.yml
|
|
26
|
+
.DS_Store
|
data/Gemfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in rhapsody.gemspec
|
|
4
|
+
gemspec
|
|
5
|
+
|
|
6
|
+
gem 'faraday', '~> 0.9.0'
|
|
7
|
+
|
|
8
|
+
group :test do
|
|
9
|
+
gem 'rspec', '~> 3.0.0'
|
|
10
|
+
gem 'factory_girl', '~> 4.4.0'
|
|
11
|
+
gem 'debugger', '~> 1.6.8'
|
|
12
|
+
gem 'pry', '~> 0.10.0'
|
|
13
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Jason Kim
|
|
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
|
+
# Rhapsody
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'rhapsody'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install rhapsody
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Running tests
|
|
22
|
+
|
|
23
|
+
Rhapsody gem uses RSpec and FactoryGirl.
|
|
24
|
+
|
|
25
|
+
1. Get the API key and API secret from
|
|
26
|
+
[Rhapsody Developers site](https://developer.rhapsody.com/).
|
|
27
|
+
|
|
28
|
+
2. Create a file called `config.yml` in `spec` directory.
|
|
29
|
+
|
|
30
|
+
3. Add the following with the correct API key and API secret
|
|
31
|
+
|
|
32
|
+
``` yml
|
|
33
|
+
config_variables:
|
|
34
|
+
API_KEY: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
35
|
+
API_SECRET: "yyyyyyyyyyyy"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
1. Fork it ( https://github.com/[my-github-username]/rhapsody/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
data/lib/rhapsody.rb
CHANGED
|
@@ -1,36 +1,5 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "rhapsody/version"
|
|
2
|
+
require 'rhapsody/models/client'
|
|
2
3
|
|
|
3
4
|
module Rhapsody
|
|
4
|
-
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
class Album
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
class Track
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
class Genre
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
class Authentication
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
class History
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
class Library
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
class Playlist
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
class Feature
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
class Popularity
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class Search
|
|
35
|
-
end
|
|
36
|
-
end
|
|
5
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class Client
|
|
2
|
+
attr_accessor :api_key,
|
|
3
|
+
:api_secret,
|
|
4
|
+
:auth_code,
|
|
5
|
+
:redirect_url,
|
|
6
|
+
:raw_reponse,
|
|
7
|
+
:json_response,
|
|
8
|
+
:access_token,
|
|
9
|
+
:refresh_token
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def initialize(options)
|
|
15
|
+
@api_key = options['api_key']
|
|
16
|
+
@api_secret = options['api_secret']
|
|
17
|
+
@auth_code = options['auth_code']
|
|
18
|
+
@redirect_url = options['redirect_url']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def connect
|
|
22
|
+
host_url = 'https://api.rhapsody.com'
|
|
23
|
+
oauth_path = '/oauth/access_token'
|
|
24
|
+
|
|
25
|
+
connection = Faraday.new(:url => host_url) do |faraday|
|
|
26
|
+
faraday.request :url_encoded
|
|
27
|
+
faraday.response :logger
|
|
28
|
+
faraday.adapter Faraday.default_adapter
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
post_hash = {
|
|
32
|
+
client_id: @api_key,
|
|
33
|
+
client_secret: @api_secret,
|
|
34
|
+
response_type: 'code',
|
|
35
|
+
grant_type: 'authorization_code',
|
|
36
|
+
code: @auth_code,
|
|
37
|
+
redirect_uri: @redirect_url
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@raw_response = connection.post(oauth_path, post_hash)
|
|
41
|
+
@json_response = JSON.parse(@raw_response)
|
|
42
|
+
|
|
43
|
+
# token = JSON.parse(res.env[:body])['access_token']
|
|
44
|
+
|
|
45
|
+
# render json: res.env[:body]
|
|
46
|
+
end
|
|
47
|
+
end
|
data/rhapsody.gemspec
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'rhapsody/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "rhapsody"
|
|
8
|
+
spec.version = Rhapsody::VERSION
|
|
9
|
+
spec.authors = ["Jason Kim"]
|
|
10
|
+
spec.email = ["jasonkim@rhapsody.com"]
|
|
11
|
+
spec.summary = %q{NOT READY: A Ruby object-oriented interface to the Rhapsody REST API}
|
|
12
|
+
spec.description = %q{Rhapsody REST API gem provides a Ruby object-oriented interface.}
|
|
13
|
+
spec.homepage = "https://github.com/serv/rhapsody"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Rhapsody do
|
|
4
|
+
it 'loads spec/config.yml' do
|
|
5
|
+
yaml = ConfigHelper.load
|
|
6
|
+
config_variables = yaml['config_variables']
|
|
7
|
+
|
|
8
|
+
expect(config_variables).not_to be_empty
|
|
9
|
+
expect(config_variables['API_KEY'].length).not_to eql(0)
|
|
10
|
+
expect(config_variables['API_SECRET'].length).not_to eql(0)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'checks version' do
|
|
14
|
+
expect(Rhapsody::VERSION).to eql('0.0.2')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require_relative '../lib/rhapsody'
|
|
3
|
+
|
|
4
|
+
module ConfigHelper
|
|
5
|
+
def ConfigHelper.load
|
|
6
|
+
config_path = Dir.pwd.to_s + '/spec/config.yml'
|
|
7
|
+
|
|
8
|
+
if File.exist?(config_path)
|
|
9
|
+
YAML.load_file(config_path)
|
|
10
|
+
else
|
|
11
|
+
raise 'spec/config.yml not found.'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'factory_girl'
|
|
3
|
+
|
|
4
|
+
# Load config.yml
|
|
5
|
+
require_relative './config_helper'
|
|
6
|
+
|
|
7
|
+
# Load gem files
|
|
8
|
+
require_relative '../lib/rhapsody/models/client'
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
config.include FactoryGirl::Syntax::Methods
|
|
12
|
+
config.include ConfigHelper
|
|
13
|
+
end
|
metadata
CHANGED
|
@@ -1,46 +1,92 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rhapsody
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.0.2
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Jason Kim
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
13
|
-
dependencies:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
date: 2014-08-11 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.6'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.6'
|
|
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
|
+
description: Rhapsody REST API gem provides a Ruby object-oriented interface.
|
|
42
|
+
email:
|
|
43
|
+
- jasonkim@rhapsody.com
|
|
17
44
|
executables: []
|
|
18
45
|
extensions: []
|
|
19
46
|
extra_rdoc_files: []
|
|
20
47
|
files:
|
|
48
|
+
- ".gitignore"
|
|
49
|
+
- Gemfile
|
|
50
|
+
- Gemfile.lock
|
|
51
|
+
- LICENSE.txt
|
|
52
|
+
- README.md
|
|
53
|
+
- Rakefile
|
|
21
54
|
- lib/rhapsody.rb
|
|
55
|
+
- lib/rhapsody/models/client.rb
|
|
56
|
+
- lib/rhapsody/version.rb
|
|
57
|
+
- rhapsody.gemspec
|
|
58
|
+
- spec/app/rhapsody_spec.rb
|
|
59
|
+
- spec/config_helper.rb
|
|
60
|
+
- spec/factories/clients.rb
|
|
61
|
+
- spec/models/client_spec.rb
|
|
62
|
+
- spec/spec_helper.rb
|
|
22
63
|
homepage: https://github.com/serv/rhapsody
|
|
23
|
-
licenses:
|
|
64
|
+
licenses:
|
|
65
|
+
- MIT
|
|
66
|
+
metadata: {}
|
|
24
67
|
post_install_message:
|
|
25
68
|
rdoc_options: []
|
|
26
69
|
require_paths:
|
|
27
70
|
- lib
|
|
28
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
-
none: false
|
|
30
72
|
requirements:
|
|
31
|
-
- -
|
|
73
|
+
- - ">="
|
|
32
74
|
- !ruby/object:Gem::Version
|
|
33
75
|
version: '0'
|
|
34
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
-
none: false
|
|
36
77
|
requirements:
|
|
37
|
-
- -
|
|
78
|
+
- - ">="
|
|
38
79
|
- !ruby/object:Gem::Version
|
|
39
80
|
version: '0'
|
|
40
81
|
requirements: []
|
|
41
82
|
rubyforge_project:
|
|
42
|
-
rubygems_version:
|
|
83
|
+
rubygems_version: 2.4.1
|
|
43
84
|
signing_key:
|
|
44
|
-
specification_version:
|
|
45
|
-
summary: A Ruby object-oriented interface to the Rhapsody REST API
|
|
46
|
-
test_files:
|
|
85
|
+
specification_version: 4
|
|
86
|
+
summary: 'NOT READY: A Ruby object-oriented interface to the Rhapsody REST API'
|
|
87
|
+
test_files:
|
|
88
|
+
- spec/app/rhapsody_spec.rb
|
|
89
|
+
- spec/config_helper.rb
|
|
90
|
+
- spec/factories/clients.rb
|
|
91
|
+
- spec/models/client_spec.rb
|
|
92
|
+
- spec/spec_helper.rb
|