flickrie 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/flickrie.gemspec +1 -1
- data/lib/flickrie/version.rb +1 -1
- metadata +22 -150
- data/.gitignore +0 -10
- data/.travis.yml +0 -4
- data/.yardopts +0 -11
- data/CHANGELOG.md +0 -139
- data/Gemfile +0 -9
- data/Rakefile +0 -60
- data/spec/custom_matchers.rb +0 -51
- data/spec/files/photo.bla +0 -0
- data/spec/files/photo.jpg +0 -0
- data/spec/files/video.mov +0 -0
- data/spec/flickrie/api_methods_spec.rb +0 -124
- data/spec/flickrie/error_spec.rb +0 -26
- data/spec/flickrie/instance_spec.rb +0 -17
- data/spec/flickrie/license_spec.rb +0 -15
- data/spec/flickrie/location_spec.rb +0 -24
- data/spec/flickrie/media_count_spec.rb +0 -22
- data/spec/flickrie/media_spec.rb +0 -292
- data/spec/flickrie/oauth_spec.rb +0 -25
- data/spec/flickrie/photo_spec.rb +0 -132
- data/spec/flickrie/set_spec.rb +0 -76
- data/spec/flickrie/upload_client_spec.rb +0 -43
- data/spec/flickrie/user_spec.rb +0 -84
- data/spec/flickrie/video_spec.rb +0 -52
- data/spec/flickrie_spec.rb +0 -15
- data/spec/spec_helper.rb +0 -71
- data/spec/vcr_cassettes/api_methods/people/get_media_from_user.yml +0 -108
- data/spec/vcr_cassettes/api_methods/people/get_public_media_from_user.yml +0 -108
- data/spec/vcr_cassettes/api_methods/photos/add_and_remove_tags.yml +0 -528
- data/spec/vcr_cassettes/api_methods/photos/get_context.yml +0 -108
- data/spec/vcr_cassettes/api_methods/photos/get_counts.yml +0 -108
- data/spec/vcr_cassettes/api_methods/photos/get_exif.yml +0 -73
- data/spec/vcr_cassettes/api_methods/photos/get_favorites.yml +0 -73
- data/spec/vcr_cassettes/api_methods/photos/get_from_contacts.yml +0 -73
- data/spec/vcr_cassettes/api_methods/photos/get_info.yml +0 -108
- data/spec/vcr_cassettes/api_methods/photos/get_public_from_user_contacts.yml +0 -73
- data/spec/vcr_cassettes/api_methods/photos/get_sizes.yml +0 -73
- data/spec/vcr_cassettes/api_methods/photos/search.yml +0 -108
- data/spec/vcr_cassettes/api_methods/photosets/get_media.yml +0 -108
- data/spec/vcr_cassettes/api_methods/upload/replace.yml +0 -126
- data/spec/vcr_cassettes/api_methods/upload/upload.yml +0 -82
- data/spec/vcr_cassettes/api_methods/upload/upload_asynchronously.yml +0 -117
- data/spec/vcr_cassettes/error/a_request_was_made_and_failed/be_raised.yml +0 -84
- data/spec/vcr_cassettes/error/a_request_was_made_and_failed/have_code_attribute_present.yml +0 -84
- data/spec/vcr_cassettes/flickrie/a_new_credential_is_filled_in/reset_the_client.yml +0 -233
- data/spec/vcr_cassettes/instance/client_is_already_initialized/be_able_to_call_API_methods.yml +0 -152
- data/spec/vcr_cassettes/license/get/have_all_attributes_correctly_set.yml +0 -38
- data/spec/vcr_cassettes/media/from_contacts/have_all_attributes_correctly_set.yml +0 -73
- data/spec/vcr_cassettes/media/from_set/have_all_attributes_correctly_set.yml +0 -38
- data/spec/vcr_cassettes/media/from_user/have_all_attributes_correctly_set.yml +0 -38
- data/spec/vcr_cassettes/media/get_context/have_all_attributes_correctly_set.yml +0 -38
- data/spec/vcr_cassettes/media/get_exif/get_exif_correctly.yml +0 -73
- data/spec/vcr_cassettes/media/get_info/have_all_attributes_correctly_set.yml +0 -108
- data/spec/vcr_cassettes/media/public_from_user/have_all_attributes_correctly_set.yml +0 -38
- data/spec/vcr_cassettes/media/search/have_all_attributes_correctly_set.yml +0 -38
- data/spec/vcr_cassettes/media_count/get/have_correctly_set_all_attributes.yml +0 -73
- data/spec/vcr_cassettes/o_auth/incorrect_credentials/raise_exceptions.yml +0 -249
- data/spec/vcr_cassettes/photo/get_info/have_all_attributes_correctly_set.yml +0 -38
- data/spec/vcr_cassettes/photo/get_sizes/have_attributes_correctly_set.yml +0 -73
- data/spec/vcr_cassettes/photo/search/have_all_sizes_available.yml +0 -38
- data/spec/vcr_cassettes/set/from_user/have_all_attributes_correctly_set.yml +0 -143
- data/spec/vcr_cassettes/set/get_info/have_all_attributes_correctly_set.yml +0 -283
- data/spec/vcr_cassettes/upload_client/content_type/pass_the_content_type.yml +0 -117
- data/spec/vcr_cassettes/upload_client/invalid_credentials/raise_errors.yml +0 -276
- data/spec/vcr_cassettes/user/find_by_username_or_email/have_all_attributes_correctly_set.yml +0 -73
- data/spec/vcr_cassettes/user/get_info/have_all_attributes_correctly_set.yml +0 -73
- data/spec/vcr_cassettes/video/get_info/have_all_attributes_correctly_set.yml +0 -38
- data/spec/vcr_cassettes/video/get_sizes/have_all_attributes_correctly_set.yml +0 -73
data/spec/flickrie/set_spec.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Flickrie::Set do
|
5
|
-
before(:all) do
|
6
|
-
@attributes = {
|
7
|
-
:id => SET_ID,
|
8
|
-
:secret => '25bb44852b',
|
9
|
-
:server => '7049',
|
10
|
-
:farm => 8,
|
11
|
-
:title => 'Speleologija',
|
12
|
-
:description => 'Slike sa škole speleologije Velebit.',
|
13
|
-
:primary_media_id => PHOTO_ID,
|
14
|
-
:primary_photo_id => PHOTO_ID,
|
15
|
-
:primary_video_id => PHOTO_ID,
|
16
|
-
:comments_count => 0,
|
17
|
-
:photos_count => 97,
|
18
|
-
:videos_count => 1,
|
19
|
-
:media_count => 98,
|
20
|
-
:owner => {
|
21
|
-
:nsid => USER_NSID
|
22
|
-
}
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_common_attributes(set)
|
27
|
-
@attributes.keys.each do |attribute|
|
28
|
-
set.send(attribute).should correspond_to(@attributes[attribute])
|
29
|
-
end
|
30
|
-
|
31
|
-
set.photos.each { |object| object.should be_a_photo }
|
32
|
-
set.videos.each { |object| object.should be_a_video }
|
33
|
-
set.media.each { |object| object.should be_a_media }
|
34
|
-
|
35
|
-
# Time
|
36
|
-
set.created_at.should be_an_instance_of(Time)
|
37
|
-
set.updated_at.should be_an_instance_of(Time)
|
38
|
-
|
39
|
-
# Other
|
40
|
-
set.url.should_not be_empty
|
41
|
-
set.views_count.should be_a_number
|
42
|
-
set.can_comment?.should be_a_boolean
|
43
|
-
end
|
44
|
-
|
45
|
-
context "get info" do
|
46
|
-
it "should have all attributes correctly set", :vcr do
|
47
|
-
[
|
48
|
-
Flickrie.get_set_info(SET_ID),
|
49
|
-
Flickrie::Set.public_new('id' => SET_ID).get_info
|
50
|
-
].
|
51
|
-
each { |set| test_common_attributes(set) }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "from user" do
|
56
|
-
it "should have all attributes correctly set", :vcr do
|
57
|
-
set = Flickrie.sets_from_user(USER_NSID).find { |set| set.id == SET_ID }
|
58
|
-
test_common_attributes(set)
|
59
|
-
set.needs_interstitial?.should be_false
|
60
|
-
set.visibility_can_see_set?.should be_true
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "blank set" do
|
65
|
-
it "should have all attributes equal to nil" do
|
66
|
-
attributes = Flickrie::Set.instance_methods -
|
67
|
-
Object.instance_methods -
|
68
|
-
[:photos, :videos, :media, :[], :get_info]
|
69
|
-
set = Flickrie::Set.public_new
|
70
|
-
|
71
|
-
attributes.each do |attribute|
|
72
|
-
set.send(attribute).should be_nil
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Flickrie::UploadClient do
|
4
|
-
context "content type" do
|
5
|
-
it "should pass the content type", :vcr do
|
6
|
-
photo_path = File.expand_path("../../files/photo.bla", __FILE__)
|
7
|
-
photo_id = Flickrie.upload(photo_path, :content_type => "image/jpeg")
|
8
|
-
Flickrie.photos_from_user(USER_NSID).map(&:id).should include(photo_id)
|
9
|
-
Flickrie.delete_photo(photo_id)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should raise an error on unknown content type", :vcr do
|
13
|
-
photo_path = File.expand_path("../../files/photo.bla", __FILE__)
|
14
|
-
expect { Flickrie.upload(photo_path) }.to raise_error(Flickrie::Error)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "invalid credentials" do
|
19
|
-
it "should raise errors", :vcr do
|
20
|
-
Flickrie.api_key = nil
|
21
|
-
Flickrie.shared_secret = nil
|
22
|
-
Flickrie.access_token = nil
|
23
|
-
Flickrie.access_secret = nil
|
24
|
-
|
25
|
-
expect { Flickrie.upload(PHOTO_PATH) }.to raise_error(Flickrie::Error)
|
26
|
-
|
27
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
28
|
-
expect { Flickrie.upload(PHOTO_PATH) }.to raise_error(Flickrie::Error)
|
29
|
-
|
30
|
-
Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
|
31
|
-
expect { Flickrie.upload(PHOTO_PATH) }.to raise_error(Flickrie::Error)
|
32
|
-
|
33
|
-
Flickrie.access_token = ENV['FLICKR_ACCESS_TOKEN']
|
34
|
-
expect { Flickrie.upload(PHOTO_PATH) }.to raise_error(Flickrie::Error)
|
35
|
-
|
36
|
-
Flickrie.access_secret = ENV['FLICKR_ACCESS_SECRET']
|
37
|
-
expect { Flickrie.upload(PHOTO_PATH) }.to_not raise_error
|
38
|
-
|
39
|
-
photo = Flickrie.photos_from_user(USER_NSID).find { |photo| photo.title == "photo" }
|
40
|
-
Flickrie.delete_photo(photo.id)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/spec/flickrie/user_spec.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Flickrie::User do
|
4
|
-
before(:all) do
|
5
|
-
@attributes = {
|
6
|
-
:id => USER_NSID,
|
7
|
-
:nsid => USER_NSID,
|
8
|
-
:username => USER_USERNAME,
|
9
|
-
:real_name => USER_USERNAME,
|
10
|
-
:location => "Zagreb, Croatia",
|
11
|
-
:time_zone => {
|
12
|
-
:label => "Sarajevo, Skopje, Warsaw, Zagreb",
|
13
|
-
:offset => "+01:00"
|
14
|
-
},
|
15
|
-
:description => "I'm a programmer, and I'm gonna program a badass Ruby library for Flickr.",
|
16
|
-
:icon_server => "5464",
|
17
|
-
:icon_farm => 6,
|
18
|
-
:pro? => false,
|
19
|
-
:media_count => 98
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
context "get info" do
|
24
|
-
it "should have all attributes correctly set", :vcr do
|
25
|
-
[
|
26
|
-
Flickrie.get_user_info(USER_NSID),
|
27
|
-
Flickrie::User.public_new('nsid' => USER_NSID).get_info
|
28
|
-
].
|
29
|
-
each do |user|
|
30
|
-
@attributes.keys.each do |attribute|
|
31
|
-
user.send(attribute).should correspond_to(@attributes[attribute])
|
32
|
-
end
|
33
|
-
|
34
|
-
[:profile_url, :mobile_url, :photos_url, :buddy_icon_url].each do |attribute|
|
35
|
-
user.send(attribute).should_not be_empty
|
36
|
-
end
|
37
|
-
|
38
|
-
[:first_taken, :first_uploaded].each do |time_attribute|
|
39
|
-
user.send(time_attribute).should be_an_instance_of(Time)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "find by username or email" do
|
46
|
-
it "should have all attributes correctly set", :vcr do
|
47
|
-
[
|
48
|
-
Flickrie.find_user_by_username(USER_USERNAME),
|
49
|
-
Flickrie.find_user_by_email(USER_EMAIL)
|
50
|
-
].
|
51
|
-
each do |user|
|
52
|
-
user.id.should == USER_NSID
|
53
|
-
user.nsid.should == USER_NSID
|
54
|
-
user.username.should == USER_USERNAME
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "getting media" do
|
60
|
-
it "should get the right kind of media", :vcr do
|
61
|
-
user = Flickrie::User.public_new('nsid' => USER_NSID)
|
62
|
-
user.public_photos.each { |object| object.should be_a_photo }
|
63
|
-
user.public_videos.each { |object| object.should be_a_video }
|
64
|
-
user.public_media.each { |object| object.should be_a_media }
|
65
|
-
user.photos.each { |object| object.should be_a_photo }
|
66
|
-
user.videos.each { |object| object.should be_a_video }
|
67
|
-
user.media.each { |object| object.should be_a_media }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "blank user" do
|
72
|
-
it "should have all attributes equal to nil" do
|
73
|
-
attributes = Flickrie::User.instance_methods -
|
74
|
-
Object.instance_methods -
|
75
|
-
[:public_photos, :public_videos, :public_media,
|
76
|
-
:photos, :videos, :media, :[], :get_info]
|
77
|
-
user = Flickrie::User.public_new
|
78
|
-
|
79
|
-
attributes.each do |attribute|
|
80
|
-
user.send(attribute).should be_nil
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/spec/flickrie/video_spec.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Flickrie::Video do
|
4
|
-
context "get info" do
|
5
|
-
it "should have all attributes correctly set", :vcr do
|
6
|
-
video = Flickrie.get_video_info(VIDEO_ID)
|
7
|
-
|
8
|
-
video.ready?.should be_true
|
9
|
-
video.failed?.should be_false
|
10
|
-
video.pending?.should be_false
|
11
|
-
|
12
|
-
video.duration.should == 16
|
13
|
-
video.width.should == 352
|
14
|
-
video.height.should == 288
|
15
|
-
|
16
|
-
video.source_url.should be_nil
|
17
|
-
video.download_url.should be_nil
|
18
|
-
video.mobile_download_url.should be_nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "get sizes" do
|
23
|
-
it "should have all attributes correctly set", :vcr do
|
24
|
-
[
|
25
|
-
Flickrie.get_video_sizes(VIDEO_ID),
|
26
|
-
Flickrie::Video.public_new('id' => VIDEO_ID).get_sizes
|
27
|
-
].
|
28
|
-
each do |video|
|
29
|
-
[:can_download?, :can_blog?, :can_print?].each do |attribute|
|
30
|
-
video.send(attribute).should be_a_boolean
|
31
|
-
end
|
32
|
-
|
33
|
-
video.source_url.should_not be_empty
|
34
|
-
video.download_url.should_not be_empty
|
35
|
-
video.mobile_download_url.should_not be_empty
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "blank" do
|
41
|
-
it "should have attributes equal to nil" do
|
42
|
-
attributes = Flickrie::Video.instance_methods -
|
43
|
-
Flickrie::Media.instance_methods -
|
44
|
-
Object.instance_methods -
|
45
|
-
[:get_info, :get_sizes, :[]]
|
46
|
-
video = Flickrie::Video.public_new
|
47
|
-
attributes.each do |attribute|
|
48
|
-
video.send(attribute).should be_nil
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/spec/flickrie_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
describe Flickrie do
|
2
|
-
context "a new credential is filled in" do
|
3
|
-
it "should reset the client", :vcr do
|
4
|
-
Flickrie.api_key = nil
|
5
|
-
expect { Flickrie.get_licenses }.to raise_error(Flickrie::Error)
|
6
|
-
expect { Flickrie.upload(PHOTO_PATH) }.to raise_error(Flickrie::Error)
|
7
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
8
|
-
expect { Flickrie.get_licenses }.to_not raise_error(Flickrie::Error)
|
9
|
-
expect { Flickrie.upload(PHOTO_PATH) }.to_not raise_error(Flickrie::Error)
|
10
|
-
|
11
|
-
photo = Flickrie.photos_from_user(USER_NSID).find { |photo| photo.title == "photo" }
|
12
|
-
Flickrie.delete_photo(photo.id)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'flickrie'
|
3
|
-
require 'vcr'
|
4
|
-
begin require 'debugger'; rescue LoadError; end
|
5
|
-
require 'custom_matchers'
|
6
|
-
|
7
|
-
RSpec.configure do |c|
|
8
|
-
c.before(:all) do
|
9
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
10
|
-
Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
|
11
|
-
Flickrie.access_token = ENV['FLICKR_ACCESS_TOKEN']
|
12
|
-
Flickrie.access_secret = ENV['FLICKR_ACCESS_SECRET']
|
13
|
-
end
|
14
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
15
|
-
c.around(:each, :vcr) do |example|
|
16
|
-
# If you want to tag an example with :vcr, you have to wrap it in a context block
|
17
|
-
klass = example.metadata[:example_group][:example_group][:description_args].first
|
18
|
-
folder = klass.to_s.split('::').last.split(/(?=[A-Z])/).map(&:downcase).join('_')
|
19
|
-
subfolder = example.metadata[:example_group][:description_args].first
|
20
|
-
cassette_name = example.metadata[:description_args].first.match(/^should /).post_match
|
21
|
-
VCR.use_cassette("#{folder}/#{subfolder}/#{cassette_name}") { example.call }
|
22
|
-
end
|
23
|
-
c.fail_fast = true
|
24
|
-
end
|
25
|
-
|
26
|
-
VCR.configure do |c|
|
27
|
-
c.cassette_library_dir = 'spec/vcr_cassettes'
|
28
|
-
c.hook_into :faraday
|
29
|
-
c.default_cassette_options = {
|
30
|
-
:record => :new_episodes,
|
31
|
-
:serialize_with => :syck, # So it doesn't output in binary form
|
32
|
-
:match_requests_on => [:method, VCR.request_matchers.uri_without_param(:api_key)] # Don't require the API key
|
33
|
-
}
|
34
|
-
c.filter_sensitive_data('API_KEY') { ENV['FLICKR_API_KEY'] }
|
35
|
-
c.filter_sensitive_data('ACCESS_TOKEN') { ENV['FLICKR_ACCESS_TOKEN'] }
|
36
|
-
end
|
37
|
-
|
38
|
-
PHOTO_PATH = File.expand_path('../files/photo.jpg', __FILE__).freeze
|
39
|
-
MEDIA_ID = '6946979188'.freeze
|
40
|
-
PHOTO_ID = '6946979188'.freeze
|
41
|
-
VIDEO_ID = '7093038981'.freeze
|
42
|
-
SET_ID = '72157629851991663'.freeze
|
43
|
-
USER_NSID = '67131352@N04'.freeze
|
44
|
-
USER_USERNAME = 'Janko Marohnić'.freeze
|
45
|
-
USER_EMAIL = 'janko.marohnic@gmail.com'.freeze
|
46
|
-
EXTRAS = %w[license date_upload date_taken owner_name
|
47
|
-
icon_server original_format last_update geo tags machine_tags
|
48
|
-
o_dims views media path_alias url_sq url_q url_t url_s url_n
|
49
|
-
url_m url_z url_c url_l url_o].join(',').freeze
|
50
|
-
# for copying:
|
51
|
-
# 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
|
52
|
-
|
53
|
-
klasses = [Flickrie::Set, Flickrie::Photo, Flickrie::Video, Flickrie::Location, Flickrie::User]
|
54
|
-
klasses.each do |klass|
|
55
|
-
klass.instance_eval do
|
56
|
-
def public_new(*args)
|
57
|
-
new(*args)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class Hash
|
63
|
-
def except!(*keys)
|
64
|
-
keys.each { |key| delete(key) }
|
65
|
-
self
|
66
|
-
end
|
67
|
-
|
68
|
-
def except(*keys)
|
69
|
-
self.dup.except!(*keys)
|
70
|
-
end
|
71
|
-
end
|