flickrie 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ module Flickrie
9
9
  end
10
10
 
11
11
  def [](key) @info[key] end
12
+ # @!parse attr_reader :hash
12
13
  def hash() @info end
13
14
 
14
15
  private
@@ -1,19 +1,25 @@
1
1
  module Flickrie
2
2
  module Media
3
3
  class Tag
4
+ # @!parse attr_reader :id
4
5
  def id() @info['id'] end
6
+ # @!parse attr_reader :raw
5
7
  def raw() @info['raw'] end
8
+ # @!parse attr_reader :content
6
9
  def content() @info['_content'] end
7
10
 
11
+ # @!parse attr_reader :machine_tag?
8
12
  def machine_tag?
9
13
  @info['machine_tag'].to_i == 1 if @info['machine_tag']
10
14
  end
11
15
 
16
+ # @!parse attr_reader :author
12
17
  def author
13
18
  User.new('nsid' => @info['author']) if @info['author']
14
19
  end
15
20
 
16
21
  def [](key) @info[key] end
22
+ # @!parse attr_reader :hash
17
23
  def hash() @info end
18
24
 
19
25
  private
@@ -1,12 +1,17 @@
1
1
  module Flickrie
2
2
  module Media
3
3
  class Visibility
4
+ # @!parse attr_reader :public?
4
5
  def public?() @info['ispublic'].to_i == 1 if @info['ispublic'] end
6
+ # @!parse attr_reader :friends?
5
7
  def friends?() @info['isfriend'].to_i == 1 if @info['isfriend'] end
8
+ # @!parse attr_reader :family?
6
9
  def family?() @info['isfamily'].to_i == 1 if @info['isfamily'] end
10
+ # @!parse attr_reader :contacts?
7
11
  def contacts?() @info['iscontact'].to_i == 1 if @info['iscontact'] end
8
12
 
9
13
  def [](key) @info[key] end
14
+ # @!parse attr_reader :hash
10
15
  def hash() @info end
11
16
 
12
17
  private
@@ -2,8 +2,12 @@ require 'date'
2
2
 
3
3
  module Flickrie
4
4
  class MediaCount
5
+ # @!parse attr_reader :value
5
6
  def value() Integer(@info['count']) rescue nil end
6
7
 
8
+ # @return [Range]
9
+ #
10
+ # @!parse attr_reader :date_range
7
11
  def date_range
8
12
  dates =
9
13
  case @dates_kind
@@ -19,10 +23,13 @@ module Flickrie
19
23
  end
20
24
  alias time_interval date_range
21
25
 
26
+ # @!parse attr_reader :from
22
27
  def from() date_range.begin end
28
+ # @!parse attr_reader :to
23
29
  def to() date_range.end end
24
30
 
25
31
  def [](key) @info[key] end
32
+ # @!parse attr_reader :hash
26
33
  def hash() @info end
27
34
 
28
35
  private
@@ -7,7 +7,7 @@ module Flickrie
7
7
 
8
8
  private
9
9
 
10
- def self.new_connection(request_token = nil) # :nodoc:
10
+ def self.new_connection(request_token = nil)
11
11
  Faraday.new(params) do |b|
12
12
  b.use Middleware::Retry
13
13
  b.use FaradayMiddleware::OAuth,
@@ -27,8 +27,8 @@ module Flickrie
27
27
  {
28
28
  :url => URL,
29
29
  :request => {
30
- :open_timeout => Flickrie.open_timeout || OPEN_TIMEOUT,
31
- :timeout => Flickrie.timeout || TIMEOUT
30
+ :open_timeout => Flickrie.open_timeout || DEFAULTS[:open_timeout],
31
+ :timeout => Flickrie.timeout || DEFAULTS[:timeout]
32
32
  }
33
33
  }
34
34
  end
@@ -1,5 +1,4 @@
1
1
  module Flickrie
2
- # See Flickrie::Media for the other methods.
3
2
  class Photo
4
3
  include Media
5
4
 
@@ -16,6 +15,7 @@ module Flickrie
16
15
  'Original' => 'o'
17
16
  }
18
17
 
18
+ # @!parse attr_reader :size
19
19
  def size() @size end
20
20
 
21
21
  def square!(number) @size = "Square #{number}"; self end
@@ -32,8 +32,7 @@ module Flickrie
32
32
  def large(number) dup.large!(number) end
33
33
  def original() dup.original! end
34
34
 
