imgurapi 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bf0890e8455b773f65d61bf4610a1c184ae1efe
4
- data.tar.gz: 2def72d0ba0969f465fa2068e804f893656c56d6
3
+ metadata.gz: 344fb356417a799b6cc13e4a6e08ba78809ce7f0
4
+ data.tar.gz: e39fdbdd13ed1315a705cb67d87486e21d0966c5
5
5
  SHA512:
6
- metadata.gz: 28772edd6e0ddc0fdf123b422e740b7d0d245c0ff238e60112f2d94b4f59482b2e33a06f27addd3f5779d2af1779bf5fdc087bf65e4b8c05f80ec16537780b7f
7
- data.tar.gz: 719bd53a67db00ead9a5db9d7dd239edafdb1238f5ef6e8bccdc5fcea09092f543126ec3ad2f693ae6c3e00669abf26f813219eb7ec69acd07b615c9ba68454d
6
+ metadata.gz: b113935848a157b42a1307c770b37e10d340427b5f9234f7d0a7ea8dcf58a5fd5ff7cf703d5c4e665f0463ca160528a240952c7f2f40f9dd02bd64e04a1f5c9b
7
+ data.tar.gz: 604d743f0769a33675f7f6d2bc478fe20aed80a161814fef1654bf4051816a6f2272173539dbc879e850af497866a36d4b1643d344c7c9870216fc618296fbd2
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Imgur
2
2
 
3
3
  This gem allows you to interact with Imgur's authenticated API, version 3.
4
+
4
5
  It doesn't implement all the available endpoints. So far:
5
6
  - image upload, find and delete
6
7
  - account image count, account details, account image list
@@ -20,7 +21,7 @@ Check your inbox, you will receive an email with your application Client Id and
20
21
 
21
22
  Add this line to your application's Gemfile:
22
23
  ```ruby
23
- gem 'imgurruby'
24
+ gem 'imgurapi'
24
25
  ```
25
26
 
26
27
  And then run:
@@ -51,8 +52,8 @@ imgur_session = Imgur::Session.new(client_id: 'CLIENT_ID', client_secret: 'CLIEN
51
52
 
52
53
  Your account:
53
54
  ```ruby
54
- account = imgur_session.account
55
- {"id"=>123, "url"=>"my_account", "bio"=>nil, "reputation"=>7, "created"=>1352279501, "pro_expiration"=>false}
55
+ account = imgur_session.account.account
56
+ => #<Imgur::Account:0x007fd399b6b678 @id=123, @url="my_account", @bio=nil, @reputation=7, @created=1352279501, @pro_expiration=false>
56
57
  ```
57
58
 
58
59
  How many images you have:
@@ -94,6 +95,14 @@ Feel free to use it in your Rails views:
94
95
  <%= image_tag my_image.link %>
95
96
  ```
96
97
 
98
+ Alternatively, you can use `url` instead of `link` because it provides image resizing.
99
+ ```
100
+ <%= image_tag my_image.url %>
101
+ <%= image_tag my_image.url(:small) %>
102
+ ```
103
+ With no arguments, it's the same as `link`.
104
+ Available sizes are small (`:small_square`, `:small` or `:s`) and large (`:large_thumbnail`, `:large` or `:l`)
105
+
97
106
  How many images do you have at the moment?
98
107
  ```ruby
99
108
  puts imgur_session.account.image_count
@@ -1,19 +1,28 @@
1
1
  module Imgur
2
2
  class Image < Base
3
3
 
4
+ IMAGE_URL = 'http://i.imgur.com/'
5
+ IMAGE_EXTENSION = 'jpg' # jpg is the default extension for every Imgur image
6
+
7
+ def link
8
+ @link ||= "#{IMAGE_URL}#{id}.#{IMAGE_EXTENSION}"
9
+ end
10
+
4
11
  # Provides the download URL in case you know a valid imgur hash and don't want to make a network trip with .find
5
12
  # Just in case you don't need the full Imgur::Image object
6
- def url(size = nil)
13
+ def url(size)
7
14
  size = case size
8
- when :small_square
15
+ when :small_square, :small, :s
9
16
  's'
10
- when :large_thumbnail
17
+ when :large_thumbnail, :large, :l
11
18
  'l'
19
+ else
20
+ ''
12
21
  end
13
22
 
14
23
  splitted_link = link.split('.')
15
-
16
- splitted_link.insert(splitted_link.size - 1, size).join
24
+ splitted_link[splitted_link.size - 2] << size
25
+ splitted_link.join '.'
17
26
  end
18
27
  end
19
28
  end
data/lib/imgur/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Imgur
2
2
 
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgurapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Cruz Horts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-02 00:00:00.000000000 Z
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday