imgurapi 3.1.0 → 3.2.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/lib/imgurapi/models/image.rb +11 -5
- data/lib/imgurapi/session.rb +5 -0
- data/lib/imgurapi/version.rb +1 -1
- data/spec/imgurapi/models/image_spec.rb +5 -3
- 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: dc8dabbb161b89c8c24be36fe0ce9229bbf95947
|
4
|
+
data.tar.gz: 8f9d4b79aac9514f49e6d3c9ff29a0a2e519091f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73c32e9b7fda8bd7b13c9601ffa455c9fe135b11644d1f775a7a9c812c45f49856e0106c4c932a1c044906215a68458ab97753e683b11ad1ca93b40951004b80
|
7
|
+
data.tar.gz: ffbb1013112ac0e84f3f588101a07d0efe08ddef304be8f7cc8426f2be6049b9045cd5c14fd5947a357ec5e1001a509b01142d73c847b2767f585cef1d08a613
|
@@ -1,16 +1,22 @@
|
|
1
1
|
module Imgurapi
|
2
2
|
class Image < Base
|
3
3
|
|
4
|
-
|
4
|
+
IMGUR_HOST = 'i.imgur.com'
|
5
5
|
IMAGE_EXTENSION = 'jpg' # jpg is the default extension for every Imgur image
|
6
6
|
|
7
|
-
def link
|
8
|
-
|
7
|
+
def link(use_ssl = false)
|
8
|
+
protocol = if use_ssl
|
9
|
+
'https://'
|
10
|
+
else
|
11
|
+
'http://'
|
12
|
+
end
|
13
|
+
|
14
|
+
"#{protocol}#{IMGUR_HOST}/#{id}.#{IMAGE_EXTENSION}"
|
9
15
|
end
|
10
16
|
|
11
17
|
# Provides the download URL in case you know a valid imgur hash and don't want to make a network trip with .find
|
12
18
|
# Just in case you don't need the full Imgurapi::Image object
|
13
|
-
def url(size
|
19
|
+
def url(size: nil, use_ssl: false)
|
14
20
|
size = case size
|
15
21
|
when :small_square, :small, :s
|
16
22
|
's'
|
@@ -20,7 +26,7 @@ module Imgurapi
|
|
20
26
|
''
|
21
27
|
end
|
22
28
|
|
23
|
-
splitted_link = link.split('.')
|
29
|
+
splitted_link = link(use_ssl).split('.')
|
24
30
|
splitted_link[splitted_link.size - 2] << size
|
25
31
|
splitted_link.join '.'
|
26
32
|
end
|
data/lib/imgurapi/session.rb
CHANGED
@@ -12,6 +12,7 @@ module Imgurapi
|
|
12
12
|
@client_secret = options[:client_secret]
|
13
13
|
@access_token = options[:access_token]
|
14
14
|
@refresh_token = options[:refresh_token]
|
15
|
+
@use_ssl = !!options[:use_ssl]
|
15
16
|
end
|
16
17
|
|
17
18
|
# Singleton initializer to allow access_token reuse
|
@@ -25,6 +26,10 @@ module Imgurapi
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
29
|
+
def use_ssl?
|
30
|
+
@use_ssl
|
31
|
+
end
|
32
|
+
|
28
33
|
def access_token=(access_token)
|
29
34
|
@access_token = access_token
|
30
35
|
|
data/lib/imgurapi/version.rb
CHANGED
@@ -14,8 +14,10 @@ describe Imgurapi::Image do
|
|
14
14
|
image = Imgurapi::Image.new(id: 'hash')
|
15
15
|
|
16
16
|
expect(image.url).to eq "http://i.imgur.com/hash.jpg"
|
17
|
-
expect(image.url(:random_size)).to eq "http://i.imgur.com/hash.jpg"
|
18
|
-
expect(image.url(:small_square)).to eq "http://i.imgur.com/hashs.jpg"
|
19
|
-
expect(image.url(:large_thumbnail)).to eq "http://i.imgur.com/hashl.jpg"
|
17
|
+
expect(image.url(size: :random_size)).to eq "http://i.imgur.com/hash.jpg"
|
18
|
+
expect(image.url(size: :small_square)).to eq "http://i.imgur.com/hashs.jpg"
|
19
|
+
expect(image.url(size: :large_thumbnail, use_ssl: false)).to eq "http://i.imgur.com/hashl.jpg"
|
20
|
+
expect(image.url(use_ssl: true)).to eq "https://i.imgur.com/hash.jpg"
|
21
|
+
expect(image.url(size: :large_thumbnail, use_ssl: true)).to eq "https://i.imgur.com/hashl.jpg"
|
20
22
|
end
|
21
23
|
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: 3.1
|
4
|
+
version: 3.2.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: 2017-09-
|
11
|
+
date: 2017-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|