35
- #--
36
- # Alternate size methods
35
+ # @comment Alternate size methods
37
36
  def square75() square(75) end
38
37
  def square75!() square!(75) end
39
38
  def square150() square(150) end
@@ -58,13 +57,17 @@ module Flickrie
58
57
  SIZES.select { |_,v| @info["url_#{v}"] }.keys
59
58
  end
60
59
 
60
+ # @!parse attr_reader :width
61
61
  def width() Integer(@info["width_#{size_abbr}"]) rescue nil end
62
+ # @!parse attr_reader :height
62
63
  def height() Integer(@info["height_#{size_abbr}"]) rescue nil end
64
+ # @!parse attr_reader :source_url
63
65
  def source_url() @info["url_#{size_abbr}"] end
64
66
 
67
+ # @!parse attr_reader :rotation
65
68
  def rotation() Integer(@info['rotation']) rescue nil end
66
69
 
67
- # Same as calling <tt>Flickrie.get_photo_sizes(photo.id)</tt>
70
+ # Same as calling `Flickrie.get_photo_sizes(photo.id)`.
68
71
  def get_sizes(params = {}, info = nil)
69
72
  info ||= Flickrie.client.get_media_sizes(id, params).body['sizes']
70
73
  @info['usage'] ||= {}
data/lib/flickrie/set.rb CHANGED
@@ -1,52 +1,72 @@
1
1
  module Flickrie
2
2
  class Set
3
+ # @!parse attr_reader :id
3
4
  def id() @info['id'] end
5
+ # @!parse attr_reader :secret
4
6
  def secret() @info['secret'] end
7
+ # @!parse attr_reader :server
5
8
  def server() @info['server'] end
9
+ # @!parse attr_reader :farm
6
10
  def farm() @info['farm'] end
11
+ # @!parse attr_reader :title
7
12
  def title() @info['title'] end
13
+ # @!parse attr_reader :description
8
14
  def description() @info['description'] end
9
15
 
16
+ # @!parse attr_reader :primary_media_id
10
17
  def primary_media_id() @info['primary'] end
11
18
  alias primary_photo_id primary_media_id
12
19
  alias primary_video_id primary_media_id
13
20
 
21
+ # @!parse attr_reader :views_count
14
22
  def views_count() Integer(@info['count_views']) rescue nil end
23
+ # @!parse attr_reader :comments_count
15
24
  def comments_count() Integer(@info['count_comments']) rescue nil end
25
+ # @!parse attr_reader :photos_count
16
26
  def photos_count() Integer(@info['count_photos']) rescue nil end
27
+ # @!parse attr_reader :videos_count
17
28
  def videos_count() Integer(@info['count_videos']) rescue nil end
29
+ # @!parse attr_reader :media_count
18
30
  def media_count
19
31
  photos_count + videos_count rescue nil
20
32
  end
21
33
 
22
- # Returns an instance of Flickrie::User
34
+ # @return [Flickrie::User]
35
+ #
36
+ # @!parse attr_reader :owner
23
37
  def owner() User.new('nsid' => @info['owner']) if @info['owner'] end
24
38
 
25
- # Same as calling <tt>Flickrie.photos_from_set(set.id)</tt>
39
+ # Same as calling `Flickrie.photos_from_set(set.id)`.
26
40
  def photos(params = {}) Flickrie.photos_from_set(id, params) end
27
- # Same as calling <tt>Flickrie.videos_from_set(set.id)</tt>
41
+ # Same as calling `Flickrie.videos_from_set(set.id)`.
28
42
  def videos(params = {}) Flickrie.videos_from_set(id, params) end
29
- # Same as calling <tt>Flickrie.media_from_set(set.id)</tt>
43
+ # Same as calling `Flickrie.media_from_set(set.id)`.
30
44
  def media(params = {}) Flickrie.media_from_set(id, params) end
31
45
 
46
+ # @!parse attr_reader :can_comment?
32
47
  def can_comment?() Integer(@info['can_comment']) == 1 rescue nil end
33
48
 
34
- #--
35
- # TODO: Figure out what this is
49
+ # @comment TODO: Figure out what this is
50
+ # @!parse attr_reader :needs_interstitial?
36
51
  def needs_interstitial?() Integer(@info['needs_interstitial']) == 1 rescue nil end
52
+ # @!parse attr_reader :visibility_can_see_set?
37
53
  def visibility_can_see_set?() Integer(@info['visibility_can_see_set']) == 1 rescue nil end
