songkickr 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/LICENSE +1 -1
  2. data/README.rdoc +11 -4
  3. data/VERSION +1 -1
  4. data/doc/APIKeyNotSet.html +214 -0
  5. data/doc/LICENSE.html +133 -0
  6. data/doc/README_rdoc.html +170 -0
  7. data/doc/Songkickr/Artist.html +305 -0
  8. data/doc/Songkickr/ArtistResult.html +334 -0
  9. data/doc/Songkickr/ConcertSetlistResult.html +301 -0
  10. data/doc/Songkickr/Event.html +556 -0
  11. data/doc/Songkickr/EventResult.html +332 -0
  12. data/doc/Songkickr/Location.html +326 -0
  13. data/doc/Songkickr/LocationResult.html +335 -0
  14. data/doc/Songkickr/Performance.html +326 -0
  15. data/doc/Songkickr/Remote.html +715 -0
  16. data/doc/Songkickr/Setlist.html +398 -0
  17. data/doc/Songkickr/SetlistItem.html +263 -0
  18. data/doc/Songkickr/Venue.html +292 -0
  19. data/doc/Songkickr.html +328 -0
  20. data/doc/created.rid +16 -0
  21. data/doc/images/brick.png +0 -0
  22. data/doc/images/brick_link.png +0 -0
  23. data/doc/images/bug.png +0 -0
  24. data/doc/images/bullet_black.png +0 -0
  25. data/doc/images/bullet_toggle_minus.png +0 -0
  26. data/doc/images/bullet_toggle_plus.png +0 -0
  27. data/doc/images/date.png +0 -0
  28. data/doc/images/find.png +0 -0
  29. data/doc/images/loadingAnimation.gif +0 -0
  30. data/doc/images/macFFBgHack.png +0 -0
  31. data/doc/images/package.png +0 -0
  32. data/doc/images/page_green.png +0 -0
  33. data/doc/images/page_white_text.png +0 -0
  34. data/doc/images/page_white_width.png +0 -0
  35. data/doc/images/plugin.png +0 -0
  36. data/doc/images/ruby.png +0 -0
  37. data/doc/images/tag_green.png +0 -0
  38. data/doc/images/wrench.png +0 -0
  39. data/doc/images/wrench_orange.png +0 -0
  40. data/doc/images/zoom.png +0 -0
  41. data/doc/index.html +144 -0
  42. data/doc/js/darkfish.js +116 -0
  43. data/doc/js/jquery.js +32 -0
  44. data/doc/js/quicksearch.js +114 -0
  45. data/doc/js/thickbox-compressed.js +10 -0
  46. data/doc/lib/songkickr/artist_rb.html +52 -0
  47. data/doc/lib/songkickr/artist_result_rb.html +52 -0
  48. data/doc/lib/songkickr/concert_setlist_result_rb.html +52 -0
  49. data/doc/lib/songkickr/event_rb.html +52 -0
  50. data/doc/lib/songkickr/event_result_rb.html +52 -0
  51. data/doc/lib/songkickr/location_rb.html +52 -0
  52. data/doc/lib/songkickr/location_result_rb.html +52 -0
  53. data/doc/lib/songkickr/performance_rb.html +52 -0
  54. data/doc/lib/songkickr/remote_rb.html +52 -0
  55. data/doc/lib/songkickr/setlist_item_rb.html +52 -0
  56. data/doc/lib/songkickr/setlist_rb.html +52 -0
  57. data/doc/lib/songkickr/venue_rb.html +52 -0
  58. data/doc/lib/songkickr_rb.html +56 -0
  59. data/doc/rdoc.css +759 -0
  60. data/lib/songkickr/artist.rb +17 -6
  61. data/lib/songkickr/artist_result.rb +25 -22
  62. data/lib/songkickr/concert_setlist_result.rb +6 -2
  63. data/lib/songkickr/event.rb +42 -3
  64. data/lib/songkickr/event_result.rb +3 -1
  65. data/lib/songkickr/location.rb +28 -3
  66. data/lib/songkickr/location_result.rb +8 -3
  67. data/lib/songkickr/performance.rb +20 -4
  68. data/lib/songkickr/remote.rb +102 -60
  69. data/lib/songkickr/setlist.rb +20 -0
  70. data/lib/songkickr/setlist_item.rb +6 -0
  71. data/lib/songkickr.rb +16 -3
  72. data/songkickr.gemspec +60 -12
  73. data/test.rb +12 -11
  74. metadata +66 -13
