flickrie 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -117,7 +117,7 @@ Flickrie.shared_secret = "<your shared secret>"
117
117
 
118
118
  url = Flickrie.get_authorization_url
119
119
  puts "Visit this url to authorize: #{url}"
120
- puts "Then enter the code that was displayed: "
120
+ puts "If you agreed, the code was displayed afterwards. Enter it: "
121
121
  code = gets.strip
122
122
  Flickrie.authorize!(code)
123
123
  puts "You're all done! Now go make some authenticated requests. Make me proud, son."
@@ -14,7 +14,7 @@ module Flickrie
14
14
  :consumer_secret => shared_secret,
15
15
  :token => token,
16
16
  :token_secret => token_secret
17
- conn.response :json, :content_type => /\bjson$/
17
+ conn.response :json, :content_type => /(text\/plain)|(json)$/
18
18
  conn.adapter Faraday.default_adapter
19
19
  end
20
20
 
@@ -87,6 +87,10 @@ module Flickrie
87
87
  end
88
88
 
89
89
  # photos
90
+ def add_media_tags(media_id, tags)
91
+ post 'flickr.photos.addTags', :photo_id => media_id, :tags => tags
92
+ end
93
+
90
94
  def get_media_info(media_id)
91
95
  get 'flickr.photos.getInfo', :photo_id => media_id
92
96
  end
@@ -95,6 +99,10 @@ module Flickrie
95
99
  get 'flickr.photos.getSizes', :photo_id => media_id
96
100
  end
97
101
 
102
+ def remove_media_tag(tag_id)
103
+ post 'flickr.photos.removeTag', :tag_id => tag_id
104
+ end
105
+
98
106
  def search_media(params = {})
99
107
  params[:extras] = [params[:extras], 'media'].compact.join(',')
100
108
  get 'flickr.photos.search', params
@@ -1,5 +1,6 @@
1
1
  require 'flickrie/media/visibility'
2
2
  require 'flickrie/media/note'
3
+ require 'flickrie/media/tag'
3
4
  require 'flickrie/location'
4
5
  require 'date'
5
6
 
@@ -110,12 +111,7 @@ module Flickrie
110
111
  info['description'] = info['description']['_content']
111
112
  info['comments_count'] = info.delete('comments')['_content']
112
113
  info['dates']['uploaded'] = info.delete('dateuploaded')
113
- info['machine_tags'] = info['tags']['tag'].
114
- select { |tag| tag['machine_tag'].to_i == 1 }.
115
- map { |tag| tag['_content']}.join(' ')
116
- info['tags'] = info['tags']['tag'].
117
- select { |tag| tag['machine_tag'].to_i == 0 }.
118
- map { |tag| tag['_content']}.join(' ')
114
+ info['tags'] = info['tags']['tag'].map { |info| Tag.new(info) }
119
115
 
120
116
  @info.update(info)
121
117
  self
@@ -1,3 +1,3 @@
1
1
  module Flickrie
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/flickrie.rb CHANGED
@@ -41,6 +41,12 @@ module Flickrie
41
41
  end
42
42
 
43
43
  # photos
44
+ def add_media_tags(media_id, tags)
45
+ client.add_media_tags(media_id, tags)
46
+ end
47
+ alias add_photo_tags add_media_tags
48
+ alias add_video_tags add_media_tags
49
+
44
50
  def get_media_info(media_id)
45
51
  response = client.get_media_info(media_id)
46
52
  Media.from_info(response.body['photo'])
data/test/media_test.rb CHANGED
@@ -11,6 +11,9 @@ end
11
11
  class MediaTest < Test::Unit::TestCase
12
12
  def setup
13
13
  Flickrie.api_key = ENV['FLICKR_API_KEY']
14
+ Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
15
+ Flickrie.token = ENV['FLICKR_TOKEN']
16
+ Flickrie.token_secret = ENV['FLICKR_TOKEN_SECRET']
14
17
  @media_id = 6946979188
15
18
  @set_id = 72157629851991663
16
19
  @user_nsid = '67131352@N04'
@@ -33,8 +36,12 @@ class MediaTest < Test::Unit::TestCase
33
36
  assert_equal '7049', media.server
34
37
  assert_equal 8, media.farm
35
38
  assert_equal 'IMG_0796', media.title
36
- assert_equal 'luka', media.tags
37
- assert_equal '', media.machine_tags
39
+
40
+ assert_equal 'luka', media.tags.join(' ')
41
+ assert_equal @user_nsid, media.tags.first.author.nsid
42
+ assert_equal 'luka', media.tags.first.raw
43
+ assert_equal false, media.tags.first.machine_tag?
44
+
38
45
  assert_equal 1, media.views_count
39
46
  assert_equal 1, media.comments_count
40
47
  assert_equal '0', media.license.id
@@ -65,14 +72,14 @@ class MediaTest < Test::Unit::TestCase
65
72
  assert_equal false, media.visibility.family?
66
73
  assert_equal nil, media.visibility.contacts?
67
74
 
68
- assert_equal false, media.can_comment?
69
- assert_equal false, media.can_add_meta?
75
+ assert_equal true, media.can_comment?
76
+ assert_equal true, media.can_add_meta?
70
77
  assert_equal true, media.can_everyone_comment?
