imgurz 0.0.4 → 0.0.5

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/imgurz/client.rb +8 -1
  3. data/tests/test.rb +9 -4
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1aac921f29b2c8fcf1585c45f96cdd73359e480e
4
- data.tar.gz: 69888c27859d2aea46da54496454ca26efdada2d
3
+ metadata.gz: 3e081cfb22b562214c3e2600734e643337a097bd
4
+ data.tar.gz: f158b61f632a01e77a2d3c4ad541597545c270ee
5
5
  SHA512:
6
- metadata.gz: af745926a647d86d0ac923f98f436d19bb8c8993b00aa1006ce00c16fee8b18852e6e87db6412dd676a97569d935c09b96ec4f2608073b7d8daf703c131c0930
7
- data.tar.gz: 3aab0a39330f60945bb1b2123804831357e1848023c24177d7c0e6dfb88445a3d7d15837654fde8212f6f99149f6bbe606dcbac09328a0e15297eb61eb9b7701
6
+ metadata.gz: dcc1402a678a457fe1e8ebe2b43bb87e4d5d8c398f86fb6ff10d59b4f1b400e78ff09aee8b3577879e533652e0c63cb086a98306944452a4cf941dfef268d78b
7
+ data.tar.gz: 96afce5580597df87bd5393572dd53e1ff4a218ce6c45cb7b08bed684925b174be99f38de744948ba71ebbda2e46cd4106ce4f850e77c6291be42017b777907a
data/lib/imgurz/client.rb CHANGED
@@ -17,6 +17,11 @@ module Imgurz
17
17
  self
18
18
  end
19
19
 
20
+ def into(album_id)
21
+ @album_id = album_id
22
+ self
23
+ end
24
+
20
25
  def upload(image)
21
26
  return self.upload_file(image) if image.kind_of?(File) # already a file
22
27
  self.upload_file_at(image) # we assume that a path is given
@@ -44,7 +49,9 @@ module Imgurz
44
49
  self.as_anonymous unless @method
45
50
  request['Authorization'] = "Client-ID #{key}" if @method=='anonymous'
46
51
  request['Authorization'] = "Bearer #{key}" if @method=='registered'
47
- request.set_form_data(image:file_content)
52
+ data = {image:file_content}
53
+ data[:album] = @album_id if @album_id
54
+ request.set_form_data(data)
48
55
  response = http.request(request)
49
56
  JSON.parse response.body
50
57
  end
data/tests/test.rb CHANGED
@@ -8,16 +8,21 @@ YOUR_CLIENT_SECRET = ''
8
8
  YOUR_TOKEN = ''
9
9
  YOUR_REFRESH_TOKEN = ''
10
10
 
11
-
11
+ YOUR_ALBUM_ID = nil
12
+ YOUR_TEST_IMAGE = 'tests/lama.gif'
12
13
 
13
14
  # Upload using a path, as an anononymous user
14
15
  client = Imgurz::Client.new YOUR_CLIENT_ID
15
- puts client.anonymous.upload('tests/lama.gif')
16
+ puts client.anonymous.upload(YOUR_TEST_IMAGE)
16
17
 
17
18
  # Upload using a path, as a registered user (with a token)
18
19
  client = Imgurz::Client.new YOUR_TOKEN
19
- puts client.as_regsitered.upload('tests/lama.gif')
20
+ puts client.as_regsitered.upload(YOUR_TEST_IMAGE)
21
+
22
+ # Upload using a path, as a registered user (with a token), into an album
23
+ client = Imgurz::Client.new YOUR_TOKEN
24
+ puts client.as_regsitered.into(YOUR_ALBUM_ID).upload(YOUR_TEST_IMAGE)
20
25
 
21
- # Refresh token
26
+ # # Refresh token
22
27
  token = Imgurz::Token.new(YOUR_CLIENT_ID, YOUR_CLIENT_SECRET)
23
28
  puts token.refresh(YOUR_REFRESH_TOKEN)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgurz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Zielony