yaccl 1.0.pre.alpha2 → 1.0.pre.alpha3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ff7a4a6aca93021fe40a4982b61fd27df22ee4f
4
- data.tar.gz: fcdb6ac4bb4de4351cce0cce62f14e9437e01bae
3
+ metadata.gz: 78933e5e1b79ac8cb88ca155e3036c73eec12a08
4
+ data.tar.gz: e65eacc0d1ad149fe4530faa286622994c2b4c4d
5
5
  SHA512:
6
- metadata.gz: e2f32d54a5a8e1a71d01c3f93ac7ac5ab28ae7e38c2c6d3e3ff84dc854cb01f0928dceb17517102b90f8d0fc5aeca9eb6ead86a22f704d80943b13d5431593a3
7
- data.tar.gz: 3ceebc2361d3ac2048873d7a70b401b6a4053dc70e0e412c80d58e5db401466b659f679b2542084a3228040553bcd68dbdc63887bbdcbfe8520e30a6586da198
6
+ metadata.gz: b572e67d6dd5051d167132f5e79204e84f044da057d727a36b0c1eacd66435e3b7716e6ebc97c74334d8e3ec2a73fa75c177c2911d73dee76edbe1b0322430c9
7
+ data.tar.gz: e5eaa0cdd87bf8ada2ad6929340d73e5d9fca7737a6438514369ea6b30f17a262f53b7926a6f909019060091960f8870cc66eaa04fa79cbab42c1f06f17b4727
@@ -33,7 +33,6 @@ module YACCL
33
33
  @total ||= do_get_children.num_items
34
34
  end
35
35
 
36
-
37
36
  private
38
37
 
39
38
  def do_get_children
@@ -106,9 +106,9 @@ module YACCL
106
106
  value = (value.to_f * 1000).to_i if value.is_a?(Time)
107
107
  if value.is_a?(Array)
108
108
  hash.merge!("propertyId[#{index}]" => id)
109
- value.each_with_index { |v, idx|
109
+ value.each_with_index do |v, idx|
110
110
  hash.merge!("propertyValue[#{index}][#{idx}]" => value[idx])
111
- }
111
+ end
112
112
  else
113
113
  hash.merge!("propertyId[#{index}]" => id,
114
114
  "propertyValue[#{index}]" => value)
@@ -137,7 +137,7 @@ module YACCL
137
137
  def multipart_post(options)
138
138
  url = URI.parse(options[:url])
139
139
  req = Net::HTTP::Post::Multipart.new(url.path, options[:body])
140
- options[:headers].each {|key, value| req[key] = value }
140
+ options[:headers].each { |key, value| req[key] = value }
141
141
  req.basic_auth @username, @password if @username
142
142
  opts = url.scheme == 'https' ? { use_ssl: true , verify_mode: OpenSSL::SSL::VERIFY_NONE } : {}
143
143
  Net::HTTP.start(url.host, url.port, opts) { |http| http.request(req) }
@@ -54,7 +54,7 @@ module YACCL
54
54
  repositoryId: repository.id,
55
55
  objectId: cmis_object_id,
56
56
  content: content,
57
- changeToken:change_token })
57
+ changeToken: change_token })
58
58
  end
59
59
  end
60
60
 
@@ -25,7 +25,6 @@ module YACCL
25
25
  end
26
26
  end
27
27
 
28
-
29
28
  private
30
29
 
31
30
  def method_name(property_name)
@@ -42,7 +41,7 @@ module YACCL
42
41
  if raw['succinctProperties']
43
42
  result = raw['succinctProperties']
44
43
  elsif raw['properties']
45
- result = raw['properties'].inject({}) do |h, (k, v)|
44
+ result = raw['properties'].reduce({}) do |h, (k, v)|
46
45
  val = v['value']
47
46
  val = v['value'].first if v['value'].is_a?(Array) and v['cardinality'] == 'single'
48
47
  val = Time.at(val / 1000) if val and v['type'] == 'datetime'
@@ -65,8 +65,6 @@ module YACCL
65
65
  repositoryId: repository.id,
66
66
  objectId: cmis_object_id })
67
67
 