@@ -1,13 +1,24 @@
1
1
  module Songkickr
2
+ # A single artist
3
+ #
4
+ # {
5
+ # "uri":"http://www.songkick.com/artists/253846-radiohead",
6
+ # "displayName":"Radiohead",
7
+ # "id":253846,
8
+ # "onTourUntil":"2010-01-01"
9
+ # }
10
+ #
11
+ # http://www.songkick.com/developer/artist-search
2
12
  class Artist
3
- attr_accessor :href, :display_name, :id, :uri, :onTourUntil
13
+ attr_accessor :uri, :display_name, :id, :uri, :on_tour_until
4
14
 
15
+ # Accepts a hash of artist attributes.
5
16
  def initialize(artist_hash = {})
6
- @href = artist_hash["href"]
7
- @display_name = artist_hash["displayName"]
8
- @id = artist_hash["id"]
9
- @uri = artist_hash["uri"]
10
- @onTourUntil = artist_hash["onTourUntil"]
17
+ @uri = artist_hash["uri"]
18
+ @display_name = artist_hash["displayName"]
19
+ @id = artist_hash["id"]
20
+ @uri = artist_hash["uri"]
21
+ @on_tour_until = artist_hash["onTourUntil"]
11
22
  end
12
23
  end
13
24
  end
@@ -1,29 +1,32 @@
1
1
  module Songkickr
2
+ # A class to represent the result hash of an Artist search.
2
3
  class ArtistResult
3
- attr_accessor :page, :total_entries, :results
4
+ attr_accessor :page, :total_entries, :results
4
5
 
5
- def initialize(result_hash = {})
6
- results_page = result_hash["resultsPage"]
6
+ # Takes the result hash directly and parses out the page and total entries and finally passes off to the parse_results method to get the results.
7
+ def initialize(result_hash = {})
8
+ results_page = result_hash["resultsPage"]
7
9
 
8
- if results_page
9
- @page = results_page["page"]
10
- @total_entries = results_page["totalEntries"]
11
- @results = parse_results results_page["results"]
12
- end
13
- end
10
+ if results_page
11
+ @page = results_page["page"]
12
+ @total_entries = results_page["totalEntries"]
13
+ @results = parse_results results_page["results"]
14
+ end
15
+ end
14
16
 
15
- protected
16
-
17
- def parse_results(results = {})
18
- artists = []
19
- if results.include?("artist")
20
- results["artist"].each do |artist|
21
- artists << Songkickr::Artist.new(artist)
22
- end
23
- end
24
-
25
- artists
26
- end
17
+ protected
27
18
 
19
+ # Take the results hash directly and parse the artists into Artist objects.
20
+ #
21
+ # Returns an array of Artists.
22
+ def parse_results(results = {})
23
+ artists = []
24
+ if results.include?("artist")
25
+ results["artist"].each do |artist|
26
+ artists << Songkickr::Artist.new(artist)
27
+ end
28
+ end
29
+ artists
30
+ end
28
31
  end
29
- end
32
+ end
@@ -1,9 +1,12 @@
1
1
  module Songkickr
2
+ # A class to represent the result hash of an Setlist search.
3
+ #
4
+ # http://www.songkick.com/developer/setlists
2
5
  class ConcertSetlistResult
3
6
  attr_accessor :results
4
7
 
8
+ # Takes the result ash and passes it to parse_results
5
9
  def initialize(result_hash = {})
6
-
7
10
  if result_hash["resultsPage"]
8
11
  results_page = result_hash["resultsPage"]
9
12
 
@@ -17,7 +20,8 @@ module Songkickr
17
20
 
18
21
 
19
22
  protected
20
-
23
+
24
+ # Parses the setlist items into an array of SetlistItems
21
25
  def parse_results(results = {})
22
26
  setlists = []
23
27
  if results.include?("setlist")
@@ -1,6 +1,43 @@
1
1
  module Songkickr
