firstfm 0.1.2 → 0.2.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/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/LICENSE.txt +0 -0
- data/README.rdoc +0 -0
- data/Rakefile +0 -0
- data/VERSION.yml +3 -3
- data/firstfm.gemspec +8 -5
- data/lib/firstfm/artist.rb +11 -0
- data/lib/firstfm/event.rb +0 -0
- data/lib/firstfm/geo.rb +0 -0
- data/lib/firstfm/image.rb +40 -0
- data/lib/firstfm/location.rb +0 -0
- data/lib/firstfm/track.rb +0 -0
- data/lib/firstfm/venue.rb +0 -0
- data/lib/firstfm.rb +2 -0
- data/test/fixtures/artists.xml +0 -0
- data/test/fixtures/event.xml +0 -0
- data/test/fixtures/events.xml +0 -0
- data/test/fixtures/geo_event.xml +0 -0
- data/test/fixtures/geo_events.xml +0 -0
- data/test/fixtures/top_tracks.xml +0 -0
- data/test/fixtures/tracks.xml +0 -0
- data/test/fixtures/venue.xml +0 -0
- data/test/fixtures/venues.xml +0 -0
- data/test/helper.rb +0 -0
- data/test/test_artist.rb +0 -0
- data/test/test_geo.rb +0 -0
- data/test/test_track.rb +0 -0
- data/test/test_venue.rb +0 -0
- metadata +61 -26
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,6 +2,7 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
activesupport (3.0.9)
|
5
|
+
chronic (0.6.1)
|
5
6
|
crack (0.1.8)
|
6
7
|
fakeweb (1.3.0)
|
7
8
|
git (1.2.5)
|
@@ -21,6 +22,7 @@ PLATFORMS
|
|
21
22
|
DEPENDENCIES
|
22
23
|
activesupport (~> 3.0.7)
|
23
24
|
bundler (~> 1.0.0)
|
25
|
+
chronic
|
24
26
|
fakeweb
|
25
27
|
httparty
|
26
28
|
jeweler (~> 1.6.2)
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.rdoc
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/VERSION.yml
CHANGED
data/firstfm.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{firstfm}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aleksandr Lossenko"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-07-27}
|
13
13
|
s.description = %q{Firstfm is a ruby wrapper for the Last.fm APIs ( http://www.last.fm/api ). My main focus is to import events from Last.FM, but with time I will try to add support for all API methods.}
|
14
14
|
s.email = %q{aleksandr.lossenko@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/firstfm/artist.rb",
|
29
29
|
"lib/firstfm/event.rb",
|
30
30
|
"lib/firstfm/geo.rb",
|
31
|
+
"lib/firstfm/image.rb",
|
31
32
|
"lib/firstfm/location.rb",
|
32
33
|
"lib/firstfm/track.rb",
|
33
34
|
"lib/firstfm/venue.rb",
|
@@ -49,17 +50,17 @@ Gem::Specification.new do |s|
|
|
49
50
|
s.homepage = %q{http://github.com/egze/firstfm}
|
50
51
|
s.licenses = ["MIT"]
|
51
52
|
s.require_paths = ["lib"]
|
52
|
-
s.rubygems_version = %q{1.
|
53
|
+
s.rubygems_version = %q{1.6.2}
|
53
54
|
s.summary = %q{A ruby wrapper for the Last.fm APIs}
|
54
55
|
|
55
56
|
if s.respond_to? :specification_version then
|
56
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
57
57
|
s.specification_version = 3
|
58
58
|
|
59
|
-
if Gem::Version.new(Gem::
|
59
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
60
|
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
61
61
|
s.add_runtime_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
|
62
62
|
s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.7"])
|
63
|
+
s.add_runtime_dependency(%q<chronic>, [">= 0"])
|
63
64
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
65
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
65
66
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
@@ -68,6 +69,7 @@ Gem::Specification.new do |s|
|
|
68
69
|
s.add_dependency(%q<httparty>, [">= 0"])
|
69
70
|
s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
|
70
71
|
s.add_dependency(%q<activesupport>, ["~> 3.0.7"])
|
72
|
+
s.add_dependency(%q<chronic>, [">= 0"])
|
71
73
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
72
74
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
73
75
|
s.add_dependency(%q<rcov>, [">= 0"])
|
@@ -77,6 +79,7 @@ Gem::Specification.new do |s|
|
|
77
79
|
s.add_dependency(%q<httparty>, [">= 0"])
|
78
80
|
s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
|
79
81
|
s.add_dependency(%q<activesupport>, ["~> 3.0.7"])
|
82
|
+
s.add_dependency(%q<chronic>, [">= 0"])
|
80
83
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
81
84
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
82
85
|
s.add_dependency(%q<rcov>, [">= 0"])
|
data/lib/firstfm/artist.rb
CHANGED
@@ -12,6 +12,17 @@ module Firstfm
|
|
12
12
|
@name = params[:name]
|
13
13
|
end
|
14
14
|
|
15
|
+
def get_images(page = 1, limit = 50)
|
16
|
+
name_params = self.mbid.empty? ? {:artist => self.name} : {:mbid => self.mbid}
|
17
|
+
response = self.class.get("/2.0/", {:query => {:method => 'artist.getImages', :page => page, :limit => limit, :api_key => Firstfm::CONFIG['api_key']}.merge(name_params)})
|
18
|
+
images_array = (response["lfm"] and response["lfm"]["images"] and response["lfm"]["images"]["image"]) || []
|
19
|
+
images = Image.init_from_array(images_array)
|
20
|
+
WillPaginate::Collection.create(page, limit) do |pager|
|
21
|
+
pager.replace images
|
22
|
+
pager.total_entries = response["lfm"]["images"]["total"].to_i rescue 0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
15
26
|
def self.search(artist, page = 1, limit = 50)
|
16
27
|
response = get("/2.0/", {:query => {:method => 'artist.search', :artist => artist, :page => page, :limit => limit, :api_key => Firstfm::CONFIG['api_key']}})
|
17
28
|
artists_array = (response and response["lfm"] and response["lfm"]["results"] and response["lfm"]["results"]["artistmatches"] and response["lfm"]["results"]["artistmatches"]["artist"]) || []
|
data/lib/firstfm/event.rb
CHANGED
File without changes
|
data/lib/firstfm/geo.rb
CHANGED
File without changes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Firstfm
|
2
|
+
|
3
|
+
class Image
|
4
|
+
|
5
|
+
attr_accessor :title, :url, :dateadded, :format, :owner_name, :owner_url, :sizes, :thumbsup, :thumbsdown, :artist
|
6
|
+
|
7
|
+
include HTTParty
|
8
|
+
base_uri 'ws.audioscrobbler.com'
|
9
|
+
format :xml
|
10
|
+
|
11
|
+
def self.init_from_array(array)
|
12
|
+
return [] unless array.is_a?(Array)
|
13
|
+
array.inject([]) do |arr, image|
|
14
|
+
arr << init_from_hash(image)
|
15
|
+
arr
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.init_from_hash(hash)
|
20
|
+
return nil unless hash.is_a?(Hash)
|
21
|
+
Image.new.tap do |image|
|
22
|
+
image.title = hash["title"]
|
23
|
+
image.url = hash["url"]
|
24
|
+
image.dateadded = Chronic.parse(hash["dateadded"])
|
25
|
+
image.format = hash["format"]
|
26
|
+
image.sizes = hash["sizes"]["size"]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def original
|
31
|
+
self.sizes.detect {|s| s.attributes["name"] == "original"}
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_width(width)
|
35
|
+
self.sizes.detect {|s| s.attributes["width"].to_i >= width}
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/firstfm/location.rb
CHANGED
File without changes
|
data/lib/firstfm/track.rb
CHANGED
File without changes
|
data/lib/firstfm/venue.rb
CHANGED
File without changes
|
data/lib/firstfm.rb
CHANGED
data/test/fixtures/artists.xml
CHANGED
File without changes
|
data/test/fixtures/event.xml
CHANGED
File without changes
|
data/test/fixtures/events.xml
CHANGED
File without changes
|
data/test/fixtures/geo_event.xml
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/test/fixtures/tracks.xml
CHANGED
File without changes
|
data/test/fixtures/venue.xml
CHANGED
File without changes
|
data/test/fixtures/venues.xml
CHANGED
File without changes
|
data/test/helper.rb
CHANGED
File without changes
|
data/test/test_artist.rb
CHANGED
File without changes
|
data/test/test_geo.rb
CHANGED
File without changes
|
data/test/test_track.rb
CHANGED
File without changes
|
data/test/test_venue.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firstfm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
- 1
|
8
8
|
- 2
|
9
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Aleksandr Lossenko
|
@@ -14,101 +15,130 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-07-27 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
prerelease: false
|
22
22
|
type: :runtime
|
23
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
27
29
|
segments:
|
28
30
|
- 0
|
29
31
|
version: "0"
|
30
|
-
requirement: *id001
|
31
32
|
name: httparty
|
32
|
-
|
33
|
+
version_requirements: *id001
|
33
34
|
prerelease: false
|
35
|
+
- !ruby/object:Gem::Dependency
|
34
36
|
type: :runtime
|
35
|
-
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
36
39
|
requirements:
|
37
40
|
- - ~>
|
38
41
|
- !ruby/object:Gem::Version
|
42
|
+
hash: 1923831917
|
39
43
|
segments:
|
40
44
|
- 3
|
41
45
|
- 0
|
42
|
-
-
|
46
|
+
- pre
|
47
|
+
- 2
|
43
48
|
version: 3.0.pre2
|
44
|
-
requirement: *id002
|
45
49
|
name: will_paginate
|
46
|
-
|
50
|
+
version_requirements: *id002
|
47
51
|
prerelease: false
|
52
|
+
- !ruby/object:Gem::Dependency
|
48
53
|
type: :runtime
|
49
|
-
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
57
|
- - ~>
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 9
|
53
60
|
segments:
|
54
61
|
- 3
|
55
62
|
- 0
|
56
63
|
- 7
|
57
64
|
version: 3.0.7
|
58
|
-
requirement: *id003
|
59
65
|
name: activesupport
|
66
|
+
version_requirements: *id003
|
67
|
+
prerelease: false
|
60
68
|
- !ruby/object:Gem::Dependency
|
69
|
+
type: :runtime
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
name: chronic
|
80
|
+
version_requirements: *id004
|
61
81
|
prerelease: false
|
82
|
+
- !ruby/object:Gem::Dependency
|
62
83
|
type: :development
|
63
|
-
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
64
86
|
requirements:
|
65
87
|
- - ~>
|
66
88
|
- !ruby/object:Gem::Version
|
89
|
+
hash: 23
|
67
90
|
segments:
|
68
91
|
- 1
|
69
92
|
- 0
|
70
93
|
- 0
|
71
94
|
version: 1.0.0
|
72
|
-
requirement: *id004
|
73
95
|
name: bundler
|
74
|
-
|
96
|
+
version_requirements: *id005
|
75
97
|
prerelease: false
|
98
|
+
- !ruby/object:Gem::Dependency
|
76
99
|
type: :development
|
77
|
-
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
78
102
|
requirements:
|
79
103
|
- - ~>
|
80
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 11
|
81
106
|
segments:
|
82
107
|
- 1
|
83
108
|
- 6
|
84
109
|
- 2
|
85
110
|
version: 1.6.2
|
86
|
-
requirement: *id005
|
87
111
|
name: jeweler
|
88
|
-
|
112
|
+
version_requirements: *id006
|
89
113
|
prerelease: false
|
114
|
+
- !ruby/object:Gem::Dependency
|
90
115
|
type: :development
|
91
|
-
|
116
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
92
118
|
requirements:
|
93
119
|
- - ">="
|
94
120
|
- !ruby/object:Gem::Version
|
121
|
+
hash: 3
|
95
122
|
segments:
|
96
123
|
- 0
|
97
124
|
version: "0"
|
98
|
-
requirement: *id006
|
99
125
|
name: rcov
|
100
|
-
|
126
|
+
version_requirements: *id007
|
101
127
|
prerelease: false
|
128
|
+
- !ruby/object:Gem::Dependency
|
102
129
|
type: :development
|
103
|
-
|
130
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
104
132
|
requirements:
|
105
133
|
- - ">="
|
106
134
|
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
107
136
|
segments:
|
108
137
|
- 0
|
109
138
|
version: "0"
|
110
|
-
requirement: *id007
|
111
139
|
name: fakeweb
|
140
|
+
version_requirements: *id008
|
141
|
+
prerelease: false
|
112
142
|
description: Firstfm is a ruby wrapper for the Last.fm APIs ( http://www.last.fm/api ). My main focus is to import events from Last.FM, but with time I will try to add support for all API methods.
|
113
143
|
email: aleksandr.lossenko@gmail.com
|
114
144
|
executables: []
|
@@ -130,6 +160,7 @@ files:
|
|
130
160
|
- lib/firstfm/artist.rb
|
131
161
|
- lib/firstfm/event.rb
|
132
162
|
- lib/firstfm/geo.rb
|
163
|
+
- lib/firstfm/image.rb
|
133
164
|
- lib/firstfm/location.rb
|
134
165
|
- lib/firstfm/track.rb
|
135
166
|
- lib/firstfm/venue.rb
|
@@ -157,23 +188,27 @@ rdoc_options: []
|
|
157
188
|
require_paths:
|
158
189
|
- lib
|
159
190
|
required_ruby_version: !ruby/object:Gem::Requirement
|
191
|
+
none: false
|
160
192
|
requirements:
|
161
193
|
- - ">="
|
162
194
|
- !ruby/object:Gem::Version
|
195
|
+
hash: 3
|
163
196
|
segments:
|
164
197
|
- 0
|
165
198
|
version: "0"
|
166
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
|
+
none: false
|
167
201
|
requirements:
|
168
202
|
- - ">="
|
169
203
|
- !ruby/object:Gem::Version
|
204
|
+
hash: 3
|
170
205
|
segments:
|
171
206
|
- 0
|
172
207
|
version: "0"
|
173
208
|
requirements: []
|
174
209
|
|
175
210
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.
|
211
|
+
rubygems_version: 1.6.2
|
177
212
|
signing_key:
|
178
213
|
specification_version: 3
|
179
214
|
summary: A ruby wrapper for the Last.fm APIs
|