68
-
69
-
70
68
  result.map { |r| Policy.new(r, repository) }
71
69
  end
72
70
 
@@ -2,12 +2,10 @@ module YACCL
2
2
  class Query
3
3
 
4
4
  def initialize(repository, statement, options)
5
- options.stringify_keys!
6
-
7
5
  @repository = repository
8
- @connection = repository.connection
9
-
10
6
  @statement = statement
7
+
8
+ options.stringify_keys!
11
9
  @max_items = options['max_items'] || 10
12
10
  @skip_count = options['skip_count'] || 0
13
11
 
@@ -32,15 +30,14 @@ module YACCL
32
30
  @total ||= do_query.num_items
33
31
  end
34
32
 
35
-
36
33
  private
37
34
 
38
35
  def do_query
39
- result = @connection.execute!({ cmisselector: 'query',
40
- repositoryId: @repository.id,
41
- q: @statement,
42
- maxItems: @max_items,
43
- skipCount: @skip_count })
36
+ result = @repository.connection.execute!({ cmisselector: 'query',
37
+ repositoryId: @repository.id,
38
+ q: @statement,
39
+ maxItems: @max_items,
40
+ skipCount: @skip_count })
44
41
 
45
42
  results = result['results'].map do |r|
46
43
  ObjectFactory.create(r, @repository)
@@ -97,6 +97,26 @@ module YACCL
97
97
  Query.new(self, statement, options)
98
98
  end
99
99
 
100
+ def each_query_result(statement, options = {})
101
+ options.stringify_keys!
102
+
103
+ query_opts = {}
104
+ query_opts['skip_count'] = options['from']
105
+ query_opts['max_items'] = options['fetch_size']
106
+
107
+ limit = options['limit'] || 10
108
+ limit = BigDecimal::INFINITY if limit == :all
109
+
110
+ query = query(statement, query_opts)
111
+ counter = 0
112
+ while query.has_next? && counter < limit
113
+ query.next_results.each do |object|
114
+ break unless counter < limit
115
+ yield object
116
+ counter = counter.next
117
+ end
118
+ end
119
+ end
100
120
 
101
121
  private
102
122
 
@@ -38,7 +38,7 @@ module YACCL
38
38
  end
39
39
 
40
40
  def update(changed_property_defs)
41
- new_defs = changed_property_defs.map(&:to_hash).inject({}) do |result, element|
41
+ new_defs = changed_property_defs.map(&:to_hash).reduce({}) do |result, element|
42
42
  result[element[:id]] = element
43
43
  result
44
44
  end
@@ -1,3 +1,3 @@
1
1
  module YACCL
2
- VERSION = '1.0-alpha2'
2
+ VERSION = '1.0-alpha3'
3
3
  end
@@ -33,13 +33,13 @@ describe YACCL::Document do
33
33
  doc.delete
34
34
  end
35
35
 
36
- #it 'set content - attached' do
37
- # new_object = @repo.new_document
38
- # new_object.name = 'doc3'
39
- # new_object.object_type_id = 'cmis:document'
40
- # doc = @repo.root.create(new_object)
41
- # doc.set_content(StringIO.new('content3'), 'text/plain', 'doc3.txt') # set content on attached doc
42
- # doc.content.should eq 'content3'
43
- # doc.delete
44
- #end
36
+ # it 'set content - attached' do
37
+ # new_object = @repo.new_document
38
+ # new_object.name = 'doc3'
39
+ # new_object.object_type_id = 'cmis:document'
40
+ # doc = @repo.root.create(new_object)
41
+ # doc.set_content(StringIO.new('content3'), 'text/plain', 'doc3.txt') # set content on attached doc
42
+ # doc.content.should eq 'content3'
43
+ # doc.delete
44
+ # end
45
45
  end
@@ -62,7 +62,7 @@ describe YACCL::Object do
62
62
  it 'unfile' do
63
63
  doc = create_document
64
64
  doc.unfile
65
- #TODO check
65
+ # TODO check
66
66
  doc.delete
67
67
  end
68
68
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaccl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.pre.alpha2
4
+ version: 1.0.pre.alpha3
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-02-20 00:00:00.000000000 Z
12
+ date: 2014-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus