songkicky 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/lib/artist.rb +12 -0
- data/lib/event.rb +18 -1
- data/lib/festival.rb +9 -0
- data/lib/json_api.rb +1 -1
- data/lib/songkicky.rb +5 -0
- data/lib/user.rb +26 -0
- data/lib/venue.rb +10 -0
- metadata +8 -6
- data/songkicky.gemspec +0 -52
data/Rakefile
CHANGED
@@ -11,6 +11,8 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/saleandro/songkicky"
|
12
12
|
gem.authors = ["Sabrina Leandro"]
|
13
13
|
gem.add_development_dependency "json", ">= 0"
|
14
|
+
gem.files = [".document", ".gitignore","LICENSE", "Rakefile", "VERSION",'lib/**/*.rb']
|
15
|
+
|
14
16
|
end
|
15
17
|
Jeweler::GemcutterTasks.new
|
16
18
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.1
|
data/lib/artist.rb
CHANGED
@@ -4,10 +4,22 @@ module Songkicky
|
|
4
4
|
class Artist
|
5
5
|
include JsonApi
|
6
6
|
|
7
|
+
attr_accessor :name, :mbid
|
8
|
+
|
7
9
|
class << self
|
8
10
|
def find_by_mbid(mbid)
|
11
|
+
raise Error.new("MusicBrainz id is blank") if mbid.nil? || mbid.strip == ''
|
12
|
+
|
9
13
|
Artist.new(mbid)
|
10
14
|
end
|
15
|
+
|
16
|
+
def find_by_name(name)
|
17
|
+
raise Error.new("Name is blank") if name.nil? || name.strip == ''
|
18
|
+
|
19
|
+
a = Artist.new(nil)
|
20
|
+
a.name = name
|
21
|
+
a
|
22
|
+
end
|
11
23
|
end
|
12
24
|
|
13
25
|
def initialize(mbid)
|
data/lib/event.rb
CHANGED
@@ -7,16 +7,33 @@ module Songkicky
|
|
7
7
|
attr_accessor :id,
|
8
8
|
:name,
|
9
9
|
:date,
|
10
|
+
:popularity,
|
11
|
+
:venue,
|
10
12
|
:lat, :lng,
|
11
|
-
:metro_area
|
13
|
+
:metro_area,
|
14
|
+
:headliners,
|
15
|
+
:festival,
|
16
|
+
:type
|
12
17
|
|
13
18
|
def initialize(hash)
|
14
19
|
@id = hash['id']
|
20
|
+
@type = hash['type']
|
21
|
+
|
22
|
+
@festival = Festival.new(hash['series']) if @type.downcase == 'festival'
|
23
|
+
|
15
24
|
@name = hash['displayName']
|
25
|
+
|
26
|
+
@popularity = hash['popularity']
|
27
|
+
|
16
28
|
@date = Date.strptime(hash['start']['date'], '%Y-%m-%d')
|
29
|
+
|
17
30
|
@lat = hash['location']['lat']
|
18
31
|
@lng = hash['location']['lng']
|
32
|
+
@venue = Venue.new(hash['venue'])
|
19
33
|
@metro_area = MetroArea.new(hash['venue']['metroArea'])
|
34
|
+
|
35
|
+
headlines = hash['performance'].select {|p| p['billing'] == 'headline'}
|
36
|
+
@headliners = headlines.map {|p| Artist.find_by_name(p['artist']['displayName'])}
|
20
37
|
end
|
21
38
|
end
|
22
39
|
end
|
data/lib/festival.rb
ADDED
data/lib/json_api.rb
CHANGED
@@ -34,7 +34,7 @@ module Songkicky
|
|
34
34
|
rescue OpenURI::HTTPError => e
|
35
35
|
case e.message
|
36
36
|
when /403/
|
37
|
-
raise "Are you sure you set your Songkicky.apikey correctly? It's set to: '#{Songkicky.apikey}'"
|
37
|
+
raise Songkicky::Error.new("Are you sure you set your Songkicky.apikey correctly? It's set to: '#{Songkicky.apikey}'")
|
38
38
|
else
|
39
39
|
raise e
|
40
40
|
end
|
data/lib/songkicky.rb
CHANGED
@@ -3,11 +3,16 @@ $:.unshift(File.dirname(__FILE__))
|
|
3
3
|
require 'artist'
|
4
4
|
require 'event'
|
5
5
|
require 'metro_area'
|
6
|
+
require 'user'
|
7
|
+
require 'venue'
|
8
|
+
require 'festival'
|
6
9
|
|
7
10
|
module Songkicky
|
8
11
|
class << self
|
9
12
|
attr_accessor :apikey
|
10
13
|
end
|
14
|
+
|
15
|
+
class Error < StandardError; end
|
11
16
|
end
|
12
17
|
|
13
18
|
|
data/lib/user.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'json_api'
|
2
|
+
|
3
|
+
module Songkicky
|
4
|
+
class User
|
5
|
+
include JsonApi
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def find_by_username(username)
|
9
|
+
raise Error.new("Username is blank") if username.nil? || username.strip == ''
|
10
|
+
User.new(username)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(username)
|
15
|
+
@username = username
|
16
|
+
@past_events = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def past_events
|
20
|
+
return @past_events if @past_events
|
21
|
+
|
22
|
+
events_hash = all("users/#{@username}/gigography.json", 'event')
|
23
|
+
@past_events = events_hash.map {|hash| Event.new(hash) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/venue.rb
ADDED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: songkicky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sabrina Leandro
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-04 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -45,15 +45,17 @@ files:
|
|
45
45
|
- .document
|
46
46
|
- .gitignore
|
47
47
|
- LICENSE
|
48
|
-
- README
|
49
48
|
- Rakefile
|
50
49
|
- VERSION
|
51
50
|
- lib/artist.rb
|
52
51
|
- lib/event.rb
|
52
|
+
- lib/festival.rb
|
53
53
|
- lib/json_api.rb
|
54
54
|
- lib/metro_area.rb
|
55
55
|
- lib/songkicky.rb
|
56
|
-
-
|
56
|
+
- lib/user.rb
|
57
|
+
- lib/venue.rb
|
58
|
+
- README
|
57
59
|
has_rdoc: true
|
58
60
|
homepage: http://github.com/saleandro/songkicky
|
59
61
|
licenses: []
|
data/songkicky.gemspec
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{songkicky}
|
8
|
-
s.version = "0.0.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Sabrina Leandro"]
|
12
|
-
s.date = %q{2010-08-31}
|
13
|
-
s.description = %q{Very simple Ruby wrapper for Songkick's API. (http://developer.songkick.com/)}
|
14
|
-
s.email = %q{saleandro@yahoo.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/artist.rb",
|
27
|
-
"lib/event.rb",
|
28
|
-
"lib/json_api.rb",
|
29
|
-
"lib/metro_area.rb",
|
30
|
-
"lib/songkicky.rb",
|
31
|
-
"songkicky.gemspec"
|
32
|
-
]
|
33
|
-
s.homepage = %q{http://github.com/saleandro/songkicky}
|
34
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
-
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = %q{1.3.7}
|
37
|
-
s.summary = %q{Wrapper for Songkick's API.}
|
38
|
-
|
39
|
-
if s.respond_to? :specification_version then
|
40
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
-
s.specification_version = 3
|
42
|
-
|
43
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
-
s.add_development_dependency(%q<json>, [">= 0"])
|
45
|
-
else
|
46
|
-
s.add_dependency(%q<json>, [">= 0"])
|
47
|
-
end
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<json>, [">= 0"])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|