cdnconnect-api 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/cdnconnect_api.rb +19 -10
- 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: cd6b1fa74023415fa1b4a66f45f23563295dad9a
|
4
|
+
data.tar.gz: 1a849ee61d2d9903faefa7b3ba43deb575b0cfae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd2d29668600520d2db891d053b6757ff855b305b18f6f37b05eb52b72b21345fe9e9742986d907d6da66efe3a0450467ea6bf2967640a4a84df236f3b42eab4
|
7
|
+
data.tar.gz: 51305c08c62822d81f60e6f4ba3c21aa897261d1e7f5bfce7c5476c055a90f3d1b8e531828a2a5a77e526b8fc1adcfbc3e1ae5b06eec882d417afdd81137c161
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# CDN Connect API Ruby Client, v0.3.
|
1
|
+
# CDN Connect API Ruby Client, v0.3.2
|
2
2
|
|
3
3
|
CDN Connect makes it easier to manage production assets for teams of developers and designers, all while serving files from a fast content delivery network. Features include image optimization, resizing, cropping, filters, changing output formats, convert to WebP image format, etc. The CDN Connect API Ruby Client makes it easier to upload files and interact with the API with only a few lines of code.
|
4
4
|
|
data/lib/cdnconnect_api.rb
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require 'faraday'
|
16
|
-
require 'faraday/utils'
|
17
16
|
require 'signet/oauth_2/client'
|
18
17
|
require 'cdnconnect_api/response'
|
19
18
|
require 'logger'
|
@@ -26,7 +25,7 @@ module CDNConnect
|
|
26
25
|
class APIClient
|
27
26
|
|
28
27
|
@@application_name = 'cdnconnect-api-ruby'
|
29
|
-
@@application_version = '0.3.
|
28
|
+
@@application_version = '0.3.2'
|
30
29
|
@@user_agent = @@application_name + ' v' + @@application_version
|
31
30
|
@@api_host = 'https://api.cdnconnect.com'
|
32
31
|
@@api_version = 'v1'
|
@@ -206,7 +205,8 @@ module CDNConnect
|
|
206
205
|
return upload_url_response
|
207
206
|
end
|
208
207
|
upload_url = upload_url_response.get_result('upload_url')
|
209
|
-
|
208
|
+
upload_id = upload_url_response.get_result('upload_id')
|
209
|
+
@logger.debug("Received new upload url, #{upload_id}")
|
210
210
|
else
|
211
211
|
@logger.debug("Use prefetched upload url")
|
212
212
|
end
|
@@ -262,8 +262,13 @@ module CDNConnect
|
|
262
262
|
|
263
263
|
# an upload response also contains a new upload url.
|
264
264
|
# Save it for the next upload to the same destination.
|
265
|
-
|
266
|
-
|
265
|
+
new_upload_url = upload_response.get_result('upload_url')
|
266
|
+
new_upload_id = upload_response.get_result('upload_url_upload_id')
|
267
|
+
if new_upload_url != nil
|
268
|
+
@logger.debug("Received upload url in upload response, #{new_upload_id}")
|
269
|
+
set_prefetched_upload_url(destination_path,
|
270
|
+
new_upload_url)
|
271
|
+
end
|
267
272
|
end
|
268
273
|
|
269
274
|
end
|
@@ -597,7 +602,7 @@ module CDNConnect
|
|
597
602
|
if destination_path == "/"
|
598
603
|
destination_path = ""
|
599
604
|
end
|
600
|
-
upload_id =
|
605
|
+
upload_id = ((9_999_999 - 1_000_000) * rand + 1_000_000).to_i
|
601
606
|
api_path = "#{destination_path}/upload-#{upload_id}.json"
|
602
607
|
|
603
608
|
@logger.debug("get_upload_url: #{api_path}")
|
@@ -890,10 +895,14 @@ module CDNConnect
|
|
890
895
|
end
|
891
896
|
|
892
897
|
def human_file_size(bytes)
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
898
|
+
begin
|
899
|
+
units = %w{B KB MB GB TB}
|
900
|
+
e = (Math.log(bytes)/Math.log(1024)).floor
|
901
|
+
s = "%.2f" % (bytes.to_f / 1024**e)
|
902
|
+
s.sub(/\.?0*$/, units[e])
|
903
|
+
rescue
|
904
|
+
bytes
|
905
|
+
end
|
897
906
|
end
|
898
907
|
|
899
908
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdnconnect-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bradley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|