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 +4 -4
- data/README.md +12 -3
- data/lib/imgur/models/image.rb +14 -5
- data/lib/imgur/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344fb356417a799b6cc13e4a6e08ba78809ce7f0
|
4
|
+
data.tar.gz: e39fdbdd13ed1315a705cb67d87486e21d0966c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 '
|
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
|
-
|
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
|
data/lib/imgur/models/image.rb
CHANGED
@@ -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
|
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.
|
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
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.
|
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-
|
11
|
+
date: 2015-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|