songkickr 0.3.3 → 0.4.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.
- checksums.yaml +7 -0
- data/.bundle/config +2 -0
- data/.gitignore +1 -0
- data/.travis.yml +8 -0
- data/Gemfile.lock +42 -22
- data/LICENSE +1 -1
- data/README.rdoc +14 -9
- data/Rakefile +3 -4
- data/lib/songkickr/artist.rb +2 -2
- data/lib/songkickr/artist_result.rb +4 -24
- data/lib/songkickr/calendar_entry.rb +23 -0
- data/lib/songkickr/calendar_result.rb +10 -0
- data/lib/songkickr/concert_setlist_result.rb +5 -27
- data/lib/songkickr/event.rb +8 -14
- data/lib/songkickr/event_result.rb +5 -23
- data/lib/songkickr/location.rb +4 -4
- data/lib/songkickr/location_result.rb +5 -30
- data/lib/songkickr/metro_area.rb +28 -0
- data/lib/songkickr/metro_area_result.rb +12 -0
- data/lib/songkickr/performance.rb +17 -12
- data/lib/songkickr/remote.rb +18 -198
- data/lib/songkickr/remote_api/artist_details.rb +17 -0
- data/lib/songkickr/remote_api/event_details.rb +17 -0
- data/lib/songkickr/remote_api/past_events.rb +48 -0
- data/lib/songkickr/remote_api/similar_artists.rb +14 -0
- data/lib/songkickr/remote_api/upcoming_events.rb +125 -0
- data/lib/songkickr/remote_api/user_events_and_trackings.rb +143 -0
- data/lib/songkickr/remote_api/venue_details.rb +16 -0
- data/lib/songkickr/result_set.rb +27 -0
- data/lib/songkickr/setlist.rb +7 -12
- data/lib/songkickr/setlist_item.rb +1 -1
- data/lib/songkickr/tracking.rb +18 -0
- data/lib/songkickr/tracking_result.rb +24 -0
- data/lib/songkickr/venue.rb +10 -2
- data/lib/songkickr/venue_result.rb +32 -0
- data/lib/songkickr/version.rb +1 -1
- data/lib/songkickr.rb +24 -17
- data/songkickr.gemspec +17 -44
- data/test/fixtures/event_7391451.json +732 -1
- data/test/fixtures/location_search.json +38 -0
- data/test/fixtures/metro_area.json +11 -0
- data/test/fixtures/users_attendance_calendar.json +243 -0
- data/test/fixtures/vcr/artist_events.yml +1394 -0
- data/test/fixtures/vcr/artist_search.yml +38 -0
- data/test/fixtures/vcr/artists_gigography.yml +187 -0
- data/test/fixtures/vcr/concert_setlists.yml +47 -0
- data/test/fixtures/vcr/event_search.yml +110 -0
- data/test/fixtures/vcr/invalid_api_key.yml +6 -36
- data/test/fixtures/vcr/invalid_artist_id.yml +6 -6
- data/test/fixtures/vcr/invalid_event_id.yml +6 -6
- data/test/fixtures/vcr/invalid_user.yml +6 -6
- data/test/fixtures/vcr/invalid_venue_id.yml +6 -6
- data/test/fixtures/vcr/location_search.yml +42 -0
- data/test/fixtures/vcr/metro_areas_events.yml +1535 -0
- data/test/fixtures/vcr/similar_artists.yml +64 -0
- data/test/fixtures/vcr/users_artist_tracking.yml +99 -0
- data/test/fixtures/vcr/users_attendance.yml +66 -0
- data/test/fixtures/vcr/users_attendance_calendar.yml +51 -0
- data/test/fixtures/vcr/users_events.yml +809 -0
- data/test/fixtures/vcr/users_gigography.yml +2782 -0
- data/test/fixtures/vcr/users_metro_area_tracking.yml +66 -0
- data/test/fixtures/vcr/users_muted_artists.yml +66 -0
- data/test/fixtures/vcr/users_tracked_artists.yml +75 -0
- data/test/fixtures/vcr/users_tracked_events_calendar.yml +1901 -0
- data/test/fixtures/vcr/users_tracked_metro_areas.yml +37 -0
- data/test/fixtures/vcr/valid_artist.yml +9 -9
- data/test/fixtures/vcr/valid_event.yml +103 -38
- data/test/fixtures/vcr/valid_user.yml +634 -44
- data/test/fixtures/vcr/valid_venue.yml +25 -26
- data/test/fixtures/vcr/venue_calendar.yml +500 -0
- data/test/fixtures/vcr/venue_search.yml +42 -0
- data/test/helper.rb +1 -27
- data/test/songkickr/test_calendar_entry.rb +15 -0
- data/test/songkickr/test_event.rb +8 -9
- data/test/songkickr/test_location.rb +11 -11
- data/test/songkickr/test_metro_area.rb +17 -0
- data/test/songkickr/test_remote.rb +149 -3
- data/test/songkickr/test_setlist_item.rb +20 -0
- data/test/songkickr/test_venue.rb +1 -2
- data/test.rb +3 -5
- metadata +120 -152
- data/bin/autospec +0 -16
- data/bin/convert_to_should_syntax +0 -16
- data/bin/guard +0 -16
- data/bin/htmldiff +0 -16
- data/bin/httparty +0 -16
- data/bin/jeweler +0 -16
- data/bin/ldiff +0 -16
- data/bin/rake +0 -16
- data/bin/rake2thor +0 -16
- data/bin/rg +0 -16
- data/bin/ri +0 -16
- data/bin/rspec +0 -16
- data/bin/thor +0 -16
- data/doc/APIError.html +0 -241
- data/doc/APIKeyNotSet.html +0 -203
- data/doc/LICENSE.html +0 -133
- data/doc/README_rdoc.html +0 -173
- data/doc/ResourceNotFound.html +0 -203
- data/doc/Songkickr/Artist.html +0 -278
- data/doc/Songkickr/ArtistResult.html +0 -308
- data/doc/Songkickr/ConcertSetlistResult.html +0 -283
- data/doc/Songkickr/Event.html +0 -491
- data/doc/Songkickr/EventResult.html +0 -306
- data/doc/Songkickr/Location.html +0 -299
- data/doc/Songkickr/LocationResult.html +0 -309
- data/doc/Songkickr/Performance.html +0 -295
- data/doc/Songkickr/Remote.html +0 -864
- data/doc/Songkickr/Setlist.html +0 -360
- data/doc/Songkickr/SetlistItem.html +0 -244
- data/doc/Songkickr/Venue.html +0 -265
- data/doc/Songkickr.html +0 -261
- data/doc/created.rid +0 -16
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -110
- data/doc/js/darkfish.js +0 -153
- data/doc/js/jquery.js +0 -18
- data/doc/js/navigation.js +0 -142
- data/doc/js/quicksearch.js +0 -114
- data/doc/js/search.js +0 -94
- data/doc/js/search_index.js +0 -1
- data/doc/js/searcher.js +0 -228
- data/doc/js/thickbox-compressed.js +0 -10
- data/doc/lib/songkickr/artist_rb.html +0 -52
- data/doc/lib/songkickr/artist_result_rb.html +0 -52
- data/doc/lib/songkickr/concert_setlist_result_rb.html +0 -52
- data/doc/lib/songkickr/event_rb.html +0 -52
- data/doc/lib/songkickr/event_result_rb.html +0 -52
- data/doc/lib/songkickr/location_rb.html +0 -52
- data/doc/lib/songkickr/location_result_rb.html +0 -52
- data/doc/lib/songkickr/performance_rb.html +0 -52
- data/doc/lib/songkickr/remote_rb.html +0 -52
- data/doc/lib/songkickr/setlist_item_rb.html +0 -52
- data/doc/lib/songkickr/setlist_rb.html +0 -52
- data/doc/lib/songkickr/venue_rb.html +0 -52
- data/doc/lib/songkickr_rb.html +0 -56
- data/doc/rdoc.css +0 -543
- data/doc/table_of_contents.html +0 -185
- 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
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
|
@@ -1,32 +1,52 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
songkickr (0.
|
|
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 (
|
|
10
|
-
i18n (~> 0.6)
|
|
11
|
-
|
|
12
|
-
|
|
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.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
38
|
-
rake
|
|
39
|
-
|
|
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
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
|
-
|
|
21
|
-
results = remote.events(
|
|
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
|
-
|
|
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
|
|
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-
|
|
46
|
+
Copyright (c) 2010-2013 Jared Mehle. See LICENSE for details.
|
|
42
47
|
|
|
43
|
-
==
|
|
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
|
|
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
|
|
2
|
-
require
|
|
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 =
|
|
15
|
+
version = Songkickr::VERSION ? Songkickr::VERSION : ""
|
|
17
16
|
|
|
18
17
|
rdoc.rdoc_dir = 'rdoc'
|
|
19
18
|
rdoc.title = "songkickr #{version}"
|
data/lib/songkickr/artist.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
data/lib/songkickr/event.rb
CHANGED
|
@@ -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, :
|
|
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(
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
data/lib/songkickr/location.rb
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
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
|
|