cmis-ruby 0.4.5 → 0.4.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6300b89602721735d348dd99b9d7ce9fae2074fb
4
- data.tar.gz: 190dcc1be7ee2376722d4cd59880a5e88026eb2a
3
+ metadata.gz: bc1ea1cc077ed4b4c93cd43fa9a70057739c8e72
4
+ data.tar.gz: 9e2fedaca4470a343789aba8f881c6d5145ac640
5
5
  SHA512:
6
- metadata.gz: dd204d03e16bc16f596e30cf44b3be210df6fdda65f233274e1d4dff6c5b395240c8ce04be187a407271b149f14474d1fa6609e1d95a9499ea24a7573c8c35f4
7
- data.tar.gz: d2a62d24c5be1a78c9f9c12b8e29a9622dea66c591f9cd923df4e6d158ad23643417319ffb16157e3511ff327488e19ef9b1c7e230fbfe02786ff9ef4c397e37
6
+ metadata.gz: 614d6bfa3c3b4f9bfcd8022d652e42c4dc7cd554c9bb786f88cfcdc12089db2bd5cd99e462163645d47f3adeea56d1b544041f9e4beb03dddd5d62e8d17e7580
7
+ data.tar.gz: 9931cd84d1a5918f094f11fb270fe4538d8a81809885b149f0eca92aa953f0744b49b6727ba651e0e722eaf44558f78e485d7651ac3dbdd5c1967a776a45e6e9
@@ -1,3 +1,5 @@
1
+ require 'ext/all'
2
+
1
3
  require 'cmis/exceptions'
2
4
  require 'cmis/helpers'
3
5
  require 'cmis/object_factory'
@@ -1,7 +1,5 @@
1
1
  require 'bigdecimal'
2
2
  require 'cmis/query_result'
3
- require 'core_ext/hash/keys'
4
- require 'core_ext/hash/slice'
5
3
 
6
4
  module CMIS
7
5
  class Children
@@ -2,8 +2,6 @@ require 'cmis/connection/request_modifier'
2
2
  require 'cmis/connection/response_parser'
3
3
  require 'cmis/connection/url_resolver'
4
4
  require 'cmis/version'
5
- require 'core_ext/hash/compact'
6
- require 'core_ext/hash/keys'
7
5
  require 'faraday'
8
6
 
9
7
  module CMIS
@@ -14,14 +12,9 @@ module CMIS
14
12
  message = "option `service_url` must be set"
15
13
  service_url = options[:service_url] or raise message
16
14
 
17
- adapter = (options[:adapter] || :net_http).to_sym
15
+ options[:adapter] ||= :net_http
18
16
 
19
- headers = {
20
- user_agent: "cmis-ruby/#{VERSION} [#{adapter}]"
21
- }.merge(options[:headers] || {})
22
- conn_opts = { headers: headers, ssl: options[:ssl] }.compact
23
-
24
- @http = Faraday.new(conn_opts) do |builder|
17
+ @http = Faraday.new(connection_options(options)) do |builder|
25
18
  builder.use RequestModifier
26
19
  builder.request :multipart
27
20
  builder.request :url_encoded
@@ -30,7 +23,7 @@ module CMIS
30
23
  builder.basic_auth(options[:username], options[:password])
31
24
  end
32
25
 
33
- builder.adapter adapter
26
+ builder.adapter options[:adapter].to_sym
34
27
  builder.response :logger if options[:log_requests]
35
28
  builder.use ResponseParser
36
29
  end
@@ -54,5 +47,17 @@ module CMIS
54
47
 
55
48
  response.body
56
49
  end
50
+
51
+ private
52
+
53
+ def connection_options(options)
54
+ headers = { user_agent: "cmis-ruby/#{VERSION} [#{options[:adapter]}]" }
55
+ headers.merge!(options[:headers]) if options[:headers]
56
+
57
+ conn_opts = { headers: headers }
58
+ conn_opts[:ssl] = options[:ssl] if options[:ssl]
59
+
60
+ conn_opts
61
+ end
57
62
  end
58
63
  end
@@ -1,4 +1,3 @@
1
- require 'core_ext/hash/compact'
2
1
  require 'faraday'
3
2
 
4
3
  module CMIS
@@ -6,7 +5,7 @@ module CMIS
6
5
  class RequestModifier < Faraday::Middleware
7
6
  def call(env)
8
7
  if env[:body]
9
- env[:body].compact!
8
+ env[:body].reject! { |_, v| v.nil? }
10
9
  wrap_content(env)
11
10
  massage_properties(env)
12
11
  end
@@ -1,5 +1,3 @@
1
- require 'core_ext/hash/keys'
2
-
3
1
  module CMIS
4
2
  class Document < Object
5
3
  def initialize(raw, repository)
@@ -60,6 +60,10 @@ module CMIS
60
60
  folderId: cmis_object_id }, opts)
61
61
  end
62
62
 
63
+ def root?
64
+ cmis_object_id == repository.root_folder_id
65
+ end
66
+
63
67
  private
