hypem 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 +15 -8
- data/fixtures/vcr_cassettes/user_friends.yml +44 -0
- data/hypem.gemspec +2 -2
- data/lib/hypem/user.rb +21 -4
- data/lib/hypem/version.rb +1 -1
- data/spec/user_spec.rb +15 -1
- metadata +18 -17
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Hypem Ruby Gem  #
|
2
2
|
## Introduction ##
|
3
|
-
This is an unoffical Ruby gem for the **Hype Machine**
|
3
|
+
This is an unoffical Ruby gem for the **Hype Machine** read-only API. It supports all of the Playlist request methods and a growing number of User methods. It currently only supports Ruby `1.9.x`.
|
4
4
|
|
5
5
|
## Usage ##
|
6
6
|
|
@@ -54,22 +54,29 @@ Each playlist has a `tracks` attribute containing an array of `Hypem::Tracks`'s.
|
|
54
54
|
******
|
55
55
|
|
56
56
|
### User ###
|
57
|
-
|
57
|
+
Users can be accessed via `Hypem.user('username')` and have various methods:
|
58
|
+
#### General Methods ####
|
59
|
+
- `user.get_profile` updates the user object with the following attributes: `full_name`, `location`, `image_url`, `followed_users_count`, `followed_items_count`, `followed_sites_blog`, and `followed_queries_count`
|
58
60
|
|
59
|
-
- `
|
61
|
+
- `user.get_friends` retrieves the users's friends and sets the `friends` attribute to an array of `Hypem::User` objects with extended information (similar to `get_profile`)
|
60
62
|
|
61
|
-
|
63
|
+
#### Playlist Methods ####
|
64
|
+
`Hypem::User` offers several methods for accessing a particular user's personalized playlists:
|
62
65
|
|
63
|
-
- `
|
66
|
+
- `user.loved_playlist` --- a user's loved tracks
|
64
67
|
|
65
|
-
- `
|
68
|
+
- `user.obsessed_playlist` --- a user's obsessed tracks
|
66
69
|
|
67
|
-
- `
|
70
|
+
- `user.feed_playlist` --- a user's tracks from all followed entities
|
71
|
+
|
72
|
+
- `user.friends_favorites_playlist` --- a user's friends' favorited tracks
|
73
|
+
|
74
|
+
- `user.friends_history_playlist` --- tracks from a user's friends' listening histories
|
68
75
|
|
69
76
|
******
|
70
77
|
|
71
78
|
### Track ###
|
72
|
-
All
|
79
|
+
All Playlist objects have a `tracks` attribute containing an array of `Hypem::Track`s. A sample object inspect is as follows:
|
73
80
|
|
74
81
|
#<Hypem::Track
|
75
82
|
artist="Hot Chip"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://hypem.com/api/get_friends?username=jackca
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message:
|
14
|
+
headers:
|
15
|
+
server:
|
16
|
+
- nginx/1.0.12
|
17
|
+
date:
|
18
|
+
- Sun, 25 Mar 2012 03:00:06 GMT
|
19
|
+
content-type:
|
20
|
+
- text/html
|
21
|
+
transfer-encoding:
|
22
|
+
- chunked
|
23
|
+
connection:
|
24
|
+
- close
|
25
|
+
set-cookie:
|
26
|
+
- AUTH=03%3A944cc1ba58791e209abd7bb5ab98a727%3A1332644405%3A1276002699%3ACA-US;
|
27
|
+
expires=Tue, 21-Mar-2028 03:00:05 GMT; path=/; domain=hypem.com
|
28
|
+
x-hacker:
|
29
|
+
- Hey, if you're reading this, you should drop us an email at hypem.com/contact,
|
30
|
+
maybe we can work together!
|
31
|
+
access-control-allow-origin:
|
32
|
+
- ! '*'
|
33
|
+
access-control-allow-headers:
|
34
|
+
- ! '*'
|
35
|
+
vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
body:
|
38
|
+
encoding: ASCII-8BIT
|
39
|
+
string: ! '[{"username":"anthony","dateadded":1331660275,"fullname":"Anthony","profile_url":"http:\/\/hypem.com\/anthony","userpic":"http:\/\/faces-s3.hypem.com\/20727986008_75.png","favorites_count":{"user":127,"item":355,"site":30,"query":13,"followers":1874},"radio_avail":false},{"username":"janestar","dateadded":"1292962523","fullname":null,"profile_url":"http:\/\/hypem.com\/janestar","userpic":"http:\/\/static-ak.hypem.net\/images\/bg-album-art.gif","favorites_count":{"user":0,"item":4,"site":0,"query":0,"followers":3},"radio_avail":false},{"username":"jstreet","dateadded":"0","fullname":"Justin
|
40
|
+
Street","profile_url":"http:\/\/hypem.com\/jstreet","userpic":"http:\/\/faces-s3.hypem.com\/39640740001973_75.png","favorites_count":{"user":7,"item":367,"site":24,"query":0,"followers":4},"radio_avail":false},{"username":"danielzarick","dateadded":"0","fullname":"Daniel
|
41
|
+
Zarick","profile_url":"http:\/\/hypem.com\/danielzarick","userpic":"http:\/\/faces-s3.hypem.com\/782356165259973_75.png","favorites_count":{"user":25,"item":9,"site":0,"query":4,"followers":12},"radio_avail":false}]'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Sun, 25 Mar 2012 03:00:06 GMT
|
44
|
+
recorded_with: VCR 2.0.0
|
data/hypem.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Hypem::VERSION
|
8
8
|
s.authors = ["Jack Anderson"]
|
9
9
|
s.email = ["jackcanderson@gmail.com"]
|
10
|
-
s.homepage = ""
|
11
|
-
s.summary = "a
|
10
|
+
s.homepage = "https://github.com/JackCA/hypem"
|
11
|
+
s.summary = "a Ruby wrapper for the Hype Machine read-only API"
|
12
12
|
|
13
13
|
s.rubyforge_project = "hypem"
|
14
14
|
|
data/lib/hypem/user.rb
CHANGED
@@ -2,7 +2,7 @@ module Hypem
|
|
2
2
|
class User
|
3
3
|
attr_reader :full_name, :joined_at, :location, :twitter_username, :image_url,
|
4
4
|
:followed_users_count, :followed_items_count, :followed_sites_count,
|
5
|
-
:followed_queries_count
|
5
|
+
:followed_queries_count, :friends
|
6
6
|
|
7
7
|
def initialize(name)
|
8
8
|
raise ArgumentError unless name.is_a? String
|
@@ -11,16 +11,33 @@ module Hypem
|
|
11
11
|
|
12
12
|
def get_profile
|
13
13
|
response = Request.new("/api/get_profile?username=#{@name}").get.response.body
|
14
|
+
update_from_response(response)
|
15
|
+
return self
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_friends
|
19
|
+
array_response = Request.new("/api/get_friends?username=#{@name}").get.response.body
|
20
|
+
@friends = array_response.map do |r|
|
21
|
+
name = r['username']
|
22
|
+
user = User.new(name)
|
23
|
+
user.update_from_response(r)
|
24
|
+
user
|
25
|
+
end
|
26
|
+
return self
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_from_response(response)
|
14
30
|
@full_name = response['fullname']
|
15
|
-
@joined_at = Time.at response['joined_ts']
|
16
31
|
@location = response['location']
|
17
|
-
@twitter_username = response['twitter_username']
|
18
32
|
@image_url = response['userpic']
|
19
33
|
@followed_users_count = response['favorites_count']['user']
|
20
34
|
@followed_items_count = response['favorites_count']['item']
|
21
35
|
@followed_sites_count = response['favorites_count']['site']
|
22
36
|
@followed_queries_count = response['favorites_count']['query']
|
23
|
-
|
37
|
+
|
38
|
+
# only returned on get_profile
|
39
|
+
@joined_at = Time.at(response['joined_ts']) unless response['joined_ts'].nil?
|
40
|
+
@twitter_username = response['twitter_username']
|
24
41
|
end
|
25
42
|
|
26
43
|
#playlist requests
|
data/lib/hypem/version.rb
CHANGED
data/spec/user_spec.rb
CHANGED
@@ -43,7 +43,7 @@ describe Hypem::User do
|
|
43
43
|
|
44
44
|
describe ".get_profile" do
|
45
45
|
let(:user_with_profile) do
|
46
|
-
VCR.use_cassette('user_profile') {
|
46
|
+
VCR.use_cassette('user_profile') {user.get_profile}
|
47
47
|
end
|
48
48
|
|
49
49
|
subject {user_with_profile}
|
@@ -59,4 +59,18 @@ describe Hypem::User do
|
|
59
59
|
its(:followed_queries_count) {should == 15}
|
60
60
|
end
|
61
61
|
|
62
|
+
describe ".get_friends" do
|
63
|
+
let(:user_with_friends) do
|
64
|
+
VCR.use_cassette('user_friends') {user.get_friends}
|
65
|
+
end
|
66
|
+
|
67
|
+
subject {user_with_friends}
|
68
|
+
|
69
|
+
its(:friends) {should be_an Array}
|
70
|
+
|
71
|
+
it "has an array of users" do
|
72
|
+
user_with_friends.friends.first.should be_a Hypem::User
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
62
76
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hypem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70304769757740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70304769757740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vcr
|
27
|
-
requirement: &
|
27
|
+
requirement: &70304769757240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70304769757240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70304769756860 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70304769756860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: faraday
|
49
|
-
requirement: &
|
49
|
+
requirement: &70304769756320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0.7'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70304769756320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: multi_json
|
60
|
-
requirement: &
|
60
|
+
requirement: &70304769755820 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.1'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70304769755820
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: hashie
|
71
|
-
requirement: &
|
71
|
+
requirement: &70304769755360 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '1.2'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70304769755360
|
80
80
|
description:
|
81
81
|
email:
|
82
82
|
- jackcanderson@gmail.com
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- fixtures/vcr_cassettes/loved_playlist.yml
|
100
100
|
- fixtures/vcr_cassettes/obsessed_playlist.yml
|
101
101
|
- fixtures/vcr_cassettes/popular_playlist.yml
|
102
|
+
- fixtures/vcr_cassettes/user_friends.yml
|
102
103
|
- fixtures/vcr_cassettes/user_profile.yml
|
103
104
|
- hypem.gemspec
|
104
105
|
- lib/hypem.rb
|
@@ -115,7 +116,7 @@ files:
|
|
115
116
|
- spec/spec_helper.rb
|
116
117
|
- spec/track_spec.rb
|
117
118
|
- spec/user_spec.rb
|
118
|
-
homepage:
|
119
|
+
homepage: https://github.com/JackCA/hypem
|
119
120
|
licenses: []
|
120
121
|
post_install_message:
|
121
122
|
rdoc_options: []
|
@@ -129,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
130
|
version: '0'
|
130
131
|
segments:
|
131
132
|
- 0
|
132
|
-
hash:
|
133
|
+
hash: 2867882639312664006
|
133
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
135
|
none: false
|
135
136
|
requirements:
|
@@ -138,13 +139,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
139
|
version: '0'
|
139
140
|
segments:
|
140
141
|
- 0
|
141
|
-
hash:
|
142
|
+
hash: 2867882639312664006
|
142
143
|
requirements: []
|
143
144
|
rubyforge_project: hypem
|
144
145
|
rubygems_version: 1.8.10
|
145
146
|
signing_key:
|
146
147
|
specification_version: 3
|
147
|
-
summary: a
|
148
|
+
summary: a Ruby wrapper for the Hype Machine read-only API
|
148
149
|
test_files:
|
149
150
|
- spec/hypem_spec.rb
|
150
151
|
- spec/playlist_spec.rb
|