asposecloud 1.0.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.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.project +18 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +21 -0
  6. data/README.md +71 -0
  7. data/Rakefile +1 -0
  8. data/Samples/Barcode/Test_Builder.rb +35 -0
  9. data/Samples/Barcode/Test_Reader.rb +34 -0
  10. data/Samples/Cells/Test_Converter.rb +34 -0
  11. data/Samples/Email/Test_Converter.rb +31 -0
  12. data/Samples/Email/Test_Document.rb +31 -0
  13. data/Samples/Pdf/Test_Converter.rb +38 -0
  14. data/Samples/Pdf/Test_TextEditor.rb +33 -0
  15. data/Samples/Slides/Test_Converter.rb +35 -0
  16. data/Samples/Storage/Test_Folder.rb +42 -0
  17. data/Samples/Words/Test_Converter.rb +34 -0
  18. data/Samples/tasks/Test_Converter.rb +31 -0
  19. data/Samples/tasks/Test_Document.rb +33 -0
  20. data/Tests/Data/barcodeQR.png +0 -0
  21. data/Tests/Data/email_test.eml +21 -0
  22. data/Tests/Data/email_test_attach.eml +64 -0
  23. data/Tests/Data/test_convert_cell.xlsx +0 -0
  24. data/Tests/Data/test_convert_slide.pptx +0 -0
  25. data/Tests/Data/test_convertlocal.docx +0 -0
  26. data/Tests/Data/test_convertlocal.pdf +0 -0
  27. data/Tests/Data/test_file_on_storage.pdf +0 -0
  28. data/Tests/Data/test_replace_text.pdf +0 -0
  29. data/Tests/Data/test_tasks.mpp +0 -0
  30. data/Tests/Data/test_uploadfile.docx +0 -0
  31. data/Tests/Output/barcodeQR.png +0 -0
  32. data/Tests/Output/converted_file.doc +0 -0
  33. data/Tests/Output/converted_file.pdf +0 -0
  34. data/Tests/Output/converted_file.tiff +0 -0
  35. data/Tests/Output/email_test.msg +0 -0
  36. data/Tests/Output/test_convert_slide.png +0 -0
  37. data/Tests/Output/test_file_on_storage.doc +0 -0
  38. data/Tests/Output/testfile.jpeg +0 -0
  39. data/Tests/barcode_tests.rb +45 -0
  40. data/Tests/cell_tests.rb +41 -0
  41. data/Tests/email_tests.rb +43 -0
  42. data/Tests/pdf_tests.rb +76 -0
  43. data/Tests/slide_tests.rb +41 -0
  44. data/Tests/storage_tests.rb +86 -0
  45. data/Tests/tasks_tests.rb +24 -0
  46. data/Tests/word_tests.rb +34 -0
  47. data/asposecloud.gemspec +24 -0
  48. data/lib/Barcode/builder.rb +45 -0
  49. data/lib/Barcode/reader.rb +65 -0
  50. data/lib/Cells/chart_editor.rb +91 -0
  51. data/lib/Cells/convertor.rb +144 -0
  52. data/lib/Cells/extractor.rb +86 -0
  53. data/lib/Cells/text_editor.rb +94 -0
  54. data/lib/Cells/workbook.rb +224 -0
  55. data/lib/Cells/worksheet.rb +375 -0
  56. data/lib/Common/aspose_app.rb +51 -0
  57. data/lib/Common/product.rb +34 -0
  58. data/lib/Common/utils.rb +172 -0
  59. data/lib/Email/converter.rb +50 -0
  60. data/lib/Email/document.rb +67 -0
  61. data/lib/Ocr/extractor.rb +105 -0
  62. data/lib/Pdf/annotation_editor.rb +263 -0
  63. data/lib/Pdf/converter.rb +127 -0
  64. data/lib/Pdf/document.rb +220 -0
  65. data/lib/Pdf/extractor.rb +107 -0
  66. data/lib/Pdf/text_editor.rb +121 -0
  67. data/lib/Slides/converter.rb +79 -0
  68. data/lib/Slides/document.rb +208 -0
  69. data/lib/Slides/extractor.rb +135 -0
  70. data/lib/Storage/folder.rb +128 -0
  71. data/lib/Words/builder.rb +82 -0
  72. data/lib/Words/converter.rb +67 -0
  73. data/lib/Words/document.rb +117 -0
  74. data/lib/Words/extractor.rb +153 -0
  75. data/lib/Words/mail_merge.rb +65 -0
  76. data/lib/aspose_barcode.rb +21 -0
  77. data/lib/aspose_cells.rb +24 -0
  78. data/lib/aspose_common.rb +29 -0
  79. data/lib/aspose_email.rb +20 -0
  80. data/lib/aspose_ocr.rb +21 -0
  81. data/lib/aspose_pdf.rb +23 -0
  82. data/lib/aspose_slides.rb +21 -0
  83. data/lib/aspose_storage.rb +19 -0
  84. data/lib/aspose_tasks.rb +23 -0
  85. data/lib/aspose_words.rb +23 -0
  86. data/lib/asposecloud.rb +29 -0
  87. data/lib/asposecloud/version.rb +3 -0
  88. data/lib/tasks/assignments.rb +71 -0
  89. data/lib/tasks/calendar.rb +56 -0
  90. data/lib/tasks/converter.rb +48 -0
  91. data/lib/tasks/document.rb +143 -0
  92. data/lib/tasks/resources.rb +69 -0
  93. metadata +187 -0