38
54
 
55
+ # @!parse attr_reader :created_at
39
56
  def created_at() Time.at(Integer(@info['date_create'])) rescue nil end
57
+ # @!parse attr_reader :updated_at
40
58
  def updated_at() Time.at(Integer(@info['date_update'])) rescue nil end
41
59
 
60
+ # @!parse attr_reader :url
42
61
  def url
43
62
  "http://www.flickr.com/photos/#{owner.nsid}/sets/#{id}"
44
63
  end
45
64
 
46
65
  def [](key) @info[key] end
66
+ # @!parse attr_reader :hash
47
67
  def hash() @info end
48
68
 
49
- # Same as calling <tt>Flickrie.get_set_info(set.id)</tt>
69
+ # Same as calling `Flickrie.get_set_info(set.id)`
50
70
  def get_info(info = nil)
51
71
  info ||= Flickrie.client.get_set_info(id).body['photoset']
52
72
  @info.update(info)
@@ -1,15 +1,20 @@
1
1
  module Flickrie
2
2
  class Ticket
3
+ # @!parse attr_reader :id
3
4
  def id() @info['id'] end
5
+ # @!parse attr_reader :media_id
4
6
  def media_id() @info['photoid'] end
5
7
  alias photo_id media_id
6
8
  alias video_id media_id
7
9
 
10
+ # @!parse attr_reader :complete?
8
11
  def complete?() Integer(@info['complete']) == 1 rescue nil end
9
12
 
13
+ # @!parse attr_reader :imported_at
10
14
  def imported_at() Time.at(Integer(@info['imported'])) rescue nil end
11
15
 
12
16
  def [](key) @info[key] end
17
+ # @!parse attr_reader :hash
13
18
  def hash() @info end
14
19
 
15
20
  private
@@ -1,43 +1,7 @@
1
- require 'faraday_middleware'
1
+ require 'faraday'
2
2
 
3
3
  module Flickrie
4
- class << self
5
- # :nodoc:
6
- def upload_client
7
- @upload_client ||= new_upload_client
8
- end
9
-
10
- def new_upload_client(access_token_hash = {})
11
- UploadClient.new(upload_params) do |b|
12
- b.use Middleware::Retry
13
- b.use FaradayMiddleware::OAuth,
14
- :consumer_key => api_key,
15
- :consumer_secret => shared_secret,
16
- :token => access_token_hash[:token] || access_token,
17
- :token_secret => access_token_hash[:secret] || access_secret
18
- b.request :multipart
19
-
20
- b.use Middleware::UploadStatusCheck
21
- b.use FaradayMiddleware::ParseXml
22
- b.use Middleware::OAuthCheck
23
-
24
- b.adapter :net_http
25
- end
26
- end
27
-
28
- private
29
-
30
- def upload_params
31
- {
32
- :url => 'http://api.flickr.com/services',
33
- :request => {
34
- :open_timeout => open_timeout || OPEN_TIMEOUT
35
- }
36
- }
37
- end
38
- end
39
-
40
- class UploadClient < Faraday::Connection # :nodoc:
4
+ class UploadClient < Faraday::Connection
41
5
  def upload(media, params = {})
42
6
  file = get_file(media, params[:content_type])
43
7
  title = file.original_filename.match(/\.\w{3,4}$/).pre_match
@@ -76,7 +40,7 @@ module Flickrie
76
40
  %w[.wmv] => 'video/x-ms-wmv',
77
41
  %w[.flv .f4v .f4p .f4a .f4b] => 'video/x-flv',
78
42
  %w[.avi] => 'video/avi'
79
- }.freeze
43
+ }
80
44
 
81
45
  def get_file(object, content_type = nil)
82
46
  file, content_type, file_path =
data/lib/flickrie/user.rb CHANGED
@@ -2,16 +2,26 @@ require 'date'
2
2
 
3
3
  module Flickrie
4
4
  class User
5
+ # @!parse attr_reader :id
5
6
  def id() @info['id'] end
7
+ # @!parse attr_reader :nsid
6
8
  def nsid() @info['nsid'] end
9
+ # @!parse attr_reader :username
7
10
  def username() @info['username'] end
11
+ # @!parse attr_reader :real_name
8
12
  def real_name() @info['realname'] end
13
+ # @!parse attr_reader :location
9
14
  def location() @info['location'] end
15
+ # @!parse attr_reader :description
10
16
  def description() @info['description'] end
17
+ # @!parse attr_reader :path_alias
11
18
  def path_alias() @info['path_alias'] end
19
+ # @!parse attr_reader :icon_server
12
20
  def icon_server() @info['iconserver'] end
21
+ # @!parse attr_reader :icon_farm
13
22
  def icon_farm() @info['iconfarm'] end
14
23
 
24
+ # @!parse attr_reader :buddy_icon_url
15
25
  def buddy_icon_url
16
26
  if icon_farm
17
27
  if icon_server.to_i > 0 && (nsid || id)
@@ -22,34 +32,46 @@ module Flickrie
22
32
  end
23
33
  end
24
34
 
25
- # ==== Example
35
+ # Returns the time zone of the user. Example:
26
36
  #
27
- # user.time_zone.offset # => "+01:00"
28
- # user.time_zone.label # => "Sarajevo, Skopje, Warsaw, Zagreb"
37
+ # user.time_zone.offset # => "+01:00"
38
+ # user.time_zone.label # => "Sarajevo, Skopje, Warsaw, Zagreb"
39
+ #
40
+ # @!parse attr_reader :time_zone
29
41
  def time_zone() Struct.new(:label, :offset).new(*@info['timezone'].values) rescue nil end
30
42
 
43
+ # @!parse attr_reader :photos_url
31
44
  def photos_url() @info['photosurl'] || "http://www.flickr.com/photos/#{nsid || id}" end
45
+ # @!parse attr_reader :profile_url
32
46
  def profile_url() @info['profileurl'] || "http://www.flickr.com/people/#{nsid || id}" end
47
+ # @!parse attr_reader :mobile_url
33
48
  def mobile_url() @info['mobileurl'] end
34
49
 
50
+ # @!parse attr_reader :first_taken
35
51
  def first_taken() DateTime.parse(@info['photos']['firstdatetaken']).to_time rescue nil end
52
+ # @!parse attr_reader :first_uploaded
36
53
  def first_uploaded() Time.at(Integer(@info['photos']['firstdate'])) rescue nil end
37
54
 
55
+ # @!parse attr_reader :favorited_at
38
56
  def favorited_at() Time.at(Integer(@info['favedate'])) rescue nil end
39
57
 
58
+ # @!parse attr_reader :media_count
40
59
  def media_count() Integer(@info['photos']['count']) rescue nil end
41
60
  alias photos_count media_count
42
61
  alias videos_count media_count
43
62
 
44
- # The same as calling <tt>Flickrie.public_photos_from_user(user.nsid)</tt>
45
- def public_photos() Flickrie.public_photos_from_user(nsid || id) end
63
+ # @comment TODO: public videos, media and without public
64
+ # The same as calling `Flickrie.public_photos_from_user(user.nsid)`
65
+ def public_photos(params = {}) Flickrie.public_photos_from_user(nsid || id, params) end
46
66
 
67
+ # @!parse attr_reader :pro?
47
68
  def pro?() Integer(@info['ispro']) == 1 rescue nil end
48
69
 
49
70
  def [](key) @info[key] end
71
+ # @!parse attr_reader :hash
50
72
  def hash() @info end
51
73
 
52
- # The same as calling <tt>Flickrie.get_user_info(user.nsid)</tt>
74
+ # The same as calling `Flickrie.get_user_info(user.nsid)`
53
75
  def get_info(params = {}, info = nil)
54
76
  info ||= Flickrie.client.get_user_info(nsid || id, params).body['person']
55
77
  @info.update(info)
@@ -1,3 +1,3 @@
1
1
  module Flickrie
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -1,22 +1,30 @@
1
1
  module Flickrie
2
- # See Flickrie::Media for the other methods.
3
2
  class Video
4
3
  include Media
5
4
 
5
+ # @!parse attr_reader :ready?
6
6
  def ready?() Integer(@video['ready']) == 1 rescue nil end
7
+ # @!parse attr_reader :failed?
7
8
  def failed?() Integer(@video['failed']) == 1 rescue nil end
9
+ # @!parse attr_reader :pending?
8
10
  def pending?() Integer(@video['pending']) == 1 rescue nil end
9
11
 
12
+ # @!parse attr_reader :duration
10
13
  def duration() Integer(@video['duration']) rescue nil end
11
14
 
15
+ # @!parse attr_reader :width
12
16
  def width() Integer(@video['width']) rescue nil end
