flickraw 0.4.5 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/flickraw.rb +14 -14
- data/rakefile +2 -1
- metadata +45 -44
data/lib/flickraw.rb
CHANGED
@@ -22,11 +22,11 @@
|
|
22
22
|
|
23
23
|
require 'net/http'
|
24
24
|
require 'md5'
|
25
|
-
require '
|
25
|
+
require 'json'
|
26
26
|
require 'cgi'
|
27
27
|
|
28
28
|
module FlickRaw
|
29
|
-
VERSION='0.
|
29
|
+
VERSION='0.5'
|
30
30
|
|
31
31
|
FLICKR_HOST='api.flickr.com'.freeze
|
32
32
|
|
@@ -58,15 +58,12 @@ module FlickRaw
|
|
58
58
|
def self.structify(obj, name = '')
|
59
59
|
if obj.is_a? Hash
|
60
60
|
if name =~ /s$/ and obj[$`].is_a? Array
|
61
|
-
list = structify obj
|
61
|
+
list = structify obj.delete($`)
|
62
62
|
list.extend SimpleOStruct
|
63
63
|
list.instance_eval { obj.each {|kv, vv| __attr_define kv, vv } }
|
64
64
|
list
|
65
|
-
elsif obj['_content']
|
66
|
-
|
67
|
-
content.extend SimpleOStruct
|
68
|
-
content.instance_eval { obj.each {|kv, vv| __attr_define kv, vv } }
|
69
|
-
content
|
65
|
+
elsif obj.keys == ['_content']
|
66
|
+
obj['_content'].to_s
|
70
67
|
else
|
71
68
|
Response.new obj
|
72
69
|
end
|
@@ -76,6 +73,8 @@ module FlickRaw
|
|
76
73
|
obj
|
77
74
|
end
|
78
75
|
end
|
76
|
+
|
77
|
+
def to_s; @_content || super end
|
79
78
|
end
|
80
79
|
|
81
80
|
class FailedResponse < StandardError
|
@@ -183,16 +182,16 @@ module FlickRaw
|
|
183
182
|
code = xml[/code="([^"]+)"/, 1]
|
184
183
|
raise FailedResponse.new(msg, code, 'flickr.upload')
|
185
184
|
end
|
186
|
-
Response.structify( {:stat => 'ok', :photoid => xml[/<photoid>(\w+)<\/photoid>/, 1], :ticketid => xml[/<ticketid>(
|
185
|
+
Response.structify( {:stat => 'ok', :photoid => xml[/<photoid>(\w+)<\/photoid>/, 1], :ticketid => xml[/<ticketid>([^<]+)<\/ticketid>/, 1]})
|
187
186
|
end
|
188
187
|
|
189
188
|
private
|
190
189
|
def parse_response(response, req = nil)
|
191
|
-
|
192
|
-
raise FailedResponse.new(
|
193
|
-
name,
|
190
|
+
json = JSON.load(response.body.gsub(/:([^\s])/, ': \1'))
|
191
|
+
raise FailedResponse.new(json['message'], json['code'], req) if json.delete('stat') == 'fail'
|
192
|
+
name, json = json.to_a.first if json.size == 1
|
194
193
|
|
195
|
-
res = Response.structify
|
194
|
+
res = Response.structify json, name
|
196
195
|
lookup_token(req, res)
|
197
196
|
res
|
198
197
|
end
|
@@ -244,4 +243,5 @@ end
|
|
244
243
|
#
|
245
244
|
# recent_photos = flickr.photos.getRecent
|
246
245
|
# puts recent_photos[0].title
|
247
|
-
def flickr; $
|
246
|
+
def flickr; $flickraw ||= FlickRaw::Flickr.new end
|
247
|
+
|
data/rakefile
CHANGED
@@ -11,13 +11,14 @@ PKG_FILES = FileList["lib/flickraw.rb", "flickraw_rdoc.rb", "copying.txt", "READ
|
|
11
11
|
spec = Gem::Specification.new do |s|
|
12
12
|
s.summary = "Flickr library with a syntax close to the syntax described on http://www.flickr.com/services/api"
|
13
13
|
s.name = "flickraw"
|
14
|
-
s.author = "
|
14
|
+
s.author = "Mael Clerambault"
|
15
15
|
s.email = "maelclerambault@yahoo.fr"
|
16
16
|
s.homepage = "http://flickraw.rubyforge.org"
|
17
17
|
s.rubyforge_project = "flickraw"
|
18
18
|
s.version = FlickRaw::VERSION
|
19
19
|
s.files = PKG_FILES
|
20
20
|
s.test_files = FileList["test/*.rb"].to_a
|
21
|
+
s.add_dependency 'json'
|
21
22
|
end
|
22
23
|
|
23
24
|
Rake::RDocTask.new do |rd|
|
metadata
CHANGED
@@ -1,26 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
2
4
|
name: flickraw
|
3
5
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
version: "0.5"
|
7
|
+
date: 2008-11-10 00:00:00 +01:00
|
8
|
+
summary: Flickr library with a syntax close to the syntax described on http://www.flickr.com/services/api
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: maelclerambault@yahoo.fr
|
12
|
+
homepage: http://flickraw.rubyforge.org
|
13
|
+
rubyforge_project: flickraw
|
14
|
+
description:
|
8
15
|
autorequire:
|
9
|
-
bindir: bin
|
10
|
-
cert_chain: []
|
11
|
-
|
12
|
-
date: 2008-04-24 00:00:00 +02:00
|
13
16
|
default_executable:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Mael Clerambault
|
24
31
|
files:
|
25
32
|
- lib/flickraw.rb
|
26
33
|
- flickraw_rdoc.rb
|
@@ -28,36 +35,30 @@ files:
|
|
28
35
|
- README
|
29
36
|
- TODO
|
30
37
|
- rakefile
|
31
|
-
- examples/
|
38
|
+
- examples/interestingness.rb
|
32
39
|
- examples/upload.rb
|
40
|
+
- examples/flickr_KDE.rb
|
33
41
|
- examples/auth.rb
|
34
|
-
- examples/interestingness.rb
|
35
42
|
- test/test.rb
|
36
|
-
|
37
|
-
|
38
|
-
post_install_message:
|
43
|
+
test_files:
|
44
|
+
- test/test.rb
|
39
45
|
rdoc_options: []
|
40
46
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
version: "0"
|
48
|
-
version:
|
49
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: "0"
|
54
|
-
version:
|
47
|
+
extra_rdoc_files: []
|
48
|
+
|
49
|
+
executables: []
|
50
|
+
|
51
|
+
extensions: []
|
52
|
+
|
55
53
|
requirements: []
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
-
|
55
|
+
dependencies:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: json
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.0.0
|
64
|
+
version:
|