cloudconvert 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fbd33992f2bb0eb736b817259e26ff729b3f3066
4
+ data.tar.gz: b3452c6677786aba313a97c260eb13e8d83c306a
5
+ SHA512:
6
+ metadata.gz: 2904f73386d4f1110fa1f95b9f239270bb223b492f0d86f2a71ae7cbfc53b009c2c65ec0125a1c537560f0c042c53806a163d1a1815003ec3a6ca9c784099dc8
7
+ data.tar.gz: 97550957b2be2e493e131359d90aaf16c22e0444a190a0a6bda8a0040011a7a60ea1e3cc79807d983ca683a007f310c86db62db7dac44827901126a55fecd870
data/.gitignore CHANGED
@@ -15,3 +15,7 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.xml
19
+ .idea/.name
20
+ .idea/.rakeTasks
21
+ *.iml
data/README.md CHANGED
@@ -33,8 +33,8 @@ Start a Conversion on Cloud convert
33
33
 
34
34
  conversion = Cloudconvert::Conversion.new
35
35
 
36
- # to start file conversion (options parameter is optional)
37
- conversion.convert(inputformat, outputformat, file_path, options)
36
+ # to start file conversion (options & callback_url parameters are optional)
37
+ conversion.convert(inputformat, outputformat, file_path, callback_url, options)
38
38
 
39
39
  # options parameter is Conversion type specific options , which you can get from,
40
40
  conversion.converter_options(inputformat, outputformat)
@@ -1,112 +1,105 @@
1
1
  module Cloudconvert
2
2
  class Conversion
3
- attr_accessor :convert_request_url, :conn , :request_connection, :process_id, :conversion_connection
4
-
5
- #request_connection => specific to file conversion
6
-
7
- def initialize
8
- raise Cloudconvert::API_KEY_ERROR if Cloudconvert.configuration.api_key == nil
9
- @conversion_connection = Faraday.new(:url => Cloudconvert::CONVERSION_URL)
10
- end
11
-
12
- #convert request for file
13
- def convert(inputformat, outputformat, file_path = nil, options = {})
14
- raise "File path cant be blank" if file_path == nil
15
- @convert_request_url = start_conversion(inputformat, outputformat)
16
- #initiate connection with new response host
17
- initiate_connection(@convert_request_url)
18
- upload(build_upload_params(file_path, outputformat, options))
19
- end
20
-
21
- #lists all conversions
22
- def list_conversions
23
- response = @conversion_connection.get '/processes', {:apikey => api_key }
24
- parse_response(response.body)
25
- end
26
-
27
-
28
- #cancels current conversion
29
- def cancel_conversion
30
- response = @request_connection.get "/process/#{@process_id.to_s}/cancel"
31
- parse_response(response.body)
32
- end
33
-
34
- #deletes finished conversion
35
- def delete_conversion
36
- response = @request_connection.get "/process/#{@process_id.to_s}/delete"
37
- parse_response(response.body)
38
- end
39
-
40
- #upload request
41
- def upload(upload_params)
42
- response = @request_connection.post "/process/#{@process_id.to_s}", upload_params
43
- parse_response(response.body)
44
- end
45
-
46
-
47
- # checks if conversion finished for process id and returns download link
48
- def download_link
49
- response = status
50
- response["step"] == "finished" ? "http:#{response['output']['url']}" : nil
51
- end
52
-
53
- # checks status of conversion with process_id
54
- def status
55
- response = @request_connection.get "/process/#{@process_id.to_s}"
56
- parse_response(response.body)
57
- end
58
-
59
- #returns all possible conversions and options
60
- def converter_options(inputformat ="", outputformat = "")
61
- response = @conversion_connection.get "conversiontypes", {:inputformat => inputformat,:outputformat => outputformat }
62
- parse_response(response.body)
63
- end
64
-
65
-
66
- #######################################################################################################
67
- #######################################################################################################
68
- def api_key
69
- raise Cloudconvert::API_KEY_ERROR if Cloudconvert.configuration.api_key == nil
70
- Cloudconvert.configuration.api_key
71
- end
72
-
73
- def callback
74
- Cloudconvert.configuration.callback
75
- end
76
-
77
- #send conversion http request
78
- def conversion_post_request(inputformat, outputformat)
79
- @conversion_connection.post "https://api.cloudconvert.org/process?inputformat=#{inputformat}&outputformat=#{outputformat}&apikey=#{api_key}"
80
- end
81
-
82
- def start_conversion(inputformat, outputformat)
83
- response = conversion_post_request(inputformat,outputformat)
84
-
85
- parsed_response = parse_response(response.body)
86
- @process_id = parsed_response["id"]
87
-
88
- "https://#{parsed_response['host']}"
89
- end
90
-
91
- def initiate_connection(url)
92
- @request_connection = Faraday.new(:url => url)
93
- end
94
-
95
- #building params for local file
96
- def build_upload_params(file_path, outputformat, options = {})
97
- upload_params = { :format => outputformat}
98
- upload_params.merge!(:callback => callback) if callback != nil
99
- upload_params.merge!(:input => "download",:link => file_path )
100
- upload_params.merge!(options)
101
- end
102
-
103
- def parse_response(response)
104
- JSON.parse(response)
105
- end
106
-
107
- #######################################################################################################
108
- #######################################################################################################
3
+ attr_accessor :convert_request_url, :conn , :request_connection, :process_id, :conversion_connection
4
+
5
+ #request_connection => specific to file conversion
6
+
7
+ def initialize
8
+ raise Cloudconvert::API_KEY_ERROR if Cloudconvert.configuration.api_key == nil
9
+ @conversion_connection = Faraday.new(:url => Cloudconvert::CONVERSION_URL)
10
+ end
11
+
12
+ #convert request for file
13
+ def convert(inputformat, outputformat, file_path, callback_url = nil, options = {})
14
+ raise "File path cant be blank" if file_path.nil?
15
+ @convert_request_url = start_conversion(inputformat, outputformat)
16
+ #initiate connection with new response host
17
+ initiate_connection(@convert_request_url)
18
+ upload(build_upload_params(file_path, outputformat, callback_url, options))
19
+ end
20
+
21
+ #lists all conversions
22
+ def list_conversions
23
+ response = @conversion_connection.get '/processes', {:apikey => api_key }
24
+ parse_response(response.body)
25
+ end
26
+
27
+
28
+ #cancels current conversion
29
+ def cancel_conversion
30
+ response = @request_connection.get "/process/#{@process_id.to_s}/cancel"
31
+ parse_response(response.body)
32
+ end
33
+
34
+ #deletes finished conversion
35
+ def delete_conversion
36
+ response = @request_connection.get "/process/#{@process_id.to_s}/delete"
37
+ parse_response(response.body)
38
+ end
39
+
40
+ #upload request
41
+ def upload(upload_params)
42
+ response = @request_connection.post "/process/#{@process_id.to_s}", upload_params
43
+ parse_response(response.body)
44
+ end
45
+
46
+
47
+ # checks if conversion finished for process id and returns download link
48
+ def download_link
49
+ response = status
50
+ response["step"] == "finished" ? "http:#{response['output']['url']}" : nil
51
+ end
52
+
53
+ # checks status of conversion with process_id
54
+ def status
55
+ response = @request_connection.get "/process/#{@process_id.to_s}"
56
+ parse_response(response.body)
57
+ end
58
+
59
+ #returns all possible conversions and options
60
+ def converter_options(inputformat ="", outputformat = "")
61
+ response = @conversion_connection.get "conversiontypes", {:inputformat => inputformat,:outputformat => outputformat }
62
+ parse_response(response.body)
63
+ end
64
+
65
+ def api_key
66
+ raise Cloudconvert::API_KEY_ERROR if Cloudconvert.configuration.api_key == nil
67
+ Cloudconvert.configuration.api_key
68
+ end
69
+
70
+ def callback(callback_url = nil)
71
+ callback_url || Cloudconvert.configuration.callback
72
+ end
73
+
74
+ #send conversion http request
75
+ def conversion_post_request(inputformat, outputformat)
76
+ @conversion_connection.post "https://api.cloudconvert.org/process?inputformat=#{inputformat}&outputformat=#{outputformat}&apikey=#{api_key}"
77
+ end
78
+
79
+ def start_conversion(inputformat, outputformat)
80
+ response = conversion_post_request(inputformat,outputformat)
81
+
82
+ parsed_response = parse_response(response.body)
83
+ @process_id = parsed_response["id"]
84
+
85
+ "https://#{parsed_response['host']}"
86
+ end
87
+
88
+ def initiate_connection(url)
89
+ @request_connection = Faraday.new(:url => url)
90
+ end
91
+
92
+ #building params for local file
93
+ def build_upload_params(file_path, outputformat, callback_url = nil, options = {})
94
+ upload_params = { :format => outputformat}
95
+ upload_params.merge!(:callback => callback(callback_url)) if callback(callback_url).present?
96
+ upload_params.merge!(:input => "download",:link => file_path )
97
+ upload_params.merge!(options)
98
+ end
99
+
100
+ def parse_response(response)
101
+ JSON.parse(response)
102
+ end
109
103
 
