resthome 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/examples/last_fm_web_service.rb +35 -0
- data/lib/resthome.rb +3 -3
- data/resthome.gemspec +3 -1
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.4
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'resthome'
|
2
|
+
|
3
|
+
class LastFmWebService < RESTHome
|
4
|
+
route :find_albums, '/2.0/', :query => {'method' => 'library.getalbums'}, :resource => 'albums'
|
5
|
+
# find_albums_by_user
|
6
|
+
|
7
|
+
route :find_neighbors, '/2.0/', :query => {'method' => 'user.getneighbours'} do |res|
|
8
|
+
res['neighbours']['user']
|
9
|
+
end
|
10
|
+
# find_neighbors_by_user
|
11
|
+
|
12
|
+
route :find_top_tracks, '/2.0/', :query => {'method' => 'user.gettoptracks'} do |res|
|
13
|
+
res['track']['track']
|
14
|
+
end
|
15
|
+
# find_top_tracks_by_user
|
16
|
+
|
17
|
+
route :find_track, '/2.0/', :query => {'method' => 'track.getinfo'}, :resource => 'track'
|
18
|
+
# find_track_by_artist_and_track
|
19
|
+
|
20
|
+
route :find_top_albums, '/2.0/', :query => {'method' => 'user.gettopalbums'} do |res|
|
21
|
+
res['topalbums']['album']
|
22
|
+
end
|
23
|
+
# find_top_albums_by_user
|
24
|
+
|
25
|
+
def initialize(api_key)
|
26
|
+
@api_key = api_key
|
27
|
+
self.base_uri = "http://ws.audioscrobbler.com"
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_options!(options)
|
31
|
+
options[:query] ||= {}
|
32
|
+
options[:query]['format'] = 'json'
|
33
|
+
options[:query]['api_key'] = @api_key
|
34
|
+
end
|
35
|
+
end
|
data/lib/resthome.rb
CHANGED
@@ -226,7 +226,7 @@ class RESTHome
|
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
229
|
-
def method_missing(method, *args) #:nodoc:
|
229
|
+
def method_missing(method, *args, &block) #:nodoc:
|
230
230
|
if method.to_s =~ /^find_(.*?)_by_(.*)$/
|
231
231
|
find_method = "find_#{$1}"
|
232
232
|
find_args = $2.split '_and_'
|
@@ -241,9 +241,9 @@ class RESTHome
|
|
241
241
|
if start > 0
|
242
242
|
send_args = args[0..(start-1)]
|
243
243
|
send_args << options
|
244
|
-
return self.send(find_method, *send_args)
|
244
|
+
return self.send(find_method, *send_args, &block)
|
245
245
|
else
|
246
|
-
return self.send(find_method, options)
|
246
|
+
return self.send(find_method, options, &block)
|
247
247
|
end
|
248
248
|
else
|
249
249
|
super
|
data/resthome.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{resthome}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Doug Youch"]
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
27
|
"examples/chargify_web_service.rb",
|
28
|
+
"examples/last_fm_web_service.rb",
|
28
29
|
"examples/wordpress_web_service.rb",
|
29
30
|
"lib/resthome.rb",
|
30
31
|
"resthome.gemspec",
|
@@ -39,6 +40,7 @@ Gem::Specification.new do |s|
|
|
39
40
|
s.summary = %q{RESTful web services consumer}
|
40
41
|
s.test_files = [
|
41
42
|
"examples/chargify_web_service.rb",
|
43
|
+
"examples/last_fm_web_service.rb",
|
42
44
|
"examples/wordpress_web_service.rb",
|
43
45
|
"spec/helper.rb",
|
44
46
|
"spec/lib/resthome_spec.rb"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resthome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 4
|
10
|
+
version: 0.6.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Doug Youch
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- Rakefile
|
139
139
|
- VERSION
|
140
140
|
- examples/chargify_web_service.rb
|
141
|
+
- examples/last_fm_web_service.rb
|
141
142
|
- examples/wordpress_web_service.rb
|
142
143
|
- lib/resthome.rb
|
143
144
|
- resthome.gemspec
|
@@ -180,6 +181,7 @@ specification_version: 3
|
|
180
181
|
summary: RESTful web services consumer
|
181
182
|
test_files:
|
182
183
|
- examples/chargify_web_service.rb
|
184
|
+
- examples/last_fm_web_service.rb
|
183
185
|
- examples/wordpress_web_service.rb
|
184
186
|
- spec/helper.rb
|
185
187
|
- spec/lib/resthome_spec.rb
|