public
Description: An update of Scott Raymond's insanely easy flickr library
Clone URL: git://github.com/ctagg/flickr.git
More work on groups.
Tidied up Manifest
Chris Taggart (author)
Mon May 12 06:39:01 -0700 2008
commit  2bd476fc5b656b20adf451f647fb4dc88add782d
tree    351c5896bfffae80942f4eee5c4d7107519c5b08
parent  12a6397989f5db3cd38eca633e3d0e5324ed006b
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 == 1.0.5 2008-05-12
0
 
0
-* 1 major enhancement:
0
+* 1 major change:
0
   * Updated and refactored Flickr::Group class and Flickr#groups method to work with current Flickr API. Flickr#groups now searches for given group, rather than groups.getActiveList (which no longer exists as Flickr API call)
0
 * Minor enhancements:
0
   * Tweaked internals so new client instance isn't created each time new object (e.g. photo, user) is created
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
1
2
 
3
 
 
4
5
6
7
 
8
9
 
10
 
 
 
 
 
11
 
 
 
 
 
 
0
@@ -1,27 +1,11 @@
0
 History.txt
0
 LICENSE
0
-License.txt
0
 Manifest.txt
0
-PostInstall.txt
0
-README
0
 README.txt
0
 Rakefile
0
 TODO
0
 lib/flickr.rb
0
-script/console
0
 script/destroy
0
 script/generate
0
-script/txt2html
0
 setup.rb
0
-spec/flickr_spec.rb
0
-spec/spec_helper.rb
0
-tasks/deployment.rake
0
-tasks/environment.rake
0
-tasks/website.rake
0
 test/test_flickr.rb
0
-test/test_helper.rb
0
-website/index.html
0
-website/index.txt
0
-website/javascripts/rounded_corners_lite.inc.js
0
-website/stylesheets/screen.css
0
-website/template.html.erb
...
283
284
285
286
 
 
 
 
287
288
289
...
582
583
584
585
 
586
587
588
...
602
603
604
605
606
 
 
607
608
609
...
283
284
285
 
286
287
288
289
290
291
292
...
585
586
587
 
588
589
590
591
...
605
606
607
 
 
608
609
610
611
612
0
@@ -283,7 +283,10 @@ class Flickr
0
         
0
     # Implements flickr.people.getPublicGroups
0
     def groups
0
- @client.people_getPublicGroups('user_id'=>@id)['groups']['group'].collect { |group| Group.new(group['nsid'], @api_key) }
0
+ @client.people_getPublicGroups('user_id'=>@id)['groups']['group'].collect { |group| Group.new( "id" => group['nsid'],
0
+ "name" => group['name'],
0
+ "eighteenplus" => group['eighteenplus'],
0
+ "client" => @client) }
0
     end
0
     
0
     # Implements flickr.people.getPublicPhotos. Options hash allows you to add
0
@@ -582,7 +585,7 @@ class Flickr
0
   # flickr.groups.pools.getPhotos
0
   # flickr.groups.pools.remove
0
   class Group
0
- attr_reader :id, :client, :name, :members, :online, :privacy, :chatid, :chatcount, :url
0
+ attr_reader :id, :client, :description, :name, :eighteenplus, :members, :online, :privacy, :url#, :chatid, :chatcount
0
     
0
     def initialize(id_or_params_hash=nil, api_key=nil)
0
       if id_or_params_hash.is_a?(Hash)
0
@@ -602,8 +605,8 @@ class Flickr
0
       @members = info['members']
0
       @online = info['online']
0
       @privacy = info['privacy']
0
- @chatid = info['chatid']
0
- @chatcount = info['chatcount']
0
+ # @chatid = info['chatid']
0
+ # @chatcount = info['chatcount']
0
       @url = @client.urls_getGroup('group_id'=>@id)['group']['url']
0
       self
0
     end
...
231
232
233
234
 
235
236
237
...
269
270
271
272
273
274
275
276
 
277
278
279
...
296
297
298
299
300
301
302
303
304
 
305
306
307
308
309
310
311
312
313
314
 
315
316
317
318
319
 
320
321
322
323
324
325
326
 
 
327
328
329
330
331
332
333
 
 
 
 
334
335
336
 
337
338
339
340
 
 
 
 
 
 
 
 
 
 
341
342
343
...
631
632
633
634
 
635
636
 
637
638
639
...
644
645
646
 
 
 
 
 
 
 
 
647
648
649
...
719
720
721
 
 
 
 
 
 
 
 
722
723
724
...
231
232
233
 
234
235
236
237
...
269
270
271
 
 
 
 
 
272
273
274
275
...
292
293
294
 
 
 
 
 
 
295
296
297
298
299
300
301
 
 
 
 
302
303
304
305
 
 
306
307
 
 
 
 
 
 
308
309
310
311
 
 
 
 
 
312
313
314
315
316
317
 
318
319
 
 
 
320
321
322
323
324
325
326
327
328
329
330
331
332
...
620
621
622
 
623
624
625
626
627
628
629
...
634
635
636
637
638
639
640
641
642
643
644
645
646
647
...
717
718
719
720
721
722
723
724
725
726
727
728
729
730
0
@@ -231,7 +231,7 @@ class TestFlickr < Test::Unit::TestCase
0
     assert_kind_of Flickr::Group, group = groups.first
0
     assert_equal "group1", group.id
0
     assert_equal "Group One", group.name
0
- assert_equal "0", group.instance_variable_get(:@eighteenplus)
0
+ assert_equal "0", group.eighteenplus
0
     assert_equal f, group.client
0
   end
