flickr 2.0.1 → 2.0.2
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.
- checksums.yaml +4 -4
- data/.gitignore +11 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -0
- data/README.md +251 -0
- data/flickr.gemspec +33 -0
- data/flickr_rdoc.rb +7 -7
- data/lib/flickr.rb +21 -19
- data/lib/flickr/version.rb +1 -1
- data/rakefile +19 -6
- metadata +69 -14
- data/README.rdoc +0 -192
- data/test/test.rb +0 -471
- data/test/test_cache.rb +0 -45
- data/test/test_request.rb +0 -36
- data/test/test_response.rb +0 -30
- data/test/test_upload.rb +0 -41
data/test/test_cache.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
lib = File.dirname(__FILE__)
|
4
|
-
$:.unshift lib unless $:.include?(lib)
|
5
|
-
|
6
|
-
require 'test/unit'
|
7
|
-
require 'tempfile'
|
8
|
-
require 'yaml'
|
9
|
-
require 'benchmark'
|
10
|
-
|
11
|
-
class TestCache < Test::Unit::TestCase
|
12
|
-
|
13
|
-
def test_read_and_write
|
14
|
-
::Flickr.class_variable_set :@@initialized, false if ::Flickr.class_variable_get :@@initialized
|
15
|
-
|
16
|
-
file = Tempfile.new(['flickr-gem-test', '.yml'])
|
17
|
-
path = file.path
|
18
|
-
file.close
|
19
|
-
file.unlink
|
20
|
-
|
21
|
-
refute File.exist? path
|
22
|
-
|
23
|
-
::Flickr.cache = path
|
24
|
-
|
25
|
-
no_cache_timer = Benchmark.realtime do
|
26
|
-
::Flickr.new
|
27
|
-
end
|
28
|
-
|
29
|
-
assert File.exist? path
|
30
|
-
from_disk = YAML.load_file path
|
31
|
-
assert_equal Array, from_disk.class
|
32
|
-
assert_equal 222, from_disk.count
|
33
|
-
assert from_disk.all? { |x| /\Aflickr(\.(?i:[a-z]+))+\z/ === x }
|
34
|
-
|
35
|
-
cache_timer = Benchmark.realtime do
|
36
|
-
::Flickr.new
|
37
|
-
end
|
38
|
-
|
39
|
-
assert_operator no_cache_timer, :>, cache_timer
|
40
|
-
assert_operator 10, :<, no_cache_timer / cache_timer
|
41
|
-
|
42
|
-
ensure
|
43
|
-
File.unlink path
|
44
|
-
end
|
45
|
-
end
|
data/test/test_request.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
lib = File.dirname(__FILE__)
|
4
|
-
$:.unshift lib unless $:.include?(lib)
|
5
|
-
|
6
|
-
require 'test/unit'
|
7
|
-
|
8
|
-
class TestRequest < Test::Unit::TestCase
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@flickr = ::Flickr.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_flickr_api_is_accessible_via_methods
|
15
|
-
Flickr.new.send :build_classes, ['flickr.fully.legal']
|
16
|
-
|
17
|
-
assert_equal true, @flickr.methods.include?(:fully)
|
18
|
-
assert_equal true, @flickr.fully.methods.include?(:legal)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_invalid_endpoint_definition
|
22
|
-
e = assert_raises(RuntimeError) do
|
23
|
-
Flickr.new.send :build_classes, ['not_flickr.something.method']
|
24
|
-
end
|
25
|
-
assert_equal "Invalid namespace", e.message
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_invalid_keys_are_skipped
|
29
|
-
assert_nothing_raised {
|
30
|
-
Flickr.new.send :build_classes, ["flickr.hacked; end; raise 'Pwned'; def x"]
|
31
|
-
}
|
32
|
-
|
33
|
-
assert_equal false, @flickr.methods.include?(:hacked)
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
data/test/test_response.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
lib = File.dirname(__FILE__)
|
4
|
-
$:.unshift lib unless $:.include?(lib)
|
5
|
-
|
6
|
-
require 'test/unit'
|
7
|
-
|
8
|
-
class TestResponse < Test::Unit::TestCase
|
9
|
-
|
10
|
-
def test_response_keys_are_turned_into_methods
|
11
|
-
subject = Flickr::Response.new({ 'le_gal' => 'ok', }, nil)
|
12
|
-
|
13
|
-
assert_equal true, subject.methods.include?(:le_gal)
|
14
|
-
assert_equal 'ok', subject.le_gal
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_invalid_keys_are_skipped
|
18
|
-
response_hash = {
|
19
|
-
'illegal; end; raise "Pwned"; def x' => 'skipped'
|
20
|
-
}
|
21
|
-
|
22
|
-
assert_nothing_raised {
|
23
|
-
Flickr::Response.new(response_hash, nil)
|
24
|
-
}
|
25
|
-
|
26
|
-
subject = Flickr::Response.new(response_hash, nil)
|
27
|
-
assert_equal false, subject.methods.include?(:illegal)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/test/test_upload.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
lib = File.dirname(__FILE__)
|
4
|
-
$:.unshift lib unless $:.include?(lib)
|
5
|
-
|
6
|
-
require 'test/unit'
|
7
|
-
|
8
|
-
class TestUpload < Test::Unit::TestCase
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@flickr = ::Flickr.new
|
12
|
-
|
13
|
-
@flickr.access_token = ENV['FLICKR_ACCESS_TOKEN']
|
14
|
-
@flickr.access_secret = ENV['FLICKR_ACCESS_SECRET']
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_upload
|
18
|
-
u = info = nil
|
19
|
-
path = File.dirname(__FILE__) + '/image testée.jpg'
|
20
|
-
title = "Titre de l'image testée"
|
21
|
-
description = "Ceci est la description de l'image testée"
|
22
|
-
|
23
|
-
assert File.exist? path
|
24
|
-
|
25
|
-
assert_nothing_raised do
|
26
|
-
u = @flickr.upload_photo path,
|
27
|
-
:title => title,
|
28
|
-
:description => description
|
29
|
-
end
|
30
|
-
|
31
|
-
assert_nothing_raised do
|
32
|
-
info = @flickr.photos.getInfo :photo_id => u.to_s
|
33
|
-
end
|
34
|
-
|
35
|
-
assert_equal title, info.title
|
36
|
-
assert_equal description, info.description
|
37
|
-
|
38
|
-
assert_nothing_raised {@flickr.photos.delete :photo_id => u.to_s}
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|