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.
@@ -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"
@@ -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: 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 -04:00
12
+ date: 2009-07-21 00:00:00 -04: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:
@@ -53,8 +53,6 @@ extra_rdoc_files:
53
53
  files:
54
54
  - README.rdoc
55
55
  - Rakefile
56
- - lib/fleakr
57
- - lib/fleakr/api
58
56
  - lib/fleakr/api/file_parameter.rb
59
57
  - lib/fleakr/api/method_request.rb
60
58
  - lib/fleakr/api/option.rb
@@ -64,12 +62,10 @@ files:
64
62
  - lib/fleakr/api/upload_request.rb
65
63
  - lib/fleakr/api/value_parameter.rb
66
64
  - lib/fleakr/api.rb
67
- - lib/fleakr/core_ext
68
65
  - lib/fleakr/core_ext/false_class.rb
69
66
  - lib/fleakr/core_ext/hash.rb
70
67
  - lib/fleakr/core_ext/true_class.rb
71
68
  - lib/fleakr/core_ext.rb
72
- - lib/fleakr/objects
73
69
  - lib/fleakr/objects/authentication_token.rb
74
70
  - lib/fleakr/objects/comment.rb
75
71
  - lib/fleakr/objects/contact.rb
@@ -83,16 +79,15 @@ files:
83
79
  - lib/fleakr/objects/tag.rb
84
80
  - lib/fleakr/objects/user.rb
85
81
  - lib/fleakr/objects.rb
86
- - lib/fleakr/support
87
82
  - lib/fleakr/support/attribute.rb
88
83
  - lib/fleakr/support/object.rb
89
84
  - lib/fleakr/support.rb
90
85
  - lib/fleakr/version.rb
91
86
  - lib/fleakr.rb
92
- - test/fixtures
93
87
  - test/fixtures/auth.checkToken.xml
94
88
  - test/fixtures/auth.getFullToken.xml
95
89
  - test/fixtures/auth.getToken.xml
90
+ - test/fixtures/contacts.getList.xml
96
91
  - test/fixtures/contacts.getPublicList.xml
97
92
  - test/fixtures/groups.pools.getPhotos.xml
98
93
  - test/fixtures/people.findByEmail.xml
@@ -112,9 +107,6 @@ files:
112
107
  - test/fixtures/tags.getListUser.xml
113
108
  - test/fixtures/tags.getRelated.xml
114
109
  - test/test_helper.rb
115
- - test/unit
116
- - test/unit/fleakr
117
- - test/unit/fleakr/api
118
110
  - test/unit/fleakr/api/file_parameter_test.rb
119
111
  - test/unit/fleakr/api/method_request_test.rb
120
112
  - test/unit/fleakr/api/option_test.rb
@@ -123,11 +115,9 @@ files:
123
115
  - test/unit/fleakr/api/response_test.rb
124
116
  - test/unit/fleakr/api/upload_request_test.rb
125
117
  - test/unit/fleakr/api/value_parameter_test.rb
126
- - test/unit/fleakr/core_ext
127
118
  - test/unit/fleakr/core_ext/false_class_test.rb
128
119
  - test/unit/fleakr/core_ext/hash_test.rb
129
120
  - test/unit/fleakr/core_ext/true_class_test.rb
130
- - test/unit/fleakr/objects
131
121
  - test/unit/fleakr/objects/authentication_token_test.rb
132
122
  - test/unit/fleakr/objects/comment_test.rb
133
123
  - test/unit/fleakr/objects/contact_test.rb
@@ -140,12 +130,13 @@ files:
140
130
  - test/unit/fleakr/objects/set_test.rb
141
131
  - test/unit/fleakr/objects/tag_test.rb
142
132
  - test/unit/fleakr/objects/user_test.rb
143
- - test/unit/fleakr/support
144
133
  - test/unit/fleakr/support/attribute_test.rb
145
134
  - test/unit/fleakr/support/object_test.rb
146
135
  - test/unit/fleakr_test.rb
147
136
  has_rdoc: true
148
137
  homepage: http://sneaq.net
138
+ licenses: []
139
+
149
140
  post_install_message:
150
141
  rdoc_options:
151
142
  - --main
@@ -167,9 +158,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
158
  requirements: []
168
159
 
169
160
  rubyforge_project:
170
- rubygems_version: 1.3.1
161
+ rubygems_version: 1.3.4
171
162
  signing_key:
172
- specification_version: 2
163
+ specification_version: 3
173
164
  summary: A small, yet powerful, gem to interface with Flickr photostreams
174
165
  test_files: []
175
166