0
   
0
@@ -269,11 +269,7 @@ class TestFlickr < Test::Unit::TestCase
0
   # ##### Flickr::User tests
0
   #
0
   def test_should_instantiate_user
0
- user = Flickr::User.new({ 'id' => 'foo123',
0
- 'username' => 'some_user',
0
- 'name' => 'Some User',
0
- 'foo' => 'bar',
0
- 'auth_token' => 'foobar789'})
0
+ user = new_user
0
     assert_equal 'foo123', user.id
0
     assert_equal 'some_user', user.username
0
     assert_equal 'bar', user.instance_variable_get(:@foo) # should collect all other params up and store as instance variables
0
@@ -296,48 +292,41 @@ class TestFlickr < Test::Unit::TestCase
0
   def test_should_instantiate_new_client_when_instantiating_user_if_no_client_passed_in_params
0
     f = flickr_client
0
     Flickr.expects(:new).returns(f)
0
- user = Flickr::User.new({ 'id' => 'foo123',
0
- 'username' => 'some_user',
0
- 'name' => 'Some User',
0
- 'auth_token' => 'foobar789',
0
- 'shared_secret' => 'some_secret',
0
- 'api_key' => 'an_api_key' })
0
+ user = new_user( 'api_key' => 'an_api_key' )
0
     assert_equal f, user.client
0
   end
0
   
0
   def test_should_not_instantiate_new_client_when_instantiating_user_if_client_passed_in_params
0
     f = flickr_client
0
     Flickr.expects(:new).never
0
- user = Flickr::User.new({ 'id' => 'foo123',
0
- 'username' => 'some_user',
0
- 'name' => 'Some User',
0
- 'client' => f })
0
+ user = new_user( 'client' => f )
0
     assert_equal f, user.client
0
   end
0
   
0
- def test_should_not_instantiate_new_client_if_existing_client_passed
0
- f = flickr_client
0
+ def test_should_not_instantiate_client_if_no_api_key_passed
0
     Flickr.expects(:new).never
0
- user = Flickr::User.new({ 'id' => 'foo123',
0
- 'username' => 'some_user',
0
- 'name' => 'Some User',
0
- 'api_key' => 'an_api_key',
0
- 'client' => f })
0
- assert_equal f, user.client
0
+ user = new_user
0
+ assert_nil user.client
0
   end
0
   
0
- def test_should_not_instantiate_client_if_no_api_key_passed
0
- user = Flickr::User.new({ 'id' => 'foo123',
0
- 'username' => 'some_user',
0
- 'name' => 'Some User'})
0
- assert_nil user.client
0
+ def test_should_get_users_public_groups
0
+ f = flickr_client
0
+ f.expects(:request).with("people.getPublicGroups", anything).returns(dummy_groups_response)
0
+ new_user( 'client' => f ).groups
0
   end
0
   
0
- def test_should_not_instantiate_new_client_when_instantiating_user_if_existing_client_passed_to_user_as_param
0
+ def test_should_instantiate_users_public_groups
0
     f = flickr_client
0
- Flickr.expects(:new).never
0
- user = Flickr::User.new('client' => f)
0
- assert_equal f, user.client
0
+ f.stubs(:request).returns(dummy_groups_response)
0
+ user = new_user( 'client' => f )
0
+
0
+ groups = user.groups
0
+ assert_equal 2, groups.size
0
+ assert_kind_of Flickr::Group, group = groups.first
0
+ assert_equal "group1", group.id
0
+ assert_equal "Group One", group.name
0
+ assert_equal "0", group.eighteenplus
0
+ assert_equal f, group.client
0
   end
0
   
0
   # def test_getInfo
0
@@ -631,9 +620,10 @@ class TestFlickr < Test::Unit::TestCase
0
   
0
   # new api for instantiating groups
0
   def test_should_instantiate_group_from_params_hash
0
- group = Flickr::Group.new("id" => "group1", "name" => "Group One", "foo" => "bar")
0
+ group = Flickr::Group.new("id" => "group1", "name" => "Group One", "eighteenplus" => "1", "foo" => "bar")
0
     assert_equal "group1", group.id
0
     assert_equal "Group One", group.name
0
+ assert_equal "1", group.eighteenplus
0
     assert_equal "bar", group.instance_variable_get(:@foo)
0
   end
0
   
0
@@ -644,6 +634,14 @@ class TestFlickr < Test::Unit::TestCase
0
     assert_equal f, group.client
0
   end
0
   
0
+ def test_should_provide_id_name_eighteenplus_description_members_online_privacy_reader_methods_for_group
0
+ g = Flickr::Group.new
0
+ %w(id name eighteenplus description members online privacy).each do |m|
0
+ g.instance_variable_set("@#{m}", "foo_#{m}")
0
+ assert_equal "foo_#{m}", g.send(m)
0
+ end
0
+ end
0
+
0
   # def test_should_initialize_photo_from_id
0
   # photo = Flickr::Photo.new("foo123")
0
   # assert_equal "foo123", photo.id
0
@@ -719,6 +717,14 @@ class TestFlickr < Test::Unit::TestCase
0
     f
0
   end
0
   
0
+ def new_user(options={})
0
+ Flickr::User.new({ 'id' => 'foo123',
0
+ 'username' => 'some_user',
0
+ 'name' => 'Some User',
0
+ 'foo' => 'bar',
0
+ 'auth_token' => 'foobar789'}.merge(options))
0
+
0
+ end
0
   def new_photo(options={})
0
     Flickr::Photo.new("1418878",
0
                       "foo123",

Comments

    No one has commented yet.