2
+ # A single event
3
+ #
4
+ # {
5
+ # "displayName": "Vampire Weekend at O2 Academy Brixton (February 16, 2010)",
6
+ # "type": "Concert",
7
+ # "uri": "http://www.songkick.com/concerts/3037536-vampire-weekend-at-o2-academy-brixton?utm_medium=partner&utm_source=131",
8
+ # "venue": {
9
+ # "lng": -0.1187418,
10
+ # "displayName": "O2 Academy Brixton",
11
+ # "lat": 51.4681089,
12
+ # "id": 17522
13
+ # },
14
+ # "location": {
15
+ # "lng": -0.1187418,
16
+ # "city": "London, UK",
17
+ # "lat": 51.4681089
18
+ # },
19
+ # "start": {
20
+ # "time": "19:30:00",
21
+ # "date": "2010-02-16"
22
+ # },
23
+ # "performance": [{
24
+ # "artist": {
25
+ # "uri": "http://www.songkick.com/artists/288696-vampire-weekend",
26
+ # "displayName": "Vampire Weekend",
27
+ # "id": 288696,
28
+ # "identifier": [{"mbid": "af37c51c-0790-4a29-b995-456f98a6b8c9"}]
29
+ # }
30
+ # "displayName": "Vampire Weekend",
31
+ # "billingIndex": 1,
32
+ # "id": 5380281,
33
+ # "billing": "headline"
34
+ # }],
35
+ # "id": 3037536
36
+ # }
37
+ #
38
+ # http://www.songkick.com/developer/artist-search
2
39
  class Event
3
- attr_accessor :type, :display_name, :location, :start, :uri, :id, :lat, :lng, :performance, :status, :venue, :tickets_uri
40
+ attr_accessor :type, :display_name, :location, :start, :uri, :id, :lat, :lng, :performances, :status, :venue, :tickets_uri
4
41
 
5
42
  def initialize(event_hash)
6
43
  @type = event_hash["type"]
@@ -10,17 +47,19 @@ module Songkickr
10
47
  @venue = Songkickr::Venue.new event_hash["venue"]
11
48
  @start = start_hash_to_datetime event_hash["start"]
12
49
  @uri = event_hash["uri"]
13
- @performance = parse_performance event_hash["performance"]
50
+ @performances = parse_performance event_hash["performance"]
14
51
  @id = event_hash["id"]
15
52
  @tickets_uri = event_hash["ticketsUri"]
16
53
  end
17
54
 
18
55
  protected
19
-
56
+
57
+ # Takes the start hash and turns in into a DateTime object.
20
58
  def start_hash_to_datetime(start_hash)
21
59
  datetime = DateTime.parse("#{start_hash["date"]} #{start_hash["time"]}")
22
60
  end
23
61
 
62
+ # Builds a list of Performance objects.
24
63
  def parse_performance(performance_array = nil)
25
64
  performances = []
26
65
  if performance_array
@@ -1,7 +1,9 @@
1
1
  module Songkickr
2
+ # A class to represent the result hash of an Event search.
2
3
  class EventResult
3
4
  attr_accessor :page, :total_entries, :results
4
-
5
+
6
+ # Takes the result hash directly and parses out the page and total entries and finally passes off to the parse_results method to get the results.
5
7
  def initialize(result_hash = {})
6
8
  results_page = result_hash["resultsPage"]
7
9
 
@@ -1,19 +1,44 @@
1
1
  module Songkickr
2
+ # A class to represent the hash of a Location.
3
+ #
4
+ # {
5
+ # "city":{
6
+ # "displayName":"London",
7
+ # "country":{
8
+ # "displayName":"UK"},
9
+ # "lng":-0.128,
10
+ # "lat":51.5078
11
+ # },
12
+ # "metroArea":{
13
+ # "uri":"http://www.songkick.com/metro_areas/24426-uk-london",
14
+ # "displayName":"London",
15
+ # "country":{ "displayName":"UK" },
16
+ # "id":24426,
17
+ # "lng":-0.128,
18
+ # "lat":51.5078
19
+ # }
20
+ # }
21
+ # }
22
+ #
23
+ # http://www.songkick.com/developer/location-search
2
24
  class Location
3
- attr_accessor :city, :lat, :lng
25
+ attr_accessor :city, :lat, :lng, :metro_area
4
26
 
