flickr 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +6 -6
  2. data/flickr.rb +30 -26
  3. metadata +34 -28
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/rdoctask'
4
4
  require 'rake/gempackagetask'
5
5
  require 'rubygems'
6
6
 
7
- task :default => [ :test, :gem, :rdoc ]
7
+ task :default => [ :gem, :rdoc ]
8
8
 
9
9
  Rake::TestTask.new("test") { |t|
10
10
  t.test_files = FileList['test*.rb']
@@ -18,17 +18,17 @@ Rake::RDocTask.new { |rdoc|
18
18
  spec = Gem::Specification.new do |s|
19
19
  s.add_dependency('xml-simple', '>= 1.0.7')
20
20
  s.name = 'flickr'
21
- s.version = "1.0.0"
21
+ s.version = "1.0.1"
22
22
  s.platform = Gem::Platform::RUBY
23
- s.summary = "An insanely easy interface to the Flickr photo-sharing service. By Scott Raymond."
23
+ s.summary = "An insanely easy interface to the Flickr photo-sharing service. By Scott Raymond. Maintainer: Patrick Plattes"
24
24
  s.requirements << 'Flickr developers API key'
25
25
  s.files = Dir.glob("*").delete_if { |item| item.include?("svn") }
26
26
  s.require_path = '.'
27
27
  s.autorequire = 'flickr'
28
- s.author = "Scott Raymond"
29
- s.email = "sco@redgreenblu.com"
28
+ s.author = "Scott Raymond, Patrick Plattes"
29
+ s.email = "patrick@erdbeere.net"
30
30
  s.rubyforge_project = "flickr"
31
- s.homepage = "http://redgreenblu.com/flickr/"
31
+ s.homepage = "http://flickr.rubyforge.org/"
32
32
  end
33
33
  Rake::GemPackageTask.new(spec) do |pkg|
34
34
  pkg.need_zip = true
data/flickr.rb CHANGED
@@ -54,7 +54,7 @@ class Flickr
54
54
  attr_accessor :user
55
55
 
56
56
  # Replace this API key with your own (see http://www.flickr.com/services/api/misc.api_keys.html)
57
- def initialize(api_key='86e18ef2a064ff2255845e029208d7f4', email=nil, password=nil)
57
+ def initialize(api_key=nil, email=nil, password=nil)
58
58
  @api_key = api_key
59
59
  @host = 'http://flickr.com'
60
60
  @api = '/services/rest'
@@ -88,19 +88,19 @@ class Flickr
88
88
  @email = email
89
89
  @password = password
90
90
  user = request('test.login')['user'] rescue fail
91
- @user = User.new(user['id'])
91
+ @user = User.new(user['id'], @api_key)
92
92
  end
93
93
 
94
94
  # Implements flickr.urls.lookupGroup and flickr.urls.lookupUser
95
95
  def find_by_url(url)
96
96
  response = urls_lookupUser('url'=>url) rescue urls_lookupGroup('url'=>url) rescue nil
97
- (response['user']) ? User.new(response['user']['id']) : Group.new(response['group']['id']) unless response.nil?
97
+ (response['user']) ? User.new(response['user']['id'], @api_key) : Group.new(response['group']['id'], @api_key) unless response.nil?
98
98
  end
99
99
 
100
100
  # Implements flickr.photos.getRecent and flickr.photos.search
101
101
  def photos(*criteria)
102
102
  photos = (criteria[0]) ? photos_search(criteria[0]) : photos_getRecent
103
- photos['photos']['photo'].collect { |photo| Photo.new(photo['id']) }
103
+ photos['photos']['photo'].collect { |photo| Photo.new(photo['id'], @api_key) }
104
104
  end
105
105
 
106
106
  # Gets public photos with a given tag
@@ -112,15 +112,15 @@ class Flickr
112
112
  def users(lookup=nil)
113
113
  if(lookup)
114
114
  user = people_findByEmail('find_email'=>lookup)['user'] rescue people_findByUsername('username'=>lookup)['user']
115
- return User.new(user['nsid'])
115
+ return User.new(user['nsid'], @api_key)
116
116
  else
117
- return people_getOnlineList['online']['user'].collect { |person| User.new(person['nsid']) }
117
+ return people_getOnlineList['online']['user'].collect { |person| User.new(person['nsid'], @api_key) }
118
118
  end
119
119
  end
120
120
 
121
121
  # Implements flickr.groups.getActiveList
122
122
  def groups
123
- groups_getActiveList['activegroups']['group'].collect { |group| Group.new(group['nsid']) }
123
+ groups_getActiveList['activegroups']['group'].collect { |group| Group.new(group['nsid'], @api_key) }
124
124
  end
125
125
 
126
126
  # Implements flickr.tags.getRelated
@@ -161,13 +161,14 @@ class Flickr
161
161
 
162
162
  attr_reader :client, :id, :name, :location, :photos_url, :url, :count, :firstdate, :firstdatetaken
163
163
 
164
- def initialize(id=nil, username=nil, email=nil, password=nil)
164
+ def initialize(id=nil, username=nil, email=nil, password=nil, api_key=nil)
165
165
  @id = id
166
166
  @username = username
167
167
  @email = email
168
168
  @password = password
169
- @client = Flickr.new
169
+ @client = Flickr.new @api_key
170
170
  @client.login(email, password) if email and password
171
+ @api_key = api_key
171
172
  end
172
173
 
173
174
  def username
@@ -197,12 +198,12 @@ class Flickr
197
198
 
198
199
  # Implements flickr.people.getPublicGroups
199
200
  def groups
200
- @client.people_getPublicGroups('user_id'=>@id)['groups']['group'].collect { |group| Group.new(group['nsid']) }
201
+ @client.people_getPublicGroups('user_id'=>@id)['groups']['group'].collect { |group| Group.new(group['nsid'], @api_key) }
201
202
  end
202
203
 
203
204
  # Implements flickr.people.getPublicPhotos
204
205
  def photos
205
- @client.people_getPublicPhotos('user_id'=>@id)['photos']['photo'].collect { |photo| Photo.new(photo['id']) }
206
+ @client.people_getPublicPhotos('user_id'=>@id)['photos']['photo'].collect { |photo| Photo.new(photo['id'], @api_key) }
206
207
  # what about non-public photos?
207
208
  end
208
209
 
@@ -213,19 +214,19 @@ class Flickr
213
214
 
214
215
  # Implements flickr.contacts.getPublicList and flickr.contacts.getList
215
216
  def contacts
216
- @client.contacts_getPublicList('user_id'=>@id)['contacts']['contact'].collect { |contact| User.new(contact['nsid']) }
217
+ @client.contacts_getPublicList('user_id'=>@id)['contacts']['contact'].collect { |contact| User.new(contact['nsid'], @api_key) }
217
218
  #or
218
219
  end
219
220
 
220
221
  # Implements flickr.favorites.getPublicList and flickr.favorites.getList
221
222
  def favorites
222
- @client.favorites_getPublicList('user_id'=>@id)['photos']['photo'].collect { |photo| Photo.new(photo['id']) }
223
+ @client.favorites_getPublicList('user_id'=>@id)['photos']['photo'].collect { |photo| Photo.new(photo['id'], @api_key) }
223
224
  #or
224
225
  end
225
226
 
226
227
  # Implements flickr.photosets.getList
227
228
  def photosets
228
- @client.photosets_getList('user_id'=>@id)['photosets']['photoset'].collect { |photoset| Photoset.new(photoset['id']) }
229
+ @client.photosets_getList('user_id'=>@id)['photosets']['photoset'].collect { |photoset| Photoset.new(photoset['id'], @api_key) }
229
230
  end
230
231
 
231
232
  # Implements flickr.tags.getListUser
@@ -235,9 +236,9 @@ class Flickr
235
236
 
236
237
  # Implements flickr.photos.getContactsPublicPhotos and flickr.photos.getContactsPhotos
237
238
  def contactsPhotos
238
- @client.photos_getContactsPublicPhotos('user_id'=>@id)['photos']['photo'].collect { |photo| Photo.new(photo['id']) }
239
+ @client.photos_getContactsPublicPhotos('user_id'=>@id)['photos']['photo'].collect { |photo| Photo.new(photo['id'], @api_key) }
239
240
  # or
240
- #@client.photos_getContactsPhotos['photos']['photo'].collect { |photo| Photo.new(photo['id']) }
241
+ #@client.photos_getContactsPhotos['photos']['photo'].collect { |photo| Photo.new(photo['id'], @api_key) }
241
242
  end
242
243
 
243
244
  def to_s
@@ -266,9 +267,10 @@ class Flickr
266
267
 
267
268
  attr_reader :id, :client
268
269
 
269
- def initialize(id=nil)
270
+ def initialize(id=nil, api_key=nil)
270
271
  @id = id
271
- @client = Flickr.new
272
+ @api_key = api_key
273
+ @client = Flickr.new @api_key
272
274
  end
273
275
 
274
276
  def title
@@ -330,8 +332,8 @@ class Flickr
330
332
  # Implements flickr.photos.getContext
331
333
  def context
332
334
  context = @client.photos_getContext('photo_id'=>@id)
333
- @previousPhoto = Photo.new(context['prevphoto']['id'])
334
- @nextPhoto = Photo.new(context['nextphoto']['id'])
335
+ @previousPhoto = Photo.new(context['prevphoto']['id'], @api_key)
336
+ @nextPhoto = Photo.new(context['nextphoto']['id'], @api_key)
335
337
  return [@previousPhoto, @nextPhoto]
336
338
  end
337
339
 
@@ -415,7 +417,7 @@ class Flickr
415
417
  def getInfo
416
418
  info = @client.photos_getInfo('photo_id'=>@id)['photo']
417
419
  @title = info['title']
418
- @owner = User.new(info['owner']['nsid'])
420
+ @owner = User.new(info['owner']['nsid'], @api_key)
419
421
  @server = info['server']
420
422
  @isfavorite = info['isfavorite']
421
423
  @license = info['license']
@@ -436,9 +438,10 @@ class Flickr
436
438
  class Group
437
439
  attr_reader :id, :client, :name, :members, :online, :privacy, :chatid, :chatcount, :url
438
440
 
439
- def initialize(id=nil)
441
+ def initialize(id=nil, api_key=nil)
440
442
  @id = id
441
- @client = Flickr.new
443
+ @api_key = api_key
444
+ @client = Flickr.new @api_key
442
445
  end
443
446
 
444
447
  # Implements flickr.groups.getInfo and flickr.urls.getGroup
@@ -468,16 +471,17 @@ class Flickr
468
471
 
469
472
  attr_reader :id, :client, :owner, :primary, :photos, :title, :description, :url
470
473
 
471
- def initialize(id=nil)
474
+ def initialize(id=nil, api_key=nil)
472
475
  @id = id
473
- @client = Flickr.new
476
+ @api_key = api_key
477
+ @client = Flickr.new @api_key
474
478
  end
475
479
 
476
480
  # Implements flickr.photosets.getInfo
477
481
  # private, once we can call it as needed
478
482
  def getInfo
479
483
  info = @client.photosets_getInfo('photosets_id'=>@id)['photoset']
480
- @owner = User.new(info['owner'])
484
+ @owner = User.new(info['owner'], @api_key)
481
485
  @primary = info['primary']
482
486
  @photos = info['photos']
483
487
  @title = info['title']
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.1
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: flickr
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2005-04-19
8
- summary: An insanely easy interface to the Flickr photo-sharing service. By Scott Raymond.
6
+ version: 1.0.1
7
+ date: 2008-02-25 00:00:00 +01:00
8
+ summary: "An insanely easy interface to the Flickr photo-sharing service. By Scott Raymond. Maintainer: Patrick Plattes"
9
9
  require_paths:
10
- - "."
11
- author: Scott Raymond
12
- email: sco@redgreenblu.com
13
- homepage: http://redgreenblu.com/flickr/
10
+ - .
11
+ email: patrick@erdbeere.net
12
+ homepage: http://flickr.rubyforge.org/
14
13
  rubyforge_project: flickr
15
14
  description:
16
15
  autorequire: flickr
@@ -19,33 +18,40 @@ bindir: bin
19
18
  has_rdoc: false
20
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
21
20
  requirements:
22
- -
23
- - ">"
24
- - !ruby/object:Gem::Version
25
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
26
24
  version:
27
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Scott Raymond, Patrick Plattes
28
31
  files:
29
- - flickr.rb
30
- - index.html
31
- - pkg
32
- - Rakefile
33
- - test_flickr.rb
32
+ - index.html
33
+ - test_flickr.rb
34
+ - flickr.rb
35
+ - Rakefile
34
36
  test_files: []
37
+
35
38
  rdoc_options: []
39
+
36
40
  extra_rdoc_files: []
41
+
37
42
  executables: []
43
+
38
44
  extensions: []
45
+
39
46
  requirements:
40
- - Flickr developers API key
47
+ - Flickr developers API key
41
48
  dependencies:
42
- - !ruby/object:Gem::Dependency
43
- name: xml-simple
44
- version_requirement:
45
- version_requirements: !ruby/object:Gem::Version::Requirement
46
- requirements:
47
- -
48
- - ">="
49
- - !ruby/object:Gem::Version
50
- version: 1.0.7
51
- version:
49
+ - !ruby/object:Gem::Dependency
50
+ name: xml-simple
51
+ version_requirement:
52
+ version_requirements: !ruby/object:Gem::Version::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.0.7
57
+ version: