lastfm 0.4.0 → 0.5.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
@@ -53,6 +53,14 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
53
53
  * user.getRecentTracks
54
54
  * user.getNeighbours
55
55
 
56
+ === Geo
57
+
58
+ * geo.getEvents
59
+
60
+ === Library
61
+
62
+ * library.getArtists
63
+
56
64
  == Installation
57
65
 
58
66
  === Archive Installation
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
data/lastfm.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "lib/lastfm/method_category/artist.rb",
30
30
  "lib/lastfm/method_category/auth.rb",
31
31
  "lib/lastfm/method_category/base.rb",
32
+ "lib/lastfm/method_category/geo.rb",
32
33
  "lib/lastfm/method_category/track.rb",
33
34
  "lib/lastfm/response.rb",
34
35
  "lib/lastfm/util.rb",
@@ -0,0 +1,9 @@
1
+ class Lastfm
2
+ module MethodCategory
3
+ class Geo < Base
4
+ regular_method :get_events, [], [[:location, nil], [:distance, nil], [:limit, nil], [:page, nil]] do |response|
5
+ response.xml['events']['event']
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class Lastfm
2
+ module MethodCategory
3
+ class Library < Base
4
+ regular_method :get_artists, [:user], [[:limit, nil], [:page, nil]] do |response|
5
+ response.xml['artists']['artist']
6
+ end
7
+ end
8
+ end
9
+ end
data/lib/lastfm.rb CHANGED
@@ -10,6 +10,8 @@ require 'lastfm/method_category/auth'
10
10
  require 'lastfm/method_category/track'
11
11
  require 'lastfm/method_category/artist'
12
12
  require 'lastfm/method_category/user'
13
+ require 'lastfm/method_category/geo'
14
+ require 'lastfm/method_category/library'
13
15
 
14
16
  class Lastfm
15
17
  API_ROOT = 'http://ws.audioscrobbler.com/2.0'
@@ -43,6 +45,14 @@ class Lastfm
43
45
  MethodCategory::User.new(self)
44
46
  end
45
47
 
48
+ def geo
49
+ MethodCategory::Geo.new(self)
50
+ end
51
+
52
+ def library
53
+ MethodCategory::Library.new(self)
54
+ end
55
+
46
56
  def request(method, params = {}, http_method = :get, with_signature = false, with_session = false)
47
57
  params[:method] = method
48
58
  params[:api_key] = @api_key
@@ -0,0 +1,58 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <lfm status="ok">
3
+ <events xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" location="Boulder, Denver CO, United States" page="1" perPage="1" totalPages="1" total="1">
4
+ <event xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" >
5
+ <id>1958795</id>
6
+ <title>Transistor Festival</title>
7
+ <artists>
8
+ <artist>Not Breathing</artist>
9
+ <artist>Iuengliss</artist>
10
+ <artist>kuxaan-sum</artist>
11
+ <artist>Entropic Advance</artist>
12
+ <artist>Page 27</artist>
13
+ <artist>Brocken Spectre</artist>
14
+ <artist>And Many More...</artist>
15
+ <artist>The 47th Star</artist>
16
+ <artist>c.db.sn.</artist>
17
+ <artist>Kontrolled Demolition</artist>
18
+ <headliner>Not Breathing</headliner>
19
+ </artists>
20
+ <venue>
21
+ <id>8898699</id>
22
+ <name>The Walnut Room</name>
23
+ <location>
24
+ <city>Denver, CO</city>
25
+ <country>United States</country>
26
+ <street>3131 Walnut Street</street>
27
+ <postalcode>80205</postalcode>
28
+ <geo:point>
29
+ <geo:lat>39.764316</geo:lat>
30
+ <geo:long>-104.979679</geo:long>
31
+ </geo:point>
32
+ </location>
33
+ <url>http://www.last.fm/venue/8898699+The+Walnut+Room</url>
34
+ <website>www.thewalnutroom.com</website>
35
+ <phonenumber>(303) 292-1700</phonenumber>
36
+ <image size="small">http://userserve-ak.last.fm/serve/34/18629169.png</image>
37
+ <image size="medium">http://userserve-ak.last.fm/serve/64/18629169.png</image>
38
+ <image size="large">http://userserve-ak.last.fm/serve/126/18629169.png</image>
39
+ <image size="extralarge">http://userserve-ak.last.fm/serve/252/18629169.png</image>
40
+ <image size="mega">http://userserve-ak.last.fm/serve/_/18629169/The+Walnut+Room+twrlogo.png</image>
41
+ </venue>
42
+ <startDate>Fri, 10 Jun 2011 01:58:01</startDate>
43
+ <endDate>Sun, 12 Jun 2011 01:58:01</endDate>
44
+ <description></description>
45
+ <image size="small">http://userserve-ak.last.fm/serve/34/166214.jpg</image>
46
+ <image size="medium">http://userserve-ak.last.fm/serve/64/166214.jpg</image>
47
+ <image size="large">http://userserve-ak.last.fm/serve/126/166214.jpg</image>
48
+ <image size="extralarge">http://userserve-ak.last.fm/serve/252/166214.jpg</image>
49
+ <attendance>1</attendance>
50
+ <reviews>0</reviews>
51
+ <tag>lastfm:event=1958795</tag>
52
+ <url>http://www.last.fm/festival/1958795+Transistor+Festival</url>
53
+ <website>http://www.thewalnutroom.com/posts/detail/2570</website>
54
+ <tickets></tickets>
55
+ <cancelled>0</cancelled>
56
+ </event>
57
+ </events>
58
+ </lfm>
@@ -0,0 +1,26 @@
1
+ <lfm status="ok">
2
+ <artists user="RJ" page="1" perPage="50" totalPages="20">
3
+ <artist rank="1">
4
+ <name>Dream Theater</name>
5
+ <playcount>1346</playcount>
6
+ <tagcount>0</tagcount>
7
+ <mbid>28503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid>
8
+ <url>http://www.last.fm/music/Dream+Theater</url>
9
+ <streamable>1</streamable>
10
+ <image size="small">http://userserve-ak.last.fm/serve/50/95853.jpg</image>
11
+ <image size="medium">http://userserve-ak.last.fm/serve/85/95853.jpg</image>
12
+ <image size="large">http://userserve-ak.last.fm/serve/160/95853.jpg</image>
13
+ </artist>
14
+ <artist rank="2">
15
+ <name>Dark Castle</name>
16
+ <playcount>1201</playcount>
17
+ <tagcount>0</tagcount>
18
+ <mbid>38503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid>
19
+ <url>http://www.last.fm/music/Dark+Castle</url>
20
+ <streamable>1</streamable>
21
+ <image size="small">http://userserve-ak.last.fm/serve/50/95855.jpg</image>
22
+ <image size="medium">http://userserve-ak.last.fm/serve/85/95855.jpg</image>
23
+ <image size="large">http://userserve-ak.last.fm/serve/160/95855.jpg</image>
24
+ </artist>
25
+ </artists>
26
+ </lfm>
data/spec/lastfm_spec.rb CHANGED
@@ -345,8 +345,36 @@ XML
345
345
  end
