lastfm 0.2.1 → 0.3.0

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.rdoc CHANGED
@@ -46,6 +46,12 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
46
46
 
47
47
  * artist.getEvents
48
48
 
49
+ === User
50
+
51
+ * user.getInfo
52
+ * user.getFriends
53
+ * user.getRecentTracks
54
+
49
55
  == Installation
50
56
 
51
57
  === Archive Installation
@@ -61,6 +67,12 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
61
67
 
62
68
  == Features/Problems
63
69
 
70
+ == Commiters
71
+
72
+ * mattfawcett <https://github.com/mattfawcett>
73
+ * peplin <https://github.com/peplin>
74
+ * liff <https://github.com/liff>
75
+
64
76
  == Note on Patches/Pull Requests
65
77
 
66
78
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
data/lib/lastfm.rb CHANGED
@@ -9,6 +9,7 @@ require 'lastfm/method_category/base'
9
9
  require 'lastfm/method_category/auth'
10
10
  require 'lastfm/method_category/track'
11
11
  require 'lastfm/method_category/artist'
12
+ require 'lastfm/method_category/user'
12
13
 
13
14
  class Lastfm
14
15
  API_ROOT = 'http://ws.audioscrobbler.com/2.0'
@@ -38,6 +39,10 @@ class Lastfm
38
39
  MethodCategory::Artist.new(self)
39
40
  end
40
41
 
42
+ def user
43
+ MethodCategory::User.new(self)
44
+ end
45
+
41
46
  def request(method, params = {}, http_method = :get, with_signature = false, with_session = false)
42
47
  params[:method] = method
43
48
  params[:api_key] = @api_key
@@ -0,0 +1,17 @@
1
+ class Lastfm
2
+ module MethodCategory
3
+ class User < Base
4
+ regular_method :get_info, [:user], [] do |response|
5
+ response.xml['user'][0]
6
+ end
7
+
8
+ regular_method :get_friends, [:user], [[:recenttracks, nil], [:limit, nil], [:page, nil]] do |response|
9
+ response.xml['friends']['user']
10
+ end
11
+
12
+ regular_method :get_recent_tracks, [:user], [[:limit, nil], [:page, nil], [:to, nil], [:from, nil]] do |response|
13
+ response.xml['recenttracks']['track']
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ <lfm status="ok" total="1" page="1" perPage="50" totalPages="1">
2
+ <friends for="joanofarctan">
3
+ <user>
4
+ <name>polaroide</name>
5
+ <image size="small">...</image>
6
+ <image size="medium">...</image>
7
+ <image size="large">...</image>
8
+ <url>http://www.last.fm/user/polaroide/</url>
9
+ </user>
10
+ </friends>
11
+ </lfm>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <lfm status="ok">
3
+ <user>
4
+ <id>1000002</id>
5
+ <name>RJ</name>
6
+ <realname>Richard Jones </realname>
7
+ <url>http://www.last.fm/user/RJ</url>
8
+ <image>http://userserve-ak.last.fm/serve/126/8270359.jpg</image>
9
+ <country>UK</country>
10
+ <age>27</age>
11
+ <gender>m</gender>
12
+ <subscriber>1</subscriber>
13
+ <playcount>54189</playcount>
14
+ <playlists>4</playlists>
15
+ <bootstrap>0</bootstrap>
16
+ <registered unixtime="1037793040">2002-11-20 11:50</registered>
17
+ </user>
18
+ </lfm>
@@ -0,0 +1,23 @@
1
+ <lfm status="ok">
2
+ <recenttracks user="RJ" page="1" perPage="10" totalPages="3019">
3
+ <track nowplaying="true">
4
+ <artist mbid="2f9ecbed-27be-40e6-abca-6de49d50299e">Aretha Franklin</artist>
5
+ <name>Sisters Are Doing It For Themselves</name>
6
+ <mbid/>
7
+ <album mbid=""/>
8
+ <url>www.last.fm/music/Aretha+Franklin/_/Sisters+Are+Doing+It+For+Themselves</url>
9
+ <date uts="1213031819">9 Jun 2008, 17:16</date>
10
+ <streamable>1</streamable>
11
+ </track>
12
+ <track>
13
+ <name>I Believe in You</name>
14
+ <artist mbid="">Kylie Minogue</artist>
15
+ <url>http://www.last.fm/music/Kylie+Minogue/_/I+Believe+in+You</url>
16
+ <streamable fulltrack="0">0</streamable>
17
+ <image size="small">http://userserve-ak.last.fm/serve/34s/8822309.jpg</image>
18
+ <image size="medium">http://userserve-ak.last.fm/serve/64s/8822309.jpg</image>
19
+ <image size="large">http://userserve-ak.last.fm/serve/126/8822309.jpg</image>
20
+ <image size="extralarge">http://userserve-ak.last.fm/serve/300x300/8822309.jpg</image>
21
+ </track>
22
+ </recenttracks>
23
+ </lfm>
data/spec/lastfm_spec.rb CHANGED
@@ -344,4 +344,47 @@ XML
344
344
  events[0]['tags']['tag'].should == ["pop", "dance", "female vocalists", "80s", "cher"]
