spacer 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,82 @@
1
+ # $Id$
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib spacer]))
5
+
6
+ def stubbing_http_response_with(xml_or_json_response)
7
+ if STUB_NETWORK
8
+ response = stub(:body => xml_or_json_response)
9
+ Net::HTTP.any_instance.stubs(:request).returns(response)
10
+ end
11
+ yield
12
+ end
13
+
14
+ def example_user_response_json
15
+ '{"image":"http:\/\/x.myspace.com\/images\/no_pic.gif","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}'
16
+ end
17
+
18
+ def example_profile_response_json
19
+ '{"aboutme":"","age":104,"basicprofile":{"__type":"Profile:#MySpace.Services.DataContracts","image":"http:\/\/x.myspace.com\/images\/no_pic.gif","name":"BrownPunk!","type":2,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"webUri":"http:\/\/www.myspace.com\/107265345"},"city":"CHICAGO","country":"US","culture":"en-US","gender":"Female","hometown":"","maritalstatus":"Single","postalcode":"60614","region":"Illinois"}'
20
+ end
21
+
22
+ def example_friends_response_json
23
+ '{"count":2,"friends":[{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/b2.ac-images.myspacecdn.com\/00000\/20\/52\/2502_s.jpg","name":"Tom","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":6221,"userType":"RegularUser","webUri":"http:\/\/www.myspace.com\/tom"},{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/x.myspace.com\/images\/no_pic.gif","name":"Video Jukebox","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":330729305,"userType":"Application","webUri":"http:\/\/www.myspace.com\/330729305"}],"next":null,"prev":null,"topFriends":null,"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/x.myspace.com\/images\/no_pic.gif","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
24
+ end
25
+
26
+ def example_albums_response_json
27
+ '{"albums":[{"__type":"Album:#MySpace.Services.DataContracts","albumUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/albums\/1580520","defaultImage":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/m_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","id":1580520,"location":"","photoCount":1,"photosUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/albums\/1580520\/photos","privacy":"Everyone","title":"My Photos","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}],"count":1,"next":null,"prev":null,"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
28
+ end
29
+
30
+ def example_album_by_id_response_json
31
+ '{"albumUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/albums\/1580520","defaultImage":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/m_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","id":1580520,"location":"","photoCount":1,"photosUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/albums\/1580520\/photos","privacy":"Everyone","title":"My Photos","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
32
+ end
33
+
34
+ def example_photos_for_album_response_json
35
+ '{"count":1,"next":null,"photos":[{"__type":"Photo:#MySpace.Services.DataContracts","caption":"","id":19071328,"imageUri":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/l_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","photoUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/albums\/1580520\/photos\/19071328","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}],"prev":null,"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
36
+ end
37
+
38
+ def example_photos_response_json
39
+ '{"count":1,"next":null,"photos":[{"__type":"Photo:#MySpace.Services.DataContracts","caption":"","id":19071328,"imageUri":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/l_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","photoUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/photos\/19071328","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}],"prev":null,"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
40
+ end
41
+
42
+ def example_interests_response_json
43
+ '{"books":"","general":"","heroes":"Stewart Copeland","movies":"","music":"","television":"","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
44
+ end
45
+
46
+ def example_details_response_json
47
+ '{"bodyType":"No Answer","children":"No Answer","drink":"No Answer","education":"No Answer","ethnicity":"No Answer","herefor":"Friends","hometown":"","income":"No Answer","orientation":"No Answer","religion":"No Answer","smoke":"No Answer","status":"Single","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"},"zodiacsign":null}'
48
+ end
49
+
50
+ def example_videos_response_json
51
+ '{"count":1,"next":null,"prev":null,"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"},"videos":[{"__type":"Video:#MySpace.Services.DataContracts","country":"US","datecreated":"\/Date(1202587923333-0800)\/","dateupdated":"\/Date(1202587923333-0800)\/","description":"pet","id":27953679,"language":"en","mediastatus":"WatingForUpload","mediatype":"4","privacy":"Public","resourceuserid":"107265345","runtime":"0","thumbnail":"http:\/\/b5.ac-images.myspacecdn.com\/02091\/50\/94\/2091104905_thumb1.jpg","title":"Keechu","totalrating":"0","totalviews":"0","totalvotes":"0","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"},"videoUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/videos\/27953679"}]}'
52
+ end
53
+
54
+ def example_video_response_json
55
+ '{"country":"US","datecreated":"\/Date(1202587923333-0800)\/","dateupdated":"\/Date(1202587923333-0800)\/","description":"pet","id":27953679,"language":"en","mediastatus":"ProcessingSuccessful","mediatype":"4","privacy":"Public","resourceuserid":"107265345","runtime":"18","thumbnail":"http:\/\/b5.ac-images.myspacecdn.com\/02091\/50\/94\/2091104905_thumb1.jpg","title":"Keechu","totalrating":"0","totalviews":"0","totalvotes":"0","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"},"videoUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/videos\/27953679"}'
56
+ end
57
+
58
+ def example_photo_response_json
59
+ '{"caption":"hi mom","id":19071328,"imageUri":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/l_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","photoUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/photos\/19071328","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
60
+ end
61
+
62
+ def example_status_response_json
63
+ '{"status":"none","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
64
+ end
65
+
66
+ def example_mood_response_json
67
+ '{"mood":"none","user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
68
+ end
69
+
70
+ def example_friendship_response_for_one_friend_json
71
+ '{"friendship":[{"areFriends":true,"friendId":107265345}],"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
72
+ end
73
+
74
+ def example_friendship_response_for_multiple_friends_json
75
+ '{"friendship":[{"areFriends":true,"friendId":107265345},{"areFriends":false,"friendId":107265346}],"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
76
+ end
77
+
78
+ def example_groups_response_json
79
+ '{"Groups":[{"__type":"Group:#MySpace.Services.DataContracts","approveMembers":false,"categoryId":23,"categoryName":null,"city":null,"country":null,"createDate":"\/Date(1123398180000-0700)\/","description":"For people who love\/worship\/talk about Tom Morello and his insane guitar wizardry","descriptionShort":null,"groupId":100875536,"groupName":"Tom Morello etc.","groupUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/groups\/100875536","groupUrl":null,"imageId":0,"imageType":null,"isAdult":false,"isPrivate":false,"isPublic":true,"memberBulletins":false,"memberCount":107,"memberImages":false,"membersCanInvite":false,"moderatorUserId":0,"nonMemberBoardPosting":false,"postalCode":null,"region":null,"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}},{"__type":"Group:#MySpace.Services.DataContracts","approveMembers":false,"categoryId":2,"categoryName":null,"city":null,"country":null,"createDate":"\/Date(1112112360000-0700)\/","description":"This is a group for the Nissan XTERRA owners! www.xterraownersclub.com<br>\u000aif you own a X and youre not on xoc.com check it out!!","descriptionShort":null,"groupId":100326220,"groupName":"XOC","groupUri":"http:\/\/api.msappspace.com\/v1\/users\/107265345\/groups\/100326220","groupUrl":null,"imageId":0,"imageType":null,"isAdult":false,"isPrivate":false,"isPublic":true,"memberBulletins":false,"memberCount":301,"memberImages":false,"membersCanInvite":false,"moderatorUserId":0,"nonMemberBoardPosting":false,"postalCode":null,"region":null,"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}],"count":2,"next":null,"prev":null,"user":{"__type":"User:#MySpace.Services.DataContracts","image":"http:\/\/a375.ac-images.myspacecdn.com\/images01\/3\/s_975e32aedf2bd81fbe2bf8d3d6d4674e.jpg","name":"BrownPunk!","onlineNow":false,"uri":"http:\/\/api.msappspace.com\/v1\/users\/107265345","userId":107265345,"userType":"Band","webUri":"http:\/\/www.myspace.com\/107265345"}}'
80
+ end
81
+
82
+ # EOF
File without changes
data/test/test_user.rb ADDED
@@ -0,0 +1,33 @@
1
+ # $Id$
2
+
3
+ STUB_NETWORK = true
4
+
5
+ require File.join(File.dirname(__FILE__), %w[test_helper])
6
+ require 'test/unit'
7
+ require 'mocha'
8
+
9
+ class TestUser < Test::Unit::TestCase
10
+
11
+ def setup
12
+ api_key = 'http://www.myspace.com/yourapp'
13
+ secret_key = 'secretkey'
14
+ myspace = Spacer::Client.new(api_key, secret_key)
15
+ stubbing_http_response_with example_user_response_json do
16
+ @user = myspace.user('107265345')
17
+ end
18
+ end
19
+
20
+ def test_get_profile
21
+ stubbing_http_response_with example_profile_response_json do
22
+ profile = @user.profile
23
+ assert_equal "CHICAGO", profile.city
24
+ end
25
+ end
26
+
27
+ def test_get_friends
28
+ stubbing_http_response_with example_friends_response_json do
29
+ friends = @user.friends
30
+ assert_equal 'Tom', friends.first.name
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: spacer
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.5.0
7
+ date: 2008-02-09 00:00:00 -06:00
8
+ summary: Ruby API for the MySpace Platform REST API
9
+ require_paths:
10
+ - lib
11
+ email: shanev@gmail.com
12
+ homepage: http://shanesbrain.net
13
+ rubyforge_project: spacer
14
+ description: Ruby API for the MySpace Platform REST API
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Shane Vitarana
31
+ files:
32
+ - History.txt
33
+ - MIT-LICENSE
34
+ - Manifest.txt
35
+ - README.txt
36
+ - Rakefile
37
+ - bin/spacer
38
+ - lib/spacer.rb
39
+ - lib/spacer/auth.rb
40
+ - lib/spacer/client.rb
41
+ - lib/spacer/model.rb
42
+ - lib/spacer/models/album.rb
43
+ - lib/spacer/models/details.rb
44
+ - lib/spacer/models/group.rb
45
+ - lib/spacer/models/interest.rb
46
+ - lib/spacer/models/mood.rb
47
+ - lib/spacer/models/photo.rb
48
+ - lib/spacer/models/profile.rb
49
+ - lib/spacer/models/status.rb
50
+ - lib/spacer/models/user.rb
51
+ - lib/spacer/models/video.rb
52
+ - tasks/annotations.rake
53
+ - tasks/doc.rake
54
+ - tasks/gem.rake
55
+ - tasks/manifest.rake
56
+ - tasks/post_load.rake
57
+ - tasks/rubyforge.rake
58
+ - tasks/setup.rb
59
+ - tasks/spec.rake
60
+ - tasks/svn.rake
61
+ - tasks/test.rake
62
+ - test/test_client.rb
63
+ - test/test_helper.rb
64
+ - test/test_spacer.rb
65
+ - test/test_user.rb
66
+ test_files:
67
+ - test/test_client.rb
68
+ - test/test_helper.rb
69
+ - test/test_spacer.rb
70
+ - test/test_user.rb
71
+ rdoc_options:
72
+ - --main
73
+ - README.txt
74
+ extra_rdoc_files:
75
+ - History.txt
76
+ - README.txt
77
+ - bin/spacer
78
+ executables:
79
+ - spacer
80
+ extensions: []
81
+
82
+ requirements: []
83
+
84
+ dependencies: []
85
+