346
346
  end
347
347
 
348
+ describe '#geo' do
349
+ it 'should return an instance of Lastfm::Geo' do
350
+ @lastfm.geo.should be_an_instance_of(Lastfm::MethodCategory::Geo)
351
+ end
352
+
353
+ it 'should get events' do
354
+ @lastfm.should_receive(:request).with('geo.getEvents', {
355
+ :location => 'Boulder',
356
+ :distance => nil,
357
+ :limit => nil,
358
+ :page => nil
359
+ }).and_return(make_response('geo_get_events'))
360
+
361
+ events = @lastfm.geo.get_events('Boulder')
362
+ events.size.should eql(1)
363
+ events[0]['title'].should eql('Transistor Festival')
364
+ events[0]['artists'].size.should == 2
365
+ events[0]['artists']['headliner'].should eql('Not Breathing')
366
+ events[0]['venue']['name'].should eql('The Walnut Room')
367
+ events[0]['venue']['location']['city'].should eql('Denver, CO')
368
+ events[0]['venue']['location']['point']['lat'].should eql("39.764316")
369
+ events[0]['image'].size.should eql(4)
370
+ events[0]['image'][0]['size'].should eql('small')
371
+ events[0]['image'][0]['content'].should eql('http://userserve-ak.last.fm/serve/34/166214.jpg')
372
+ events[0]['startDate'].should eql("Fri, 10 Jun 2011 01:58:01")
373
+ end
374
+ end
375
+
348
376
  describe '#user' do
349
- it 'should return and instance of Lastfm::User' do
377
+ it 'should return an instance of Lastfm::User' do
350
378
  @lastfm.user.should be_an_instance_of(Lastfm::MethodCategory::User)
351
379
  end
352
380
 
@@ -401,4 +429,23 @@ XML
401
429
  end
402
430
  end
403
431
  end
432
+
433
+ describe '#library' do
434
+ it 'should return an instance of Lastfm::Library' do
435
+ @lastfm.library.should be_an_instance_of(Lastfm::MethodCategory::Library)
436
+ end
437
+
438
+ describe '#get_artists' do
439
+ it 'should get the artists\' info' do
440
+ @lastfm.should_receive(:request).with('library.getArtists', {
441
+ :user => 'test',
442
+ :limit => nil,
443
+ :page => nil
444
+ }).and_return(make_response('library_get_artists'))
445
+ artists = @lastfm.library.get_artists('test')
446
+ artists[1]['name'].should eql('Dark Castle')
447
+ artists.size.should == 2
448
+ end
449
+ end
450
+ end
404
451
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lastfm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - youpy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-06 00:00:00 +09:00
18
+ date: 2011-06-13 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -99,11 +99,15 @@ files:
99
99
  - lib/lastfm/method_category/artist.rb
100
100
  - lib/lastfm/method_category/auth.rb
101
101
  - lib/lastfm/method_category/base.rb
102
+ - lib/lastfm/method_category/geo.rb
103
+ - lib/lastfm/method_category/library.rb
102
104
  - lib/lastfm/method_category/track.rb
103
105
  - lib/lastfm/method_category/user.rb
104
106
  - lib/lastfm/response.rb
105
107
  - lib/lastfm/util.rb
106
108
  - spec/fixtures/artist_get_events.xml
109
+ - spec/fixtures/geo_get_events.xml
110
+ - spec/fixtures/library_get_artists.xml
107
111
  - spec/fixtures/ng.xml
108
112
  - spec/fixtures/ok.xml
109
113
  - spec/fixtures/track_get_info.xml