345
345
  end
346
346
  end
347
+
348
+ describe '#user' do
349
+ it 'should return and instance of Lastfm::User' do
350
+ @lastfm.user.should be_an_instance_of(Lastfm::MethodCategory::User)
351
+ end
352
+
353
+ describe '#get_info' do
354
+ it 'should get user info' do
355
+ @lastfm.should_receive(:request).with('user.getInfo', {:user => 'test'}).and_return(make_response('user_get_info'))
356
+ info = @lastfm.user.get_info('test')
357
+ info['id'].should eql('1000002')
358
+ end
359
+ end
360
+
361
+ describe '#get_friends' do
362
+ it 'should get user\'s friends' do
363
+ @lastfm.should_receive(:request).with('user.getFriends', {
364
+ :user => 'test',
365
+ :recenttracks => nil,
366
+ :page => nil,
367
+ :limit => nil
368
+ }).and_return(make_response('user_get_friends'))
369
+ friends = @lastfm.user.get_friends('test')
370
+ friends.size.should == 1
371
+ friends[0]['name'].should eql('polaroide')
372
+ end
373
+ end
374
+
375
+ describe '#get_recent_tracks' do
376
+ it 'should get user\'s recent tracks' do
377
+ @lastfm.should_receive(:request).with('user.getRecentTracks', {
378
+ :user => 'test',
379
+ :page => nil,
380
+ :limit => nil,
381
+ :to => nil,
382
+ :from => nil
383
+ }).and_return(make_response('user_get_recent_tracks'))
384
+ tracks = @lastfm.user.get_recent_tracks('test')
385
+ tracks[1]['artist']['content'].should eql('Kylie Minogue')
386
+ tracks.size.should == 2
387
+ end
388
+ end
389
+ end
347
390
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lastfm
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 19
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - youpy
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-06 00:00:00 +09:00
18
+ date: 2011-03-13 00:00:00 +09:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rspec
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 15
27
30
  segments:
28
31
  - 2
29
32
  - 0
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: httparty
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 3
41
46
  segments:
42
47
  - 0
43
48
  version: "0"
@@ -47,9 +52,11 @@ dependencies:
47
52
  name: xml-simple
48
53
  prerelease: false
49
54
  requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
50
56
  requirements:
51
57
  - - ">="
52
58
  - !ruby/object:Gem::Version
59
+ hash: 3
53
60
  segments:
54
61
  - 0
55
62
  version: "0"
@@ -59,9 +66,11 @@ dependencies:
59
66
  name: activesupport
60
67
  prerelease: false
61
68
  requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
62
70
  requirements:
63
71
  - - ">="
64
72
  - !ruby/object:Gem::Version
73
+ hash: 1
65
74
  segments:
66
75
  - 3
67
76
  - 0
@@ -91,6 +100,7 @@ files:
91
100
  - lib/lastfm/method_category/auth.rb
92
101
  - lib/lastfm/method_category/base.rb
93
102
  - lib/lastfm/method_category/track.rb
103
+ - lib/lastfm/method_category/user.rb
94
104
  - lib/lastfm/response.rb
95
105
  - lib/lastfm/util.rb
96
106
  - spec/fixtures/artist_get_events.xml
@@ -103,6 +113,9 @@ files:
103
113
  - spec/fixtures/track_get_top_fans.xml
104
114
  - spec/fixtures/track_get_top_tags.xml
105
115
  - spec/fixtures/track_search.xml
116
+ - spec/fixtures/user_get_friends.xml
117
+ - spec/fixtures/user_get_info.xml
118
+ - spec/fixtures/user_get_recent_tracks.xml
106
119
  - spec/lastfm_spec.rb
107
120
  - spec/method_category_spec.rb
108
121
  - spec/response_spec.rb
@@ -117,23 +130,27 @@ rdoc_options: []
117
130
  require_paths:
118
131
  - lib
119
132
  required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
120
134
  requirements:
121
135
  - - ">="
122
136
  - !ruby/object:Gem::Version
137
+ hash: 3
123
138
  segments:
124
139
  - 0
125
140
  version: "0"
126
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
127
143
  requirements:
128
144
  - - ">="
129
145
  - !ruby/object:Gem::Version
146
+ hash: 3
130
147
  segments:
131
148
  - 0
132
149
  version: "0"
133
150
  requirements: []
134
151
 
135
152
  rubyforge_project:
136
- rubygems_version: 1.3.6
153
+ rubygems_version: 1.5.0
137
154
  signing_key:
138
155
  specification_version: 3
139
156
  summary: A Ruby interface for Last.fm Web Services