active_cmis 0.1.13 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{active_cmis}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Joeri Samson"]
12
+ s.date = %q{2011-04-11}
13
+ s.description = %q{A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS.}
14
+ s.email = %q{joeri@xaop.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "TODO",
25
+ "active_cmis.gemspec",
26
+ "lib/active_cmis.rb",
27
+ "lib/active_cmis/acl.rb",
28
+ "lib/active_cmis/acl_entry.rb",
29
+ "lib/active_cmis/active_cmis.rb",
30
+ "lib/active_cmis/atomic_types.rb",
31
+ "lib/active_cmis/attribute_prefix.rb",
32
+ "lib/active_cmis/collection.rb",
33
+ "lib/active_cmis/document.rb",
34
+ "lib/active_cmis/exceptions.rb",
35
+ "lib/active_cmis/folder.rb",
36
+ "lib/active_cmis/internal/caching.rb",
37
+ "lib/active_cmis/internal/connection.rb",
38
+ "lib/active_cmis/internal/utils.rb",
39
+ "lib/active_cmis/ns.rb",
40
+ "lib/active_cmis/object.rb",
41
+ "lib/active_cmis/policy.rb",
42
+ "lib/active_cmis/property_definition.rb",
43
+ "lib/active_cmis/query_result.rb",
44
+ "lib/active_cmis/rel.rb",
45
+ "lib/active_cmis/relationship.rb",
46
+ "lib/active_cmis/rendition.rb",
47
+ "lib/active_cmis/repository.rb",
48
+ "lib/active_cmis/server.rb",
49
+ "lib/active_cmis/type.rb",
50
+ "lib/active_cmis/version.rb"
51
+ ]
52
+ s.homepage = %q{http://xaop.com/labs/activecmis/}
53
+ s.require_paths = ["lib"]
54
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
55
+ s.rubygems_version = %q{1.5.1}
56
+ s.summary = %q{A library to interact with CMIS repositories through the AtomPub/REST binding}
57
+
58
+ if s.respond_to? :specification_version then
59
+ s.specification_version = 3
60
+
61
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
62
+ s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.1"])
63
+ else
64
+ s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
65
+ end
66
+ else
67
+ s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
68
+ end
69
+ end
70
+
data/lib/active_cmis.rb CHANGED
@@ -26,3 +26,4 @@ require 'active_cmis/active_cmis'
26
26
  require 'active_cmis/internal/utils'
27
27
  require 'active_cmis/rel'
28
28
  require 'active_cmis/attribute_prefix'
29
+ require 'active_cmis/query_result'
@@ -49,7 +49,7 @@ module ActiveCMIS
49
49
  end
50
50
  return repository
51
51
  else
52
- raise "Configuration does not have correct format (not a hash)"
52
+ raise "Configuration does not have correct format (#{config.class} is not a hash)"
53
53
  end
54
54
  end
55
55
 
@@ -81,7 +81,7 @@ module ActiveCMIS
81
81
  raise "Configuration not found in file"
82
82
  end
83
83
  else
84
- raise "Configuration file does not have right format (not a hash)"
84
+ raise "Configuration file #{file} does not have right format (not a hash)"
85
85
  end
86
86
  end
87
87
  end
@@ -22,7 +22,7 @@ module ActiveCMIS
22
22
 
23
23
  class String < CommonBase
24
24
  attr_reader :max_length
25
- def initialize(max_length)
25
+ def initialize(max_length = nil)
26
26
  @max_length = max_length
27
27
  end
28
28
 
@@ -47,10 +47,10 @@ module ActiveCMIS
47
47
  private :_cmis2rb, :_rb2cmis
48
48
  end
49
49
 
50
- # Precision is ignored?
50
+ # Qarning: Precision is ignored?
51
51
  class Decimal < CommonBase
52
52
  attr_reader :precision, :min_value, :max_value
53
- def initialize(precision, min_value, max_value)
53
+ def initialize(precision = nil, min_value = nil, max_value = nil)
54
54
  @precision, @min_value, @max_value = precision, min_value, max_value
55
55
  end
56
56
 
@@ -77,7 +77,7 @@ module ActiveCMIS
77
77
 
78
78
  class Integer < CommonBase
79
79
  attr_reader :min_value, :max_value
80
- def initialize(min_value, max_value)
80
+ def initialize(min_value = nil, max_value = nil)
81
81
  @min_value, @max_value = min_value, max_value
82
82
  end
83
83
 
@@ -106,7 +106,7 @@ module ActiveCMIS
106
106
  attr_reader :resolution
107
107
 
108
108
  @instances ||= {}
109
- def self.new(precision)
109
+ def self.new(precision = TIME)
110
110
  raise ArgumentError.new("Got precision = #{precision.inspect}") unless [YEAR, DATE, TIME].include? precision.to_s.downcase
111
111
  @instances[precision] ||= super
112
112
  end
@@ -228,5 +228,18 @@ module ActiveCMIS
228
228
 
229
229
  private :_cmis2rb, :_rb2cmis
230
230
  end
231
+
232
+ # Map of XML property elements to the corresponding AtomicTypes
233
+ MAPPING = {
234
+ "propertyString" => ActiveCMIS::AtomicType::String,
235
+ "propertyBoolean" => ActiveCMIS::AtomicType::Boolean,
236
+ "propertyId" => ActiveCMIS::AtomicType::ID,
237
+ "propertyDateTime" => ActiveCMIS::AtomicType::DateTime,
238
+ "propertyInteger" => ActiveCMIS::AtomicType::Integer,
239
+ "propertyDecimal" => ActiveCMIS::AtomicType::Decimal,
240
+ "propertyHtml" => ActiveCMIS::AtomicType::HTML,
241
+ "propertyUri" => ActiveCMIS::AtomicType::URI,
242
+ }
243
+
231
244
  end
232
245
  end
@@ -0,0 +1,40 @@
1
+ module ActiveCMIS
2
+ # QueryResults are returned when doing a query
3
+ # You can retrieve the values they contain either by the properties ID or by the query name.
4
+ #
5
+ # Since it is possible that a JOIN is being requested it is not guaranteed that either the query name or the object ID are unique.
6
+ # If that's not the case then it is impossible to retrieve one of the two values. It is therefore important to choose unique queryNames
7
+ # Furthermore, it is not possible to guess which type a query is returning, and therefore it is also not possible to know whether a property is repeating or not, it is possible that a repeating property contains 0 or 1 values, in which case nil or that single value are returned. If multiple values are found for a property then an Array with those properties will be returned
8
+ class QueryResult
9
+ def initialize(atom_entry)
10
+ @atom_entry = atom_entry
11
+ properties = atom_entry.xpath("cra:object/c:properties/c:*", NS::COMBINED)
12
+ @properties_by_id = {}
13
+ @properties_by_query_name = {}
14
+ properties.each do |property|
15
+ type = ActiveCMIS::AtomicType::MAPPING[property.node_name]
16
+ converter = type.new
17
+
18
+ values = property.xpath("c:value", NS::COMBINED)
19
+ # FIXME: If attributes are repeating, but have 0-1 value they won't be in array
20
+ if values.length > 1
21
+ value = values.map {|v| converter.cmis2rb(v)}
22
+ elsif !values.empty?
23
+ value = converter.cmis2rb(values)
24
+ else
25
+ value = nil
26
+ end
27
+ @properties_by_id[property["propertyDefinitionId"]] = value
28
+ @properties_by_query_name[property["queryName"]] = value
29
+ end
30
+ end
31
+
32
+ def property_by_id(name)
33
+ @properties_by_id[name]
34
+ end
35
+
36
+ def property_by_query_name(name)
37
+ @properties_by_query_name[name]
38
+ end
39
+ end
40
+ end
@@ -145,7 +145,7 @@ module ActiveCMIS
145
145
  # @option options [String] :renditionFilter ('cmis:none') Possible values: 'cmis:none', '*' (all), comma-separated list of rendition kinds or mimetypes
146
146
  # @option options [Integer] :maxItems used for paging
147
147
  # @option options [Integer] :skipCount (0) used for paging
148
- # @return [Collection]
148
+ # @return [Collection] A collection with each return value wrapped in a QueryResult
149
149
  def query(query_string, options = {})
150
150
  raise "This repository does not support queries" if capabilities["Query"] == "none"
151
151
  # For the moment we make no difference between metadataonly,fulltextonly,bothseparate and bothcombined
@@ -162,7 +162,9 @@ module ActiveCMIS
162
162
  # FIXME: options are not respected yet by pick_template
163
163
  url = pick_template("query", :mimetype => "application/atom+xml", :type => "feed")
164
164
  url = fill_in_template(url, options.merge("q" => query_string))
165
- Collection.new(self, url)
165
+ Collection.new(self, url) do |entry|
166
+ QueryResult.new(entry)
167
+ end
166
168
  end
167
169
 
168
170
  # The root folder of the repository (as defined in the CMIS standard)
@@ -1,8 +1,8 @@
1
1
  module ActiveCMIS
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 1
5
- PATCH = 13
4
+ MINOR = 2
5
+ PATCH = 0
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,39 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_cmis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 13
10
- version: 0.1.13
5
+ version: 0.2.0
11
6
  platform: ruby
12
7
  authors:
13
- - Joeri Samson
8
+ - Joeri Samson
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-04-09 00:00:00 +02:00
13
+ date: 2011-04-11 00:00:00 +02:00
19
14
  default_executable:
20
15
  dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: nokogiri
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 5
30
- segments:
31
- - 1
32
- - 4
33
- - 1
34
- version: 1.4.1
35
- type: :runtime
36
- version_requirements: *id001
16
+ - !ruby/object:Gem::Dependency
17
+ name: nokogiri
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.4.1
25
+ type: :runtime
26
+ version_requirements: *id001
37
27
  description: A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS.
38
28
  email: joeri@xaop.com
39
29
  executables: []
@@ -41,38 +31,40 @@ executables: []
41
31
  extensions: []
42
32
 
43
33
  extra_rdoc_files:
44
- - LICENSE
45
- - README.md
46
- - TODO
34
+ - LICENSE
35
+ - README.md
36
+ - TODO
47
37
  files:
48
- - LICENSE
49
- - README.md
50
- - Rakefile
51
- - TODO
52
- - lib/active_cmis.rb
53
- - lib/active_cmis/acl.rb
54
- - lib/active_cmis/acl_entry.rb
55
- - lib/active_cmis/active_cmis.rb
56
- - lib/active_cmis/atomic_types.rb
57
- - lib/active_cmis/attribute_prefix.rb
58
- - lib/active_cmis/collection.rb
59
- - lib/active_cmis/document.rb
60
- - lib/active_cmis/exceptions.rb
61
- - lib/active_cmis/folder.rb
62
- - lib/active_cmis/internal/caching.rb
63
- - lib/active_cmis/internal/connection.rb
64
- - lib/active_cmis/internal/utils.rb
65
- - lib/active_cmis/ns.rb
66
- - lib/active_cmis/object.rb
67
- - lib/active_cmis/policy.rb
68
- - lib/active_cmis/property_definition.rb
69
- - lib/active_cmis/rel.rb
70
- - lib/active_cmis/relationship.rb
71
- - lib/active_cmis/rendition.rb
72
- - lib/active_cmis/repository.rb
73
- - lib/active_cmis/server.rb
74
- - lib/active_cmis/type.rb
75
- - lib/active_cmis/version.rb
38
+ - LICENSE
39
+ - README.md
40
+ - Rakefile
41
+ - TODO
42
+ - active_cmis.gemspec
43
+ - lib/active_cmis.rb
44
+ - lib/active_cmis/acl.rb
45
+ - lib/active_cmis/acl_entry.rb
46
+ - lib/active_cmis/active_cmis.rb
47
+ - lib/active_cmis/atomic_types.rb
48
+ - lib/active_cmis/attribute_prefix.rb
49
+ - lib/active_cmis/collection.rb
50
+ - lib/active_cmis/document.rb
51
+ - lib/active_cmis/exceptions.rb
52
+ - lib/active_cmis/folder.rb
53
+ - lib/active_cmis/internal/caching.rb
54
+ - lib/active_cmis/internal/connection.rb
55
+ - lib/active_cmis/internal/utils.rb
56
+ - lib/active_cmis/ns.rb
57
+ - lib/active_cmis/object.rb
58
+ - lib/active_cmis/policy.rb
59
+ - lib/active_cmis/property_definition.rb
60
+ - lib/active_cmis/query_result.rb
61
+ - lib/active_cmis/rel.rb
62
+ - lib/active_cmis/relationship.rb
63
+ - lib/active_cmis/rendition.rb
64
+ - lib/active_cmis/repository.rb
65
+ - lib/active_cmis/server.rb
66
+ - lib/active_cmis/type.rb
67
+ - lib/active_cmis/version.rb
76
68
  has_rdoc: true
77
69
  homepage: http://xaop.com/labs/activecmis/
78
70
  licenses: []
@@ -81,31 +73,23 @@ post_install_message:
81
73
  rdoc_options: []
82
74
 
83
75
  require_paths:
84
- - lib
76
+ - lib
85
77
  required_ruby_version: !ruby/object:Gem::Requirement
86
78
  none: false
87
79
  requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 59
91
- segments:
92
- - 1
93
- - 8
94
- - 6
95
- version: 1.8.6
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.6
96
83
  required_rubygems_version: !ruby/object:Gem::Requirement
97
84
  none: false
98
85
  requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
105
89
  requirements: []
106
90
 
107
91
  rubyforge_project:
108
- rubygems_version: 1.6.2
92
+ rubygems_version: 1.5.1
109
93
  signing_key:
110
94
  specification_version: 3
111
95
  summary: A library to interact with CMIS repositories through the AtomPub/REST binding