saaspose 0.0.1 → 0.0.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/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/Gemfile.lock +4 -2
- data/README.md +35 -62
- data/lib/saaspose/cells.rb +2 -2
- data/lib/saaspose/configuration.rb +5 -33
- data/lib/saaspose/pdf.rb +6 -11
- data/lib/saaspose/slides.rb +3 -5
- data/lib/saaspose/storage.rb +11 -12
- data/lib/saaspose/utils.rb +32 -40
- data/lib/saaspose/version.rb +1 -1
- data/lib/saaspose/words.rb +3 -5
- data/saaspose.gemspec +2 -1
- data/spec/lib/saaspose/utils_spec.rb +18 -0
- data/spec/lib/saaspose_spec.rb +11 -52
- data/spec/spec_helper.rb +33 -1
- data/spec/vcr_cassettes/ensure_remote_file_saaspose_test_doc.yml +3 -3
- data/spec/vcr_cassettes/ensure_remote_file_saaspose_test_pdf.yml +3 -3
- data/spec/vcr_cassettes/ensure_remote_file_saaspose_test_ppt.yml +3 -3
- data/spec/vcr_cassettes/ensure_remote_file_saaspose_test_xls.yml +3 -3
- data/spec/vcr_cassettes/saaspose/cells_should_generate_a_pdf_from_a_remote_xls.yml +6 -43
- data/spec/vcr_cassettes/saaspose/pdf_should_generate_a_png_from_a_page_of_a_remote_pdf.yml +868 -0
- data/spec/vcr_cassettes/saaspose/pdf_should_generate_a_png_from_a_remote_pdf.yml +817 -854
- data/spec/vcr_cassettes/saaspose/pdf_should_read_the_number_of_pages_from_a_remote_pdf.yml +5 -8
- data/spec/vcr_cassettes/saaspose/slides_should_generate_a_pdf_from_a_remote_ppt.yml +2 -2
- data/spec/vcr_cassettes/saaspose/storage_should_get_a_list_of_files_from_the_root_dir.yml +3 -3
- data/spec/vcr_cassettes/saaspose/storage_should_upload_a_file_to_the_root_dir.yml +5 -6
- data/spec/vcr_cassettes/saaspose/words_should_generate_a_pdf_from_a_remote_doc.yml +274 -715
- metadata +59 -14
data/.gitignore
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
4
|
+
saaspose (0.0.2)
|
5
|
+
confiture (~> 0.1)
|
5
6
|
rest-client (~> 1.6)
|
6
7
|
|
7
8
|
GEM
|
@@ -9,6 +10,7 @@ GEM
|
|
9
10
|
specs:
|
10
11
|
addressable (2.2.7)
|
11
12
|
coderay (1.0.6)
|
13
|
+
confiture (0.1.2)
|
12
14
|
crack (0.3.1)
|
13
15
|
diff-lcs (1.1.3)
|
14
16
|
method_source (0.7.1)
|
@@ -39,6 +41,6 @@ PLATFORMS
|
|
39
41
|
DEPENDENCIES
|
40
42
|
pry (~> 0.9)
|
41
43
|
rspec (~> 2.9)
|
42
|
-
|
44
|
+
saaspose!
|
43
45
|
vcr (~> 2.1)
|
44
46
|
webmock (~> 1.8)
|
data/README.md
CHANGED
@@ -1,79 +1,52 @@
|
|
1
|
-
#Saaspose
|
1
|
+
# Ruby bindings to Saaspose REST API
|
2
2
|
|
3
|
-
This
|
3
|
+
This gem provides a access to the [Saaspose REST API](http://saaspose.com/docs/display/rest/Home).
|
4
4
|
|
5
|
+
## Installation
|
5
6
|
|
6
|
-
|
7
|
+
gem install saaspose
|
7
8
|
|
8
|
-
|
9
|
+
or using bundler
|
9
10
|
|
10
|
-
|
11
|
-
<tr>
|
12
|
-
<th>Module</th>
|
13
|
-
<th>Description</th>
|
14
|
-
</tr>
|
11
|
+
gem "saaspose"
|
15
12
|
|
16
|
-
|
17
|
-
<td>Common</td>
|
18
|
-
<td>This module provides the features commonly used by other sections of the SDK.</td>
|
19
|
-
</tr>
|
13
|
+
## Configuration
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
Saaspose::Configuration.configure do |config|
|
16
|
+
config.app_sid = ENV["SAASPOSE_APPSID"]
|
17
|
+
config.app_key = ENV["SAASPOSE_APPKEY"]
|
18
|
+
end
|
25
19
|
|
26
|
-
|
27
|
-
<td>Pdf</td>
|
28
|
-
<td>This module provides the features to manipulate PDF files using Saaspose.Pdf.</td>
|
29
|
-
</tr>
|
20
|
+
## Usage
|
30
21
|
|
31
|
-
|
32
|
-
<td>Words</td>
|
33
|
-
<td>This module provides the features to manipulate Word files using Saaspose.Words.</td>
|
34
|
-
</tr>
|
22
|
+
Please have a look at the specs to see all the examples!
|
35
23
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
24
|
+
# generate a png from a page of a remote pdf
|
25
|
+
Saaspose::Pdf.convert("remote_pdf_file.pdf", "local_png.png", 1)
|
26
|
+
# read the number of pages from a remote pdf
|
27
|
+
Saaspose::Pdf.page_count"remote_pdf_file.pdf"
|
28
|
+
# => 1
|
40
29
|
|
41
|
-
|
42
|
-
|
43
|
-
<td>This module provides the features to manipulate Powerpoint files using Saaspose.Slides.</td>
|
44
|
-
</tr>
|
30
|
+
# generate a pdf from a remote ppt
|
31
|
+
Saaspose::Slides.convert"remote_ppt_file.ppt", "local_pdf.pdf")
|
45
32
|
|
46
|
-
|
47
|
-
|
48
|
-
<td>This module provides the features to manipulate bar codes using Saaspose.BarCode.</td>
|
49
|
-
</tr>
|
33
|
+
# generate a pdf from a remote doc
|
34
|
+
Saaspose::Words.convert"remote_doc_file.doc", "local_pdf.pdf")
|
50
35
|
|
36
|
+
# generate a pdf from a remote xls
|
37
|
+
Saaspose::Cells.convert("remote_xls_file.xls", "local_pdf.pdf")
|
51
38
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
###Data
|
57
|
-
|
58
|
-
In order to manipulate any files, you first need to upload them to the Saaspose storage using Storage module.
|
59
|
-
|
60
|
-
###Output
|
61
|
-
|
62
|
-
The Saaspose.SDK for Ruby allows you to save the output files at your specified location.
|
63
|
-
|
64
|
-
|
65
|
-
###Help Material
|
66
|
-
|
67
|
-
You may get help regarding Saaspose API or Saaspose.SDK for Ruby on [www.saaspose.com](http://www.saaspose.com).
|
68
|
-
|
69
|
-
##How to use Saaspose.SDK for Ruby?
|
70
|
-
|
71
|
-
Please see the Saaaspose.SDK for Ruby Examples sections in the [Documentation](http://www.saaspose.com/docs).
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
39
|
+
# upload a file to the root dir
|
40
|
+
Saaspose::Storage.upload("example.pdf", "")
|
77
41
|
|
42
|
+
# get a list of files from the root dir
|
43
|
+
files = Saaspose::Storage.files("")
|
44
|
+
files.first
|
45
|
+
# => <struct Saaspose::Storage::RemoteFile name="test", folder=true, modified=1969-12-31 14:00:00 +0100, size=0>
|
78
46
|
|
47
|
+
## License
|
79
48
|
|
49
|
+
"THE BEER-WARE LICENSE" (Revision 42):
|
50
|
+
[ps@nofail.de](mailto:ps@nofail.de) wrote this file. As long as you retain this notice you
|
51
|
+
can do whatever you want with this stuff. If we meet some day, and you think
|
52
|
+
this stuff is worth it, you can buy me a beer in return Peter Schröder
|
data/lib/saaspose/cells.rb
CHANGED
@@ -1,39 +1,11 @@
|
|
1
|
+
require "confiture"
|
1
2
|
require "logger"
|
2
3
|
|
3
4
|
module Saaspose
|
4
5
|
class Configuration
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
attr_accessor :init
|
10
|
-
|
11
|
-
def configure(options={})
|
12
|
-
init_config
|
13
|
-
if block_given?
|
14
|
-
yield self
|
15
|
-
else
|
16
|
-
options.each do |key, value|
|
17
|
-
send(:"#{key}=", value)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
self
|
21
|
-
end
|
22
|
-
|
23
|
-
def reset
|
24
|
-
init_config(true)
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def init_config(force=false)
|
30
|
-
return if @init && !force
|
31
|
-
@init = true
|
32
|
-
@product_uri = ""
|
33
|
-
@app_key = ""
|
34
|
-
@app_sid = ""
|
35
|
-
@logger = Logger.new(STDERR)
|
36
|
-
end
|
37
|
-
end
|
6
|
+
include Confiture::Configuration
|
7
|
+
confiture_allowed_keys(:product_uri, :app_sid, :app_key, :logger)
|
8
|
+
confiture_mandatory_keys(:product_uri, :app_sid, :app_key)
|
9
|
+
confiture_defaults(:product_uri => "http://api.saaspose.com/v1.0/", :logger => Logger.new(STDERR))
|
38
10
|
end
|
39
11
|
end
|
data/lib/saaspose/pdf.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
|
-
require "rexml/document"
|
2
|
-
|
3
1
|
module Saaspose
|
4
2
|
class Pdf
|
5
3
|
class << self
|
6
|
-
def convert(name,
|
7
|
-
|
8
|
-
|
9
|
-
response = RestClient.get(signed_url, :accept => 'application/json')
|
10
|
-
Utils.save_file(response, local_file)
|
4
|
+
def convert(name, file, page_number, options={:format=>:png, :height=>800, :width=>600})
|
5
|
+
url = "pdf/#{name}/pages/#{page_number}"
|
6
|
+
Utils.call_and_save(url, options, file)
|
11
7
|
end
|
12
8
|
|
13
9
|
def page_count(name)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
REXML::Document.new(response.body).elements.size
|
10
|
+
url = "pdf/#{name}/pages"
|
11
|
+
result = Utils.call_and_parse(url)
|
12
|
+
result["Pages"]["Links"].size
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
data/lib/saaspose/slides.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module Saaspose
|
2
2
|
class Slides
|
3
3
|
class << self
|
4
|
-
def convert(name,
|
5
|
-
|
6
|
-
|
7
|
-
response = RestClient.get(signed_url, :accept => 'application/json')
|
8
|
-
Utils.save_file(response, local_file)
|
4
|
+
def convert(name, file, options={:format=>:pdf})
|
5
|
+
url = "slides/#{name}"
|
6
|
+
Utils.call_and_save(url, options, file)
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
data/lib/saaspose/storage.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
|
-
require "
|
1
|
+
require "rest-client"
|
2
2
|
|
3
3
|
module Saaspose
|
4
4
|
class Storage
|
5
|
-
|
5
|
+
RemoteFile = Struct.new(:name, :folder, :modified, :size)
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def upload(local_file_path, remote_folder_path)
|
9
|
-
file_name =
|
10
|
-
url_file = "
|
9
|
+
file_name = File.basename(local_file_path)
|
10
|
+
url_file = "storage/file/#{remote_folder_path.empty? ? "" : "/#{remote_folder_path}" }#{file_name}"
|
11
11
|
signed_url = Utils.sign(url_file)
|
12
|
-
RestClient.put(signed_url,
|
12
|
+
RestClient.put(signed_url, File.new(local_file_path, 'rb'), :accept => 'application/json')
|
13
13
|
end
|
14
14
|
|
15
15
|
def files(remote_folder_path="")
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
signed_url = Utils.sign(url_folder)
|
20
|
-
response = RestClient.get(signed_url, :accept => 'application/json')
|
21
|
-
result = JSON.parse(response.body)
|
16
|
+
uri = "storage/folder"
|
17
|
+
uri << "/#{remote_folder_path}" unless remote_folder_path.empty?
|
18
|
+
result = Utils.call_and_parse(uri)
|
22
19
|
|
23
20
|
result["Files"].map do |entry|
|
24
|
-
|
21
|
+
seconds_since_epoch = entry["ModifiedDate"].scan(/[0-9]+/)[0].to_i
|
22
|
+
date = Time.at((seconds_since_epoch-(21600000 + 18000000))/1000)
|
23
|
+
RemoteFile.new(entry["Name"], entry["IsFolder"], date, entry["Size"])
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
data/lib/saaspose/utils.rb
CHANGED
@@ -3,60 +3,52 @@ require 'rest_client'
|
|
3
3
|
require 'openssl'
|
4
4
|
require 'base64'
|
5
5
|
require 'uri'
|
6
|
+
require 'json'
|
6
7
|
|
7
8
|
module Saaspose
|
8
9
|
class Utils
|
10
|
+
DIGEST = OpenSSL::Digest::Digest.new('sha1')
|
9
11
|
class << self
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
url =
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# create a signature using the private key and the URL
|
24
|
-
raw_signature = OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), Configuration.app_key, url_to_sign)
|
25
|
-
|
26
|
-
#Convert raw to encoded string
|
27
|
-
signature = Base64.strict_encode64(raw_signature).tr('+/','-_')
|
28
|
-
|
29
|
-
#remove invalid character
|
30
|
-
signature = signature.gsub(/[=_-]/,'=' => '', '_' => '%2f', '-' => '%2b')
|
31
|
-
|
32
|
-
#Define expression
|
33
|
-
pat = /%[0-9a-f]{2}/
|
34
|
-
|
35
|
-
#Replace the portion matched to the above pattern to upper case
|
36
|
-
6.times do
|
37
|
-
signature = signature.sub(pat, pat.match(signature).to_s.upcase)
|
38
|
-
end
|
39
|
-
|
40
|
-
# prepend the server and append the signature.
|
41
|
-
url_to_sign + "&signature=#{signature}"
|
12
|
+
def sign(uri, options=nil)
|
13
|
+
options = options ? options.dup : {}
|
14
|
+
options.merge!(:appSID => Configuration.app_sid)
|
15
|
+
url = "#{Configuration.product_uri}#{uri}"
|
16
|
+
|
17
|
+
url << "?" << options.map{|key, value| "#{key}=#{CGI::escape(value.to_s)}"}.join("&")
|
18
|
+
|
19
|
+
signature = OpenSSL::HMAC.digest(DIGEST, Configuration.app_key, url)
|
20
|
+
signature = Base64.strict_encode64(signature).chop
|
21
|
+
signature = URI::escape(signature, /[^A-z0-9]/)
|
22
|
+
|
23
|
+
"#{url}&signature=#{signature}"
|
42
24
|
end
|
43
25
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
26
|
+
def call(uri, options=nil)
|
27
|
+
signed_url = Utils.sign(uri, options)
|
28
|
+
log(:debug, "calling: #{signed_url}")
|
29
|
+
RestClient.get(signed_url, :accept => 'application/json')
|
30
|
+
rescue
|
31
|
+
log(:error, "error: #{$!.inspect}")
|
32
|
+
raise
|
47
33
|
end
|
48
34
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
35
|
+
def call_and_parse(uri, options=nil)
|
36
|
+
response = call(uri, options)
|
37
|
+
JSON.parse(response.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
def call_and_save(uri, options, file)
|
41
|
+
response = response = call(uri, options)
|
54
42
|
Utils.save_file(response, file)
|
55
43
|
end
|
56
44
|
|
57
45
|
def save_file(response_stream, local_file)
|
58
46
|
File.open(local_file, "wb") { |file| file.write(response_stream.body) }
|
59
47
|
end
|
48
|
+
|
49
|
+
def log(severity, message)
|
50
|
+
Configuration.logger.send(severity, message) if Configuration.logger
|
51
|
+
end
|
60
52
|
end
|
61
53
|
end
|
62
54
|
end
|
data/lib/saaspose/version.rb
CHANGED
data/lib/saaspose/words.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module Saaspose
|
2
2
|
class Words
|
3
3
|
class << self
|
4
|
-
def convert(name,
|
5
|
-
|
6
|
-
|
7
|
-
response = RestClient.get(signedURL, :accept => 'application/json')
|
8
|
-
Utils.save_file(response, local_file)
|
4
|
+
def convert(name, file, options={:format=>:pdf})
|
5
|
+
url = "words/#{name}"
|
6
|
+
Utils.call_and_save(url, options, file)
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
data/saaspose.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.summary = s.description = "Ruby bindings to Saaspose REST API"
|
10
10
|
s.authors = ["Peter Schröder"]
|
11
11
|
s.email = 'phoetmail@googlemail.com'
|
12
|
-
s.homepage = '
|
12
|
+
s.homepage = 'https://github.com/phoet/saaspose'
|
13
13
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
s.add_dependency 'rest-client', '~> 1.6'
|
20
|
+
s.add_dependency 'confiture', '~> 0.1'
|
20
21
|
|
21
22
|
s.add_development_dependency 'vcr', '~> 2.1'
|
22
23
|
s.add_development_dependency 'webmock', '~> 1.8'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Saaspose::Utils do
|
4
|
+
before(:each) do
|
5
|
+
Saaspose::Configuration.configure do |config|
|
6
|
+
config.app_sid = "SAASPOSE_APPSID"
|
7
|
+
config.app_key = "SAASPOSE_APPKEY"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "signing" do
|
12
|
+
let(:signed_url) { "http://api.saaspose.com/v1.0/path?uschi=true&a_param=yes&appSID=SAASPOSE_APPSID&signature=kOJ7Xip6DwLMBOS7ZX9%2FxCkPn1w" }
|
13
|
+
|
14
|
+
it "should sign a uri" do
|
15
|
+
Saaspose::Utils.sign("path", {:uschi => true, :a_param => :yes}).should eql(signed_url)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/lib/saaspose_spec.rb
CHANGED
@@ -1,15 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
4
|
-
REMOTE_ROOT_DIR = ""
|
5
|
-
|
6
|
-
PNG_PATH = "/tmp/test.png"
|
7
|
-
PDF_PATH = "/tmp/test.pdf"
|
8
|
-
|
9
|
-
TEST_PDF_NAME = "saaspose_test.pdf"
|
10
|
-
TEST_PPT_NAME = "saaspose_test.ppt"
|
11
|
-
TEST_DOC_NAME = "saaspose_test.doc"
|
12
|
-
TEST_XLS_NAME = "saaspose_test.xls"
|
3
|
+
describe Saaspose do
|
13
4
|
|
14
5
|
before(:all) do
|
15
6
|
configure_client
|
@@ -17,12 +8,15 @@ describe "saaspose" do
|
|
17
8
|
end
|
18
9
|
|
19
10
|
before(:each) do
|
11
|
+
configure_client
|
20
12
|
[PNG_PATH, PDF_PATH].each { |path| FileUtils.rm(path) if File.exists?(path) }
|
21
13
|
end
|
22
14
|
|
23
15
|
context "pdf" do
|
24
|
-
|
25
|
-
|
16
|
+
let(:page_number) { 1 }
|
17
|
+
|
18
|
+
it "should generate a png from a page of a remote pdf", :vcr => true do
|
19
|
+
Saaspose::Pdf.convert(TEST_PDF_NAME, PNG_PATH, page_number)
|
26
20
|
File.exists?(PNG_PATH).should be_true
|
27
21
|
end
|
28
22
|
|
@@ -33,14 +27,14 @@ describe "saaspose" do
|
|
33
27
|
|
34
28
|
context "slides" do
|
35
29
|
it "should generate a pdf from a remote ppt", :vcr => true do
|
36
|
-
Saaspose::Slides.convert(TEST_PPT_NAME, PDF_PATH
|
30
|
+
Saaspose::Slides.convert(TEST_PPT_NAME, PDF_PATH)
|
37
31
|
File.exists?(PDF_PATH).should be_true
|
38
32
|
end
|
39
33
|
end
|
40
34
|
|
41
35
|
context "words" do
|
42
36
|
it "should generate a pdf from a remote doc", :vcr => true do
|
43
|
-
Saaspose::Words.convert(TEST_DOC_NAME, PDF_PATH
|
37
|
+
Saaspose::Words.convert(TEST_DOC_NAME, PDF_PATH)
|
44
38
|
File.exists?(PDF_PATH).should be_true
|
45
39
|
end
|
46
40
|
end
|
@@ -53,53 +47,18 @@ describe "saaspose" do
|
|
53
47
|
end
|
54
48
|
|
55
49
|
context "storage" do
|
56
|
-
let(:folder) { Saaspose::Storage::
|
50
|
+
let(:folder) { Saaspose::Storage::RemoteFile.new("test", true, Time.at(1334562314), 0) }
|
57
51
|
|
58
52
|
it "should upload a file to the root dir", :vcr => true do
|
59
53
|
resp = Saaspose::Storage.upload(fixture_path(TEST_PDF_NAME), REMOTE_ROOT_DIR)
|
60
|
-
resp.should match("
|
54
|
+
resp.should match("{\"Code\":200,\"Status\":\"OK\"}")
|
61
55
|
end
|
62
56
|
|
63
57
|
it "should get a list of files from the root dir", :vcr => true do
|
64
58
|
files = Saaspose::Storage.files(REMOTE_ROOT_DIR)
|
65
|
-
files.first.should be_an_instance_of(Saaspose::Storage::
|
59
|
+
files.first.should be_an_instance_of(Saaspose::Storage::RemoteFile)
|
66
60
|
files.map(&:name).should include(TEST_PDF_NAME)
|
67
61
|
files.first.should eql(folder)
|
68
62
|
end
|
69
63
|
end
|
70
|
-
|
71
|
-
context "utils" do
|
72
|
-
before(:each) do
|
73
|
-
Saaspose::Configuration.configure do |config|
|
74
|
-
config.app_sid = "SAASPOSE_APPSID"
|
75
|
-
config.app_key = "SAASPOSE_APPKEY"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
let(:url) { "http://example.com/path?uschi=true&a_param=yes" }
|
80
|
-
it "should sign a uri" do
|
81
|
-
Saaspose::Utils.sign(url).should eql("http://example.com/path?uschi=true&a_param=yes&appSID=SAASPOSE_APPSID&signature=zl%2BjolbjggyKZ31QgflGVILu%2F0I")
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def configure_client
|
87
|
-
Saaspose::Configuration.configure do |config|
|
88
|
-
config.product_uri = "http://api.saaspose.com/v1.0"
|
89
|
-
config.app_sid = ENV["SAASPOSE_APPSID"]
|
90
|
-
config.app_key = ENV["SAASPOSE_APPKEY"]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def ensure_remote_file(test_file)
|
95
|
-
VCR.use_cassette("ensure_remote_file #{test_file}", :record => :new_episodes, :match_requests_on => [:host, :path]) do
|
96
|
-
unless Saaspose::Storage.files.map(&:name).include?(test_file)
|
97
|
-
puts "uploading #{test_file} for testing purposes"
|
98
|
-
Saaspose::Storage.upload(fixture_path(test_file), REMOTE_ROOT_DIR)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def fixture_path(name)
|
104
|
-
File.expand_path("../fixtures/#{name}", File.dirname(__FILE__))
|
105
64
|
end
|