17
+ # @!parse attr_reader :height
13
18
  def height() Integer(@video['height']) rescue nil end
14
19
 
20
+ # @!parse attr_reader :source_url
15
21
  def source_url() @video['source_url'] end
22
+ # @!parse attr_reader :download_url
16
23
  def download_url() @video['download_url'] end
24
+ # @!parse attr_reader :mobile_download_url
17
25
  def mobile_download_url() @video['mobile_download_url'] end
18
26
 
19
- # This fetches the #source_url, #download_url and the #mobile_download_url
27
+ # This fetches the {#source\_url}, {#download\_url} and the {#mobile\_download\_url}
20
28
  def get_sizes(params = {}, info = nil)
21
29
  info ||= Flickrie.client.get_media_sizes(id, params).body['sizes']
22
30
  @info['usage'] ||= {}
@@ -35,6 +43,7 @@ module Flickrie
35
43
  self
36
44
  end
37
45
 
46
+ # Same as calling `Flickrie.get_video_info(video.id)`.
38
47
  def get_info(params = {}, info = nil)
39
48
  super
40
49
  @video = @info['video']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickrie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-18 00:00:00.000000000 Z
12
+ date: 2012-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday_middleware
16
- requirement: &70222671050620 !ruby/object:Gem::Requirement
16
+ requirement: &70204420077060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '0.9'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *70222671050620
27
+ version_requirements: *70204420077060
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: faraday
30
- requirement: &70222671049860 !ruby/object:Gem::Requirement
30
+ requirement: &70204420071080 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -38,10 +38,10 @@ dependencies:
38
38
  version: '0.9'
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *70222671049860
41
+ version_requirements: *70204420071080
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: simple_oauth
44
- requirement: &70222671049120 !ruby/object:Gem::Requirement
44
+ requirement: &70204420084940 !ruby/object:Gem::Requirement
45
45
  none: false
46
46
  requirements:
47
47
  - - ~>
@@ -49,10 +49,10 @@ dependencies:
49
49
  version: '0.1'
50
50
  type: :runtime
51
51
  prerelease: false
52
- version_requirements: *70222671049120
52
+ version_requirements: *70204420084940
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: multi_xml
55
- requirement: &70222671048580 !ruby/object:Gem::Requirement
55
+ requirement: &70204420082980 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ~>
@@ -60,10 +60,10 @@ dependencies:
60
60
  version: '0.4'
61
61
  type: :runtime
62
62
  prerelease: false
63
- version_requirements: *70222671048580
63
+ version_requirements: *70204420082980
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: rake
66
- requirement: &70222671048060 !ruby/object:Gem::Requirement
66
+ requirement: &70204420081920 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
69
  - - ~>
@@ -71,10 +71,10 @@ dependencies:
71
71
  version: '0.9'
72
72
  type: :development
73
73
  prerelease: false
74
- version_requirements: *70222671048060
74
+ version_requirements: *70204420081920
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec
77
- requirement: &70222671047560 !ruby/object:Gem::Requirement
77
+ requirement: &70204420080800 !ruby/object:Gem::Requirement
78
78
  none: false
79
79
  requirements:
80
80
  - - ! '>='
@@ -82,10 +82,10 @@ dependencies:
82
82
  version: '2'
83
83
  type: :development
84
84
  prerelease: false
85
- version_requirements: *70222671047560
85
+ version_requirements: *70204420080800
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: vcr
88
- requirement: &70222671047100 !ruby/object:Gem::Requirement
88
+ requirement: &70204420078420 !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - ~>
@@ -93,7 +93,7 @@ dependencies:
93
93
  version: '2.1'
94
94
  type: :development
95
95
  prerelease: false
96
- version_requirements: *70222671047100
96
+ version_requirements: *70204420078420
97
97
  description: This gem wraps the Flickr API with a nice object-oriented interface.
98
98
  email: janko.marohnic@gmail.com
99
99
  executables: []
@@ -102,6 +102,7 @@ extra_rdoc_files: []
102
102
  files:
103
103
  - .gitignore
104
104
  - .travis.yml
105
+ - .yardopts
105
106
  - CHANGELOG.md
106
107
  - Gemfile
107
108
  - LICENSE
@@ -195,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
196
  version: '0'
196
197
  segments:
197
198
  - 0
198
- hash: -4564017980712664051
199
+ hash: 3443351439038173602
199
200
  requirements: []
200
201
  rubyforge_project:
201
202
  rubygems_version: 1.8.11