convert_api187 1.1.0 → 1.1.2

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.
data/README.md CHANGED
@@ -36,6 +36,9 @@ result = ConvertApi.convert('pdf', :File => '/path/to/my_file.docx')
36
36
 
37
37
  # save to file
38
38
  result.file.save('/path/to/save/file.pdf')
39
+
40
+ # OR get contents as a string
41
+ result.file.contents
39
42
  ```
40
43
 
41
44
  Other result operations:
@@ -0,0 +1,7 @@
1
+ unless [].respond_to? :to_h
2
+ class Array
3
+ def to_h
4
+ Hash[self]
5
+ end
6
+ end
7
+ end
@@ -11,10 +11,10 @@ module ConvertApi
11
11
 
12
12
  def initialize
13
13
  @base_uri = URI('https://v2.convertapi.com/')
14
- @connect_timeout = 5
15
- @read_timeout = 60
14
+ @connect_timeout = 15
15
+ @read_timeout = 120
16
16
  @conversion_timeout = 180
17
- @conversion_timeout_delta = 10
17
+ @conversion_timeout_delta = 20
18
18
  @upload_timeout = 600
19
19
  @download_timeout = 600
20
20
  end
@@ -10,7 +10,7 @@ module ConvertApi
10
10
  value.file.url
11
11
  when ResultFile
12
12
  value.url
13
- when IO
13
+ when IO, StringIO
14
14
  UploadIO.new(value)
15
15
  else
16
16
  UploadIO.new(File.open(value))
@@ -31,9 +31,7 @@ module ConvertApi
31
31
  http
32
32
  end
33
33
 
34
- def save(path)
35
- path = File.join(path, filename) if File.directory?(path)
36
-
34
+ def contents
37
35
  request = Net::HTTP::Get.new(url, Client::DEFAULT_HEADERS)
38
36
 
39
37
  response = http({}).request(request)
@@ -50,8 +48,14 @@ module ConvertApi
50
48
  :headers => headers
51
49
  )
52
50
  end
51
+ response.body
52
+ end
53
+
54
+ def save(path)
55
+ path = File.join(path, filename) if File.directory?(path)
56
+
53
57
  File.open(path, 'w') do |f|
54
- f.write response.body
58
+ f.write contents
55
59
  end
56
60
 
57
61
  path
@@ -1,3 +1,3 @@
1
1
  module ConvertApi
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convert_api187
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 2
10
+ version: 1.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tomas Rutkauskas
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: exe
17
17
  cert_chain: []
18
18
 
19
- date: 2018-10-11 00:00:00 +11:00
19
+ date: 2018-10-12 00:00:00 +11:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -100,6 +100,7 @@ files:
100
100
  - Rakefile
101
101
  - convert_api.gemspec
102
102
  - lib/convert_api.rb
103
+ - lib/convert_api/array_to_h.rb
103
104
  - lib/convert_api/client.rb
104
105
  - lib/convert_api/configuration.rb
105
106
  - lib/convert_api/errors.rb