cmis-ruby 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.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +6 -0
- data/LICENSE +176 -0
- data/Rakefile +7 -0
- data/cmis-ruby.gemspec +27 -0
- data/lib/cmis-ruby.rb +20 -0
- data/lib/cmis/children.rb +95 -0
- data/lib/cmis/connection.rb +147 -0
- data/lib/cmis/document.rb +62 -0
- data/lib/cmis/folder.rb +76 -0
- data/lib/cmis/helpers.rb +58 -0
- data/lib/cmis/item.rb +11 -0
- data/lib/cmis/object.rb +120 -0
- data/lib/cmis/object_factory.rb +27 -0
- data/lib/cmis/policy.rb +26 -0
- data/lib/cmis/property_definition.rb +32 -0
- data/lib/cmis/query.rb +100 -0
- data/lib/cmis/query_result.rb +15 -0
- data/lib/cmis/relationship.rb +18 -0
- data/lib/cmis/repository.rb +112 -0
- data/lib/cmis/server.rb +43 -0
- data/lib/cmis/type.rb +106 -0
- data/lib/cmis/version.rb +3 -0
- data/readme.md +23 -0
- data/spec/document_spec.rb +45 -0
- data/spec/folder_spec.rb +75 -0
- data/spec/helper.rb +27 -0
- data/spec/object_spec.rb +100 -0
- data/spec/relationship_spec.rb +19 -0
- data/spec/repository_spec.rb +150 -0
- data/spec/server_spec.rb +22 -0
- data/spec/type_spec.rb +69 -0
- metadata +141 -0
data/spec/helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'cmis-ruby'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
META = CMIS::Server.new.repository('meta')
|
5
|
+
|
6
|
+
def create_repository(id)
|
7
|
+
delete_repository(id)
|
8
|
+
|
9
|
+
repo_type = META.type('repository')
|
10
|
+
property_definitions = repo_type.property_definitions.keys
|
11
|
+
|
12
|
+
f = repo_type.new_object
|
13
|
+
f.name = id
|
14
|
+
f.properties[:id] = id
|
15
|
+
f.properties[:supportsRelationships] = true if property_definitions.include?('supportsRelationships')
|
16
|
+
f.properties[:supportsPolicies] = true if property_definitions.include?('supportsPolicies')
|
17
|
+
f.properties[:supportsItems] = true if property_definitions.include?('supportsItems')
|
18
|
+
f.properties[:realtime] = true if property_definitions.include?('realtime')
|
19
|
+
META.root.create(f)
|
20
|
+
|
21
|
+
CMIS::Server.new.repository(id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_repository(id)
|
25
|
+
META.object(id).delete
|
26
|
+
rescue CMIS::CMISRequestError => ex
|
27
|
+
end
|
data/spec/object_spec.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require_relative './helper'
|
2
|
+
|
3
|
+
describe CMIS::Object do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@repo = create_repository('test')
|
7
|
+
end
|
8
|
+
|
9
|
+
after :all do
|
10
|
+
delete_repository('test')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'repository' do
|
14
|
+
doc = create_document
|
15
|
+
doc.repository.should be_a_kind_of CMIS::Repository
|
16
|
+
doc.repository.id.should eq 'test'
|
17
|
+
doc.delete
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'object_type' do
|
21
|
+
doc = create_document
|
22
|
+
doc.object_type.should be_a_kind_of CMIS::Type
|
23
|
+
doc.object_type.id.should eq 'cmis:document'
|
24
|
+
doc.delete
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'delete' do
|
28
|
+
doc = create_document
|
29
|
+
doc.delete
|
30
|
+
# TODO check
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'allowable actions' do
|
34
|
+
doc = create_document
|
35
|
+
actions = doc.allowable_actions
|
36
|
+
actions.should_not be_nil
|
37
|
+
actions.should_not be_empty
|
38
|
+
actions.values.each { |v| [true, false].should include v }
|
39
|
+
doc.delete
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'relationships' do
|
43
|
+
doc = create_document
|
44
|
+
rels = doc.relationships
|
45
|
+
rels.should_not be_nil
|
46
|
+
rels.each do |r|
|
47
|
+
r.should be_a_kind_of CMIS::Relationship
|
48
|
+
end
|
49
|
+
doc.delete
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'policies' do
|
53
|
+
doc = create_document
|
54
|
+
pols = doc.policies
|
55
|
+
pols.should_not be_nil
|
56
|
+
pols.each do |p|
|
57
|
+
p.should be_a_kind_of CMIS::Policy
|
58
|
+
end
|
59
|
+
doc.delete
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'unfile' do
|
63
|
+
doc = create_document
|
64
|
+
doc.unfile
|
65
|
+
# TODO check
|
66
|
+
doc.delete
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'acls' do
|
70
|
+
doc = create_document
|
71
|
+
acls = doc.acls
|
72
|
+
acls.should_not be_nil
|
73
|
+
acls.should_not be_empty
|
74
|
+
acls.should have_key :aces
|
75
|
+
acls.should have_key :isExact
|
76
|
+
[true, false].should include acls[:isExact]
|
77
|
+
doc.delete
|
78
|
+
end
|
79
|
+
|
80
|
+
# it 'add aces' do
|
81
|
+
# doc = create_document
|
82
|
+
# doc.add_aces({})
|
83
|
+
# #TODO check
|
84
|
+
# doc.delete
|
85
|
+
# end
|
86
|
+
|
87
|
+
# it 'remove aces' do
|
88
|
+
# doc = create_document
|
89
|
+
# doc.remove_aces({})
|
90
|
+
# #TODO check
|
91
|
+
# doc.delete
|
92
|
+
# end
|
93
|
+
|
94
|
+
def create_document
|
95
|
+
new_object = @repo.new_document
|
96
|
+
new_object.name = 'doc'
|
97
|
+
new_object.object_type_id = 'cmis:document'
|
98
|
+
@repo.root.create(new_object)
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative './helper'
|
2
|
+
|
3
|
+
describe CMIS::Relationship do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@dummy = CMIS::Server.new.repository('meta')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should make properties accessible through method' do
|
10
|
+
new_object = CMIS::Relationship.new({ succinctProperties: { myProp: 'myValue' } }, @dummy)
|
11
|
+
new_object.properties['myProp'].should eq 'myValue'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should raise methodmissing for unknown property' do
|
15
|
+
new_object = CMIS::Relationship.new({ succinctProperties: { 'myProp' => 'myValue' } }, @dummy)
|
16
|
+
expect { new_object.myOtherProp }.to raise_error(NoMethodError, /undefined method `myOtherProp'/)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require_relative './helper'
|
2
|
+
|
3
|
+
describe CMIS::Repository do
|
4
|
+
|
5
|
+
context 'generic' do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@id = 'meta'
|
9
|
+
@repo = CMIS::Server.new.repository(@id)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'id' do
|
13
|
+
@repo.id.should.eql? @id
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'fields' do
|
17
|
+
@repo.id.should_not be_nil
|
18
|
+
@repo.name.should_not be_nil
|
19
|
+
@repo.product_version.should_not be_nil
|
20
|
+
@repo.description.should_not be_nil
|
21
|
+
@repo.root_folder_id.should_not be_nil
|
22
|
+
@repo.capabilities.should_not be_nil
|
23
|
+
@repo.url.should_not be_nil
|
24
|
+
@repo.changes_on_type.should_not be_nil
|
25
|
+
@repo.root_folder_url.should_not be_nil
|
26
|
+
@repo.product_name.should_not be_nil
|
27
|
+
@repo.product_version.should_not be_nil
|
28
|
+
|
29
|
+
%w(1.0 1.1).should include @repo.cmis_version_supported
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'new object' do
|
33
|
+
@repo.new_folder.should be_a_kind_of CMIS::Folder
|
34
|
+
@repo.new_document.should be_a_kind_of CMIS::Document
|
35
|
+
@repo.new_relationship.should be_a_kind_of CMIS::Relationship
|
36
|
+
@repo.new_policy.should be_a_kind_of CMIS::Policy
|
37
|
+
@repo.new_item.should be_a_kind_of CMIS::Item
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'repositories' do
|
41
|
+
CMIS::Server.new.repositories
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'repository' do
|
45
|
+
r = CMIS::Server.new.repository('generali')
|
46
|
+
r.name.should eq 'generali'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'root' do
|
50
|
+
root = @repo.root
|
51
|
+
root.should be_a_kind_of CMIS::Folder
|
52
|
+
root.cmis_object_id.should eq @repo.root_folder_id
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'object' do
|
56
|
+
id = @repo.root_folder_id
|
57
|
+
object = @repo.object(id)
|
58
|
+
object.should be_a_kind_of CMIS::Folder
|
59
|
+
object.cmis_object_id.should eq id
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'type - document' do
|
63
|
+
document = @repo.type('cmis:document')
|
64
|
+
document.should be_a_kind_of CMIS::Type
|
65
|
+
document.id.should eq 'cmis:document'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'type - folder' do
|
69
|
+
folder = @repo.type('cmis:folder')
|
70
|
+
folder.should be_a_kind_of CMIS::Type
|
71
|
+
folder.id.should eq 'cmis:folder'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'upn' do
|
76
|
+
|
77
|
+
before :all do
|
78
|
+
@repo = create_repository('testrepository')
|
79
|
+
end
|
80
|
+
|
81
|
+
after :all do
|
82
|
+
delete_repository('testrepository')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'type - relationship' do
|
86
|
+
relationship = @repo.type('cmis:relationship')
|
87
|
+
relationship.should be_a_kind_of CMIS::Type
|
88
|
+
relationship.id.should eq 'cmis:relationship'
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'type - policy' do
|
92
|
+
policy = @repo.type('cmis:policy')
|
93
|
+
policy.should be_a_kind_of CMIS::Type
|
94
|
+
policy.id.should eq 'cmis:policy'
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'type - item' do
|
98
|
+
begin
|
99
|
+
item = @repo.type('cmis:item')
|
100
|
+
item.should be_a_kind_of CMIS::Type
|
101
|
+
item.id.should eq 'cmis:item'
|
102
|
+
end unless @repo.cmis_version_supported < '1.1'
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'create, get, delete type - document' do
|
106
|
+
type_id = 'apple'
|
107
|
+
|
108
|
+
type = CMIS::Type.new
|
109
|
+
type.id = type_id
|
110
|
+
type.local_name = 'apple'
|
111
|
+
type.query_name = 'apple'
|
112
|
+
type.display_name = 'apple'
|
113
|
+
type.parent_id = 'cmis:document'
|
114
|
+
type.base_id = 'cmis:document'
|
115
|
+
type.description = 'appel'
|
116
|
+
type.creatable = true
|
117
|
+
type.fileable = true
|
118
|
+
type.queryable = true
|
119
|
+
type.controllable_policy = true
|
120
|
+
type.controllable_acl = true
|
121
|
+
type.fulltext_indexed = true
|
122
|
+
type.included_in_supertype_query = true
|
123
|
+
type.content_stream_allowed = 'allowed'
|
124
|
+
type.versionable = false
|
125
|
+
|
126
|
+
type.add_property_definition(id: 'color',
|
127
|
+
localName: 'color',
|
128
|
+
queryName: 'color',
|
129
|
+
displayName: 'color',
|
130
|
+
description: 'color',
|
131
|
+
propertyType: 'string',
|
132
|
+
cardinality: 'single',
|
133
|
+
updatability: 'readwrite',
|
134
|
+
inherited: false,
|
135
|
+
required: false,
|
136
|
+
queryable: true,
|
137
|
+
orderable: true)
|
138
|
+
|
139
|
+
@repo.create_type(type)
|
140
|
+
|
141
|
+
@repo.type(type_id).tap do |t|
|
142
|
+
t.should be_a_kind_of CMIS::Type
|
143
|
+
t.id.should eq type_id
|
144
|
+
end
|
145
|
+
|
146
|
+
@repo.type(type_id).delete
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative './helper'
|
2
|
+
|
3
|
+
describe CMIS::Server do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@server = CMIS::Server.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'repositories' do
|
10
|
+
@server.repositories.each do |repo|
|
11
|
+
repo.should be_a_kind_of CMIS::Repository
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'repository' do
|
16
|
+
id = 'meta'
|
17
|
+
repo = @server.repository(id)
|
18
|
+
repo.should be_a_kind_of CMIS::Repository
|
19
|
+
repo.id.should eq id
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/spec/type_spec.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative './helper'
|
2
|
+
|
3
|
+
describe CMIS::Type do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@repo = create_repository('test')
|
7
|
+
end
|
8
|
+
|
9
|
+
after :all do
|
10
|
+
delete_repository('test')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'shoud update types' do
|
14
|
+
type = CMIS::Type.new
|
15
|
+
type.id = 'apple'
|
16
|
+
type.local_name = 'apple'
|
17
|
+
type.query_name = 'apple'
|
18
|
+
type.display_name = 'Apple'
|
19
|
+
type.parent_id = 'cmis:document'
|
20
|
+
type.base_id = 'cmis:document'
|
21
|
+
type.description = 'The apple fruit.'
|
22
|
+
type.creatable = true
|
23
|
+
type.fileable = true
|
24
|
+
type.queryable = true
|
25
|
+
type.controllable_policy = true
|
26
|
+
type.controllable_acl = true
|
27
|
+
type.fulltext_indexed = true
|
28
|
+
type.included_in_supertype_query = true
|
29
|
+
type.content_stream_allowed = 'allowed'
|
30
|
+
type.versionable = false
|
31
|
+
|
32
|
+
type.add_property_definition(
|
33
|
+
id: 'color',
|
34
|
+
localName: 'color',
|
35
|
+
queryName: 'color',
|
36
|
+
displayName: 'Color',
|
37
|
+
description: 'The color.',
|
38
|
+
propertyType: 'string',
|
39
|
+
cardinality: 'single',
|
40
|
+
updatability: 'readwrite',
|
41
|
+
inherited: false,
|
42
|
+
required: false,
|
43
|
+
queryable: true,
|
44
|
+
orderable: true
|
45
|
+
)
|
46
|
+
|
47
|
+
full_type = @repo.create_type(type)
|
48
|
+
|
49
|
+
new_prop = CMIS::PropertyDefinition.new(
|
50
|
+
id: 'taste',
|
51
|
+
localName: 'taste',
|
52
|
+
queryName: 'taste',
|
53
|
+
displayName: 'Taste',
|
54
|
+
description: 'The taste.',
|
55
|
+
propertyType: 'string',
|
56
|
+
cardinality: 'single',
|
57
|
+
updatability: 'readwrite',
|
58
|
+
inherited: false,
|
59
|
+
required: false,
|
60
|
+
queryable: true,
|
61
|
+
orderable: true
|
62
|
+
)
|
63
|
+
|
64
|
+
full_type.update([new_prop])
|
65
|
+
|
66
|
+
full_type.delete
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cmis-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kenneth Geerts
|
8
|
+
- Michael Brackx
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: typhoeus
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.6'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.6'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: multipart-post
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.1'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: multi_json
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.5'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.5'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: activesupport
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.2'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.2'
|
70
|
+
description: |
|
71
|
+
CMIS browser binding client library in ruby.
|
72
|
+
email:
|
73
|
+
- gem@up-nxt.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE
|
81
|
+
- Rakefile
|
82
|
+
- cmis-ruby.gemspec
|
83
|
+
- lib/cmis-ruby.rb
|
84
|
+
- lib/cmis/children.rb
|
85
|
+
- lib/cmis/connection.rb
|
86
|
+
- lib/cmis/document.rb
|
87
|
+
- lib/cmis/folder.rb
|
88
|
+
- lib/cmis/helpers.rb
|
89
|
+
- lib/cmis/item.rb
|
90
|
+
- lib/cmis/object.rb
|
91
|
+
- lib/cmis/object_factory.rb
|
92
|
+
- lib/cmis/policy.rb
|
93
|
+
- lib/cmis/property_definition.rb
|
94
|
+
- lib/cmis/query.rb
|
95
|
+
- lib/cmis/query_result.rb
|
96
|
+
- lib/cmis/relationship.rb
|
97
|
+
- lib/cmis/repository.rb
|
98
|
+
- lib/cmis/server.rb
|
99
|
+
- lib/cmis/type.rb
|
100
|
+
- lib/cmis/version.rb
|
101
|
+
- readme.md
|
102
|
+
- spec/document_spec.rb
|
103
|
+
- spec/folder_spec.rb
|
104
|
+
- spec/helper.rb
|
105
|
+
- spec/object_spec.rb
|
106
|
+
- spec/relationship_spec.rb
|
107
|
+
- spec/repository_spec.rb
|
108
|
+
- spec/server_spec.rb
|
109
|
+
- spec/type_spec.rb
|
110
|
+
homepage: https://github.com/UP-nxt
|
111
|
+
licenses: []
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.2.1
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Ruby client for CMIS
|
133
|
+
test_files:
|
134
|
+
- spec/document_spec.rb
|
135
|
+
- spec/folder_spec.rb
|
136
|
+
- spec/helper.rb
|
137
|
+
- spec/object_spec.rb
|
138
|
+
- spec/relationship_spec.rb
|
139
|
+
- spec/repository_spec.rb
|
140
|
+
- spec/server_spec.rb
|
141
|
+
- spec/type_spec.rb
|