songkickr 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/config +2 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +8 -0
  5. data/Gemfile.lock +42 -22
  6. data/LICENSE +1 -1
  7. data/README.rdoc +14 -9
  8. data/Rakefile +3 -4
  9. data/lib/songkickr/artist.rb +2 -2
  10. data/lib/songkickr/artist_result.rb +4 -24
  11. data/lib/songkickr/calendar_entry.rb +23 -0
  12. data/lib/songkickr/calendar_result.rb +10 -0
  13. data/lib/songkickr/concert_setlist_result.rb +5 -27
  14. data/lib/songkickr/event.rb +8 -14
  15. data/lib/songkickr/event_result.rb +5 -23
  16. data/lib/songkickr/location.rb +4 -4
  17. data/lib/songkickr/location_result.rb +5 -30
  18. data/lib/songkickr/metro_area.rb +28 -0
  19. data/lib/songkickr/metro_area_result.rb +12 -0
  20. data/lib/songkickr/performance.rb +17 -12
  21. data/lib/songkickr/remote.rb +18 -198
  22. data/lib/songkickr/remote_api/artist_details.rb +17 -0
  23. data/lib/songkickr/remote_api/event_details.rb +17 -0
  24. data/lib/songkickr/remote_api/past_events.rb +48 -0
  25. data/lib/songkickr/remote_api/similar_artists.rb +14 -0
  26. data/lib/songkickr/remote_api/upcoming_events.rb +125 -0
  27. data/lib/songkickr/remote_api/user_events_and_trackings.rb +143 -0
  28. data/lib/songkickr/remote_api/venue_details.rb +16 -0
  29. data/lib/songkickr/result_set.rb +27 -0
  30. data/lib/songkickr/setlist.rb +7 -12
  31. data/lib/songkickr/setlist_item.rb +1 -1
  32. data/lib/songkickr/tracking.rb +18 -0
  33. data/lib/songkickr/tracking_result.rb +24 -0
  34. data/lib/songkickr/venue.rb +10 -2
  35. data/lib/songkickr/venue_result.rb +32 -0
  36. data/lib/songkickr/version.rb +1 -1
  37. data/lib/songkickr.rb +24 -17
  38. data/songkickr.gemspec +17 -44
  39. data/test/fixtures/event_7391451.json +732 -1
  40. data/test/fixtures/location_search.json +38 -0
  41. data/test/fixtures/metro_area.json +11 -0
  42. data/test/fixtures/users_attendance_calendar.json +243 -0
  43. data/test/fixtures/vcr/artist_events.yml +1394 -0
  44. data/test/fixtures/vcr/artist_search.yml +38 -0
  45. data/test/fixtures/vcr/artists_gigography.yml +187 -0
  46. data/test/fixtures/vcr/concert_setlists.yml +47 -0
  47. data/test/fixtures/vcr/event_search.yml +110 -0
  48. data/test/fixtures/vcr/invalid_api_key.yml +6 -36
  49. data/test/fixtures/vcr/invalid_artist_id.yml +6 -6
  50. data/test/fixtures/vcr/invalid_event_id.yml +6 -6
  51. data/test/fixtures/vcr/invalid_user.yml +6 -6
  52. data/test/fixtures/vcr/invalid_venue_id.yml +6 -6
  53. data/test/fixtures/vcr/location_search.yml +42 -0
  54. data/test/fixtures/vcr/metro_areas_events.yml +1535 -0
  55. data/test/fixtures/vcr/similar_artists.yml +64 -0
  56. data/test/fixtures/vcr/users_artist_tracking.yml +99 -0
  57. data/test/fixtures/vcr/users_attendance.yml +66 -0
  58. data/test/fixtures/vcr/users_attendance_calendar.yml +51 -0
  59. data/test/fixtures/vcr/users_events.yml +809 -0
  60. data/test/fixtures/vcr/users_gigography.yml +2782 -0
  61. data/test/fixtures/vcr/users_metro_area_tracking.yml +66 -0
  62. data/test/fixtures/vcr/users_muted_artists.yml +66 -0
  63. data/test/fixtures/vcr/users_tracked_artists.yml +75 -0
  64. data/test/fixtures/vcr/users_tracked_events_calendar.yml +1901 -0
  65. data/test/fixtures/vcr/users_tracked_metro_areas.yml +37 -0
  66. data/test/fixtures/vcr/valid_artist.yml +9 -9
  67. data/test/fixtures/vcr/valid_event.yml +103 -38
  68. data/test/fixtures/vcr/valid_user.yml +634 -44
  69. data/test/fixtures/vcr/valid_venue.yml +25 -26
  70. data/test/fixtures/vcr/venue_calendar.yml +500 -0
  71. data/test/fixtures/vcr/venue_search.yml +42 -0
  72. data/test/helper.rb +1 -27
  73. data/test/songkickr/test_calendar_entry.rb +15 -0
  74. data/test/songkickr/test_event.rb +8 -9
  75. data/test/songkickr/test_location.rb +11 -11
  76. data/test/songkickr/test_metro_area.rb +17 -0
  77. data/test/songkickr/test_remote.rb +149 -3
  78. data/test/songkickr/test_setlist_item.rb +20 -0
  79. data/test/songkickr/test_venue.rb +1 -2
  80. data/test.rb +3 -5
  81. metadata +120 -152
  82. data/bin/autospec +0 -16
  83. data/bin/convert_to_should_syntax +0 -16
  84. data/bin/guard +0 -16
  85. data/bin/htmldiff +0 -16
  86. data/bin/httparty +0 -16
  87. data/bin/jeweler +0 -16
  88. data/bin/ldiff +0 -16
  89. data/bin/rake +0 -16
  90. data/bin/rake2thor +0 -16
  91. data/bin/rg +0 -16
  92. data/bin/ri +0 -16
  93. data/bin/rspec +0 -16
  94. data/bin/thor +0 -16
  95. data/doc/APIError.html +0 -241
  96. data/doc/APIKeyNotSet.html +0 -203
  97. data/doc/LICENSE.html +0 -133
  98. data/doc/README_rdoc.html +0 -173
  99. data/doc/ResourceNotFound.html +0 -203
  100. data/doc/Songkickr/Artist.html +0 -278
  101. data/doc/Songkickr/ArtistResult.html +0 -308
  102. data/doc/Songkickr/ConcertSetlistResult.html +0 -283
  103. data/doc/Songkickr/Event.html +0 -491
  104. data/doc/Songkickr/EventResult.html +0 -306
  105. data/doc/Songkickr/Location.html +0 -299
  106. data/doc/Songkickr/LocationResult.html +0 -309
  107. data/doc/Songkickr/Performance.html +0 -295
  108. data/doc/Songkickr/Remote.html +0 -864
  109. data/doc/Songkickr/Setlist.html +0 -360
  110. data/doc/Songkickr/SetlistItem.html +0 -244
  111. data/doc/Songkickr/Venue.html +0 -265
  112. data/doc/Songkickr.html +0 -261
  113. data/doc/created.rid +0 -16
  114. data/doc/images/add.png +0 -0
  115. data/doc/images/brick.png +0 -0
  116. data/doc/images/brick_link.png +0 -0
  117. data/doc/images/bug.png +0 -0
  118. data/doc/images/bullet_black.png +0 -0
  119. data/doc/images/bullet_toggle_minus.png +0 -0
  120. data/doc/images/bullet_toggle_plus.png +0 -0
  121. data/doc/images/date.png +0 -0
  122. data/doc/images/delete.png +0 -0
  123. data/doc/images/find.png +0 -0
  124. data/doc/images/loadingAnimation.gif +0 -0
  125. data/doc/images/macFFBgHack.png +0 -0
  126. data/doc/images/package.png +0 -0
  127. data/doc/images/page_green.png +0 -0
  128. data/doc/images/page_white_text.png +0 -0
  129. data/doc/images/page_white_width.png +0 -0
  130. data/doc/images/plugin.png +0 -0
  131. data/doc/images/ruby.png +0 -0
  132. data/doc/images/tag_blue.png +0 -0
  133. data/doc/images/tag_green.png +0 -0
  134. data/doc/images/transparent.png +0 -0
  135. data/doc/images/wrench.png +0 -0
  136. data/doc/images/wrench_orange.png +0 -0
  137. data/doc/images/zoom.png +0 -0
  138. data/doc/index.html +0 -110
  139. data/doc/js/darkfish.js +0 -153
  140. data/doc/js/jquery.js +0 -18
  141. data/doc/js/navigation.js +0 -142
  142. data/doc/js/quicksearch.js +0 -114
  143. data/doc/js/search.js +0 -94
  144. data/doc/js/search_index.js +0 -1
  145. data/doc/js/searcher.js +0 -228
  146. data/doc/js/thickbox-compressed.js +0 -10
  147. data/doc/lib/songkickr/artist_rb.html +0 -52
  148. data/doc/lib/songkickr/artist_result_rb.html +0 -52
  149. data/doc/lib/songkickr/concert_setlist_result_rb.html +0 -52
  150. data/doc/lib/songkickr/event_rb.html +0 -52
  151. data/doc/lib/songkickr/event_result_rb.html +0 -52
  152. data/doc/lib/songkickr/location_rb.html +0 -52
  153. data/doc/lib/songkickr/location_result_rb.html +0 -52
  154. data/doc/lib/songkickr/performance_rb.html +0 -52
  155. data/doc/lib/songkickr/remote_rb.html +0 -52
  156. data/doc/lib/songkickr/setlist_item_rb.html +0 -52
  157. data/doc/lib/songkickr/setlist_rb.html +0 -52
  158. data/doc/lib/songkickr/venue_rb.html +0 -52
  159. data/doc/lib/songkickr_rb.html +0 -56
  160. data/doc/rdoc.css +0 -543
  161. data/doc/table_of_contents.html +0 -185
  162. data/test/fixtures/locations_bar.json +0 -1
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d347acbb0fa6ed84ad0d56cf83cab5af5e16cec7
4
+ data.tar.gz: 6b5dcf947c5e0467cd8653e86c0f0b12d5011e66
5
+ SHA512:
6
+ metadata.gz: 82aaa7def7817b654c7672426ca465c04f848076d64034c7dfda77b5f6a0c969e4bdb71f96217924c690b6fe7c4b9b1e7bbf9869b3b7fc6bcecff9ce854c37e3
7
+ data.tar.gz: e20637db3e43e5eff60e3d03c5b775b5a051be2316610bcdf8df2dd5a8d80eb77e9bb4f06b2685961881c76d015f705dacc8df3a7f4d534a6e990cc1d10c9d9a
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_BIN: bin
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ bin/*
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+ - ruby-head
8
+ - jruby-head
data/Gemfile.lock CHANGED
@@ -1,32 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- songkickr (0.3.3)
4
+ songkickr (0.4.0)
5
+ httparty (~> 0.8.3)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
- activesupport (3.2.12)
10
- i18n (~> 0.6)
11
- multi_json (~> 1.0)
12
- crack (0.3.1)
10
+ activesupport (4.0.0)
11
+ i18n (~> 0.6, >= 0.6.4)
12
+ minitest (~> 4.2)
13
+ multi_json (~> 1.3)
14
+ thread_safe (~> 0.1)
15
+ tzinfo (~> 0.3.37)
16
+ atomic (1.1.12)
17
+ coderay (1.0.9)
18
+ crack (0.4.1)
19
+ safe_yaml (~> 0.9.0)
13
20
  fakeweb (1.3.0)
14
21
  httparty (0.8.3)
15
22
  multi_json (~> 1.0)
16
23
  multi_xml
17
- i18n (0.6.1)
18
- multi_json (1.6.0)
19
- multi_xml (0.5.2)
20
- rake (10.0.3)
21
- redgreen (1.2.2)
22
- shoulda (3.1.1)
23
- shoulda-context (~> 1.0)
24
- shoulda-matchers (~> 1.2)
25
- shoulda-context (1.0.0)
26
- shoulda-matchers (1.2.0)
24
+ i18n (0.6.4)
25
+ json (1.8.0)
26
+ method_source (0.8.2)
27
+ minitest (4.7.5)
28
+ multi_json (1.7.7)
29
+ multi_xml (0.5.4)
30
+ pry (0.9.12.2)
31
+ coderay (~> 1.0.5)
32
+ method_source (~> 0.8)
33
+ slop (~> 3.4)
34
+ rake (10.0.4)
35
+ rdoc (4.0.1)
36
+ json (~> 1.4)
37
+ safe_yaml (0.9.4)
38
+ shoulda (3.5.0)
39
+ shoulda-context (~> 1.0, >= 1.0.1)
40
+ shoulda-matchers (>= 1.4.1, < 3.0)
41
+ shoulda-context (1.1.4)
42
+ shoulda-matchers (2.2.0)
27
43
  activesupport (>= 3.0.0)
28
- test-unit (2.5.1)
29
- vcr (2.2.4)
44
+ slop (3.4.6)
45
+ test-unit (2.5.5)
46
+ thread_safe (0.1.2)
47
+ atomic
48
+ tzinfo (0.3.37)
49
+ vcr (2.5.0)
30
50
 
31
51
  PLATFORMS
32
52
  ruby
@@ -34,10 +54,10 @@ PLATFORMS
34
54
  DEPENDENCIES
35
55
  crack
36
56
  fakeweb (>= 1.3.0)
37
- httparty
38
- rake
39
- redgreen (>= 1.2.2)
57
+ pry
58
+ rake (~> 10.0.0)
59
+ rdoc (~> 4.0.1)
40
60
  shoulda (>= 2.11.0)
41
61
  songkickr!
42
- test-unit
43
- vcr
62
+ test-unit (~> 2.5.5)
63
+ vcr (~> 2.5.0)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2011 Jared Mehle
1
+ Copyright (c) 2010-2013 Jared Mehle
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,5 +1,7 @@
1
1
  = songkickr
2
2
 
3
+ {<img src="https://travis-ci.org/jrmehle/songkickr.png?branch=master" alt="Build Status" />}[https://travis-ci.org/jrmehle/songkickr]
4
+
3
5
  A Ruby wrapper around the Songkick API. Visit www.songkick.com/developer for documentation on the Songkick API.
4
6
 
5
7
  = Install Instructions
@@ -15,15 +17,18 @@ or if your environment requires
15
17
  require 'songkickr'
16
18
  remote = Songkickr::Remote.new API_KEY
17
19
 
18
- Then call events, users_events(username), or concert_setlists(event_id)
20
+ Then call one of the remote methods such as events, users_events(username), or concert_setlists(event_id)
19
21
 
20
- results = remote.events(:query => 'Iron Maiden')
21
- results = remote.events(:query => 'As I Lay Dying')
22
+ Get an artists events by name:
23
+ results = remote.events('Iron Maiden')
22
24
 
25
+ Get a users events by username:
23
26
  results = remote.users_events('jrmehle')
24
27
 
28
+ Get a the setlists of a concert by event ID:
25
29
  results = remote.concert_setlists(2680726)
26
- results = remote.concert_setlists(2894471)
30
+
31
+ More: As of v0.4.0 songkickr supports all of Songkick's APIs. Check the RDocs for the Songkickr::RemoteApi classes.
27
32
 
28
33
 
29
34
  == Note on Patches/Pull Requests
@@ -32,17 +37,17 @@ Then call events, users_events(username), or concert_setlists(event_id)
32
37
  * Make your feature addition or bug fix.
33
38
  * Add tests for it. This is important so I don't break it in a
34
39
  future version unintentionally.
35
- * Commit, do not mess with rakefile, version, or history.
40
+ * Commit, do not mess with Rakefile, version, or history.
36
41
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
37
42
  * Send me a pull request. Bonus points for topic branches.
38
43
 
39
44
  == Copyright
40
45
 
41
- Copyright (c) 2010-2011 Jared Mehle. See LICENSE for details.
46
+ Copyright (c) 2010-2013 Jared Mehle. See LICENSE for details.
42
47
 
43
- == Thanks
48
+ == Contributors
44
49
 
45
- Thanks to Akshay Dodeja, Tomasz Stachewicz, and Dave Knapik for submitting code and pull requests.
50
+ Thanks to Andrew Chen, Akshay Dodeja, Tomasz Stachewicz, and Dave Knapik for submitting code and pull requests.
46
51
 
47
- A special thank you to Jon Nunemaker for the httparty which is used extensively within this
52
+ A special thank you to Jon Nunemaker for httparty which is used extensively within this
48
53
  gem and for the twitter gem as inspiration.
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
- require "rubygems"
2
- require "rake"
3
- require "bundler/gem_tasks"
1
+ require 'rake'
2
+ require 'bundler/gem_tasks'
4
3
 
5
4
  require 'rake/testtask'
6
5
  Rake::TestTask.new(:test) do |test|
@@ -13,7 +12,7 @@ task :default => :test
13
12
 
14
13
  require 'rdoc/task'
15
14
  Rake::RDocTask.new do |rdoc|
16
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
15
+ version = Songkickr::VERSION ? Songkickr::VERSION : ""
17
16
 
18
17
  rdoc.rdoc_dir = 'rdoc'
19
18
  rdoc.title = "songkickr #{version}"
@@ -10,15 +10,15 @@ module Songkickr
10
10
  #
11
11
  # http://www.songkick.com/developer/artist-search
12
12
  class Artist
13
- attr_accessor :uri, :display_name, :id, :on_tour_until
13
+ attr_accessor :uri, :display_name, :id, :on_tour_until, :identifier
14
14
 
15
15
  # Accepts a hash of artist attributes.
16
16
  def initialize(artist_hash = {})
17
- @uri = artist_hash["uri"]
18
17
  @display_name = artist_hash["displayName"]
19
18
  @id = artist_hash["id"]
20
19
  @uri = artist_hash["uri"]
21
20
  @on_tour_until = artist_hash["onTourUntil"]
21
+ @identifier = artist_hash["identifier"]
22
22
  end
23
23
  end
24
24
  end
@@ -1,32 +1,12 @@
1
1
  module Songkickr
2
2
  # A class to represent the result hash of an Artist search.
3
- class ArtistResult
4
- attr_accessor :page, :total_entries, :results
5
-
3
+ class ArtistResult < ResultSet
6
4
  # 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
5
  def initialize(result_hash = {})
8
- results_page = result_hash["resultsPage"]
9
-
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
16
-
17
- protected
6
+ @result_type = "Artist"
7
+ @result_key_string = "artist"
18
8
 
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
9
+ super
30
10
  end
31
11
  end
32
12
  end
@@ -0,0 +1,23 @@
1
+ module Songkickr
2
+ class CalendarEntry
3
+ attr_accessor :reason, :event, :created_at
4
+
5
+ def initialize(calendar_entry_hash = {})
6
+ @created_at = calendar_entry_hash['createdAt']
7
+ @event = Event.new calendar_entry_hash['event']
8
+ @reason = parse_reason(calendar_entry_hash['reason'])
9
+ end
10
+
11
+ protected
12
+
13
+ def parse_reason(entry_reason = {})
14
+ if entry_reason.include? 'trackedArtist'
15
+ # trackedArtist is an array of artists
16
+ entry_reason['trackedArtist'].map { |artist| Artist.new artist }
17
+ elsif entry_reason.include? 'attendance'
18
+ # attendance is a string i_might_go | im_going
19
+ entry_reason['attendance']
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ module Songkickr
2
+ class CalendarResult < ResultSet
3
+ def initialize(result_hash = {})
4
+ @result_type = "CalendarEntry"
5
+ @result_key_string = "calendarEntry"
6
+
7
+ super
8
+ end
9
+ end
10
+ end
@@ -2,35 +2,13 @@ module Songkickr
2
2
  # A class to represent the result hash of an Setlist search.
3
3
  #
4
4
  # http://www.songkick.com/developer/setlists
5
- class ConcertSetlistResult
6
- attr_accessor :results
7
-
5
+ class ConcertSetlistResult < ResultSet
8
6
  # Takes the result ash and passes it to parse_results
9
7
  def initialize(result_hash = {})
10
- if result_hash["resultsPage"]
11
- results_page = result_hash["resultsPage"]
12
-
13
- if results_page
14
- @results = parse_results results_page["results"]
15
- end
16
- else
17
- result_hash
18
- end
8
+ @result_type = "Setlist"
9
+ @result_key_string = "setlist"
10
+
11
+ super
19
12
  end
20
-
21
-
22
- protected
23
-
24
- # Parses the setlist items into an array of SetlistItems
25
- def parse_results(results = {})
26
- setlists = []
27
- if results.include?("setlist")
28
- results["setlist"].each do |setlist|
29
- setlists << Songkickr::Setlist.new(setlist)
30
- end
31
- end
32
-
33
- setlists
34
- end
35
13
  end
36
14
  end
@@ -37,9 +37,10 @@ module Songkickr
37
37
  #
38
38
  # http://www.songkick.com/developer/artist-search
39
39
  class Event
40
- attr_accessor :type, :display_name, :location, :start, :uri, :id, :lat, :lng, :performances, :status, :venue, :tickets_uri
41
-
40
+ attr_accessor :popularity, :type, :display_name, :location, :start, :uri, :id, :performances, :status, :venue, :tickets_uri
41
+
42
42
  def initialize(event_hash)
43
+ @popularity = event_hash["popularity"].to_f
43
44
  @type = event_hash["type"]
44
45
  @location = Songkickr::Location.new event_hash["location"]
45
46
  @status = event_hash["status"]
@@ -51,24 +52,17 @@ module Songkickr
51
52
  @id = event_hash["id"]
52
53
  @tickets_uri = event_hash["ticketsUri"]
53
54
  end
54
-
55
+
55
56
  protected
56
-
57
+
57
58
  # Takes the start hash and turns in into a DateTime object.
58
59
  def start_hash_to_datetime(start_hash)
59
60
  datetime = DateTime.parse("#{start_hash["date"]} #{start_hash["time"]}")
60
61
  end
61
-
62
+
62
63
  # Builds a list of Performance objects.
63
- def parse_performance(performance_array = nil)
64
- performances = []
65
- if performance_array
66
- performance_array.each do |performance|
67
- performances << Songkickr::Performance.new(performance)
68
- end
69
- end
70
-
71
- performances
64
+ def parse_performance(performances = [])
65
+ performances.map { |performance| Songkickr::Performance.new performance }
72
66
  end
73
67
  end
74
68
  end
@@ -1,31 +1,13 @@
1
1
  module Songkickr
2
2
  # A class to represent the result hash of an Event search.
3
- class EventResult
4
- attr_accessor :page, :total_entries, :results
3
+ class EventResult < ResultSet
5
4
 
6
5
  # 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
6
  def initialize(result_hash = {})
8
- results_page = result_hash["resultsPage"]
9
-
10
- if results_page
11
- @page = results_page["page"]
12
- @total_entries = results_page["totalEntries"]
13
- @results = parse_results results_page["results"]
14
- end
7
+ @result_type = "Event"
8
+ @result_key_string = "event"
9
+
10
+ super
15
11
  end
16
-
17
-
18
- protected
19
-
20
- def parse_results(results = {})
21
- events = []
22
- if results.include?("event")
23
- results["event"].each do |event|
24
- events << Songkickr::Event.new(event)
25
- end
26
- end
27
-
28
- events
29
- end
30
12
  end
31
13
  end
@@ -23,7 +23,7 @@ module Songkickr
23
23
  # http://www.songkick.com/developer/location-search
24
24
  class Location
25
25
  attr_accessor :city, :lat, :lng, :metro_area
26
-
26
+
27
27
  # Takes a location hash. Handles the different city hashes from Event and Location
28
28
  def initialize(location_hash)
29
29
  if location_hash["city"].is_a?(String) # location in Event
@@ -32,13 +32,13 @@ module Songkickr
32
32
  @lng = location_hash["lng"]
33
33
  elsif location_hash["city"].is_a?(Hash) # stand-alone Location
34
34
  city_hash = location_hash["city"]
35
- @city = city_hash["displayName"]
35
+ @city = city_hash["displayName"] if city_hash && city_hash["displayName"]
36
36
  # some locations have a null lng, lat in city hash, but have non-null in metroArea hash
37
37
  @lat = city_hash["lat"]
38
38
  @lng = city_hash["lng"]
39
39
  end
40
-
41
- @metro_area = location_hash['metroArea']
40
+
41
+ @metro_area = MetroArea.new location_hash['metroArea'] if location_hash.include? 'metroArea'
42
42
  end
43
43
  end
44
44
  end
@@ -1,36 +1,11 @@
1
1
  module Songkickr
2
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
5
- class LocationResult
6
- attr_accessor :page, :total_entries, :results
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.
3
+ class LocationResult < ResultSet
9
4
  def initialize(result_hash = {})
10
- results_page = result_hash["resultsPage"]
11
-
12
- if results_page
13
- @page = results_page["page"]
14
- @total_entries = results_page["totalEntries"]
15
- @results = parse_results results_page["results"]
16
- end
5
+ @result_type = "Location"
6
+ @result_key_string = "location"
7
+
8
+ super
17
9
  end
18
-
19
-
20
- protected
21
-
22
- # Take the results hash directly and parse the locations into Location objects.
23
- #
24
- # Returns an array of Locations.
25
- def parse_results(results = {})
26
- locations = []
27
- if results.include?("location")
28
- results["location"].each do |location|
29
- locations << Songkickr::Location.new(location)
30
- end
31
- end
32
-
33
- locations
34
- end
35
10
  end
36
11
  end
@@ -0,0 +1,28 @@
1
+ module Songkickr
2
+ # metroArea: {
3
+ # displayName: "Twin Cities",
4
+ # uri: "http://www.songkick.com/metro_areas/35130-us-twin-cities?utm_source=4791&utm_medium=partner",
5
+ # id: 35130,
6
+ # state: {
7
+ # displayName: "MN"
8
+ # },
9
+ # country: {
10
+ # displayName: "US"
11
+ # },
12
+ # lat: 44.9801,
13
+ # lng: -93.2519
14
+ # }
15
+ class MetroArea
16
+ attr_accessor :display_name, :uri, :id, :state, :country, :lat, :lng
17
+
18
+ def initialize(metro_area_hash)
19
+ @display_name = metro_area_hash["displayName"]
20
+ @id = metro_area_hash["id"]
21
+ @uri = metro_area_hash["uri"]
22
+ @state = metro_area_hash["state"]["displayName"] if metro_area_hash.include?("state") && metro_area_hash["state"].include?("displayName")
23
+ @country = metro_area_hash["country"]["displayName"] if metro_area_hash.include?("country") && metro_area_hash["country"].include?("displayName")
24
+ @lat = metro_area_hash["lat"] if metro_area_hash.include? "lat"
25
+ @lng = metro_area_hash["lng"] if metro_area_hash.include? "lng"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ module Songkickr
2
+ # A class to represent the result hash of a Metro Area search.
3
+ class MetroAreaResult < ResultSet
4
+ # 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
+ def initialize(result_hash = {})
6
+ @result_type = "MetroArea"
7
+ @result_key_string = "metroArea"
8
+
9
+ super
10
+ end
11
+ end
12
+ end
@@ -1,17 +1,22 @@
1
1
  module Songkickr
2
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
- # }
3
+ # {
4
+ # billingIndex: 2,
5
+ # billing: "headline",
6
+ # displayName: "A Day to Remember",
7
+ # artist: {
8
+ # identifier: [
9
+ # {
10
+ # href: "http://api.songkick.com/api/3.0/artists/mbid:db008806-16f6-48fc-8521-3d953709689d.json",
11
+ # mbid: "db008806-16f6-48fc-8521-3d953709689d"
12
+ # }
13
+ # ],
14
+ # displayName: "A Day to Remember",
15
+ # uri: "http://www.songkick.com/artists/470482-a-day-to-remember?utm_source=4791&utm_medium=partner",
16
+ # id: 470482
17
+ # },
18
+ # id: 34045929
19
+ # }
15
20
  class Performance
16
21
  attr_accessor :artist, :display_name, :id, :billing_index, :billing
17
22