@@ -0,0 +1,135 @@
1
+ # Copyright (c) Aspose 2002-2014. All Rights Reserved.
2
+ #
3
+ # LICENSE: This program is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU General Public License
5
+ # as published by the Free Software Foundation; either version 3
6
+ # of the License, or (at your option) any later version.
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ # You should have received a copy of the GNU General Public License
12
+ # along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
13
+ #
14
+ # @package Aspose_Cloud_SDK_For_Ruby
15
+ # @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
16
+ # @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
17
+
18
+ module Aspose
19
+ module Cloud
20
+ module Slides
21
+ class Extractor
22
+ def initialize (filename)
23
+ @filename = filename
24
+ raise 'filename not specified.' if filename.empty?
25
+ @base_uri = Aspose::Cloud::Common::Product.product_uri + '/slides/' + @filename
26
+ end
27
+ =begin
28
+ Gets total number of images in a presentation
29
+ =end
30
+ def get_image_count(folder_name = '', storage_type = 'Aspose', storage_name = '')
31
+ str_uri = "#{@base_uri}/images"
32
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
33
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
34
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Images']['List'].length
35
+ end
36
+
37
+ =begin
38
+ Gets number of images in the specified slide
39
+ @param number slide_number
40
+ =end
41
+ def get_slide_image_count(slide_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
42
+ raise 'slide_number not specified.' if slide_number <= 0
43
+
44
+ str_uri = "#{@base_uri}/slides/#{slide_number}/images"
45
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
46
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
47
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Images']['List'].length
48
+ end
49
+ =begin
50
+ Gets all shapes from the specified slide
51
+ @param number slide_number
52
+ =end
53
+ def get_shapes(slide_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
54
+ raise 'slide_number not specified.' if slide_number <= 0
55
+
56
+ str_uri = "#{@base_uri}/slides/#{slide_number}/shapes"
57
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
58
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
59
+ shapes = Hash.new
60
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['ShapeList']['ShapesLinks'].each { |item|
61
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(item['Uri']['Href'])
62
+ shapes.push(JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'})))
63
+ }
64
+ shapes
65
+ end
66
+
67
+ =begin
68
+ Get color scheme from the specified slide
69
+ @param number slide_number
70
+ =end
71
+ def get_color_scheme(slide_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
72
+ raise 'slide_number not specified.' if slide_number <= 0
73
+
74
+ str_uri = "#{@base_uri}/slides/#{slide_number}/theme/colorScheme"
75
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
76
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
77
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['ColorScheme']
78
+ end
79
+ =begin
80
+ Get font scheme from the specified slide
81
+ @param number slide_number
82
+ =end
83
+ def get_font_scheme(slide_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
84
+ raise 'slide_number not specified.' if slide_number <= 0
85
+
86
+ str_uri = "#{@base_uri}/slides/#{slide_number}/theme/fontScheme"
87
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
88
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
89
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['FontScheme']
90
+ end
91
+
92
+ =begin
93
+ Get format scheme from the specified slide
94
+ @param number slide_number
95
+ =end
96
+ def get_format_scheme(slide_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
97
+ raise 'slide_number not specified.' if slide_number <= 0
98
+
99
+ str_uri = "#{@base_uri}/slides/#{slide_number}/theme/formatScheme"
100
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
101
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
102
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['FormatScheme']
103
+ end
104
+
105
+ =begin
106
+ Gets placeholder count from a particular slide
107
+ @param number $slideNumber
108
+ =end
109
+ def get_placeholder_count(slide_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
110
+ raise 'slide_number not specified.' if slide_number <= 0
111
+
112
+ str_uri = "#{@base_uri}/slides/#{slide_number}/placeholders"
113
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
114
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
115
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Placeholders']['PlaceholderLinks'].length
116
+ end
117
+
118
+ =begin
119
+ Gets placeholder count from a particular slide
120
+ @param number $slideNumber
121
+ @param number $placeholderIndex
122
+ =end
123
+ def get_placeholder(slide_number, placeholder_index, folder_name = '', storage_type = 'Aspose', storage_name = '')
124
+ raise 'slide_number not specified.' if slide_number <= 0
125
+ raise 'placeholder_index not specified.' if placeholder_index.nil?
126
+
127
+ str_uri = "#{@base_uri}/slides/#{slide_number}/placeholders/#{placeholder_index}"
128
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
129
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
130
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Placeholder']
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,128 @@
1
+ # Copyright (c) Aspose 2002-2014. All Rights Reserved.
2
+ #
3
+ # LICENSE: This program is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU General Public License
5
+ # as published by the Free Software Foundation; either version 3
6
+ # of the License, or (at your option) any later version.
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ # You should have received a copy of the GNU General Public License
12
+ # along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
13
+ #
14
+ # @package Aspose_Cloud_SDK_For_Ruby
15
+ # @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
16
+ # @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
17
+
18
+ module Aspose
19
+ module Cloud
20
+ module AsposeStorage
21
+ # This class provides functionality to manage files in a Remote Aspose Folder
22
+ class Folder
23
+
24
+ def initialize
25
+ @str_uri_folder = Aspose::Cloud::Common::Product.product_uri + '/storage/folder/'
26
+ @str_uri_file = Aspose::Cloud::Common::Product.product_uri + '/storage/file/'
27
+ @str_uri_exist = Aspose::Cloud::Common::Product.product_uri + '/storage/exist/'
28
+ @str_uri_disc = Aspose::Cloud::Common::Product.product_uri + '/storage/disc/'
29
+ end
30
+
31
+ # Uploads file from the local path to the remote folder.
32
+ # * :localFilePath represents full local file path and name
33
+ # * :remoteFolderPath represents remote folder relative to the root. Pass empty string for the root folder.
34
+ def upload_file(local_file, remote_folder='', storage_type='Aspose', storage_name='')
35
+ raise 'Local file not specified' if local_file.empty?
36
+
37
+ filename = File.basename(local_file)
38
+ str_uri = "#{ Aspose::Cloud::Common::Product.product_uri }/storage/file/#{ remote_folder + '/' unless remote_folder.empty? }#{ filename }"
39
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
40
+
41
+ signeduri = Aspose::Cloud::Common::Utils.sign(str_uri)
42
+ response = JSON.parse(Aspose::Cloud::Common::Utils.upload_file_binary(local_file, signeduri))
43
+ response['Status'].eql? 'OK'
44
+ end
45
+
46
+
47
+ # Retrieves Files and Folder information from a remote folder. The method returns an Array of AppFile objects.
48
+ # * :remoteFolderPath represents remote folder relative to the root. Pass empty string for the root folder.
49
+ def get_files(remote_folder_path='', storage_type='Aspose', storage_name='')
50
+ str_uri = @str_uri_folder + remote_folder_path
51
+ str_uri = str_uri[0..-2] if str_uri[-1].eql? '/'
52
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
53
+
54
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
55
+ response = RestClient.get(signed_uri, :accept => 'application/json')
56
+
57
+ JSON.parse(response)['Files']
58
+ end
59
+
60
+ # check if a file exists on the storage
61
+ def file_exists(filename, storage_type = 'Aspose', storage_name = '')
62
+ raise('Filename cannot be empty') if filename.empty?
63
+
64
+ str_uri = @str_uri_exist + filename
65
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
66
+
67
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
68
+
69
+ response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'})
70
+ JSON.parse(response_stream)['FileExist']['IsExist']
71
+ end
72
+
73
+ def delete_file(filename, storage_type = 'Aspose', storage_name = '')
74
+ raise 'File name cannot be empty' if filename.empty?
75
+
76
+ str_uri = @str_uri_file + filename
77
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
78
+
79
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
80
+
81
+ response_stream = RestClient.delete(signed_str_uri, {:accept => 'application/json'})
82
+ JSON.parse(response_stream)['Code'].eql? 200
83
+ end
84
+
85
+ def create_folder (folder_name, storage_type = 'Aspose', storage_name='')
86
+ raise 'Folder name cannot be empty' if folder_name.empty?
87
+ str_uri = @str_uri_folder + folder_name
88
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
89
+
90
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
91
+ response = RestClient.put(signed_uri, '', :accept => :json)
92
+ JSON.parse(response)['Code'].eql? 200
93
+ end
94
+
95
+ def delete_folder (folder_name, storage_type = 'Aspose', storage_name='')
96
+ raise 'Folder name cannot be empty' if folder_name.empty?
97
+ str_uri = @str_uri_folder + folder_name
98
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
99
+
100
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
101
+ response = RestClient.delete(signed_uri, :accept => 'application/json')
102
+ JSON.parse(response)['Code'].eql? 200
103
+ end
104
+
105
+ def get_disc_usage (storage_type = 'Aspose', storage_name = '')
106
+ str_uri = @str_uri_disc
107
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
108
+
109
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
110
+ response = RestClient.get(signed_uri, :accept => 'application/json')
111
+ JSON.parse(response)['DiscUsage']
112
+ end
113
+
114
+ # Get file from storage
115
+ def get_file (file_name, storage_type = 'Aspose', storage_name = '')
116
+ raise 'Filename cannot be empty' if file_name.empty?
117
+
118
+ str_uri = @str_uri_file + file_name
119
+ str_uri += append_storage(storage_name) unless storage_type.eql? 'Aspose'
120
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
121
+
122
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
123
+ RestClient.get(signed_uri, :accept => 'application/json')
124
+ end
125
+ end #Class Ends Here
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,82 @@
1
+ # Copyright (c) Aspose 2002-2014. All Rights Reserved.
2
+ #
3
+ # LICENSE: This program is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU General Public License
5
+ # as published by the Free Software Foundation; either version 3
6
+ # of the License, or (at your option) any later version.
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ # You should have received a copy of the GNU General Public License
12
+ # along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
13
+ #
14
+ # @package Aspose_Cloud_SDK_For_Ruby
15
+ # @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
16
+ # @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
17
+
18
+ module Aspose
19
+ module Cloud
20
+ module Words
21
+ class Builder
22
+ def initialize(filename)
23
+ @filename = filename
24
+ raise 'filename not specified.' if filename.empty?
25
+ @base_uri = Aspose::Cloud::Common::Product.product_uri + '/words/' + @filename
26
+ end
27
+
28
+ =begin
29
+ Inserts water mark text into the document.
30
+ @param string text
31
+ @param string rotation_angle
32
+ =end
33
+ def insert_watermark_text(text, rotation_angle, folder_name = '', storage_type = 'Aspose', storage_name = '')
34
+ raise 'text not specified.' if text.empty?
35
+ raise 'rotation_angle not specified.' if rotation_angle.nil?
36
+
37
+ json_data = {:Text => text, :RotationAngle => rotation_angle}.to_json
38
+ str_uri = "#{@base_uri}/insertWatermarkText"
39
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
40
+ response_stream = RestClient.post(signed_str_uri, json_data, {:content_type => :json, :accept => 'application/json'})
41
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
42
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
43
+ end
44
+
45
+ =begin
46
+ Inserts water mark image into the document.
47
+ @param string image_file
48
+ @param string rotation_angle
49
+ =end
50
+ def insert_watermark_image(image_file, rotation_angle, folder_name = '', storage_type = 'Aspose', storage_name = '')
51
+ raise 'image_file not specified.' if image_file.empty?
52
+ raise 'rotation_angle not specified.' if rotation_angle.nil?
53
+
54
+ str_uri = "#{@base_uri}/insertWatermarkImage?imageFile=#{image_file}&rotationAngle=#{rotation_angle}"
55
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
56
+ response_stream = RestClient.post(signed_str_uri, '', {:content_type => :json, :accept => 'application/json'})
57
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
58
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
59
+ end
60
+
61
+ =begin
62
+ Replace a text with the new value in the document
63
+ @param string old_value
64
+ @param string new_value
65
+ @param string is_match_case
66
+ @param string is_match_whole_word
67
+ =end
68
+ def replace_text(old_text, new_text, is_match_case = false, is_match_whole_word = false, folder_name = '', storage_type = 'Aspose', storage_name = '')
69
+ raise 'old_text not specified.' if old_text.empty?
70
+ raise 'new_text not specified.' if new_text.nil?
71
+
72
+ json_data = {:OldValue => old_text, :NewValue => new_text, :IsMatchCase => is_match_case, :IsMatchWholeWord => is_match_whole_word}.to_json
73
+ str_uri = "#{@base_uri}/replaceText"
74
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
75
+ response_stream = RestClient.post(signed_str_uri, json_data, {:content_type => :json, :accept => 'application/json'})
76
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
77
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,67 @@
1
+ # Copyright (c) Aspose 2002-2014. All Rights Reserved.
2
+ #
3
+ # LICENSE: This program is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU General Public License
5
+ # as published by the Free Software Foundation; either version 3
6
+ # of the License, or (at your option) any later version.
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ # You should have received a copy of the GNU General Public License
12
+ # along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
13
+ #
14
+ # @package Aspose_Cloud_SDK_For_Ruby
15
+ # @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
16
+ # @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
17
+
18
+ module Aspose
19
+ module Cloud
20
+ module Words
21
+ class Converter
22
+ def initialize(filename)
23
+ @filename = filename
24
+ raise 'filename not specified.' if filename.empty?
25
+ @base_uri = Aspose::Cloud::Common::Product.product_uri + '/words/' + @filename
26
+ end
27
+
28
+ def convert(save_format, folder_name = '', storage_type = 'Aspose', storage_name = '')
29
+ raise 'save_format not specified.' if save_format.empty?
30
+
31
+ str_uri = "#{@base_uri}?format=#{save_format}"
32
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
33
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
34
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
35
+
36
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
37
+
38
+ if valid_output.empty?
39
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}"
40
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
41
+ else
42
+ valid_output
43
+ end
44
+ end
45
+
46
+ def convert_local_file(input_file_path, output_filename, save_format)
47
+ raise 'input_file_path not specified.' if input_file_path.empty?
48
+ raise 'output_filename not specified.' if output_filename.empty?
49
+ raise 'save_format not specified.' if save_format.empty?
50
+
51
+ str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/words/convert?format=#{save_format}"
52
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
53
+ response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_file_path, signed_str_uri)
54
+
55
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
56
+
57
+ if valid_output.empty?
58
+ save_format = 'zip' if save_format.eql?('html')
59
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_filename)}.#{save_format}"
60
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
61
+ end
62
+ valid_output
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,117 @@
1
+ # Copyright (c) Aspose 2002-2014. All Rights Reserved.
2
+ #
3
+ # LICENSE: This program is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU General Public License
5
+ # as published by the Free Software Foundation; either version 3
6
+ # of the License, or (at your option) any later version.
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ # You should have received a copy of the GNU General Public License
12
+ # along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
13
+ #
14
+ # @package Aspose_Cloud_SDK_For_Ruby
15
+ # @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
16
+ # @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
17
+
18
+ module Aspose
19
+ module Cloud
20
+ module Words
21
+ class Document
22
+ def initialize(filename)
23
+ @filename = filename
24
+ raise 'filename not specified.' if filename.empty?
25
+ @base_uri = "#{Aspose::Cloud::Common::Product.product_uri}/words/#{@filename}"
26
+ end
27
+
28
+ =begin
29
+ Appends a list of documents to this one.
30
+ @param string append_docs
31
+ @param import_format_modes
32
+ @param source_folder
33
+ =end
34
+ def append_document(append_docs, import_format_modes, folder_name = '', storage_type = 'Aspose', storage_name = '')
35
+ raise 'append_docs not specified.' if append_docs.empty?
36
+ raise 'import_format_modes not specified.' if import_format_modes.empty?
37
+
38
+ docs = Array.new
39
+ append_docs.to_enum.with_index(0).each { |item,i|
40
+ docs.push({ :Href => folder_name.empty? ? item : "#{folder_name}/#{item}", :ImportFormatMode => import_format_modes[i] })
41
+ }
42
+ json_data = JSON.generate({:DocumentEntries => docs})
43
+
44
+ str_uri = "#{@base_uri}/appendDocument"
45
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,'',storage_name,storage_type)
46
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
47
+ response_stream = RestClient.post(signed_str_uri, json_data, {:content_type=>:json, :accept=>'application/json'})
48
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
49
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
50
+ end
51
+
52
+ =begin
53
+ Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties
54
+ =end
55
+
56
+ def get_document_info(folder_name = '', storage_type = 'Aspose', storage_name = '')
57
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(@base_uri,folder_name,storage_name,storage_type)
58
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
59
+ JSON.parse(RestClient.get(signed_str_uri, {:accept => 'application/json'}))['Document']
60
+ end
61
+
62
+ =begin
63
+ Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties
64
+ @param string property_name
65
+ =end
66
+ def get_property(property_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
67
+ raise 'property_name not specified.' if property_name.empty?
68
+
69
+ str_uri = "#{@base_uri}/documentProperties/#{property_name}"
70
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
71
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
72
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['DocumentProperty']
73
+ end
74
+
75
+ =begin
76
+ Set document property
77
+ @param string property_name
78
+ @param string property_value
79
+ =end
80
+ def set_property(property_name, property_value, folder_name = '', storage_type = 'Aspose', storage_name = '')
81
+ raise 'property_name not specified.' if property_name.empty?
82
+ raise 'property_value not specified.' if property_value.empty?
83
+
84
+ json_data = JSON.generate('Value'=>property_value)
85
+
86
+ str_uri = "#{@base_uri}/documentProperties/#{property_name}"
87
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
88
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
89
+ JSON.parse(RestClient.put(signed_str_uri, json_data, {:content_type=>:json, :accept=>'application/json'}))['DocumentProperty']
90
+ end
91
+
92
+ =begin
93
+ Delete a document property
94
+ @param string property_name
95
+ =end
96
+ def delete_property(property_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
97
+ raise 'property_name not specified.' if property_name.empty?
98
+
99
+ str_uri = "#{@base_uri}/documentProperties/#{property_name}"
100
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
101
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
102
+ JSON.parse(RestClient.delete(signed_str_uri, {:accept=>'application/json'}))['Code'] == 200 ? true : false
103
+ end
104
+
105
+ =begin
106
+ Get Document's properties
107
+ =end
108
+ def get_properties(folder_name = '', storage_type = 'Aspose', storage_name = '')
109
+ str_uri = "#{@base_uri}/documentProperties"
110
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
111
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
112
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['DocumentProperties']['List']
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end