benschwarz-flickr-wrapper 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "flickr-wrapper"
3
- s.version = "0.1.2"
4
- s.date = "2008-05-10"
3
+ s.version = "0.1.3"
4
+ s.date = "2008-06-07"
5
5
  s.summary = "A grassroots wrapper for flickr"
6
6
  s.email = "ben@germanforblack.com"
7
7
  s.homepage = "http://github.com/benschwarz/flickr-wrapper"
8
8
  s.description = "A grassroots wrapper around flickr - Strictly for convenience"
9
9
  s.authors = ["Ben Schwarz"]
10
- s.files = ["README", "flickr-wrapper.gemspec", "lib/flickr-wrapper.rb", "lib/flickr-wrapper/base.rb", "lib/flickr-wrapper/machine_tag.rb", "lib/flickr-wrapper/photo.rb", "lib/flickr-wrapper/photoset.rb", "lib/flickr-wrapper/tag.rb", "lib/flickr-wrapper/user.rb", "lib/vendor", "lib/vendor/parallel", "lib/vendor/parallel/parallel.rb"]
10
+ s.files = ["README", "flickr-wrapper.gemspec", "lib/flickr-wrapper.rb", "lib/flickr-wrapper/base.rb", "lib/flickr-wrapper/machine_tag.rb", "lib/flickr-wrapper/photo.rb", "lib/flickr-wrapper/photoset.rb", "lib/flickr-wrapper/tag.rb", "lib/flickr-wrapper/user.rb", "lib/vendor/parallel.rb"]
11
11
  s.require_path = "lib"
12
12
 
13
13
  # Deps
@@ -1,15 +1,20 @@
1
1
  # Dependencies
2
- require 'rubygems'
2
+ begin
3
+ require 'minigems'
4
+ rescue LoadError
5
+ require 'rubygems'
6
+ end
7
+
3
8
  require 'flickr-rest'
4
9
  require 'time'
5
10
  require 'validatable'
6
11
 
7
12
  # Concurrency
8
- require File.join(File.dirname(__FILE__), 'vendor', 'parallel', 'parallel.rb')
13
+ require File.join(File.dirname(__FILE__), 'vendor', 'parallel.rb')
9
14
 
10
15
  # Namespace junkie
11
16
  module Flickr
12
- MAX_THREADS = 5
17
+ MAX_THREADS = 50
13
18
  end
14
19
 
15
20
  # Classes
@@ -35,7 +35,7 @@ class Flickr::Photo < Flickr::Base
35
35
 
36
36
  def sizes
37
37
  hash = {}
38
- (Flickr::Query.new(user_id).execute('flickr.photos.getSizes', :photo_id => id)/:size).each do |size|
38
+ (Flickr::Query.new(user_id).execute('flickr.photos.getSizes', :photo_id => id)/:size).parallel_each(Flickr::MAX_THREADS) do |size|
39
39
  hash[size['label'].downcase.to_sym] = Size.new(*%w(width height source url).map{|a| size[a]})
40
40
  end
41
41
  hash
@@ -26,7 +26,7 @@ class Flickr::PhotoSet < Flickr::Base
26
26
  # > photosets.getPhotos (1 call)
27
27
  # > Photo.find ID (n calls)
28
28
  def photos
29
- (Flickr::Query.new(user_id).execute('flickr.photosets.getPhotos', :photoset_id => id)/:photo).parallel_map(Flickr::MAX_THREADS) do |photo|
29
+ return (Flickr::Query.new(user_id).execute('flickr.photosets.getPhotos', :photoset_id => id)/:photo).parallel_map(Flickr::MAX_THREADS) do |photo|
30
30
  Flickr::Photo.find user_id, photo[:id]
31
31
  end
32
32
  end
@@ -27,7 +27,7 @@ class Flickr::User < Flickr::Base
27
27
  get_info.at(:realname).inner_text
28
28
  end
29
29
 
30
- # The psyical location string as entered in flickr
30
+ # The location string as entered in flickr
31
31
  def location
32
32
  get_info.at(:location).inner_text || "Unknown"
33
33
  end
@@ -37,6 +37,15 @@ class Flickr::User < Flickr::Base
37
37
  (get_info.at(:person)["ispro"] == "1") ? true : false
38
38
  end
39
39
 
40
+ # Do they have a buddy icon or not?
41
+ def buddy_icon?
42
+ (icon_server > 0) ? true : false
43
+ end
44
+
45
+ def buddy_icon_url
46
+ buddy_icon? ? "http://farm#{icon_farm}.static.flickr.com/#{icon_server}/buddyicons/#{nsid}.jpg" : "http://www.flickr.com/images/buddyicon.jpg"
47
+ end
48
+
40
49
  #
41
50
  # ==== Private methods
42
51
  #
@@ -47,4 +56,12 @@ class Flickr::User < Flickr::Base
47
56
  @info = Flickr::Query.new(@nsid).execute('flickr.people.getInfo', :user_id => nsid) unless @info
48
57
  @info
49
58
  end
59
+
60
+ def icon_server
61
+ get_info.at(:person)["iconserver"].to_i
62
+ end
63
+
64
+ def icon_farm
65
+ get_info.at(:person)["iconfarm"].to_i
66
+ end
50
67
  end
@@ -1,5 +1,5 @@
1
1
  # Stolen from http://rubyforge.org/projects/concurrent
2
-
2
+
3
3
  #
4
4
  # concurrent/parallel - data-parallel programming for Ruby
5
5
  #
@@ -7,12 +7,12 @@
7
7
  #
8
8
  # This file is made available under the same terms as Ruby.
9
9
  #
10
-
10
+
11
11
  module Concurrent #:nodoc:
12
12
  module Parallel #:nodoc:
13
13
  end
14
14
  end
15
-
15
+
16
16
  module Enumerable #:nodoc:
17
17
  def parallel_each( n, &block )
18
18
  parallel_subsets( n ).map do |slice|
@@ -22,7 +22,7 @@ module Enumerable #:nodoc:
22
22
  end
23
23
  self
24
24
  end
25
-
25
+
26
26
  def parallel_map( n, &block )
27
27
  parallel_subsets( n ).map do |slice|
28
28
  Thread.new { slice.map &block }
@@ -30,7 +30,7 @@ module Enumerable #:nodoc:
30
30
  a.push *thread.value
31
31
  end
32
32
  end
33
-
33
+
34
34
  def parallel_select( n, &block )
35
35
  parallel_subsets( n ).map do |slice|
36
36
  Thread.new { slice.select &block }
@@ -38,7 +38,7 @@ module Enumerable #:nodoc:
38
38
  a.push *thread.value
39
39
  end
40
40
  end
41
-
41
+
42
42
  def parallel_reject( n, &block )
43
43
  parallel_subsets( n ).map do |slice|
44
44
  Thread.new { slice.reject &block }
@@ -46,19 +46,19 @@ module Enumerable #:nodoc:
46
46
  a.push *thread.value
47
47
  end
48
48
  end
49
-
49
+
50
50
  def parallel_max( n )
51
51
  parallel_subsets( n ).map do |slice|
52
52
  Thread.new { slice.max }
53
53
  end.map { |t| t.value }.max
54
54
  end
55
-
55
+
56
56
  def parallel_min( n )
57
57
  parallel_subsets( n ).map do |slice|
58
58
  Thread.new { slice.min }
59
59
  end.map { |t| t.value }.min
60
60
  end
61
-
61
+
62
62
  def parallel_partition( n, &block )
63
63
  parallel_subsets( n ).map do |slice|
64
64
  Thread.new { slice.partition &block }
@@ -69,7 +69,7 @@ module Enumerable #:nodoc:
69
69
  acc
70
70
  end
71
71
  end
72
-
72
+
73
73
  def parallel_grep( re, n, &block )
74
74
  parallel_subsets( n ).map do |slice|
75
75
  Thread.new { slice.grep( re, &block ) }
@@ -77,7 +77,7 @@ module Enumerable #:nodoc:
77
77
  acc.push *thread.value
78
78
  end
79
79
  end
80
-
80
+
81
81
  def parallel_all?( n, &block )
82
82
  parallel_subsets( n ).map do |slice|
83
83
  Thread.new { slice.all? &block }
@@ -85,7 +85,7 @@ module Enumerable #:nodoc:
85
85
  acc && thread.value
86
86
  end
87
87
  end
88
-
88
+
89
89
  def parallel_any?( n, &block )
90
90
  parallel_subsets( n ).map do |slice|
91
91
  Thread.new { slice.any? &block }
@@ -93,7 +93,7 @@ module Enumerable #:nodoc:
93
93
  acc || thread.value
94
94
  end
95
95
  end
96
-
96
+
97
97
  def parallel_include?( n, obj )
98
98
  parallel_subsets( n ).map do |slice|
99
99
  Thread.new { slice.include? obj }
@@ -101,12 +101,12 @@ module Enumerable #:nodoc:
101
101
  acc || thread.value
102
102
  end
103
103
  end
104
-
104
+
105
105
  def parallel_subsets( n )
106
106
  to_a.parallel_subsets( n )
107
107
  end
108
108
  end
109
-
109
+
110
110
  class Array #:nodoc:
111
111
  def parallel_subsets( n )
112
112
  if n > 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benschwarz-flickr-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Schwarz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-10 00:00:00 -07:00
12
+ date: 2008-06-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -48,9 +48,7 @@ files:
48
48
  - lib/flickr-wrapper/photoset.rb
49
49
  - lib/flickr-wrapper/tag.rb
50
50
  - lib/flickr-wrapper/user.rb
51
- - lib/vendor
52
- - lib/vendor/parallel
53
- - lib/vendor/parallel/parallel.rb
51
+ - lib/vendor/parallel.rb
54
52
  has_rdoc: false
55
53
  homepage: http://github.com/benschwarz/flickr-wrapper
56
54
  post_install_message:
@@ -73,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
71
  requirements: []
74
72
 
75
73
  rubyforge_project:
76
- rubygems_version: 1.0.1
74
+ rubygems_version: 1.2.0
77
75
  signing_key:
78
76
  specification_version: 2
79
77
  summary: A grassroots wrapper for flickr