27
+ # Takes a location hash. Handles the different city hashes from Event and Location
5
28
  def initialize(location_hash)
6
- if(location_hash["city"].is_a?(String)) # location in Event
29
+ if location_hash["city"].is_a?(String) # location in Event
7
30
  @city = location_hash["city"]
8
31
  @lat = location_hash["lat"]
9
32
  @lng = location_hash["lng"]
10
- elsif(location_hash["city"].is_a?(Hash)) # stand-alone Location
33
+ elsif location_hash["city"].is_a?(Hash) # stand-alone Location
11
34
  city_hash = location_hash["city"]
12
35
  @city = city_hash["displayName"]
13
36
  # some locations have a null lng, lat in city hash, but have non-null in metroArea hash
14
37
  @lat = city_hash["lat"]
15
38
  @lng = city_hash["lng"]
16
39
  end
40
+
41
+ @metro_area = location_hash['metro_area']
17
42
  end
18
43
  end
19
44
  end
@@ -1,9 +1,11 @@
1
1
  module Songkickr
2
+ # A class to represent the result hash of a Location search.
3
+
4
+ #TODO: very similar to concert_setlist_result, event_result, and artist_result, extract common stuff to module/superclass
2
5
  class LocationResult
3
- # TODO: very similar to event_result and artist_result,
4
- # extract common stuff to module/superclass
5
6
  attr_accessor :page, :total_entries, :results
6
7
 
8
+ # Takes the result hash directly and parses out the page and total entries and finally passes off to the parse_results method to get the results.
7
9
  def initialize(result_hash = {})
8
10
  results_page = result_hash["resultsPage"]
9
11
 
@@ -16,7 +18,10 @@ module Songkickr
16
18
 
17
19
 
18
20
  protected
19
-
21
+
22
+ # Take the results hash directly and parse the locations into Location objects.
23
+ #
24
+ # Returns an array of Locations.
20
25
  def parse_results(results = {})
21
26
  locations = []
22
27
  if results.include?("location")
@@ -1,11 +1,27 @@
1
1
  module Songkickr
2
+ # A single performance by an artist.
3
+ # {
4
+ # "artist": {
5
+ # "uri": "http://www.songkick.com/artists/288696-vampire-weekend",
6
+ # "displayName": "Vampire Weekend",
7
+ # "id": 288696,
8
+ # "identifier": [{"mbid": "af37c51c-0790-4a29-b995-456f98a6b8c9"}]
9
+ # }
10
+ # "displayName": "Vampire Weekend",
11
+ # "billingIndex": 1,
12
+ # "id": 5380281,
13
+ # "billing": "headline"
14
+ # }
2
15
  class Performance
3
- attr_accessor :artist, :display_name, :id
16
+ attr_accessor :artist, :display_name, :id, :billing_index, :billing
4
17
 
18
+ # Takes a the hash of the performance. Parses out an Artist object for the artist.
5
19
  def initialize(performance_hash)
6
- @artist = Songkickr::Artist.new performance_hash["artist"]
7
- @display_name = performance_hash["displayName"]
8
- @id = performance_hash["id"]
20
+ @artist = Songkickr::Artist.new performance_hash["artist"]
21
+ @display_name = performance_hash["displayName"]
22
+ @id = performance_hash["id"]
23
+ @billing_index = performance_hash['billingIndex']
24
+ @billin = performance_hash['billing']
9
25
  end
10
26
  end
11
27
  end
@@ -1,4 +1,5 @@
1
1
  module Songkickr
2
+ # Create an instance of the remote class to interact with the Songkick API.
2
3
  class Remote
3
4
  include HTTParty
4
5
  base_uri 'api.songkick.com/api/3.0'
@@ -6,7 +7,8 @@ module Songkickr
6
7
 
7
8
  attr_reader :api_key
8
9
 
9
- # Get your api_key found here http://developer.songkick.com
10
+ # ==== Create a new instance of the remote class to talk to Songkick
11
+ # Get an API key for your app from http://developer.songkick.com/
10
12
  def initialize(api_key = nil)
11
13
  @api_key = api_key
12
14
  @api_key ||= Songkickr.api_key
@@ -14,105 +16,145 @@ module Songkickr
14
16
  self.class.default_params :apikey => @api_key
15
17
  end
16
18
 