64
68
 
65
69
  def create_in_self(object, cmis_action, opts)
@@ -1,5 +1,3 @@
1
- require 'core_ext/string/as_ruby_property'
2
-
3
1
  module CMIS
4
2
  module Helpers
5
3
  def initialize_properties(raw)
@@ -1,6 +1,3 @@
1
- require 'core_ext/hash/keys'
2
- require 'core_ext/string/as_ruby_property'
3
-
4
1
  module CMIS
5
2
  class PropertyDefinition
6
3
  def initialize(hash = {})
@@ -1,7 +1,5 @@
1
1
  require 'bigdecimal'
2
2
  require 'cmis/query_result'
3
- require 'core_ext/hash/keys'
4
- require 'core_ext/hash/slice'
5
3
 
6
4
  module CMIS
7
5
  class Query
@@ -1,7 +1,5 @@
1
1
  require 'bigdecimal'
2
2
  require 'cmis/query_result'
3
- require 'core_ext/hash/keys'
4
- require 'core_ext/hash/slice'
5
3
 
6
4
  module CMIS
7
5
  class Relationships
@@ -1,5 +1,4 @@
1
1
  require 'cmis/query'
2
- require 'core_ext/string/as_ruby_property'
3
2
  require 'json'
4
3
 
5
4
  module CMIS
@@ -1,5 +1,3 @@
1
- require 'core_ext/hash/keys'
2
- require 'core_ext/string/as_ruby_property'
3
1
  require 'json'
4
2
 
5
3
  module CMIS
@@ -1,3 +1,3 @@
1
1
  module CMIS
2
- VERSION = '0.4.5'
2
+ VERSION = '0.4.6'
3
3
  end
@@ -0,0 +1,6 @@
1
+ unless defined? ActiveSupport
2
+ require 'ext/hash/keys'
3
+ require 'ext/hash/slice'
4
+ end
5
+
6
+ require 'ext/string/as_ruby_property'
File without changes
File without changes
@@ -2,6 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  module CMIS
4
4
  describe Folder do
5
+ describe '#root?' do
6
+ before do
7
+ @folder = create_folder
8
+ end
9
+
10
+ after do
11
+ @folder.delete
12
+ end
13
+
14
+ it 'returns true for the root folder' do
15
+ expect(repository.root.root?).to be_true
16
+ end
17
+
18
+ it 'returns false for another folder' do
19
+ expect(@folder.root?).to be_false
20
+ end
21
+ end
22
+
5
23
  describe '#parent' do
6
24
  before do
7
25
  @folder = create_folder
@@ -18,13 +36,6 @@ module CMIS
18
36
  it 'is the root folder for its child' do
19
37
  expect(@folder.parent.cmis_object_id).to eq(repository.root_folder_id)
20
38
  end
21
-
22
- def create_folder
23
- folder = repository.new_folder
24
- folder.name = 'test_folder'
25
- folder.object_type_id = 'cmis:folder'
26
- repository.root.create(folder)
27
- end
28
39
  end
29
40
 
30
41
  describe '#create' do
@@ -62,5 +73,12 @@ module CMIS
62
73
  end
63
74
  end
64
75
  end
76
+
77
+ def create_folder
78
+ folder = repository.new_folder
79
+ folder.name = 'test_folder'
80
+ folder.object_type_id = 'cmis:folder'
81
+ repository.root.create(folder)
82
+ end
65
83
  end
66
84
  end
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.4.5
4
+ version: 0.4.6
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-04-01 00:00:00.000000000 Z
12
+ date: 2014-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -68,10 +68,10 @@ files:
68
68
  - lib/cmis/server.rb
69
69
  - lib/cmis/type.rb
70
70
  - lib/cmis/version.rb
71
- - lib/core_ext/hash/compact.rb
72
- - lib/core_ext/hash/keys.rb
73
- - lib/core_ext/hash/slice.rb
74
- - lib/core_ext/string/as_ruby_property.rb
71
+ - lib/ext/all.rb
72
+ - lib/ext/hash/keys.rb
73
+ - lib/ext/hash/slice.rb
74
+ - lib/ext/string/as_ruby_property.rb
75
75
  - readme.md
76
76
  - spec/cmis-ruby/document_spec.rb
77
77
  - spec/cmis-ruby/folder_spec.rb
@@ -1,20 +0,0 @@
1
- class Hash
2
- # Returns a hash with non +nil+ values.
3
- #
4
- # hash = { a: true, b: false, c: nil}
5
- # hash.compact # => { a: true, b: false}
6
- # hash # => { a: true, b: false, c: nil}
7
- # { c: nil }.compact # => {}
8
- def compact
9
- self.select { |_, value| !value.nil? }
10
- end
11
-
12
- # Replaces current hash with non +nil+ values.
13
- #
14
- # hash = { a: true, b: false, c: nil}
15
- # hash.compact! # => { a: true, b: false}
16
- # hash # => { a: true, b: false}
17
- def compact!
18
- self.reject! { |_, value| value.nil? }
19
- end
20
- end