flickrie 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +5 -0
- data/LICENSE +22 -0
- data/README.md +151 -0
- data/Rakefile +18 -0
- data/finished_api_methods.md +84 -0
- data/flickrie.gemspec +20 -0
- data/lib/flickrie/client.rb +103 -0
- data/lib/flickrie/license.rb +38 -0
- data/lib/flickrie/location.rb +62 -0
- data/lib/flickrie/media/note.rb +23 -0
- data/lib/flickrie/media/visibility.rb +14 -0
- data/lib/flickrie/media.rb +254 -0
- data/lib/flickrie/photo.rb +109 -0
- data/lib/flickrie/set.rb +89 -0
- data/lib/flickrie/user.rb +84 -0
- data/lib/flickrie/version.rb +3 -0
- data/lib/flickrie/video.rb +62 -0
- data/lib/flickrie.rb +98 -0
- data/test/client_test.rb +41 -0
- data/test/license_test.rb +30 -0
- data/test/location_test.rb +21 -0
- data/test/media_test.rb +309 -0
- data/test/photo_test.rb +149 -0
- data/test/set_test.rb +85 -0
- data/test/user_test.rb +63 -0
- data/test/video_test.rb +69 -0
- metadata +106 -0
data/test/set_test.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test/unit'
|
3
|
+
require 'flickrie'
|
4
|
+
|
5
|
+
Flickrie::Set.instance_eval do
|
6
|
+
def public_new(*args)
|
7
|
+
new(*args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class SetTest < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
14
|
+
@set_id = 72157629851991663
|
15
|
+
@user_nsid = '67131352@N04'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_set_info
|
19
|
+
get_info_assertions(Flickrie.get_set_info(@set_id))
|
20
|
+
get_info_assertions(Flickrie::Set.public_new('id' => @set_id.to_s).get_info)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_info_assertions(set)
|
24
|
+
assert_equal @set_id, set.id.to_i
|
25
|
+
assert_equal @user_nsid, set.owner.nsid
|
26
|
+
assert_equal '6946979188', set.primary_media_id
|
27
|
+
assert_equal '25bb44852b', set.secret
|
28
|
+
assert_equal '7049', set.server
|
29
|
+
assert_equal 8, set.farm
|
30
|
+
assert_equal 'Speleologija', set.title
|
31
|
+
assert_equal 'Slike sa škole speleologije Velebit.', set.description
|
32
|
+
|
33
|
+
assert_equal 99, set.media_count
|
34
|
+
assert_equal 98, set.photos_count
|
35
|
+
assert_equal 1, set.videos_count
|
36
|
+
assert_equal 0, set.comments_count
|
37
|
+
assert_equal 0, set.views_count
|
38
|
+
|
39
|
+
assert set.photos.all? { |photo| photo.is_a?(Flickrie::Photo) }
|
40
|
+
assert set.videos.all? { |video| video.is_a?(Flickrie::Video) }
|
41
|
+
assert set.media.find { |media| media.is_a?(Flickrie::Photo) }
|
42
|
+
assert set.media.find { |media| media.is_a?(Flickrie::Video) }
|
43
|
+
|
44
|
+
assert_equal false, set.can_comment?
|
45
|
+
|
46
|
+
assert_instance_of Time, set.created_at
|
47
|
+
assert_instance_of Time, set.updated_at
|
48
|
+
|
49
|
+
refute set.url.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_sets_from_user
|
53
|
+
set = Flickrie.sets_from_user(@user_nsid).
|
54
|
+
find { |set| set.id.to_i == @set_id }
|
55
|
+
|
56
|
+
assert_equal @set_id, set.id.to_i
|
57
|
+
assert_equal @user_nsid, set.owner.nsid
|
58
|
+
assert_equal '6946979188', set.primary_media_id
|
59
|
+
assert_equal '25bb44852b', set.secret
|
60
|
+
assert_equal '7049', set.server
|
61
|
+
assert_equal 8, set.farm
|
62
|
+
assert_equal 'Speleologija', set.title
|
63
|
+
assert_equal 'Slike sa škole speleologije Velebit.', set.description
|
64
|
+
|
65
|
+
assert_equal 99, set.media_count
|
66
|
+
assert_equal 98, set.photos_count
|
67
|
+
assert_equal 1, set.videos_count
|
68
|
+
assert_equal 0, set.comments_count
|
69
|
+
assert_equal 0, set.views_count
|
70
|
+
|
71
|
+
assert set.photos.all? { |photo| photo.is_a?(Flickrie::Photo) }
|
72
|
+
assert set.videos.all? { |video| video.is_a?(Flickrie::Video) }
|
73
|
+
assert set.media.find { |media| media.is_a?(Flickrie::Photo) }
|
74
|
+
assert set.media.find { |media| media.is_a?(Flickrie::Video) }
|
75
|
+
|
76
|
+
assert_equal false, set.can_comment?
|
77
|
+
assert_equal false, set.needs_interstitial?
|
78
|
+
assert_equal true, set.visibility_can_see_set?
|
79
|
+
|
80
|
+
assert_instance_of Time, set.created_at
|
81
|
+
assert_instance_of Time, set.updated_at
|
82
|
+
|
83
|
+
refute set.url.empty?
|
84
|
+
end
|
85
|
+
end
|
data/test/user_test.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test/unit'
|
3
|
+
require 'flickrie'
|
4
|
+
|
5
|
+
Flickrie::User.instance_eval do
|
6
|
+
def public_new(*args)
|
7
|
+
new(*args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class UserTest < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
14
|
+
@user_nsid = '67131352@N04'
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_get_user_info
|
18
|
+
get_info_assertions(Flickrie.get_user_info(@user_nsid))
|
19
|
+
get_info_assertions(Flickrie::User.public_new('nsid' => @user_nsid).get_info)
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_info_assertions(user)
|
23
|
+
assert_equal @user_nsid, user.id
|
24
|
+
assert_equal @user_nsid, user.nsid
|
25
|
+
assert_equal 'Janko Marohnić', user.username
|
26
|
+
assert_equal 'Janko Marohnić', user.real_name
|
27
|
+
assert_equal 'Zagreb, Croatia', user.location
|
28
|
+
assert_equal 'Sarajevo, Skopje, Warsaw, Zagreb', user.time_zone['label']
|
29
|
+
assert_equal '+01:00', user.time_zone['offset']
|
30
|
+
assert_equal <<-DESCRIPTION.chomp, user.description
|
31
|
+
I'm a programmer, and I'm gonna program a badass Ruby library for Flickr.
|
32
|
+
DESCRIPTION
|
33
|
+
|
34
|
+
refute user.profile_url.empty?
|
35
|
+
refute user.mobile_url.empty?
|
36
|
+
refute user.photos_url.empty?
|
37
|
+
|
38
|
+
assert_equal '5464', user.icon_server
|
39
|
+
assert_equal 6, user.icon_farm
|
40
|
+
refute user.buddy_icon_url.empty?
|
41
|
+
|
42
|
+
assert_equal false, user.pro?
|
43
|
+
|
44
|
+
assert_instance_of Time, user.first_taken
|
45
|
+
assert_instance_of Time, user.first_uploaded
|
46
|
+
|
47
|
+
assert_equal 99, user.media_count
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_find_user_by_username_or_email
|
51
|
+
user = Flickrie.find_user_by_username('Janko Marohnić')
|
52
|
+
|
53
|
+
assert_equal @user_nsid, user.id
|
54
|
+
assert_equal @user_nsid, user.nsid
|
55
|
+
assert_equal 'Janko Marohnić', user.username
|
56
|
+
|
57
|
+
user = Flickrie.find_user_by_email('janko.marohnic@gmail.com')
|
58
|
+
|
59
|
+
assert_equal @user_nsid, user.id
|
60
|
+
assert_equal @user_nsid, user.nsid
|
61
|
+
assert_equal 'Janko Marohnić', user.username
|
62
|
+
end
|
63
|
+
end
|
data/test/video_test.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test/unit'
|
3
|
+
require 'flickrie'
|
4
|
+
|
5
|
+
Flickrie::Video.instance_eval do
|
6
|
+
def public_new(*args)
|
7
|
+
new(*args)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class VideoTest < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
14
|
+
@video_id = 7093038981
|
15
|
+
@set_id = 72157629851991663
|
16
|
+
@user_nsid = '67131352@N04'
|
17
|
+
|
18
|
+
# license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_sq,url_q,url_t,url_s,url_n,url_m,url_z,url_c,url_l,url_o
|
19
|
+
@all_extras = %w[license date_upload date_taken owner_name
|
20
|
+
icon_server original_format last_update geo tags machine_tags
|
21
|
+
o_dims views media path_alias
|
22
|
+
url_sq url_q url_t url_s url_n url_m url_z url_c url_l url_o]
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_video_info
|
26
|
+
video = Flickrie.get_video_info(@video_id)
|
27
|
+
|
28
|
+
assert_equal true, video.ready?
|
29
|
+
assert_equal false, video.failed?
|
30
|
+
assert_equal false, video.pending?
|
31
|
+
|
32
|
+
assert_equal 16, video.duration
|
33
|
+
assert_equal 352, video.width
|
34
|
+
assert_equal 288, video.height
|
35
|
+
|
36
|
+
assert_nil video.source_url
|
37
|
+
assert_nil video.download_url
|
38
|
+
assert_nil video.mobile_download_url
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_get_video_sizes
|
42
|
+
get_sizes_assertions(Flickrie.get_video_sizes(@video_id))
|
43
|
+
get_sizes_assertions(Flickrie::Video.public_new('id' => @video_id.to_s).get_sizes)
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_sizes_assertions(video)
|
47
|
+
assert_equal true, video.can_download?
|
48
|
+
assert_equal false, video.can_blog?
|
49
|
+
assert_equal false, video.can_print?
|
50
|
+
|
51
|
+
refute video.source_url.empty?
|
52
|
+
refute video.download_url.empty?
|
53
|
+
refute video.mobile_download_url.empty?
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_methods_returning_nil
|
57
|
+
video = Flickrie::Video.new
|
58
|
+
|
59
|
+
assert_nil video.ready?
|
60
|
+
assert_nil video.failed?
|
61
|
+
assert_nil video.pending?
|
62
|
+
assert_nil video.duration
|
63
|
+
assert_nil video.width
|
64
|
+
assert_nil video.height
|
65
|
+
assert_nil video.source_url
|
66
|
+
assert_nil video.download_url
|
67
|
+
assert_nil video.mobile_download_url
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flickrie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Janko Marohnić
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday-stack
|
16
|
+
requirement: &70204839380140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70204839380140
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activesupport
|
27
|
+
requirement: &70204839379620 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70204839379620
|
36
|
+
description: This gem is a nice wrapper for the Flickr API an intuitive interface.
|
37
|
+
email:
|
38
|
+
- janko.marohnic@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- finished_api_methods.md
|
49
|
+
- flickrie.gemspec
|
50
|
+
- lib/flickrie.rb
|
51
|
+
- lib/flickrie/client.rb
|
52
|
+
- lib/flickrie/license.rb
|
53
|
+
- lib/flickrie/location.rb
|
54
|
+
- lib/flickrie/media.rb
|
55
|
+
- lib/flickrie/media/note.rb
|
56
|
+
- lib/flickrie/media/visibility.rb
|
57
|
+
- lib/flickrie/photo.rb
|
58
|
+
- lib/flickrie/set.rb
|
59
|
+
- lib/flickrie/user.rb
|
60
|
+
- lib/flickrie/version.rb
|
61
|
+
- lib/flickrie/video.rb
|
62
|
+
- test/client_test.rb
|
63
|
+
- test/license_test.rb
|
64
|
+
- test/location_test.rb
|
65
|
+
- test/media_test.rb
|
66
|
+
- test/photo_test.rb
|
67
|
+
- test/set_test.rb
|
68
|
+
- test/user_test.rb
|
69
|
+
- test/video_test.rb
|
70
|
+
homepage: https://github.com/janko-m/flickrie
|
71
|
+
licenses: []
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.8.11
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: The reason why I did this gem is because the other ones either weren't well
|
94
|
+
maintained, or they were too literal in the sense that the response from the API
|
95
|
+
call wasn't processed almost at all. It doesn't seem too bad at first, but after
|
96
|
+
a while you realize it's not pretty. So I wanted to make it pretty :)
|
97
|
+
test_files:
|
98
|
+
- test/client_test.rb
|
99
|
+
- test/license_test.rb
|
100
|
+
- test/location_test.rb
|
101
|
+
- test/media_test.rb
|
102
|
+
- test/photo_test.rb
|
103
|
+
- test/set_test.rb
|
104
|
+
- test/user_test.rb
|
105
|
+
- test/video_test.rb
|
106
|
+
has_rdoc:
|