songkick_ruby 1.0.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.textile ADDED
@@ -0,0 +1,94 @@
1
+ h1. Songkick ruby
2
+
3
+ songkick ruby is a gem for the "Songkick api":http://www.songkick.com/developer
4
+
5
+ h1. Installation
6
+
7
+ <pre>
8
+ <code>
9
+ gem install songkick_ruby
10
+ </code>
11
+ </pre>
12
+
13
+ h1. Usage
14
+
15
+ h2. First step
16
+
17
+ <pre>
18
+ <code>
19
+ client = Songkick.new("your songkick api key", :json)
20
+ # or
21
+ client = Songkick::Client.new("your songckick api key", :json)
22
+ </code>
23
+ </pre>
24
+
25
+
26
+ h2. Search
27
+
28
+ Search events.
29
+ More in,formation here: "http://www.songkick.com/developer/event-search":http://www.songkick.com/developer/event-search
30
+
31
+ <pre>
32
+ <code>
33
+ events = client.search_events(:artist_name => "lady gaga", :location => "clientip:84.102.219.109")
34
+ </code>
35
+ </pre>
36
+
37
+ Search locations.
38
+ More in,formation here: "http://www.songkick.com/developer/location-search":http://www.songkick.com/developer/location-search
39
+
40
+ <pre>
41
+ <code>
42
+ locations = client.search_locations(:query => "paris")
43
+ </code>
44
+ </pre>
45
+
46
+ Search artists.
47
+ More in,formation "here: http://www.songkick.com/developer/artist-search":here: http://www.songkick.com/developer/artist-search
48
+
49
+ <pre>
50
+ <code>
51
+ artists = client.search_locations("lady gaga")
52
+ </code>
53
+ </pre>
54
+
55
+
56
+ h2. Event
57
+
58
+ Find an event
59
+ More in,formation here: "http://www.songkick.com/developer/artist-search":http://www.songkick.com/developer/artist-search
60
+
61
+ <pre>
62
+ <code>
63
+ random_event = client.find_event(9969693)
64
+ </code>
65
+ </pre>
66
+
67
+ h2. Calendar
68
+
69
+ Get the calendar of an artist.
70
+ More information here: "http://www.songkick.com/developer/upcoming-events-for-artist":http://www.songkick.com/developer/upcoming-events-for-artist
71
+
72
+ <pre>
73
+ <code>
74
+ coldplay_calendar = client.artist_calendar(197928)
75
+ </code>
76
+ </pre>
77
+
78
+ Get the calendar of a location.
79
+ More information here: "http://www.songkick.com/developer/upcoming-events-for-metro-area":http://www.songkick.com/developer/upcoming-events-for-metro-area
80
+
81
+ <pre>
82
+ <code>
83
+ paris = client.artist_calendar(28909)
84
+ </code>
85
+ </pre>
86
+
87
+ Get the calendar of a user.
88
+ More information here: "http://www.songkick.com/developer/upcoming-events-for-user":http://www.songkick.com/developer/upcoming-events-for-user
89
+
90
+ <pre>
91
+ <code>
92
+ random_user = client.artist_calendar(847914)
93
+ </code>
94
+ </pre>
@@ -0,0 +1,19 @@
1
+ module Songkick
2
+ class Client
3
+ module Calendar
4
+
5
+ def artist_calendar(artist_id)
6
+ get "artists/#{artist_id}/calendar.#{format}"
7
+ end
8
+
9
+ def location_calendar(location_id)
10
+ get "metro_areas/#{location_id}/calendar.#{format}"
11
+ end
12
+
13
+ def user_calendar(username)
14
+ get "users/#{artist_id}/calendar.#{format}"
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module Songkick
2
+ class Client
3
+ module Event
4
+
5
+ def find_event(event_id)
6
+ get "events/#{event_id}.#{format}"
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ module Songkick
2
+ class Client
3
+ module Request
4
+
5
+ private
6
+
7
+ def get(url)
8
+ uri = API_URL + url
9
+ uri = URI.parse uri.include?("?") ? uri + "&apikey=#{api_key}" : uri + "?apikey=#{api_key}"
10
+
11
+ response = Net::HTTP.get_response(uri)
12
+ json? ? JSON.parse(response.body) : response.body
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ module Songkick
2
+ class Client
3
+ module Search
4
+
5
+ def search_events(opts)
6
+ _opts = opts.collect{|k, v| "#{k}=#{v.gsub(" ", "%20")}"}.join("&")
7
+ get "events.#{format}?#{_opts}"
8
+ end
9
+ alias_method :search_event, :search_events
10
+
11
+
12
+ def search_locations(opts)
13
+ _opts = opts.collect{|k, v| "#{k}=#{v.gsub(" ", "%20")}"}.join("&")
14
+ get "search/locations.#{format}?#{_opts}"
15
+ end
16
+ alias_method :search_location, :search_locations
17
+
18
+ def search_artists(text)
19
+ get "search/artists.#{format}?query=#{text.gsub(" ","%20")}"
20
+ end
21
+ alias_method :search_artist, :search_artists
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ require "songkick/client/calendar.rb"
2
+ require "songkick/client/event.rb"
3
+ require "songkick/client/request.rb"
4
+ require "songkick/client/search.rb"
5
+
6
+ module Songkick
7
+ class Client
8
+
9
+ API_URL = 'http://api.songkick.com/api/3.0/'
10
+
11
+ attr_accessor :api_key, :format
12
+
13
+ def initialize(api_key, format)
14
+ @api_key = api_key
15
+ @format = format
16
+ end
17
+
18
+ def format=(format)
19
+ @format = format.to_s
20
+ end
21
+
22
+ def json?
23
+ format == 'json'
24
+ end
25
+
26
+ def xml?
27
+ format == 'xml'
28
+ end
29
+
30
+ include Songkick::Client::Calendar
31
+ include Songkick::Client::Event
32
+ include Songkick::Client::Search
33
+ include Songkick::Client::Request
34
+
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module Songkick
2
+ VERSION = '1.0.0'
3
+ end
data/lib/songkick.rb ADDED
@@ -0,0 +1,16 @@
1
+ require "net/http"
2
+ require "rubygems"
3
+ require 'json'
4
+
5
+ require "songkick/version.rb"
6
+ require "songkick/client.rb"
7
+
8
+ module Songkick
9
+ class << self
10
+
11
+ def new(api_key, format)
12
+ Songkick::Client.new(api_key, format)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "songkick_ruby"
3
+ s.version = "1.0.0"
4
+ s.author = "Gregory Marcilhacy"
5
+ s.email = "g.marcilhacy@gmail.com"
6
+ s.homepage = "http://github.com/gregorym/songkick_ruby"
7
+ s.summary = "Ruby wrapper of the songkick api"
8
+
9
+ s.require_path = "lib"
10
+ s.files = %w(
11
+ README.textile
12
+ songkick_ruby.gemspec
13
+ lib/songkick.rb
14
+ lib/songkick
15
+ lib/songkick/version.rb
16
+ lib/songkick/client.rb
17
+ lib/songkick/client/calendar.rb
18
+ lib/songkick/client/event.rb
19
+ lib/songkick/client/search.rb
20
+ lib/songkick/client/request.rb
21
+ )
22
+
23
+ s.test_files = %w()
24
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: songkick_ruby
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Gregory Marcilhacy
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-12 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description:
23
+ email: g.marcilhacy@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - README.textile
32
+ - songkick_ruby.gemspec
33
+ - lib/songkick.rb
34
+ - lib/songkick/version.rb
35
+ - lib/songkick/client.rb
36
+ - lib/songkick/client/calendar.rb
37
+ - lib/songkick/client/event.rb
38
+ - lib/songkick/client/search.rb
39
+ - lib/songkick/client/request.rb
40
+ has_rdoc: true
41
+ homepage: http://github.com/gregorym/songkick_ruby
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.7
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Ruby wrapper of the songkick api
74
+ test_files: []
75
+