17
-
18
- # Parameters - http://www.songkick.com/developer/event-search
19
- #
20
- # type (concert or festival)
21
- # artists (events by any of the artists, comma-separated)
22
- # artist_name
23
- # artist_id
24
- # venue_id
25
- # setlist_item_name (name of a song which was played at the event – use with artist_id or artist_name)
26
- # min_date
27
- # max_date
28
- # location - see the Songkick website for instructions on how to use the location parameter
29
-
19
+ # ==== Event Search API
20
+ # http://www.songkick.com/developer/event-search
21
+ #
22
+ # === Parameters
23
+ # * +query+ - A hash of query parameters, see below for options.
24
+ #
25
+ # _Example:_ <code>{ :type => 'concert', :artists => 'Coolio' }</code>
26
+ #
27
+ # ==== Query Parameters
28
+ # * +type+ - valid types: concert or festival
29
+ # * +artists+ - events by any of the artists, comma-separated
30
+ # * +artist_name+ - plain text name of artist ex. 'As I Lay Dying', 'Parkway Drive', 'Animals As Leaders'
31
+ # * +artist_id+ - Songkick unique ID for an artist
32
+ # * +venue_id+ - Songkick unique ID for a venue
33
+ # * +setlist_item_name+ - name of a song which was played at the event – use with artist_id or artist_name
34
+ # * +min_date+ - Oldest date for which you want to look for events
35
+ # * +max_date+ - Most recent date for which you want to look for events
36
+ # * +location+ - See the Songkick website for instructions on how to use the location parameter http://www.songkick.com/developer/location-search
30
37
  def events(query = {})
31
38
  path = extract_path_from_query(query)
32
39
  result = self.class.get("#{path}/events.json", :query => query)
33
40
  Songkickr::EventResult.new result
34
41
  end
35
42
 
36
-
37
- # Getting detailed information of a single event
43
+ # ==== Event API
38
44
  # http://www.songkick.com/developer/upcoming-events
39
-
45
+ #
46
+ # Getting detailed information of a single event.
47
+ #
48
+ # === Parameters
49
+ # * +event_id+ - Songkick event ID. Extract the event ID either from a previous API call or from the URL of the event page on the website.
40
50
  def event(event_id)
41
51
  result = self.class.get("/events/#{event_id}.json")
42
52
  # and now for some dirrty hack
43
53
  Songkickr::Event.new result["resultsPage"]["results"]["event"]
44
54
  end
45
-
46
- # Parameters - http://groups.google.com/group/songkick-api/browse_thread/thread/af15b9a6ad3c3513#
47
- # artist_id - Songkick artist_id, use artist_search to get it
48
- # min_date
49
- # max_date
50
- # per_page
51
- # page
52
55
 
56
+ # ==== Gigography API
57
+ # http://groups.google.com/group/songkick-api/browse_thread/thread/af15b9a6ad3c3513#
58
+ #
59
+ # === Parameters
60
+ # * +artist_id+ - Songkick artist_id, use artist_search to get it
61
+ # * +query+ - A hash of query parameters, see below for options.
62
+ #
63
+ # ==== Query Parameters
64
+ # * +min_date+ - Oldest date for which you want to look for events
65
+ # * +max_date+ - Most recent date for which you want to look for events
66
+ # * +per_page+ - Number of items on a page
67
+ # * +page+ - Number of page
53
68
  def gigography(artist_id, query= {})
54
69
  result = self.class.get("/artists/#{artist_id}/gigography.json",:query=>query)
55
70
  Songkickr::EventResult.new result
56
71
  end
57
72
 
58
- # Parameters - http://www.songkick.com/developer/artist-search
59
- # full_text (full text of a search)
60
- # returns artist
61
-
73
+ # ==== Artist Search API
74
+ # Returns Artist objects.
75
+ #
76
+ # http://www.songkick.com/developer/artist-search
77
+ #
78
+ # === Parameters
79
+ # * +query+ - Search for artists by name using full text search. Results from Songkick are returned by relevancy.
80
+ #
81
+ # ==== Query Parameters
82
+ # * +artist_name+ - Name of an artist. <em>Ex. 'Lady Gaga', 'Slayer', 'Atmosphere'</em>
62
83
  def artist_search(query={})
