cmis-ruby 0.3.4 → 0.3.5
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-ruby.rb +12 -2
- data/lib/cmis/children.rb +38 -12
- data/lib/cmis/connection.rb +0 -5
- data/lib/cmis/helpers.rb +16 -2
- data/lib/cmis/object.rb +6 -2
- data/lib/cmis/property_definition.rb +0 -2
- data/lib/cmis/query.rb +0 -2
- data/lib/cmis/relationships.rb +9 -10
- data/lib/cmis/server.rb +0 -2
- data/lib/cmis/type.rb +6 -5
- data/lib/cmis/version.rb +1 -1
- data/lib/core_ext.rb +3 -0
- data/lib/core_ext/array.rb +1 -0
- data/lib/{cmis/core_ext/array.rb → core_ext/array/indifferent_access.rb} +0 -0
- data/lib/core_ext/hash.rb +1 -0
- data/lib/core_ext/hash/compact.rb +22 -0
- data/readme.md +1 -1
- metadata +7 -4
- data/lib/cmis/core_ext/hash.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc97717108219ab5cccfdc7ebbcebdae3e49459f
|
4
|
+
data.tar.gz: 7f6f2d04fdf02fdd4e903024f90cf208a3b0fbc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b85d9befb1c62a5f7077040094c7100d4dd14d1f09712d831b5e8f2362f46186923e03b236c7bfb3330c5c2795e26a17b73cfb34faa97b55da60d8756d6fb07b
|
7
|
+
data.tar.gz: 8f82470e491ee50316dc856f5ef454749a5118ae542991f89ddbdee16e3b4726681ff892c3016f3b099e44e3c271d7c5b49e77a0d49e3b1b703fe720d07851b5
|
data/lib/cmis-ruby.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
# ruby
|
2
|
+
require 'bigdecimal'
|
3
|
+
require 'json'
|
3
4
|
|
5
|
+
# core extensions
|
6
|
+
require 'active_support/core_ext'
|
7
|
+
require 'core_ext'
|
8
|
+
|
9
|
+
# HTTP
|
10
|
+
require 'typhoeus'
|
11
|
+
require 'net/http/post/multipart'
|
12
|
+
|
13
|
+
# cmis-ruby
|
4
14
|
require 'cmis/connection'
|
5
15
|
require 'cmis/exceptions'
|
6
16
|
require 'cmis/server'
|
data/lib/cmis/children.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/hash/slice'
|
2
|
-
|
3
1
|
module CMIS
|
4
2
|
class Children
|
5
3
|
# Options: from, page_size
|
@@ -66,6 +64,8 @@ module CMIS
|
|
66
64
|
@max_items = @options['page_size'] || 10
|
67
65
|
@skip_count = @options['from'] || 0
|
68
66
|
@order_by = @options['order_by']
|
67
|
+
@filter = @options['filter']
|
68
|
+
@include_relationships = @options['include_relationships']
|
69
69
|
@has_next = true
|
70
70
|
|
71
71
|
@opts = @options.slice('query', 'headers')
|
@@ -80,18 +80,44 @@ module CMIS
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def do_get_children
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
83
|
+
repository = @folder.repository
|
84
|
+
result = repository.connection.execute!({ cmisselector: 'children',
|
85
|
+
repositoryId: @folder.repository.id,
|
86
|
+
objectId: @folder.cmis_object_id,
|
87
|
+
maxItems: @max_items,
|
88
|
+
skipCount: @skip_count,
|
89
|
+
orderBy: @order_by,
|
90
|
+
includeRelationships: @include_relationships,
|
91
|
+
filter: @filter}, @opts)
|
92
|
+
|
93
|
+
results = result['objects'].map { |o| build_object_with_relationships(o) }
|
94
|
+
QueryResult.new(results, result['numItems'], result['hasMoreItems'])
|
95
|
+
end
|
96
|
+
|
97
|
+
def build_object_with_relationships(json)
|
98
|
+
object = ObjectFactory.create(json['object'], @folder.repository)
|
99
|
+
|
100
|
+
# If relationships are included, override the object method...
|
101
|
+
if relationships = build_relationships(json)
|
102
|
+
metaclass = class << object; self; end
|
103
|
+
metaclass.send(:define_method, :relationships) do
|
104
|
+
# ...and make the Array respond to `each_relationship`
|
105
|
+
def relationships.each_relationship(args, &blck)
|
106
|
+
each(&blck)
|
107
|
+
end
|
108
|
+
relationships
|
109
|
+
end
|
92
110
|
end
|
93
111
|
|
94
|
-
|
112
|
+
object
|
113
|
+
end
|
114
|
+
|
115
|
+
def build_relationships(json)
|
116
|
+
if json['object']['relationships']
|
117
|
+
json['object']['relationships'].map do |r|
|
118
|
+
ObjectFactory.create(r, @folder.repository)
|
119
|
+
end
|
120
|
+
end
|
95
121
|
end
|
96
122
|
end
|
97
123
|
end
|
data/lib/cmis/connection.rb
CHANGED
data/lib/cmis/helpers.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext'
|
2
|
-
|
3
1
|
module CMIS
|
4
2
|
module Helpers
|
5
3
|
def initialize_properties(raw)
|
@@ -24,6 +22,22 @@ module CMIS
|
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
25
|
+
def self.respond_to?(name, include_private = false)
|
26
|
+
if @properties.has_key?(name.to_s)
|
27
|
+
true
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_missing(name, *args, &block)
|
34
|
+
if @properties.has_key?(name.to_s)
|
35
|
+
@properties[name.to_s]
|
36
|
+
else
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
27
41
|
private
|
28
42
|
|
29
43
|
def method_name(property_name)
|
data/lib/cmis/object.rb
CHANGED
@@ -2,7 +2,6 @@ module CMIS
|
|
2
2
|
class Object
|
3
3
|
include Helpers
|
4
4
|
|
5
|
-
attr_reader :connection
|
6
5
|
attr_reader :repository
|
7
6
|
attr_accessor :properties
|
8
7
|
|
@@ -14,7 +13,6 @@ module CMIS
|
|
14
13
|
cmis:lastModificationDate cmis:changeToken )
|
15
14
|
|
16
15
|
@repository = repository
|
17
|
-
@connection = repository.connection
|
18
16
|
end
|
19
17
|
|
20
18
|
def object_type(opts = {})
|
@@ -109,5 +107,11 @@ module CMIS
|
|
109
107
|
def detached?
|
110
108
|
cmis_object_id.nil?
|
111
109
|
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def connection
|
114
|
+
repository.connection if repository
|
115
|
+
end
|
112
116
|
end
|
113
117
|
end
|
data/lib/cmis/query.rb
CHANGED
data/lib/cmis/relationships.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/hash/slice'
|
2
|
-
|
3
1
|
module CMIS
|
4
2
|
class Relationships
|
5
3
|
# Options: from, page_size
|
@@ -82,14 +80,15 @@ module CMIS
|
|
82
80
|
end
|
83
81
|
|
84
82
|
def do_get_relationships
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
83
|
+
connection = @object.repository.connection
|
84
|
+
result = connection.execute!({ cmisselector: 'relationships',
|
85
|
+
repositoryId: @object.repository.id,
|
86
|
+
objectId: @object.cmis_object_id,
|
87
|
+
maxItems: @max_items,
|
88
|
+
skipCount: @skip_count,
|
89
|
+
relationshipDirection: @direction,
|
90
|
+
includeSubRelationshipTypes: @include_subtypes,
|
91
|
+
typeId: @type_id }, @opts)
|
93
92
|
|
94
93
|
results = result['objects'].map do |r|
|
95
94
|
ObjectFactory.create(r, @object.repository)
|
data/lib/cmis/server.rb
CHANGED
data/lib/cmis/type.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
require 'active_support/core_ext/string/inflections'
|
2
|
-
|
3
1
|
module CMIS
|
4
2
|
class Type
|
5
|
-
attr_accessor :connection
|
6
3
|
attr_accessor :repository
|
7
4
|
|
8
5
|
def initialize(hash, repository)
|
9
6
|
@repository = repository
|
10
|
-
@connection = repository.connection if repository
|
11
|
-
|
12
7
|
@hash = hash.with_indifferent_access
|
13
8
|
|
14
9
|
properties = %w( id localName localNamespace queryName displayName baseId
|
@@ -100,5 +95,11 @@ module CMIS
|
|
100
95
|
def to_hash
|
101
96
|
@hash
|
102
97
|
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def connection
|
102
|
+
repository.connection if repository
|
103
|
+
end
|
103
104
|
end
|
104
105
|
end
|
data/lib/cmis/version.rb
CHANGED
data/lib/core_ext.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'core_ext/array/indifferent_access'
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'core_ext/hash/compact'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Added in active_support 4.1
|
2
|
+
|
3
|
+
class Hash
|
4
|
+
# Returns a hash with non +nil+ values.
|
5
|
+
#
|
6
|
+
# hash = { a: true, b: false, c: nil}
|
7
|
+
# hash.compact # => { a: true, b: false}
|
8
|
+
# hash # => { a: true, b: false, c: nil}
|
9
|
+
# { c: nil }.compact # => {}
|
10
|
+
def compact
|
11
|
+
self.select { |_, value| !value.nil? }
|
12
|
+
end
|
13
|
+
|
14
|
+
# Replaces current hash with non +nil+ values.
|
15
|
+
#
|
16
|
+
# hash = { a: true, b: false, c: nil}
|
17
|
+
# hash.compact! # => { a: true, b: false}
|
18
|
+
# hash # => { a: true, b: false}
|
19
|
+
def compact!
|
20
|
+
self.reject! { |_, value| value.nil? }
|
21
|
+
end
|
22
|
+
end
|
data/readme.md
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.5
|
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-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|
@@ -69,8 +69,6 @@ files:
|
|
69
69
|
- lib/cmis-ruby.rb
|
70
70
|
- lib/cmis/children.rb
|
71
71
|
- lib/cmis/connection.rb
|
72
|
-
- lib/cmis/core_ext/array.rb
|
73
|
-
- lib/cmis/core_ext/hash.rb
|
74
72
|
- lib/cmis/document.rb
|
75
73
|
- lib/cmis/exceptions.rb
|
76
74
|
- lib/cmis/folder.rb
|
@@ -88,6 +86,11 @@ files:
|
|
88
86
|
- lib/cmis/server.rb
|
89
87
|
- lib/cmis/type.rb
|
90
88
|
- lib/cmis/version.rb
|
89
|
+
- lib/core_ext.rb
|
90
|
+
- lib/core_ext/array.rb
|
91
|
+
- lib/core_ext/array/indifferent_access.rb
|
92
|
+
- lib/core_ext/hash.rb
|
93
|
+
- lib/core_ext/hash/compact.rb
|
91
94
|
- readme.md
|
92
95
|
- spec/document_spec.rb
|
93
96
|
- spec/folder_spec.rb
|