110
104
  end
111
-
112
105
  end
@@ -1,3 +1,3 @@
1
1
  module Cloudconvert
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudconvert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Pandurang Waghulde
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-05-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: faraday
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: json
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: Ruby wrapper for Cloud Convert
@@ -82,7 +73,7 @@ executables: []
82
73
  extensions: []
83
74
  extra_rdoc_files: []
84
75
  files:
85
- - .gitignore
76
+ - ".gitignore"
86
77
  - Gemfile
87
78
  - LICENSE.txt
88
79
  - README.md
@@ -95,26 +86,25 @@ files:
95
86
  homepage: https://github.com/pandurang90/cloudconvert
96
87
  licenses:
97
88
  - MIT
89
+ metadata: {}
98
90
  post_install_message:
99
91
  rdoc_options: []
100
92
  require_paths:
101
93
  - lib
102
94
  required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
95
  requirements:
105
- - - ! '>='
96
+ - - ">="
106
97
  - !ruby/object:Gem::Version
107
98
  version: '0'
108
99
  required_rubygems_version: !ruby/object:Gem::Requirement
109
- none: false
110
100
  requirements:
111
- - - ! '>='
101
+ - - ">="
112
102
  - !ruby/object:Gem::Version
113
103
  version: '0'
114
104
  requirements: []
115
105
  rubyforge_project:
116
- rubygems_version: 1.8.23
106
+ rubygems_version: 2.2.0
117
107
  signing_key:
118
- specification_version: 3
108
+ specification_version: 4
119
109
  summary: Ruby wrapper for Cloud Convert
120
110
  test_files: []