63
- result = self.class.get("/search/artists.json?query=#{query[:artist_name]}", :query=>query)
64
- Songkickr::ArtistResult.new result
84
+ result = self.class.get("/search/artists.json", :query => query)
85
+ Songkickr::ArtistResult.new result
65
86
  end
66
87
 
67
- # Parameters - http://www.songkick.com/developer/events-for-user
68
- #
69
- # attendance (all, im_going, i_might_go) - defaults to im_going
70
- # type (concert or festival)
71
- # artists (events by any of the artists, comma-separated)
72
- # artist_name
73
- # artist_id
74
- # venue_id
75
- # setlist_item_name (name of a song which was played at the event – use with artist_id or artist_name)
76
- # min_date
77
- # max_date
78
- # location - see the Songkick website for instructions on how to use the location parameter
79
-
88
+ # ==== User Events API
89
+ # http://www.songkick.com/developer/upcoming-events-for-user
90
+ #
91
+ # === Parameters
92
+ # * +username+ - A Songkick username.
93
+ # * +query+ - A hash of query parameters, see below for options.
94
+ #
95
+ # ==== Query Parameters
96
+ # * +attendance+ (all, im_going, i_might_go) - defaults to im_going
97
+ # * +type+ (concert or festival)
98
+ # * +artists+ (events by any of the artists, comma-separated)
99
+ # * +artist_id+ - Songkick unique ID for an artist
100
+ # * +venue_id+ - Songkick unique ID for a venue
101
+ # * +setlist_item_name+ (name of a song which was played at the event – use with artist_id or artist_name)
102
+ # * +min_date+ - Oldest date for which you want to look for events
103
+ # * +max_date+ - Most recent date for which you want to look for events
104
+ # * +location+ - see the Songkick website for instructions on how to use the location parameter
80
105
  def users_events(username, query = {})
81
106
  result = self.class.get("/users/#{username}/events.json", :query => query)
82
107
  Songkickr::EventResult.new result
83
108
  end
84
-
85
- # Metro Area Events (Upcoming) - http://www.songkick.com/developer/upcoming-events-for-metro-area
86
-
109
+
110
+ # ==== Metro Area Events (Upcoming)
111
+ # Returns an array of Events.
112
+ #
113
+ # http://www.songkick.com/developer/upcoming-events-for-metro-area
114
+ #
115
+ # === Parameters
116
+ # * +metro_area_id+ - Songkick unique ID for metro areas. Use location_search to find a metro area ID.
117
+ # * +query+ - A hash of query parameters, see below for options.
118
+ #
119
+ # ==== Query Parameters
120
+ # * +page+ - Page number
121
+ # * +per_page+ - Number of results per page, max 50.
87
122
  def metro_areas_events(metro_area_id, query = {})
88
123
  result = self.class.get("/metro_areas/#{metro_area_id}/calendar.json", :query => query)
89
124
  Songkickr::EventResult.new result
90
- end
125
+ end
91
126
 
92
- # Parameters - http://www.songkick.com/developer/setlists
127
+ # ==== Concert Setlists API
128
+ # http://www.songkick.com/developer/setlists
93
129
  #
94
- # event_id
95
-
130
+ # === Parameters
131
+ #
132
+ # * +event_id+ - Songkick event ID. Extract the event ID either from a previous API call or from the URL of the event page on the website.
96
133
  def concert_setlists(event_id)
97
134
  result = self.class.get("/events/#{event_id}/setlists.json")
98
135
  Songkickr::ConcertSetlistResult.new result
99
136
  end
100
137
 
101
- # Parameters - http://www.songkick.com/developer/location-search
138
+ # ==== Location Search API
139
+ # http://www.songkick.com/developer/location-search
102
140
  #
103
- # location - 'geo:{lat,lng}' string
104
- # query - name of location to search for
105
-
141
+ # === Parameters
142
+ # * +query+ - A hash of query parameters, see below for options.
143
+ #
144
+ # ==== Query Parameters
145
+ # * +location+ - 'geo:{lat,lng}' string <em>Ex. 'geo:{-0.128,51.5078}'</em>
106
146
  def location_search(query = {})
107
- result = self.class.get("/search/locations.json",:query=>query)
147
+ result = self.class.get("/search/locations.json", :query => query)
108
148
  Songkickr::LocationResult.new result
