cmis-ruby 0.3.7 → 0.3.8
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.
- checksums.yaml +4 -4
- data/lib/cmis/connection.rb +18 -8
- data/lib/cmis/document.rb +7 -5
- data/lib/cmis/helpers.rb +7 -6
- data/lib/cmis/object.rb +8 -6
- data/lib/cmis/version.rb +1 -1
- data/spec/repository_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5509c0d7a7ebe328fb70713c0d33286634414c3b
|
4
|
+
data.tar.gz: 1b083a997de518a72a4d3de31b955321f32184ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71aeea351aef546a84493d3090c959b62f8b318c9adc0e13ffbb98ed8125cc7ac03bb63c1ae18d82936ce2a0eb80092b1f71074b9b1b94ea0667fb0bc8ec154a
|
7
|
+
data.tar.gz: 933826ba179011b28eda09faa060b4fc722ff5ea595f0a243a9ddc9dbbec9581b50d50f40151936e02550b590c287f256cc43f5ff18588de3470f22fd73c7ea2
|
data/lib/cmis/connection.rb
CHANGED
@@ -3,8 +3,8 @@ module CMIS
|
|
3
3
|
def initialize(options)
|
4
4
|
options.symbolize_keys!
|
5
5
|
|
6
|
-
@service_url = options[:service_url] || ENV['CMIS_BROWSER_URL'] or
|
7
|
-
"option `:service_url` or ENV['CMIS_BROWSER_URL'] must be set"
|
6
|
+
@service_url = options[:service_url] || ENV['CMIS_BROWSER_URL'] or \
|
7
|
+
raise "option `:service_url` or ENV['CMIS_BROWSER_URL'] must be set"
|
8
8
|
|
9
9
|
adapter = (options[:adapter] || :net_http).to_sym
|
10
10
|
|
@@ -130,17 +130,27 @@ module CMIS
|
|
130
130
|
end
|
131
131
|
|
132
132
|
class ResponseParser < Faraday::Middleware
|
133
|
+
JSON_CONTENT_TYPE = /\/(x-)?json(;.+?)?$/
|
134
|
+
|
133
135
|
def call(env)
|
134
136
|
@app.call(env).on_complete do |env|
|
135
|
-
if env[:response_headers][:content_type] =~
|
137
|
+
if env[:response_headers][:content_type] =~ JSON_CONTENT_TYPE
|
136
138
|
env[:body] = JSON.parse(env[:body]).with_indifferent_access
|
137
|
-
|
138
|
-
ruby_exception = "CMIS::Exceptions::#{ex.camelize}".constantize
|
139
|
-
message = "#{ex.underscore.humanize}: #{env[:body][:message]}"
|
140
|
-
raise ruby_exception, message
|
141
|
-
end
|
139
|
+
check_for_exception!(env[:body])
|
142
140
|
end
|
143
141
|
end
|
144
142
|
end
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
def check_for_exception!(body)
|
147
|
+
return unless body.is_a?(Hash)
|
148
|
+
|
149
|
+
if ex = body[:exception]
|
150
|
+
ruby_exception = "CMIS::Exceptions::#{ex.camelize}".constantize
|
151
|
+
message = "#{ex.underscore.humanize}: #{body[:message]}"
|
152
|
+
raise ruby_exception, message
|
153
|
+
end
|
154
|
+
end
|
145
155
|
end
|
146
156
|
end
|
data/lib/cmis/document.rb
CHANGED
@@ -55,11 +55,13 @@ module CMIS
|
|
55
55
|
if detached?
|
56
56
|
@local_content = content
|
57
57
|
else
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
with_change_token do
|
59
|
+
server.execute!({ cmisaction: 'setContent',
|
60
|
+
repositoryId: repository.id,
|
61
|
+
objectId: cmis_object_id,
|
62
|
+
content: content,
|
63
|
+
changeToken: change_token }, opts)
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
data/lib/cmis/helpers.rb
CHANGED
@@ -12,13 +12,14 @@ module CMIS
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
def with_change_token(&block)
|
16
|
+
json = yield
|
17
|
+
if props = json['properties']
|
18
|
+
self.change_token = props['cmis:changeToken']['value']
|
19
|
+
elsif succinct_props = json['succinctProperties']
|
20
|
+
self.change_token = succinct_props['cmis:changeToken']
|
20
21
|
else
|
21
|
-
raise "Unexpected input: #{
|
22
|
+
raise "Unexpected input: #{json}"
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
data/lib/cmis/object.rb
CHANGED
@@ -3,7 +3,7 @@ module CMIS
|
|
3
3
|
include Helpers
|
4
4
|
|
5
5
|
attr_reader :repository
|
6
|
-
|
6
|
+
attr_reader :properties
|
7
7
|
|
8
8
|
def initialize(raw, repository)
|
9
9
|
initialize_properties(raw)
|
@@ -27,11 +27,13 @@ module CMIS
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def update_properties(properties, opts = {})
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
with_change_token do
|
31
|
+
server.execute!({ cmisaction: 'update',
|
32
|
+
repositoryId: repository.id,
|
33
|
+
objectId: cmis_object_id,
|
34
|
+
properties: properties,
|
35
|
+
changeToken: change_token }, opts)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
|
37
39
|
def parents(opts = {})
|
data/lib/cmis/version.rb
CHANGED
data/spec/repository_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmis-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenneth Geerts
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|