asposecloudsdk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>Aspose Cloud SDK For Ruby</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>com.aptana.ide.core.unifiedBuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>com.aptana.ruby.core.rubynature</nature>
16
+ <nature>com.aptana.projects.webnature</nature>
17
+ </natures>
18
+ </projectDescription>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in asposecloudsdk.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Assad Mahmood Qazi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ Aspose_Cloud_SDK_For_Ruby
2
+ =========================
3
+
4
+ Aspose Cloud SDK for Ruby allows you to use cloud based REST API in your applications quickly and easily.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'asposecloudsdk/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "asposecloudsdk"
8
+ spec.version = Asposecloudsdk::VERSION
9
+ spec.authors = ["Assad Mahmood Qazi"]
10
+ spec.email = ["assadvirgo@gmail.com"]
11
+ spec.description = "Aspose Cloud SDK for Ruby allows you to use Aspose API in your Ruby applications"
12
+ spec.summary = "Aspose Cloud SDK for Ruby allows you to use Aspose API in your Ruby applications"
13
+ spec.homepage = "http://www.aspose.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib","lib/Barcode","lib/Cells","lib/Common","lib/Ocr","lib/Pdf","lib/Slides","lib/Storage","lib/Words"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rest-client"
24
+ end
@@ -0,0 +1,31 @@
1
+ module Aspose
2
+ module Cloud
3
+ module Barcode
4
+ class Builder
5
+ def initialize()
6
+ #nothing
7
+ end
8
+
9
+ def save code_text, symbology, image_format, x_resolution, y_resolution, x_dimension, y_dimension
10
+ begin
11
+ str_uri = $product_uri + '/barcode/generate?text=' + code_text.to_s + '&type=' + symbology.to_s + '&format=' + image_format.to_s +
12
+ (x_resolution <= 0 ? '' : '&resolutionX=' + x_resolution.to_s) +
13
+ (y_resolution <=0 ? '' : '&resolutionY=' + y_resolution.to_s) +
14
+ (x_dimension <= 0 ? '' : '&dimensionX=' + x_dimension.to_s) +
15
+ (y_dimension <= 0 ? '' : '&dimensionY=' + y_dimension.to_s)
16
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
17
+ response = RestClient.get(signed_uri,:accept => 'application/json')
18
+ output_path = $out_put_location + 'barcode' + symbology.to_s + '.' + image_format.to_s
19
+ Aspose::Cloud::Common::Utils.save_file(response, output_path)
20
+ return output_path
21
+ rescue Exception=>e
22
+ print e
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+ end
31
+
@@ -0,0 +1,87 @@
1
+ module Aspose
2
+ module Cloud
3
+ module Barcode
4
+ class Reader
5
+ def initialize filename
6
+ @filename = filename
7
+ end
8
+
9
+ def read symbology
10
+ begin
11
+ if @filenmae == ''
12
+ raise 'Base file is not specified'
13
+ end
14
+ str_uri = $product_uri + '/barcode/' + @filename + '/recognize?' + (symbology <= 0 ? 'type=' : 'type=' + symbology.to_s)
15
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
16
+ response = RestClient.get(signed_uri,:accept => 'application/json')
17
+ json = JSON.parse(response)
18
+ if(json['Code']== 200)
19
+ return json['Barcodes']
20
+ else
21
+ return nil
22
+ end
23
+ rescue Exception=>e
24
+ print e
25
+ end
26
+ end
27
+
28
+ def read_from_local_image local_image, remote_folder, barcode_read_type,format
29
+ begin
30
+ if @filename==''
31
+ raise 'Base file is not specified.'
32
+ end
33
+ folder = Aspose::Cloud::AsposeStorage::Folder.new
34
+ folder.upload_file(local_image,remote_folder)
35
+ data = readr(File.basename(local_image), remote_folder, barcode_read_type,format)
36
+ return data
37
+ rescue Exception=>e
38
+ print e
39
+ end
40
+ end
41
+
42
+ def readr remote_image_name,remote_folder,read_type,format
43
+ begin
44
+ if @filename == ''
45
+ raise 'Base file is not specified'
46
+ end
47
+ str_uri = uri_builder(remote_image_name, remote_folder, read_type,format)
48
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
49
+ response = RestClient.get(signed_uri , :accept=>'application/json')
50
+ json = JSON.parse(response)
51
+ if(json['Code']==200)
52
+ return json['Barcodes']
53
+ else
54
+ return nil
55
+ end
56
+ rescue Exception=>e
57
+ print e
58
+ end
59
+
60
+ end
61
+
62
+ def uri_builder remote_image,remote_folder,read_type,format
63
+ uri = $product_uri + '/barcode/'
64
+ if remote_image != nil && remote_image!=''
65
+ uri += remote_image + '/'
66
+ end
67
+ uri += 'recognize?'
68
+
69
+ if read_type == 'AllSupportedTypes'
70
+ uri += 'type='
71
+ else
72
+ uri += 'type=' + read_type.to_s;
73
+ end
74
+ if format != nil && format != ''
75
+ uri += '&format=' + format;
76
+ end
77
+ if remote_folder != nil && remote_folder != ''
78
+ uri += '&folder=' + remote_folder;
79
+ end
80
+ return uri;
81
+ end
82
+
83
+ end
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,145 @@
1
+ module Aspose
2
+ module Cloud
3
+ module Cells
4
+ # This class contains features to work with charts
5
+ class ChartEditor
6
+ def initialize filename,worksheet_name
7
+ @filename = filename
8
+ @worksheet_name = worksheet_name
9
+ end
10
+
11
+ # Adds a new chart
12
+ # chartType
13
+ # upperLeftRow
14
+ # upperLeftColumn
15
+ # lowerRightRow
16
+ # lowerRightColumn
17
+
18
+ def add_chart chart_type, upper_left_row, upper_left_column, lower_right_row, lower_right_column
19
+ begin
20
+ if @filename==''
21
+ raise 'Base file not specified'
22
+ end
23
+ if @worksheet_name==''
24
+ raise 'Worksheet is not specified'
25
+ end
26
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + @worksheet_name + '/charts?chartType=' +
27
+ chart_type.to_s + '&upperLeftRow=' + upper_left_row.to_s + '&upperLeftColumn=' +
28
+ upper_left_column.to_s + '&lowerRightRow=' + lower_right_row.to_s +
29
+ '&lowerRightColumn=' + lower_right_column.to_s
30
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
31
+
32
+ response = RestClient.put signed_uri,'', {:accept => 'application/json'}
33
+ v_output = Aspose::Cloud::Common::Utils.validate_output(response)
34
+ if v_output==nil || v_output==''
35
+ folder = Aspose::Cloud::AsposeStorage::Folder.new
36
+ outputstream = folder.get_file(@filename)
37
+ outputpath = $out_put_location + @filename
38
+ Aspose::Cloud::Common::Utils.save_file(outputstream, outputpath)
39
+ return 'Chart added'
40
+ else
41
+ return v_output
42
+ end
43
+ rescue Exception=>e
44
+ print e
45
+ end
46
+ end
47
+
48
+ # Deletes a chart
49
+ # chart_index
50
+
51
+ def delete_chart chart_index
52
+ begin
53
+ if @filename==''
54
+ raise 'Base file not specified'
55
+ end
56
+ if @worksheet_name==''
57
+ raise 'Worksheet is not specified'
58
+ end
59
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + @worksheet_name + '/charts/' + chart_index.to_s
60
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
61
+
62
+ response = RestClient.delete signed_uri, {:accept => 'application/json'}
63
+ v_output = Aspose::Cloud::Common::Utils.validate_output(response)
64
+ if v_output==nil || v_output==''
65
+ folder = Aspose::Cloud::AsposeStorage::Folder.new
66
+ outputstream = folder.get_file(@filename)
67
+ outputpath = $out_put_location + @filename
68
+ Aspose::Cloud::Common::Utils.save_file(outputstream, outputpath)
69
+ return 'Chart deleted'
70
+ else
71
+ return v_output
72
+ end
73
+ rescue Exception=>e
74
+ print e
75
+ end
76
+ end
77
+
78
+ # Gets ChartArea of a chart
79
+ # chart_index
80
+
81
+ def get_chart_area chart_index
82
+ begin
83
+ if @filename==''
84
+ raise 'Base file not specified'
85
+ end
86
+ if @worksheet_name==''
87
+ raise 'Worksheet is not specified'
88
+ end
89
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + @worksheet_name + '/charts/' + chart_index.to_s + '/chartArea'
90
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
91
+ response = RestClient.get signed_uri, {:accept => 'application/json'}
92
+ json = JSON.parse(response)
93
+ return json['ChartArea']
94
+ rescue Exception=>e
95
+ print e
96
+ end
97
+ end
98
+
99
+ # Gets fill format of the ChartArea of a chart
100
+ # chart_index
101
+
102
+ def get_fill_format chart_index
103
+ begin
104
+ if @filename==''
105
+ raise 'Base file not specified'
106
+ end
107
+ if @worksheet_name==''
108
+ raise 'Worksheet is not specified'
109
+ end
110
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + @worksheet_name + '/charts/' + chart_index.to_s + '/chartArea/fillFormat'
111
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
112
+ response = RestClient.get signed_uri, {:accept => 'application/json'}
113
+ json = JSON.parse(response)
114
+ return json['FillFormat']
115
+ rescue Exception=>e
116
+ print e
117
+ end
118
+ end
119
+
120
+ # Gets border of the ChartArea of a chart
121
+ # chart_index
122
+
123
+ def get_border chart_index
124
+ begin
125
+ if @filename==''
126
+ raise 'Base file not specified'
127
+ end
128
+ if @worksheet_name==''
129
+ raise 'Worksheet is not specified'
130
+ end
131
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + @worksheet_name + '/charts/' + chart_index.to_s + '/chartArea/border'
132
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
133
+ response = RestClient.get signed_uri, {:accept => 'application/json'}
134
+ json = JSON.parse(response)
135
+ return json['Line']
136
+ rescue Exception=>e
137
+ print e
138
+ end
139
+ end
140
+ end
141
+ end
142
+
143
+
144
+ end
145
+ end
@@ -0,0 +1,225 @@
1
+ module Aspose
2
+ module Cloud
3
+ module Cells
4
+ # This class provides functionality for converting Excel Spreadsheets to other supported formats.
5
+ class Convertor
6
+ # Constructor for the Convertor Class.
7
+ # * :name represents the name of the Excel Spreadsheet on the Aspose server
8
+ def initialize()
9
+
10
+ end
11
+ def initialize filename
12
+ @filename = filename
13
+ end
14
+ def initialize filename,worksheet_name
15
+ # Instance variables
16
+ @filename = filename
17
+ @worksheet_name = worksheet_name
18
+ end
19
+ # Converts the file available at Aspose Storage and saves converted file locally.
20
+ # * :localFile represents converted local file path and name
21
+ # * :saveFormat represents the converted format. For a list of supported formats, please visit
22
+ # http://aspose.com/docs/display/cells/workbook
23
+ def convert local_file,save_format
24
+ begin
25
+ if @filename == ''
26
+ raise 'Base file is not specified'
27
+ end
28
+ url_doc = $product_uri + '/cells/' + @filename + '?format=' + save_format
29
+ signed_url = Aspose::Cloud::Common::Utils.sign(url_doc)
30
+ response = RestClient.get(signed_url, :accept => 'application/json')
31
+ validate_output = Aspose::Cloud::Common::Utils.validate_output(response)
32
+ if validate_output!=nil || validate_output!=''
33
+ output = $out_put_location + local_file + '.' + save_format
34
+ Aspose::Cloud::Common::Utils.save_file(response, output)
35
+ return output
36
+ else
37
+ return validate_output
38
+ end
39
+ rescue Exception=>e
40
+ print e
41
+ end
42
+ end
43
+
44
+ def convert_to_image image_format,worksheet_name
45
+ begin
46
+ if @filename == ''
47
+ raise 'Base File is not specified.'
48
+ end
49
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name.to_s + '?format=' + image_format.to_s
50
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
51
+ response = RestClient.get(signed_uri,:accept => 'application/json')
52
+ validate_output = Aspose::Cloud::Common::Utils.validate_output(response)
53
+ if validate_output!=nil || validate_output!=''
54
+ output = $out_put_location + worksheet_name + '.' + image_format
55
+ Aspose::Cloud::Common::Utils.save_file(response, output);
56
+ return output
57
+ else
58
+ return validate_output
59
+ end
60
+
61
+ rescue Exception=>e
62
+ print e
63
+ end
64
+ end
65
+
66
+ def save output_format
67
+ begin
68
+ if @filename==''
69
+ raise 'Base File is not specified.'
70
+ end
71
+ str_uri = $product_uri + '/cells/' + @filename + '?format=' + output_format.to_s
72
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
73
+ response = RestClient.get(signed_uri,:accept => 'application/json')
74
+ validate_output = Aspose::Cloud::Common::Utils.validate_output(response)
75
+ if validate_output==nil || validate_output==''
76
+ output = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + output_format
77
+ Aspose::Cloud::Common::Utils.save_file(response, output);
78
+ return output
79
+ else
80
+ return validate_output
81
+ end
82
+
83
+
84
+ rescue Exception=>e
85
+ print e
86
+ end
87
+ end
88
+
89
+ def worksheet_to_image image_format
90
+ begin
91
+ if @filename==''
92
+ raise 'Base file name is not specified.'
93
+ end
94
+ if @worksheet_name == ''
95
+ raise 'Worksheet is not specified'
96
+ end
97
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
98
+ @worksheet_name + '?format=' + image_format.to_s
99
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
100
+ response = RestClient.get(signed_uri,:accept => 'application/json')
101
+ v_output = Aspose::Cloud::Common::Utils.validate_output(response)
102
+ if v_output==nil || v_output==''
103
+ outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
104
+ Aspose::Cloud::Common::Utils.save_file(response, outputpath)
105
+ return outputpath
106
+ else
107
+ return v_output
108
+ end
109
+ rescue Exception=>e
110
+ print e
111
+ end
112
+
113
+ end
114
+
115
+ def picture_to_image picture_index,image_format
116
+ begin
117
+ if @filename==''
118
+ raise 'Base File is not specified'
119
+ end
120
+ if @worksheet_name==''
121
+ raise 'Worksheet is not specified'
122
+ end
123
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
124
+ @worksheet_name + '/pictures/' + picture_index.to_s + '?format=' + image_format.to_s;
125
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
126
+
127
+ response = RestClient.get(signed_uri, :accept => 'application/json')
128
+
129
+ v_output = Aspose::Cloud::Common::Utils.validate_output(response)
130
+ if v_output==nil || v_output==''
131
+ outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
132
+ Aspose::Cloud::Common::Utils.save_file(response, outputpath)
133
+ return outputpath
134
+ else
135
+ return v_output
136
+ end
137
+ rescue Exception=>e
138
+ print e
139
+ end
140
+ end
141
+
142
+ def oleobject_to_image object_index,image_format
143
+ begin
144
+ if @filename==''
145
+ raise 'Base File is not specified'
146
+ end
147
+ if @worksheet_name==''
148
+ raise 'Worksheet is not specified'
149
+ end
150
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
151
+ @worksheet_name + '/oleobjects/' + object_index.to_s + '?format=' + image_format.to_s;
152
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
153
+ response = RestClient.get(signed_uri, :accept => 'application/json')
154
+
155
+ v_output = Aspose::Cloud::Common::Utils.validate_output(response)
156
+ if v_output==nil || v_output==''
157
+ outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
158
+ Aspose::Cloud::Common::Utils.save_file(response, outputpath)
159
+ return outputpath
160
+ else
161
+ return v_output
162
+ end
163
+ rescue Exception=>e
164
+ print e
165
+ end
166
+ end
167
+
168
+ def chart_to_image chart_index,image_format
169
+ begin
170
+ if @filename==''
171
+ raise 'Base File is not specified'
172
+ end
173
+ if @worksheet_name==''
174
+ raise 'Worksheet is not specified'
175
+ end
176
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
177
+ @worksheet_name + '/charts/' + chart_index.to_s + '?format=' + image_format.to_s;
178
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
179
+
180
+ response = RestClient.get(signed_uri, :accept => 'application/json')
181
+
182
+ v_output = Aspose::Cloud::Common::Utils.validate_output(response)
183
+ if v_output==nil || v_output==''
184
+ outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
185
+ Aspose::Cloud::Common::Utils.save_file(response, outputpath)
186
+ return outputpath
187
+ else
188
+ return v_output
189
+ end
190
+ rescue Exception=>e
191
+ print e
192
+ end
193
+ end
194
+
195
+ def autoshape_to_image shape_index,image_format
196
+ begin
197
+ if @filename==''
198
+ raise 'Base File is not specified'
199
+ end
200
+ if @worksheet_name==''
201
+ raise 'Worksheet is not specified'
202
+ end
203
+ str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
204
+ @worksheet_name + '/autoshapes/' + shape_index.to_s + '?format=' + image_format.to_s;
205
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
206
+
207
+ response = RestClient.get(signed_uri, :accept => 'application/json')
208
+
209
+ v_output = Aspose::Cloud::Common::Utils.validate_output(response)
210
+ if v_output==nil || v_output==''
211
+ outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
212
+ Aspose::Cloud::Common::Utils.save_file(response, outputpath)
213
+ return outputpath
214
+ else
215
+ return v_output
216
+ end
217
+ rescue Exception=>e
218
+ print e
219
+ end
220
+ end
221
+ end
222
+ end
223
+
224
+ end
225
+ end