reagent-fleakr 0.5.0 → 0.5.1

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/README.rdoc CHANGED
@@ -89,7 +89,28 @@ When accessing a set, you can also grab all the photos that are in that set:
89
89
  => #<Fleakr::Objects::Photo:0x1140108 ... >
90
90
  >> user.sets.first.photos.first.title
91
91
  => "Untitled1"
92
+
93
+ === Contacts
94
+
95
+ Besides pulling back a given user's public contacts list, you can also retrieve the list of
96
+ contacts for the currently authenticated user (see below about authentication). For example,
97
+ you can retrieve all contacts:
98
+
99
+ >> Fleakr.contacts
100
+ => [#<Fleakr::Objects::Contact:0x111ff84 @username="bryan.ray" ...>]
101
+
102
+ Or just the contacts marked as 'family':
103
+
104
+ >> Fleakr.contacts(:family)
105
+ => [#<Fleakr::Objects::Contact:0x12db42c @username="Grandbob" ...>]
106
+
107
+ Or a specific page of contacts marked as 'friends':
92
108
 
109
+ >> Fleakr.contacts(:friends, :page => 3, :per_page => 5)
110
+ => [#<Fleakr::Objects::Contact:0x12a6c54 @username="Louise and BCG" ...>]
111
+
112
+ See the documentation for Fleakr.contacts for what options are available.
113
+
93
114
  === Photos
94
115
 
95
116
  Each photo object contains metadata about a collection of images, each representing different
@@ -306,6 +327,16 @@ just the requests you need to tune the log level:
306
327
  Even if something doesn't go wrong, this is a good way to get a sense for when you're making
307
328
  API requests.
308
329
 
330
+ == Contributors
331
+
332
+ While Fleakr started as a labor of love for me, I'm glad that others have been interested
333
+ in this project enough to contribute their ideas and code:
334
+
335
+ * {John Guenin}[http://github.com/johng]
336
+ * {Thomas Olausson}[http://github.com/latompa]
337
+
338
+ Thanks!
339
+
309
340
  == Roadmap / TODO
310
341
 
311
342
  === 0.4.x
data/Rakefile CHANGED
@@ -4,8 +4,6 @@ require 'rake/testtask'
4
4
 
5
5
  require 'lib/fleakr/version'
6
6
 
7
- task :default => :test
8
-
9
7
  spec = Gem::Specification.new do |s|
10
8
  s.name = 'fleakr'
11
9
  s.version = Fleakr::Version.to_s
@@ -18,9 +16,9 @@ spec = Gem::Specification.new do |s|
18
16
  s.homepage = 'http://sneaq.net'
19
17
  s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib,test}/**/*")
20
18
 
21
- s.add_dependency('hpricot', '~> 0.8.1')
22
- s.add_dependency('activesupport', '~> 2.0')
23
- s.add_dependency('loggable', '~> 0.2.0')
19
+ s.add_dependency('hpricot', '>= 0.6.164')
20
+ s.add_dependency('activesupport', '>= 2.0')
21
+ s.add_dependency('loggable', '>= 0.2.0')
24
22
  end
25
23
 
26
24
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -33,6 +31,23 @@ Rake::TestTask.new do |t|
33
31
  t.verbose = true
34
32
  end
35
33
 
34
+ begin
35
+ require 'rcov/rcovtask'
36
+
37
+ Rcov::RcovTask.new(:coverage) do |t|
38
+ t.libs = ['test']
39
+ t.test_files = FileList["test/**/*_test.rb"]
40
+ t.verbose = true
41
+ t.rcov_opts = ['--text-report', "-x #{Gem.path}", '-x /Library/Ruby', '-x /usr/lib/ruby']
42
+ end
43
+
44
+ task :default => :coverage
45
+
46
+ rescue LoadError
47
+ warn "\n**** Install rcov (sudo gem install relevance-rcov) to get coverage stats ****\n"
48
+ task :default => :test
49
+ end
50
+
36
51
  desc 'Generate the gemspec to serve this Gem from Github'
37
52
  task :github do
38
53
  file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
data/lib/fleakr.rb CHANGED
@@ -130,6 +130,27 @@ module Fleakr
130
130
  def self.upload(glob, options = {})
131
131
  Dir[glob].map {|file| Fleakr::Objects::Photo.upload(file, options) }
132
132
  end
133
+
134
+ # Get all contacts for the currently authenticated user. The provided contact type can be
135
+ # one of the following:
136
+ #
137
+ # [:friends] Only contacts who are friends (and not family)
138
+ # [:family] Only contacts who are family (and not friends)
139
+ # [:both] Only contacts who are both friends and family
140
+ # [:neither] Only contacts who are neither friends nor family
141
+ #
142
+ # Additional parameters supported are:
143
+ #
144
+ # [:page] The page of results to return
145
+ # [:per_page] The number of contacts to retrieve per page
146
+ #
147
+ def self.contacts(contact_type = nil, additional_options = {})
148
+ options = {}
149
+ options.merge!(:filter => contact_type) unless contact_type.nil?
150
+ options.merge!(additional_options)
151
+
152
+ Fleakr::Objects::Contact.find_all(options)
153
+ end
133
154
 
134
155
  # Get the authentication token needed for authenticated requests. Will either use
135
156
  # a valid auth_token (if available) or a mini-token to generate the auth_token.
@@ -5,18 +5,26 @@ module Fleakr
5
5
  include Fleakr::Support::Object
6
6
 
7
7
  flickr_attribute :id, :from => '@nsid'
8
- flickr_attribute :username
8
+ flickr_attribute :username, :location
9
+ flickr_attribute :name, :from => '@realname'
9
10
  flickr_attribute :icon_server, :from => '@iconserver'
10
11
  flickr_attribute :icon_farm, :from => '@iconfarm'
11
12
 
12
13
  # Retrieve a list of contacts for the specified user ID and return an initialized
13
- # collection of #User objects
14
+ # collection of User objects
14
15
  def self.find_all_by_user_id(user_id)
15
16
  response = Fleakr::Api::MethodRequest.with_response!('contacts.getPublicList', :user_id => user_id)
16
17
  (response.body/'contacts/contact').map {|c| Contact.new(c).to_user }
17
18
  end
18
19
 
19
- def to_user
20
+ # Retrieve a list of contacts for the currently authenticated user
21
+ def self.find_all(params = {})
22
+ response = Fleakr::Api::MethodRequest.with_response!('contacts.getList', params)
23
+ (response.body/'contacts/contact').map {|c| Contact.new(c) }
24
+ end
25
+
26
+ # TODO: deprecate in favor of shared behavior as a module
27
+ def to_user # :nodoc:
20
28
  user = User.new
21
29
  self.class.attributes.each do |attribute|
22
30
  attribute_name = attribute.name
@@ -12,6 +12,7 @@ module Fleakr
12
12
  # [title] The title of this photo
13
13
  # [description] The description of this photo
14
14
  # [secret] This photo's secret (used for sharing photo without permissions checking)
15
+ # [original_secret] This photo's original secret
15
16
  # [comment_count] Count of the comments attached to this photo
16
17
  # [url] This photo's page on Flickr
17
18
  # [square] The tiny square representation of this photo
@@ -46,6 +47,7 @@ module Fleakr
46
47
  flickr_attribute :owner_id, :from => ['@owner', 'owner@nsid']
47
48
  flickr_attribute :updated, :from => '@lastupdate'
48
49
  flickr_attribute :comment_count, :from => 'comments'
50
+ flickr_attribute :original_secret, :from => '@originalsecret'
49
51
 
50
52
  # TODO:
51
53
  # * visibility
@@ -3,7 +3,7 @@ module Fleakr
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- TINY = 0
6
+ TINY = 1
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, TINY].join('.')
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <rsp stat="ok">
3
+ <contacts page="1" pages="1" per_page="1000" perpage="1000" total="17">
4
+ <contact nsid="9302864@N42" username="blinky" iconserver="2263" iconfarm="3" ignored="0" realname="Mr Blinky" location="Middletown"/>
5
+ <contact nsid="63204625@N20" username="inky" iconserver="53" iconfarm="1" ignored="0" />
6
+ </contacts>
7
+ </rsp>
@@ -6,26 +6,34 @@ module Fleakr::Objects
6
6
  context "The Contact class" do
7
7
 
8
8
  should "return a list of users for a specified user's contacts" do
9
- # user_1, user_2 = [stub(), stub()]
10
- user_1 = stub()
11
- user_2 = stub()
12
-
9
+ user_1, user_2 = stub(), stub()
10
+
13
11
  contact_1, contact_2 = [stub(:to_user => user_1), stub(:to_user => user_2)]
14
-
12
+
15
13
  response = mock_request_cycle :for => 'contacts.getPublicList', :with => {:user_id => '1'}
16
-
14
+
17
15
  contact_1_doc, contact_2_doc = (response.body/'rsp/contacts/contact').to_a
18
-
16
+
19
17
  Contact.stubs(:new).with(contact_1_doc).returns(contact_1)
20
18
  Contact.stubs(:new).with(contact_2_doc).returns(contact_2)
21
-
19
+
22
20
  Contact.find_all_by_user_id('1').should == [user_1, user_2]
23
21
  end
24
22
 
23
+ should "return a list of users for an authenticated user" do
24
+ response = mock_request_cycle :for => 'contacts.getList', :with => {}
25
+ contact_1, contact_2 = [stub("contact"), stub('contact')]
26
+ contact_1_doc, contact_2_doc = (response.body/'rsp/contacts/contact').to_a
27
+
28
+ Contact.stubs(:new).with(contact_1_doc).returns(@contact_1)
29
+ Contact.stubs(:new).with(contact_2_doc).returns(@contact_2)
30
+ Contact.find_all.should == [@user_1, @user_2]
31
+ end
32
+
25
33
  end
26
34
 
27
35
  context "An instance of the Contact class" do
28
- context "when populating from an XML document" do
36
+ context "when populating from an XML document with public contacts" do
29
37
  setup do
30
38
  @object = Contact.new(Hpricot.XML(read_fixture('contacts.getPublicList')).at('contacts/contact'))
31
39
  end
@@ -36,6 +44,21 @@ module Fleakr::Objects
36
44
  should_have_a_value_for :icon_farm => '3'
37
45
 
38
46
  end
47
+
48
+ context "when populating from an XML document with authenticated user's contacts" do
49
+ setup do
50
+ @object = Contact.new(Hpricot.XML(read_fixture('contacts.getList')).at('contacts/contact'))
51
+ end
52
+
53
+ should_have_a_value_for :id => '9302864@N42'
54
+ should_have_a_value_for :username => 'blinky'
55
+ should_have_a_value_for :icon_server => '2263'
56
+ should_have_a_value_for :icon_farm => '3'
57
+ should_have_a_value_for :name => 'Mr Blinky'
58
+ should_have_a_value_for :location => 'Middletown'
59
+
60
+ end
61
+
39
62
 
40
63
  context "in general" do
41
64
 
@@ -45,7 +68,7 @@ module Fleakr::Objects
45
68
 
46
69
  User.stubs(:new).returns(user)
47
70
 
48
- [:id, :username, :icon_server, :icon_farm].each do |method|
71
+ [:id, :username, :icon_server, :icon_farm, :name, :location].each do |method|
49
72
  contact.stubs(method).with().returns(method.to_s)
50
73
  user.expects("#{method}=".to_sym).with(method.to_s)
51
74
  end
@@ -90,18 +90,19 @@ module Fleakr::Objects
90
90
 
91
91
  end
92
92
 
93
- should_have_a_value_for :id => '1'
94
- should_have_a_value_for :title => 'Tree'
95
- should_have_a_value_for :description => 'A Tree'
96
- should_have_a_value_for :farm_id => '4'
97
- should_have_a_value_for :server_id => '3085'
98
- should_have_a_value_for :owner_id => '31066442@N69'
99
- should_have_a_value_for :secret => 'secret'
100
- should_have_a_value_for :posted => '1230274722'
101
- should_have_a_value_for :taken => '2008-12-25 18:26:55'
102
- should_have_a_value_for :updated => '1230276652'
103
- should_have_a_value_for :comment_count => '0'
104
- should_have_a_value_for :url => 'http://www.flickr.com/photos/yes/1'
93
+ should_have_a_value_for :id => '1'
94
+ should_have_a_value_for :title => 'Tree'
95
+ should_have_a_value_for :description => 'A Tree'
96
+ should_have_a_value_for :farm_id => '4'
97
+ should_have_a_value_for :server_id => '3085'
98
+ should_have_a_value_for :owner_id => '31066442@N69'
99
+ should_have_a_value_for :secret => 'secret'
100
+ should_have_a_value_for :original_secret => 'sekrit'
101
+ should_have_a_value_for :posted => '1230274722'
102
+ should_have_a_value_for :taken => '2008-12-25 18:26:55'
103
+ should_have_a_value_for :updated => '1230276652'
104
+ should_have_a_value_for :comment_count => '0'
105
+ should_have_a_value_for :url => 'http://www.flickr.com/photos/yes/1'
105
106
 
106
107
  end
107
108
 
@@ -29,6 +29,21 @@ class FleakrTest < Test::Unit::TestCase
29
29
  Fleakr.user(email).should == user
30
30
  end
31
31
 
32
+ should "find all contacts for the authenticated user" do
33
+ Fleakr::Objects::Contact.expects(:find_all).with({}).returns('contacts')
34
+ Fleakr.contacts.should == 'contacts'
35
+ end
36
+
37
+ should "allow filtering when finding contacts for the authenticated user" do
38
+ Fleakr::Objects::Contact.expects(:find_all).with(:filter => :friends).returns('contacts')
39
+ Fleakr.contacts(:friends).should == 'contacts'
40
+ end
41
+
42
+ should "allow passing of additional parameters when finding contacts for the authenticated user" do
43
+ Fleakr::Objects::Contact.expects(:find_all).with(:filter => :friends, :page => 1).returns('contacts')
44
+ Fleakr.contacts(:friends, :page => 1).should == 'contacts'
45
+ end
46
+
32
47
  should "be able to perform text searches" do
33
48
  photos = [stub()]
34
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reagent-fleakr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Reagan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-13 00:00:00 -07:00
12
+ date: 2009-07-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ~>
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.8.1
23
+ version: 0.6.164
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
@@ -28,7 +28,7 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: "2.0"
34
34
  version:
@@ -38,7 +38,7 @@ dependencies:
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ~>
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: 0.2.0
44
44
  version:
@@ -93,6 +93,7 @@ files:
93
93
  - test/fixtures/auth.checkToken.xml
94
94
  - test/fixtures/auth.getFullToken.xml
95
95
  - test/fixtures/auth.getToken.xml
96
+ - test/fixtures/contacts.getList.xml
96
97
  - test/fixtures/contacts.getPublicList.xml
97
98
  - test/fixtures/groups.pools.getPhotos.xml
98
99
  - test/fixtures/people.findByEmail.xml
@@ -144,7 +145,7 @@ files:
144
145
  - test/unit/fleakr/support/attribute_test.rb
145
146
  - test/unit/fleakr/support/object_test.rb
146
147
  - test/unit/fleakr_test.rb
147
- has_rdoc: true
148
+ has_rdoc: false
148
149
  homepage: http://sneaq.net
149
150
  post_install_message:
150
151
  rdoc_options:
@@ -169,7 +170,7 @@ requirements: []
169
170
  rubyforge_project:
170
171
  rubygems_version: 1.2.0
171
172
  signing_key:
172
- specification_version: 2
173
+ specification_version: 3
173
174
  summary: A small, yet powerful, gem to interface with Flickr photostreams
174
175
  test_files: []
175
176