adobeshare 0.0.2 → 0.0.3
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/Manifest.txt +1 -0
- data/README.txt +12 -16
- data/lib/adobeshare/client.rb +9 -18
- data/lib/adobeshare/http.rb +14 -0
- data/lib/adobeshare/version.rb +1 -1
- data/lib/adobeshare.rb +1 -0
- metadata +3 -2
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
=
|
1
|
+
= Adobe Share API for Ruby
|
2
2
|
|
3
|
-
|
3
|
+
a Ruby library for "Adobe Share" using REST Web Service APIs.
|
4
4
|
|
5
5
|
* http://labs.adobe.com/technologies/share/
|
6
6
|
* http://labs.adobe.com/wiki/index.php/Share:API
|
@@ -10,8 +10,9 @@ AdobeShare::Client is a library for upload and download documents using REST API
|
|
10
10
|
=== Create client class
|
11
11
|
|
12
12
|
client = AdobeShare::Client.new
|
13
|
+
|
13
14
|
if you want to access via proxy,
|
14
|
-
|
15
|
+
add proxy param. client = Adobe::Client.new("http://your.proxy.server:8080/")
|
15
16
|
|
16
17
|
=== Set credentials
|
17
18
|
|
@@ -28,33 +29,28 @@ AdobeShare::Client is a library for upload and download documents using REST API
|
|
28
29
|
|
29
30
|
==== Upload
|
30
31
|
|
31
|
-
client.add_file
|
32
|
+
client.add_file(binary_obj, "test.pdf", "This is a Test File")
|
32
33
|
|
33
34
|
==== Download
|
34
35
|
|
35
|
-
client.get_source
|
36
|
+
binary_obj = client.get_source(nodeid)
|
36
37
|
|
37
38
|
==== Delete
|
38
39
|
|
39
|
-
client.delete_node
|
40
|
+
client.delete_node(nodeid)
|
40
41
|
|
41
42
|
|
42
|
-
# `nodeid` is the same as `docid` in the Flash web interface.
|
43
|
-
# `nodeid` indicates both the documents and the folders. Maybe.
|
44
|
-
|
45
43
|
=== Logout
|
46
44
|
client.logout
|
47
45
|
|
46
|
+
# `nodeid` is the same as `docid` in the Flash web interface.
|
47
|
+
# `nodeid` indicates both the documents and the folders. Maybe.
|
48
|
+
|
48
49
|
For details, please see examples/sample.rb
|
49
50
|
|
50
51
|
== TODO
|
51
52
|
|
52
|
-
* Test::Unit
|
53
|
-
|
54
|
-
and, these APIs are not implemented.
|
55
|
-
* Moving or renaming a file or folder
|
56
|
-
* Sharing a file
|
57
|
-
* Adding or removing recipients from a share
|
53
|
+
* Test::Unit or RSpec ???
|
58
54
|
|
59
55
|
== Requirements
|
60
56
|
|
@@ -67,4 +63,4 @@ and, these APIs are not implemented.
|
|
67
63
|
|
68
64
|
== Author
|
69
65
|
|
70
|
-
* KATO Hideyuki <
|
66
|
+
* KATO Hideyuki <hkato at rubyforge.org>
|
data/lib/adobeshare/client.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Copyright (c) KATO Hideyuki, 2007. All rights reserved.
|
5
5
|
#
|
6
|
-
require 'http-access2'
|
7
6
|
require 'rexml/document'
|
8
7
|
|
9
8
|
include REXML
|
@@ -36,7 +35,7 @@ module AdobeShare
|
|
36
35
|
|
37
36
|
#
|
38
37
|
def initialize proxy=nil
|
39
|
-
@client =
|
38
|
+
@client = HTTPClient.new(proxy, UA)
|
40
39
|
end
|
41
40
|
|
42
41
|
# Login to use Adobe Share service
|
@@ -120,29 +119,23 @@ module AdobeShare
|
|
120
119
|
res = http_client_request("POST", uri, req, headers)
|
121
120
|
end
|
122
121
|
|
123
|
-
private
|
124
|
-
|
125
|
-
# TODO this method is not tested
|
126
122
|
# Rename a node
|
127
123
|
def rename_node(nodeid, newname)
|
128
124
|
uri = ENDPOINT_DC + nodeid + "/?newname=" + newname
|
129
125
|
res = http_client_request("MOVE", uri)
|
130
126
|
end
|
131
127
|
|
132
|
-
# TODO this method is not tested
|
133
128
|
# Move a node
|
134
129
|
def move_node(nodeid, destnodeid, newname)
|
135
130
|
uri = ENDPOINT_DC + nodeid + "/?destnodeid=" + destnodeid + "&newname=" + URI.encode(newname)
|
136
131
|
res = http_client_request("MOVE", uri)
|
137
132
|
end
|
138
133
|
|
139
|
-
# TODO this method is not tested
|
140
134
|
# Replace file in an already existing node
|
141
|
-
def replace_file(file_name, description, nodeid, renditions=true)
|
142
|
-
add_file(file_name, description, nodeid, renditions)
|
135
|
+
def replace_file(data, file_name, description, nodeid, renditions=true)
|
136
|
+
add_file(data, file_name, description, nodeid, renditions)
|
143
137
|
end
|
144
138
|
|
145
|
-
# TODO this method is not tested
|
146
139
|
# Add new folder
|
147
140
|
def add_folder(name, description, nodeid)
|
148
141
|
if nodeid
|
@@ -160,12 +153,12 @@ module AdobeShare
|
|
160
153
|
doc = Document.new res
|
161
154
|
end
|
162
155
|
|
163
|
-
# TODO this method is not tested
|
164
156
|
# Share a file
|
165
157
|
def share_file(nodeid, users, message, level)
|
166
158
|
uri = ENDPOINT_DC + nodeid + "/share/"
|
167
159
|
req = Element.new "request"
|
168
160
|
share = req.add_element "share"
|
161
|
+
users = [""] unless users
|
169
162
|
users.each{|e|
|
170
163
|
user = Element.new "user"
|
171
164
|
user.text = e
|
@@ -175,28 +168,28 @@ module AdobeShare
|
|
175
168
|
req.add_element "level"
|
176
169
|
req.elements["message"].text = message
|
177
170
|
req.elements["level"].text = level
|
178
|
-
res = http_client_request("
|
171
|
+
res = http_client_request("PUT", uri, req)
|
179
172
|
doc = Document.new res
|
180
173
|
end
|
181
174
|
|
182
|
-
# TODO this method is not tested
|
183
175
|
# Unshare a file
|
184
176
|
def unshare_file(nodeid)
|
185
177
|
share_file(nodeid, nil, nil, 0)
|
186
178
|
end
|
187
179
|
|
188
|
-
# TODO this method is not tested
|
189
180
|
# Update a share file
|
190
181
|
def update_share(nodeid, users_to_add, users_to_remove, message)
|
191
182
|
uri = ENDPOINT_DC + nodeid + "/share/"
|
192
183
|
req = Element.new "request"
|
193
184
|
share = req.add_element "share"
|
185
|
+
users_to_add = [""] unless users_to_add
|
194
186
|
users_to_add.each{|e|
|
195
187
|
user = Element.new "user"
|
196
188
|
user.text = e
|
197
189
|
share.add_element user
|
198
190
|
}
|
199
191
|
unshare = req.add_element "unshare"
|
192
|
+
users_to_remove = [""] unless users_to_remove
|
200
193
|
users_to_remove.each{|e|
|
201
194
|
user = Element.new "user"
|
202
195
|
user.text = e
|
@@ -259,13 +252,11 @@ module AdobeShare
|
|
259
252
|
auth_string << "sessionid=\"#{@sessionid}\"," if @sessionid
|
260
253
|
auth_string << "apikey=\"#{@apikey}\",data=\"#{data}\",sig=\"#{sig}\""
|
261
254
|
headers["Authorization"] = auth_string
|
262
|
-
headers["User-Agent"] = UA
|
263
255
|
headers
|
264
256
|
end
|
265
257
|
|
266
258
|
# Performs a generic HTTP request.
|
267
259
|
def http_client_request(method, uri_s, request=nil, header_add={})
|
268
|
-
uri_s << "?method=MOVE" if method == "MOVE"
|
269
260
|
uri = URI.parse uri_s
|
270
261
|
headers = make_headers method, uri
|
271
262
|
headers = headers.merge header_add
|
@@ -279,7 +270,7 @@ module AdobeShare
|
|
279
270
|
when "DELETE"
|
280
271
|
res = @client.delete(uri, headers)
|
281
272
|
when "MOVE"
|
282
|
-
res = @client.
|
273
|
+
res = @client.move(uri, nil, headers)
|
283
274
|
end
|
284
275
|
body = res.body.content
|
285
276
|
status_code = res.header.response_status_code
|
@@ -300,4 +291,4 @@ module AdobeShare
|
|
300
291
|
end
|
301
292
|
class ParameterError < RuntimeError
|
302
293
|
end
|
303
|
-
end
|
294
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'http-access2'
|
2
|
+
|
3
|
+
module AdobeShare
|
4
|
+
#
|
5
|
+
# HTTPClient extensions
|
6
|
+
#
|
7
|
+
class HTTPClient < HTTPClient
|
8
|
+
|
9
|
+
# MOVE Method extension
|
10
|
+
def move(uri, query = nil, extheader = {}, &block)
|
11
|
+
request('MOVE', uri, query, nil, extheader, &block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/adobeshare/version.rb
CHANGED
data/lib/adobeshare.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: adobeshare
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-10-
|
6
|
+
version: 0.0.3
|
7
|
+
date: 2007-10-13 00:00:00 +09:00
|
8
8
|
summary: Adobe Share API for Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/adobeshare/version.rb
|
39
39
|
- lib/adobeshare/client.rb
|
40
40
|
- lib/adobeshare/node.rb
|
41
|
+
- lib/adobeshare/http.rb
|
41
42
|
- examples/sample.rb
|
42
43
|
- examples/config.yaml.sample
|
43
44
|
- setup.rb
|