convert_api 1.0.4 → 1.1.0
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 +1 -1
- data/lib/convert_api/format_detector.rb +8 -7
- data/lib/convert_api/upload_io.rb +16 -6
- data/lib/convert_api/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: 10c027fe092b92379732b9ace81b981a4cc65ae8
|
4
|
+
data.tar.gz: 30e6381b72fb1489f0a20e171afe90fd7ba4f533
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e05161c98250dc7de2af71758838af0723612bd29bb110340f8fb481e6ebd72a50e68b1d0f2d83b42ca39ba9bbe443cf7fceb15b3018ebe1ec2b86f2bec1af22
|
7
|
+
data.tar.gz: b1872e5582d1a362d72371112d690b79bf3cec4624ce86b55be515eb86540c80ae0e6eea7c18d6040794cd70c9ac36d31dfa31aecbcc248d391af15e016efefc
|
data/README.md
CHANGED
@@ -5,24 +5,25 @@ module ConvertApi
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run
|
8
|
-
|
9
|
-
format = extension[1..-1]
|
8
|
+
return @resource.file_ext.downcase if @resource.is_a?(UploadIO)
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
format
|
10
|
+
format_from_path
|
14
11
|
end
|
15
12
|
|
16
13
|
private
|
17
14
|
|
15
|
+
def format_from_path
|
16
|
+
extension = File.extname(path).downcase
|
17
|
+
format = extension[1..-1]
|
18
|
+
format || raise(FormatError, 'Unable to detect format')
|
19
|
+
end
|
20
|
+
|
18
21
|
def path
|
19
22
|
case @resource
|
20
23
|
when String
|
21
24
|
URI(@resource).path
|
22
25
|
when File
|
23
26
|
@resource.path
|
24
|
-
when UploadIO
|
25
|
-
@resource.filename
|
26
27
|
else
|
27
28
|
''
|
28
29
|
end
|
@@ -2,8 +2,6 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module ConvertApi
|
4
4
|
class UploadIO
|
5
|
-
attr_reader :io, :filename
|
6
|
-
|
7
5
|
def initialize(io, filename = nil)
|
8
6
|
@io = io
|
9
7
|
@filename = filename || io_filename || raise(FileNameError, 'IO filename must be provided')
|
@@ -14,18 +12,30 @@ module ConvertApi
|
|
14
12
|
end
|
15
13
|
|
16
14
|
def file_id
|
17
|
-
|
15
|
+
result['FileId']
|
16
|
+
end
|
17
|
+
|
18
|
+
def file_name
|
19
|
+
result['FileName']
|
20
|
+
end
|
21
|
+
|
22
|
+
def file_ext
|
23
|
+
result['FileExt']
|
18
24
|
end
|
19
25
|
|
20
26
|
private
|
21
27
|
|
28
|
+
def result
|
29
|
+
@result ||= upload_file
|
30
|
+
end
|
31
|
+
|
22
32
|
def upload_file
|
23
|
-
ConvertApi.client.upload(io, filename)
|
33
|
+
ConvertApi.client.upload(@io, @filename)
|
24
34
|
end
|
25
35
|
|
26
36
|
def io_filename
|
27
|
-
return unless io.respond_to?(:path)
|
28
|
-
File.basename(io.path)
|
37
|
+
return unless @io.respond_to?(:path)
|
38
|
+
File.basename(@io.path)
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
data/lib/convert_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convert_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Rutkauskas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|