groupdocs 0.1.1 → 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/groupdocs.gemspec +2 -3
- data/lib/groupdocs.rb +1 -0
- data/lib/groupdocs/api/helpers/access_helper.rb +2 -2
- data/lib/groupdocs/api/helpers/rest_helper.rb +4 -12
- data/lib/groupdocs/api/helpers/url_helper.rb +13 -4
- data/lib/groupdocs/api/request.rb +2 -1
- data/lib/groupdocs/datasource.rb +1 -1
- data/lib/groupdocs/errors.rb +4 -6
- data/lib/groupdocs/storage/file.rb +48 -14
- data/lib/groupdocs/storage/folder.rb +3 -4
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/api/helpers/access_helper_spec.rb +2 -2
- data/spec/groupdocs/api/helpers/rest_helper_spec.rb +10 -49
- data/spec/groupdocs/api/helpers/url_helper_spec.rb +10 -3
- data/spec/groupdocs/api/request_spec.rb +5 -0
- data/spec/groupdocs/errors_spec.rb +1 -1
- data/spec/groupdocs/storage/file_spec.rb +43 -10
- data/spec/groupdocs/storage/folder_spec.rb +6 -0
- metadata +22 -22
data/groupdocs.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
|
3
2
|
require "groupdocs/version"
|
4
3
|
|
@@ -17,12 +16,12 @@ Gem::Specification.new do |s|
|
|
17
16
|
s.require_path = 'lib'
|
18
17
|
|
19
18
|
s.add_runtime_dependency 'rest-client', '~> 1.6'
|
20
|
-
s.add_runtime_dependency 'json' , '~> 1.
|
19
|
+
s.add_runtime_dependency 'json' , '~> 1.7'
|
21
20
|
s.add_runtime_dependency 'ruby-hmac' , '~> 0.4'
|
22
21
|
|
23
22
|
s.add_development_dependency 'rspec' , '~> 2.9'
|
24
23
|
s.add_development_dependency 'rake' , '~> 0.9'
|
25
24
|
s.add_development_dependency 'simplecov', '~> 0.6'
|
26
|
-
s.add_development_dependency 'yard' , '~> 0.
|
25
|
+
s.add_development_dependency 'yard' , '~> 0.8'
|
27
26
|
s.add_development_dependency 'webmock' , '~> 1.8'
|
28
27
|
end
|
data/lib/groupdocs.rb
CHANGED
@@ -20,7 +20,7 @@ module GroupDocs
|
|
20
20
|
#
|
21
21
|
def client_id
|
22
22
|
client_id = options[:access][:client_id] || GroupDocs.client_id
|
23
|
-
client_id or raise
|
23
|
+
client_id or raise NoClientIdError, 'Client ID has not been specified.'
|
24
24
|
end
|
25
25
|
|
26
26
|
#
|
@@ -32,7 +32,7 @@ module GroupDocs
|
|
32
32
|
#
|
33
33
|
def private_key
|
34
34
|
private_key = options[:access][:private_key] || GroupDocs.private_key
|
35
|
-
private_key or raise
|
35
|
+
private_key or raise NoPrivateKeyError, 'Private Key has not been specified.'
|
36
36
|
end
|
37
37
|
|
38
38
|
#
|
@@ -22,7 +22,7 @@ module GroupDocs
|
|
22
22
|
options[:headers] = DEFAULT_HEADERS.dup
|
23
23
|
end
|
24
24
|
|
25
|
-
options[:method] = options[:method].downcase
|
25
|
+
options[:method] = options[:method].downcase.to_sym
|
26
26
|
|
27
27
|
if options[:request_body] && !options[:request_body].is_a?(Object::File)
|
28
28
|
options[:request_body] = options[:request_body].to_json
|
@@ -47,7 +47,7 @@ module GroupDocs
|
|
47
47
|
when :delete
|
48
48
|
resource[options[:path]].delete(options[:headers])
|
49
49
|
else
|
50
|
-
raise
|
50
|
+
raise UnsupportedMethodError, "Unsupported HTTP method: #{options[:method].inspect}"
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -68,19 +68,11 @@ module GroupDocs
|
|
68
68
|
end
|
69
69
|
|
70
70
|
#
|
71
|
-
# @raise [GroupDocs::
|
71
|
+
# @raise [GroupDocs::BadResponseError]
|
72
72
|
# @api private
|
73
73
|
#
|
74
74
|
def raise_bad_request_error(json)
|
75
|
-
raise
|
76
|
-
Bad response!
|
77
|
-
Request method: #{options[:method].upcase}
|
78
|
-
Request URL: #{resource[options[:path]]}
|
79
|
-
Request body: #{options[:request_body]}
|
80
|
-
Status: #{json[:status]}
|
81
|
-
Error message: #{json[:error_message]}
|
82
|
-
Response body: #{response}
|
83
|
-
ERR
|
75
|
+
raise BadResponseError, json[:error_message]
|
84
76
|
end
|
85
77
|
|
86
78
|
end # Request
|
@@ -23,12 +23,21 @@ module GroupDocs
|
|
23
23
|
private
|
24
24
|
|
25
25
|
#
|
26
|
-
#
|
26
|
+
# Normalizes path replacing two or more slashes with one.
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
#
|
30
|
+
def normalize_path
|
31
|
+
options[:path].gsub!(%r(//+), '/')
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Parses path replacing {{client_id}} with real one.
|
27
36
|
#
|
28
37
|
# @api private
|
29
38
|
#
|
30
39
|
def parse_path
|
31
|
-
options[:path]
|
40
|
+
options[:path].sub!(/\{\{client_id\}\}/, client_id)
|
32
41
|
end
|
33
42
|
|
34
43
|
#
|
@@ -53,11 +62,11 @@ module GroupDocs
|
|
53
62
|
# convert hash to base64
|
54
63
|
hash = Base64.strict_encode64(hash)
|
55
64
|
# remove trailing '='
|
56
|
-
hash
|
65
|
+
hash.gsub!(/=*$/, '')
|
57
66
|
# URL encode hash
|
58
67
|
hash = CGI.escape(hash)
|
59
68
|
# covert all hexademical characters to upper case
|
60
|
-
hash
|
69
|
+
hash.gsub!(/(%[A-Fa-f0-9]{1,2})/) { |group| group.upcase }
|
61
70
|
|
62
71
|
options[:path] << "#{separator}signature=#{hash}"
|
63
72
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rest-client'
|
2
1
|
require 'json'
|
3
2
|
require 'groupdocs/api/helpers'
|
4
3
|
|
@@ -48,6 +47,7 @@ module GroupDocs
|
|
48
47
|
# Executes API request to server.
|
49
48
|
#
|
50
49
|
# It performs the following actions step by step:
|
50
|
+
# * Normalizes path (i.e. replace // with /)
|
51
51
|
# * Parses path (i.e. replaces client ID)
|
52
52
|
# * Prepends path with version if it's set
|
53
53
|
# * URL encodes path
|
@@ -59,6 +59,7 @@ module GroupDocs
|
|
59
59
|
# @return [Hash, String] Parsed response
|
60
60
|
#
|
61
61
|
def execute!
|
62
|
+
normalize_path
|
62
63
|
parse_path
|
63
64
|
prepend_version
|
64
65
|
url_encode_path
|
data/lib/groupdocs/datasource.rb
CHANGED
data/lib/groupdocs/errors.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
module GroupDocs
|
2
|
-
module Errors
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class NoClientIdError < StandardError ; end
|
4
|
+
class NoPrivateKeyError < StandardError ; end
|
5
|
+
class UnsupportedMethodError < StandardError ; end
|
6
|
+
class BadResponseError < StandardError ; end
|
8
7
|
|
9
|
-
end # Errors
|
10
8
|
end # GroupDocs
|
@@ -4,6 +4,16 @@ module GroupDocs
|
|
4
4
|
|
5
5
|
extend GroupDocs::Api::Sugar::Lookup
|
6
6
|
|
7
|
+
DOCUMENT_TYPES = {
|
8
|
+
undefined: -1,
|
9
|
+
cells: 0,
|
10
|
+
words: 1,
|
11
|
+
slides: 2,
|
12
|
+
pdf: 3,
|
13
|
+
html: 4,
|
14
|
+
image: 5,
|
15
|
+
}
|
16
|
+
|
7
17
|
#
|
8
18
|
# Uploads file to API server.
|
9
19
|
#
|
@@ -13,8 +23,6 @@ module GroupDocs
|
|
13
23
|
# @param [String] filepath Path to file to be uploaded
|
14
24
|
# @param [String] upload_path Full path to directory to upload file to starting with "/".
|
15
25
|
# You can also add filename and then uploaded file will use it.
|
16
|
-
# @param [Hash] options Hash of options
|
17
|
-
# @option options [String] :description Optional description for file
|
18
26
|
# @param [Hash] access Access credentials
|
19
27
|
# @option access [String] :client_id
|
20
28
|
# @option access [String] :private_key
|
@@ -22,18 +30,16 @@ module GroupDocs
|
|
22
30
|
#
|
23
31
|
# @raise [ArgumentError] If path does not start with /
|
24
32
|
#
|
25
|
-
def self.upload!(filepath, upload_path = '/',
|
33
|
+
def self.upload!(filepath, upload_path = '/', access = {})
|
26
34
|
upload_path.chars.first == '/' or raise ArgumentError, "Path should start with /: #{upload_path.inspect}"
|
27
35
|
upload_path << "/#{Object::File.basename(filepath)}" unless upload_path =~ /\.(\w){3,4}$/
|
28
36
|
|
29
|
-
|
37
|
+
json = GroupDocs::Api::Request.new do |request|
|
30
38
|
request[:access] = access
|
31
39
|
request[:method] = :POST
|
32
|
-
request[:path] = "/storage/{{client_id}}/folders#{upload_path
|
40
|
+
request[:path] = "/storage/{{client_id}}/folders#{upload_path}"
|
33
41
|
request[:request_body] = Object::File.new(filepath, 'rb')
|
34
|
-
end
|
35
|
-
api.add_params(options)
|
36
|
-
json = api.execute!
|
42
|
+
end.execute!
|
37
43
|
|
38
44
|
GroupDocs::Storage::File.new(json)
|
39
45
|
end
|
@@ -52,7 +58,7 @@ module GroupDocs
|
|
52
58
|
folder = GroupDocs::Storage::Folder.new(path: path)
|
53
59
|
folder.list!({}, access).each do |entity|
|
54
60
|
if entity.is_a?(GroupDocs::Storage::Folder)
|
55
|
-
files += all!("#{path}/#{entity.name}"
|
61
|
+
files += all!("#{path}/#{entity.name}", access)
|
56
62
|
else
|
57
63
|
files << entity
|
58
64
|
end
|
@@ -83,6 +89,8 @@ module GroupDocs
|
|
83
89
|
attr_accessor :version
|
84
90
|
# @attr [Integer] type
|
85
91
|
attr_accessor :type
|
92
|
+
# @attr [Integer] file_type
|
93
|
+
attr_accessor :file_type
|
86
94
|
# @attr [Integer] access
|
87
95
|
attr_accessor :access
|
88
96
|
# @attr [String] path
|
@@ -91,6 +99,30 @@ module GroupDocs
|
|
91
99
|
# Compatibility with response JSON
|
92
100
|
alias_method :adj_name=, :name=
|
93
101
|
|
102
|
+
#
|
103
|
+
# Updates type with machine-readable format.
|
104
|
+
#
|
105
|
+
# @param [Symbol, Integer] type
|
106
|
+
# @raise [ArgumentError] if type is unknown
|
107
|
+
#
|
108
|
+
def type=(type)
|
109
|
+
if type.is_a?(Symbol)
|
110
|
+
DOCUMENT_TYPES.keys.include?(type) or raise ArgumentError, "Unknown type: #{type.inspect}"
|
111
|
+
type = DOCUMENT_TYPES[type]
|
112
|
+
end
|
113
|
+
|
114
|
+
@type = type
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# Returns document type in human-readable format.
|
119
|
+
#
|
120
|
+
# @return [Symbol]
|
121
|
+
#
|
122
|
+
def type
|
123
|
+
DOCUMENT_TYPES.invert[@type]
|
124
|
+
end
|
125
|
+
|
94
126
|
#
|
95
127
|
# Converts timestamp which is return by API server to Time object.
|
96
128
|
#
|
@@ -201,21 +233,20 @@ module GroupDocs
|
|
201
233
|
#
|
202
234
|
# Compresses file on server to given archive type.
|
203
235
|
#
|
204
|
-
# @param [Symbol] type Archive type: :zip, :rar.
|
205
236
|
# @param [Hash] access Access credentials
|
206
237
|
# @option access [String] :client_id
|
207
238
|
# @option access [String] :private_key
|
208
239
|
# @return [GroupDocs::Storage::File] Archive file
|
209
240
|
#
|
210
|
-
def compress!(
|
241
|
+
def compress!(access = {})
|
211
242
|
json = GroupDocs::Api::Request.new do |request|
|
212
243
|
request[:access] = access
|
213
244
|
request[:method] = :POST
|
214
|
-
request[:path] = "/storage/{{client_id}}/files/#{id}/archive
|
245
|
+
request[:path] = "/storage/{{client_id}}/files/#{id}/archive/zip"
|
215
246
|
end.execute!
|
216
247
|
|
217
|
-
# HACK add filename for further
|
218
|
-
json[:name] = "#{name}
|
248
|
+
# HACK add filename for further file operations
|
249
|
+
json[:name] = "#{name}.zip"
|
219
250
|
GroupDocs::Storage::File.new(json)
|
220
251
|
end
|
221
252
|
|
@@ -232,6 +263,9 @@ module GroupDocs
|
|
232
263
|
request[:method] = :DELETE
|
233
264
|
request[:path] = "/storage/{{client_id}}/files/#{guid}"
|
234
265
|
end.execute!
|
266
|
+
# TODO: workaround for http://scotland.groupdocs.com/jira/browse/CORE-423
|
267
|
+
rescue RestClient::BadRequest
|
268
|
+
nil
|
235
269
|
end
|
236
270
|
|
237
271
|
#
|
@@ -43,7 +43,7 @@ module GroupDocs
|
|
43
43
|
folder.list!({}, access).each do |entity|
|
44
44
|
if entity.is_a?(GroupDocs::Storage::Folder)
|
45
45
|
folders << entity
|
46
|
-
folders += all!("#{path}/#{entity.name}"
|
46
|
+
folders += all!("#{path}/#{entity.name}", access)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -198,13 +198,12 @@ module GroupDocs
|
|
198
198
|
# @return [Array<GroupDocs::Storage::Folder, GroupDocs::Storage::File>]
|
199
199
|
#
|
200
200
|
def list!(options = {}, access = {})
|
201
|
-
|
202
|
-
query_path.gsub!(/[\/]{2}/, '/')
|
201
|
+
options[:order_by].capitalize! if options[:order_by]
|
203
202
|
|
204
203
|
api = GroupDocs::Api::Request.new do |request|
|
205
204
|
request[:access] = access
|
206
205
|
request[:method] = :GET
|
207
|
-
request[:path] = "/storage/{{client_id}}/folders#{
|
206
|
+
request[:path] = "/storage/{{client_id}}/folders#{path}/#{name}"
|
208
207
|
end
|
209
208
|
api.add_params(options)
|
210
209
|
json = api.execute!
|
data/lib/groupdocs/version.rb
CHANGED
@@ -32,7 +32,7 @@ describe GroupDocs::Api::Helpers::Access do
|
|
32
32
|
it 'raises error if client ID has not been set' do
|
33
33
|
subject.options[:access] = {}
|
34
34
|
GroupDocs.client_id = nil
|
35
|
-
-> { subject.send(:client_id) }.should raise_error(GroupDocs::
|
35
|
+
-> { subject.send(:client_id) }.should raise_error(GroupDocs::NoClientIdError)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -52,7 +52,7 @@ describe GroupDocs::Api::Helpers::Access do
|
|
52
52
|
it 'raises error if private key has not been set' do
|
53
53
|
subject.options[:access] = {}
|
54
54
|
GroupDocs.private_key = nil
|
55
|
-
-> { subject.send(:private_key) }.should raise_error(GroupDocs::
|
55
|
+
-> { subject.send(:private_key) }.should raise_error(GroupDocs::NoPrivateKeyError)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -39,6 +39,13 @@ describe GroupDocs::Api::Helpers::REST do
|
|
39
39
|
end.should change { subject.options[:method] }.to(:get)
|
40
40
|
end
|
41
41
|
|
42
|
+
it 'converts HTTP method to symbol' do
|
43
|
+
subject.options[:method] = 'GET'
|
44
|
+
lambda do
|
45
|
+
subject.send(:prepare_request)
|
46
|
+
end.should change { subject.options[:method] }.to(:get)
|
47
|
+
end
|
48
|
+
|
42
49
|
it 'coverts request body to JSON' do
|
43
50
|
subject.options[:method] = :POST
|
44
51
|
subject.options[:request_body] = { body: 'test' }
|
@@ -88,7 +95,7 @@ describe GroupDocs::Api::Helpers::REST do
|
|
88
95
|
|
89
96
|
it 'raises error if incorrect method has been passed' do
|
90
97
|
subject.options[:method] = :TEST
|
91
|
-
-> { subject.send(:send_request) }.should raise_error(GroupDocs::
|
98
|
+
-> { subject.send(:send_request) }.should raise_error(GroupDocs::UnsupportedMethodError)
|
92
99
|
end
|
93
100
|
|
94
101
|
it 'saves response' do
|
@@ -132,56 +139,10 @@ describe GroupDocs::Api::Helpers::REST do
|
|
132
139
|
{ status: 'Failed', error_message: 'The source path is not found.' }
|
133
140
|
end
|
134
141
|
|
135
|
-
it 'raises error' do
|
136
|
-
lambda do
|
137
|
-
subject.send(:raise_bad_request_error, json)
|
138
|
-
end.should raise_error(GroupDocs::Errors::BadResponseError)
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'shows "Bad response!" message' do
|
142
|
-
lambda do
|
143
|
-
subject.send(:raise_bad_request_error, json)
|
144
|
-
end.should raise_error(message = /Bad response!/)
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'contains information about request method' do
|
148
|
-
subject.options[:method] = :get
|
149
|
-
lambda do
|
150
|
-
subject.send(:raise_bad_request_error, json)
|
151
|
-
end.should raise_error(message = /Request method: GET/)
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'contains information about request URL' do
|
155
|
-
subject.options[:path] = '/folders'
|
156
|
-
lambda do
|
157
|
-
subject.send(:raise_bad_request_error, json)
|
158
|
-
end.should raise_error(message = %r(Request URL: https?://(.+)/folders))
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'contains information about request body' do
|
162
|
-
subject.options[:request_body] = '{"test": 123}'
|
163
|
-
lambda do
|
164
|
-
subject.send(:raise_bad_request_error, json)
|
165
|
-
end.should raise_error(message = /Request body: {"test": 123}/)
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'contains information about response status' do
|
169
|
-
lambda do
|
170
|
-
subject.send(:raise_bad_request_error, json)
|
171
|
-
end.should raise_error(message = /Status: Failed/)
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'contains information about error message' do
|
175
|
-
lambda do
|
176
|
-
subject.send(:raise_bad_request_error, json)
|
177
|
-
end.should raise_error(message = /Error message: The source path is not found./)
|
178
|
-
end
|
179
|
-
|
180
|
-
it 'contains information about response body' do
|
181
|
-
mock_response('{"status": "Failed", "error_message": "The source path is not found."}')
|
142
|
+
it 'raises error with message from response' do
|
182
143
|
lambda do
|
183
144
|
subject.send(:raise_bad_request_error, json)
|
184
|
-
end.should raise_error(
|
145
|
+
end.should raise_error(GroupDocs::BadResponseError, 'The source path is not found.')
|
185
146
|
end
|
186
147
|
end
|
187
148
|
end
|
@@ -26,13 +26,20 @@ describe GroupDocs::Api::Helpers::URL do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
describe '#normalize_path' do
|
30
|
+
it 'replaces two or more slashes with one' do
|
31
|
+
subject.options[:path] = '/doc//folder///new////'
|
32
|
+
subject.send(:normalize_path)
|
33
|
+
subject.options[:path].should == '/doc/folder/new/'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
describe '#parse_path' do
|
30
38
|
it 'replaces {{client_id}} with real client ID' do
|
31
39
|
subject.options[:path] = '/doc/{{client_id}}/files/123'
|
32
40
|
subject.should_receive(:client_id).and_return('real_client_id')
|
33
|
-
|
34
|
-
|
35
|
-
end.should change { subject.options[:path] }.to('/doc/real_client_id/files/123')
|
41
|
+
subject.send(:parse_path)
|
42
|
+
subject.options[:path].should == '/doc/real_client_id/files/123'
|
36
43
|
end
|
37
44
|
end
|
38
45
|
|
@@ -46,6 +46,11 @@ describe GroupDocs::Api::Request do
|
|
46
46
|
mock_api_server('{"status":"Ok"}')
|
47
47
|
end
|
48
48
|
|
49
|
+
it 'normalizes path' do
|
50
|
+
subject.should_receive(:normalize_path)
|
51
|
+
subject.execute!
|
52
|
+
end
|
53
|
+
|
49
54
|
it 'parses path' do
|
50
55
|
subject.should_receive(:parse_path)
|
51
56
|
subject.execute!
|
@@ -5,20 +5,28 @@ describe GroupDocs::Storage::File do
|
|
5
5
|
it_behaves_like GroupDocs::Api::Entity
|
6
6
|
include_examples GroupDocs::Api::Sugar::Lookup
|
7
7
|
|
8
|
+
describe 'DOCUMENT_TYPES' do
|
9
|
+
it 'contains hash of document types' do
|
10
|
+
described_class::DOCUMENT_TYPES.should == {
|
11
|
+
undefined: -1,
|
12
|
+
cells: 0,
|
13
|
+
words: 1,
|
14
|
+
slides: 2,
|
15
|
+
pdf: 3,
|
16
|
+
html: 4,
|
17
|
+
image: 5,
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
8
22
|
describe '.upload!' do
|
9
23
|
before(:each) do
|
10
24
|
mock_api_server(load_json('file_upload'))
|
11
25
|
end
|
12
26
|
|
13
|
-
it 'accepts options hash' do
|
14
|
-
lambda do
|
15
|
-
described_class.upload!(__FILE__, '/upload_path', { description: 'Description' })
|
16
|
-
end.should_not raise_error(ArgumentError)
|
17
|
-
end
|
18
|
-
|
19
27
|
it 'accepts access credentials hash' do
|
20
28
|
lambda do
|
21
|
-
described_class.upload!(__FILE__, '/upload_path',
|
29
|
+
described_class.upload!(__FILE__, '/upload_path', client_id: 'client_id', private_key: 'private_key')
|
22
30
|
end.should_not raise_error(ArgumentError)
|
23
31
|
end
|
24
32
|
|
@@ -59,6 +67,8 @@ describe GroupDocs::Storage::File do
|
|
59
67
|
it { should respond_to(:version=) }
|
60
68
|
it { should respond_to(:type) }
|
61
69
|
it { should respond_to(:type=) }
|
70
|
+
it { should respond_to(:file_type) }
|
71
|
+
it { should respond_to(:file_type=) }
|
62
72
|
it { should respond_to(:access) }
|
63
73
|
it { should respond_to(:access=) }
|
64
74
|
it { should respond_to(:path) }
|
@@ -69,6 +79,29 @@ describe GroupDocs::Storage::File do
|
|
69
79
|
subject.method(:adj_name=).should == subject.method(:name=)
|
70
80
|
end
|
71
81
|
|
82
|
+
describe '#type=' do
|
83
|
+
it 'saves type in machine readable format if symbol is passed' do
|
84
|
+
subject.type = :words
|
85
|
+
subject.instance_variable_get(:@type).should == 1
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'does nothing if parameter is not symbol' do
|
89
|
+
subject.type = 2
|
90
|
+
subject.instance_variable_get(:@type).should == 2
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'raises error if type is unknown' do
|
94
|
+
-> { subject.type = :unknown }.should raise_error(ArgumentError)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#type' do
|
99
|
+
it 'returns type in human-readable format' do
|
100
|
+
subject.type = 1
|
101
|
+
subject.type.should == :words
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
72
105
|
describe '#created_on' do
|
73
106
|
it 'converts timestamp to Time object' do
|
74
107
|
subject.created_on = 1330450135
|
@@ -201,18 +234,18 @@ describe GroupDocs::Storage::File do
|
|
201
234
|
|
202
235
|
it 'accepts access credentials hash' do
|
203
236
|
lambda do
|
204
|
-
subject.compress!(
|
237
|
+
subject.compress!(client_id: 'client_id', private_key: 'private_key')
|
205
238
|
end.should_not raise_error(ArgumentError)
|
206
239
|
end
|
207
240
|
|
208
241
|
it 'returns archived file' do
|
209
242
|
subject.stub(name: 'resume.pdf')
|
210
|
-
subject.compress
|
243
|
+
subject.compress!.should be_a(GroupDocs::Storage::File)
|
211
244
|
end
|
212
245
|
|
213
246
|
it 'creates archive filename as filename + archive type' do
|
214
247
|
subject.stub(name: 'resume.pdf')
|
215
|
-
subject.compress
|
248
|
+
subject.compress!.name.should == 'resume.pdf.zip'
|
216
249
|
end
|
217
250
|
end
|
218
251
|
|
@@ -185,6 +185,12 @@ describe GroupDocs::Storage::Folder do
|
|
185
185
|
-> { subject.list!(page: 1, count: 1) }.should_not raise_error(ArgumentError)
|
186
186
|
end
|
187
187
|
|
188
|
+
it 'capitalizes :order_by option' do
|
189
|
+
options = { order_by: 'field' }
|
190
|
+
options[:order_by].should_receive(:capitalize!)
|
191
|
+
subject.list!(options)
|
192
|
+
end
|
193
|
+
|
188
194
|
it 'returns array' do
|
189
195
|
subject.list!.should be_an(Array)
|
190
196
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupdocs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &8547040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: '1.6'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *8547040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &8562380 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '1.
|
32
|
+
version: '1.7'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *8562380
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ruby-hmac
|
38
|
-
requirement: &
|
38
|
+
requirement: &8560380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0.4'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *8560380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &8559100 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '2.9'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *8559100
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &8557700 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0.9'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *8557700
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
|
-
requirement: &
|
71
|
+
requirement: &8556680 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,21 +76,21 @@ dependencies:
|
|
76
76
|
version: '0.6'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *8556680
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: yard
|
82
|
-
requirement: &
|
82
|
+
requirement: &8555240 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '0.
|
87
|
+
version: '0.8'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *8555240
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: webmock
|
93
|
-
requirement: &
|
93
|
+
requirement: &8568120 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '1.8'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *8568120
|
102
102
|
description: Ruby SDK for GroupDocs REST API
|
103
103
|
email: p0deje@gmail.com
|
104
104
|
executables: []
|
@@ -247,7 +247,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
247
247
|
version: '0'
|
248
248
|
segments:
|
249
249
|
- 0
|
250
|
-
hash:
|
250
|
+
hash: 1799839413682321856
|
251
251
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
252
252
|
none: false
|
253
253
|
requirements:
|
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
256
|
version: '0'
|
257
257
|
segments:
|
258
258
|
- 0
|
259
|
-
hash:
|
259
|
+
hash: 1799839413682321856
|
260
260
|
requirements: []
|
261
261
|
rubyforge_project:
|
262
262
|
rubygems_version: 1.8.10
|