71
78
  assert_equal false, media.can_everyone_add_meta?
72
79
 
73
80
  assert_equal true, media.can_download?
74
- assert_equal false, media.can_blog?
75
- assert_equal false, media.can_print?
81
+ assert_equal true, media.can_blog?
82
+ assert_equal true, media.can_print?
76
83
  assert_equal false, media.can_share?
77
84
 
78
85
  assert_equal false, media.has_people?
@@ -262,6 +269,17 @@ class MediaTest < Test::Unit::TestCase
262
269
  assert_equal nil, media.visibility.contacts?
263
270
  end
264
271
 
272
+ def test_add_media_tags
273
+ media = Flickrie.get_photo_info(@media_id)
274
+ tags_before_change = media.tags.join(' ')
275
+ Flickrie.add_media_tags(@media_id, "janko")
276
+ media.get_info
277
+ assert_equal [tags_before_change, "janko"].join(' '),
278
+ media.tags.join(' ')
279
+ tag_id = media.tags.find { |tag| tag.content == "janko" }.id
280
+ Flickrie.client.remove_media_tag(tag_id)
281
+ end
282
+
265
283
  def test_methods_returning_nil
266
284
  media = Flickrie::Photo.new
267
285
 
data/test/set_test.rb CHANGED
@@ -30,8 +30,8 @@ class SetTest < Test::Unit::TestCase
30
30
  assert_equal 'Speleologija', set.title
31
31
  assert_equal 'Slike sa škole speleologije Velebit.', set.description
32
32
 
33
- assert_equal 99, set.media_count
34
- assert_equal 98, set.photos_count
33
+ assert_equal 98, set.media_count
34
+ assert_equal 97, set.photos_count
35
35
  assert_equal 1, set.videos_count
36
36
  assert_equal 0, set.comments_count
37
37
  assert_equal 0, set.views_count
@@ -62,8 +62,8 @@ class SetTest < Test::Unit::TestCase
62
62
  assert_equal 'Speleologija', set.title
63
63
  assert_equal 'Slike sa škole speleologije Velebit.', set.description
64
64
 
65
- assert_equal 99, set.media_count
66
- assert_equal 98, set.photos_count
65
+ assert_equal 98, set.media_count
66
+ assert_equal 97, set.photos_count
67
67
  assert_equal 1, set.videos_count
68
68
  assert_equal 0, set.comments_count
69
69
  assert_equal 0, set.views_count
data/test/user_test.rb CHANGED
@@ -44,7 +44,7 @@ I'm a programmer, and I'm gonna program a badass Ruby library for Flickr.
44
44
  assert_instance_of Time, user.first_taken
45
45
  assert_instance_of Time, user.first_uploaded
46
46
 
47
- assert_equal 99, user.media_count
47
+ assert_equal 98, user.media_count
48
48
  end
49
49
 
50
50
  def test_find_user_by_username_or_email
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: 0.1.0
4
+ version: 0.1.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-04-23 00:00:00.000000000 Z
12
+ date: 2012-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday_middleware
16
- requirement: &70166247860000 !ruby/object:Gem::Requirement
16
+ requirement: &70192223006740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70166247860000
24
+ version_requirements: *70192223006740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simple_oauth
27
- requirement: &70166247859580 !ruby/object:Gem::Requirement
27
+ requirement: &70192223005740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70166247859580
35
+ version_requirements: *70192223005740
36
36
  description: This gem is a nice wrapper for the Flickr API with an intuitive interface.
37
37
  email:
38
38
  - janko.marohnic@gmail.com
@@ -64,7 +64,6 @@ files:
64
64
  - test/license_test.rb
65
65
  - test/location_test.rb
66
66
  - test/media_test.rb
67
- - test/oauth_test.rb
68
67
  - test/photo_test.rb
69
68
  - test/set_test.rb
70
69
  - test/user_test.rb
@@ -101,7 +100,6 @@ test_files:
101
100
  - test/license_test.rb
102
101
  - test/location_test.rb
103
102
  - test/media_test.rb
104
- - test/oauth_test.rb
105
103
  - test/photo_test.rb
106
104
  - test/set_test.rb
107
105
  - test/user_test.rb
data/test/oauth_test.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'test/unit'
2
- require 'flickrie'
3
-
4
- class OAuthTest < Test::Unit::TestCase
5
- def setup
6
- @photo_id = 6946979188
7
- Flickrie.api_key = ENV['FLICKR_API_KEY']
8
- Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
9
- Flickrie.token = ENV['FLICKR_TOKEN']
10
- Flickrie.token_secret = ENV['FLICKR_TOKEN_SECRET']
11
- end
12
-
13
- def test_permissions
14
- assert_nothing_raised do
15
- Flickrie.client.get "flickr.photos.getPerms", :photo_id => @photo_id
16
- Flickrie.client.post "flickr.photos.setSafetyLevel", :photo_id => @photo_id, :safety_level => 1
17
- end
18
- assert_raises(Flickrie::Error) do
19
- Flickrie.client.get "flickr.photos.delete", :photo_id => @photo_id
20
- end
21
- end
22
- end