109
149
  end
110
150
 
111
- private
112
151
 
113
- def extract_path_from_query(query = {})
114
- mbid = query.delete :mbid
115
- "/artists/mbid:#{mbid}" if mbid
116
- end
152
+ private
153
+
154
+ # Given a query, look for an mbid key and return a path to access it.
155
+ def extract_path_from_query(query = {})
156
+ mbid = query.delete :mbid
157
+ "/artists/mbid:#{mbid}" if mbid
158
+ end
117
159
  end
118
160
  end
@@ -1,7 +1,26 @@
1
1
  module Songkickr
2
+ # A single set list by an artist.
3
+ #
4
+ # {
5
+ # "displayName": "N.E.R.D. at Glastonbury Festival 2009",
6
+ # "artist": {
7
+ # "uri": "http://www.songkick.com/artists/387012-nerd?utm_source=791&utm_medium=partner"
8
+ # "identifier": [
9
+ # {
10
+ # "href": "http://api.songkick.com/api/3.0/artists/mbid:3fb49f5a-fdc0-4789-9c84-22b38b3f3cb5.json"
11
+ # "mbid": "3fb49f5a-fdc0-4789-9c84-22b38b3f3cb5"
12
+ # }
13
+ # ]
14
+ # "displayName": "N.E.R.D."
15
+ # "id": 387012
16
+ # },
17
+ # "id": 9511,
18
+ # "setlistItem": []
19
+ # }
2
20
  class Setlist
3
21
  attr_accessor :event, :setlist_items, :artist, :playlist_uri, :display_name, :id
4
22
 
23
+ # Takes the setlist hash and parses out an Event and Artist and an array of SetlistItems.
5
24
  def initialize(setlist_hash)
6
25
  @event = Songkickr::Event.new setlist_hash["event"]
7
26
  @setlist_items = parse_setlist_items setlist_hash["setlistItem"]
@@ -13,6 +32,7 @@ module Songkickr
13
32
 
14
33
  protected
15
34
 
35
+ # Takes the array of setlist items and create SetLists
16
36
  def parse_setlist_items(setlist_item_array = nil)
17
37
  setlist_items = []
18
38
  if setlist_item_array
@@ -1,7 +1,13 @@
1
1
  module Songkickr
2
+ # A single set list item.
3
+ # {
4
+ # encore: 0
5
+ # name: "Anti Matter "
6
+ # }
2
7
  class SetlistItem
3
8
  attr_accessor :encore, :name
4
9
 
10
+ # Takes the set list item hash and parses a boolean out for encore.
5
11
  def initialize(setlist_item_hash)
6
12
  @encore = !!setlist_item_hash["encore"]
7
13
  @name = setlist_item_hash["name"]
data/lib/songkickr.rb CHANGED
@@ -16,21 +16,34 @@ require dir + '/songkickr/concert_setlist_result'
16
16
  require dir + '/songkickr/remote'
17
17
  require dir + '/songkickr/artist_result'
18
18
 
19
- class APIKeyNotSet < StandardError;
19
+ class APIKeyNotSet < StandardError;
20
+ # Warns of missing API key
20
21
  def to_s
21
22
  'API key not set!'
22
23
  end
23
24
  end
24
25
 
25
26
  module Songkickr
26
-
27
- # Get your API key from http://developer.songkick.com/
27
+ # Returns the Songkick API key
28
+ # In order to use the Songkick API, you must have a Songkick API (their rule, not mine).
29
+ # Get an API key for your app from http://developer.songkick.com/
30
+ #
31
+ # ==== Example
32
+ #
33
+ # require 'songkickr'
34
+ # remote = Songkickr::Remote.new XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
35
+ # remote.api_key
36
+ # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
28
37
  def self.api_key
29
38
  raise APIKeyNotSet if @api_key.nil?
30
39
 
31
40
  @api_key
32
41
  end
33
42
 
43
+ # Set the API key. In the event you need to set the API key after initializing the the remote.
44
+ # === Parameters
45
+ #
46
+ # * +api_key+ - A developer key from Songkick. Get an API key for your app from http://developer.songkick.com/
34
47
  def self.api_key=(api_key)
35
48
  @api_key = api_key
36
49
  end