treequel 1.1.0 → 1.1.1
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.
- data.tar.gz.sig +0 -0
- data/lib/treequel.rb +3 -3
- data/lib/treequel/branch.rb +1 -1
- data/lib/treequel/model.rb +7 -2
- data/spec/treequel/model_spec.rb +13 -20
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/treequel.rb
CHANGED
@@ -25,7 +25,7 @@ end
|
|
25
25
|
|
26
26
|
# A library for interacting with LDAP modelled after Sequel.
|
27
27
|
#
|
28
|
-
# @version 1.1.
|
28
|
+
# @version 1.1.1
|
29
29
|
#
|
30
30
|
# @example
|
31
31
|
# # Connect to the directory at the specified URL
|
@@ -53,10 +53,10 @@ end
|
|
53
53
|
module Treequel
|
54
54
|
|
55
55
|
# Library version
|
56
|
-
VERSION = '1.1.
|
56
|
+
VERSION = '1.1.1'
|
57
57
|
|
58
58
|
# VCS revision
|
59
|
-
REVISION = %q$Revision:
|
59
|
+
REVISION = %q$Revision: c6d26ab6a7a4 $
|
60
60
|
|
61
61
|
# Common paths for ldap.conf
|
62
62
|
COMMON_LDAP_CONF_PATHS = %w[
|
data/lib/treequel/branch.rb
CHANGED
@@ -478,7 +478,7 @@ class Treequel::Branch
|
|
478
478
|
|
479
479
|
oc_oids = self[:objectClass] || []
|
480
480
|
oc_oids |= additional_classes.collect {|str| str.to_sym }
|
481
|
-
oc_oids <<
|
481
|
+
oc_oids << 'top' if oc_oids.empty?
|
482
482
|
|
483
483
|
oclasses = []
|
484
484
|
oc_oids.each do |oid|
|
data/lib/treequel/model.rb
CHANGED
@@ -96,6 +96,7 @@ class Treequel::Model < Treequel::Branch
|
|
96
96
|
### @param [Array<Symbol>] objectclasses the objectclasses from the entry
|
97
97
|
### @return [Set<Module>] the Set of mixin modules which apply
|
98
98
|
def self::mixins_for_objectclasses( *objectclasses )
|
99
|
+
return self.objectclass_registry[:top] if objectclasses.empty?
|
99
100
|
ocsymbols = objectclasses.flatten.collect {|oc| oc.untaint.to_sym }
|
100
101
|
|
101
102
|
# Get the union of all of the mixin sets for the objectclasses in question
|
@@ -317,7 +318,10 @@ class Treequel::Model < Treequel::Branch
|
|
317
318
|
### Apply mixins that are applicable considering the receiver's DN and the
|
318
319
|
### objectClasses from its entry.
|
319
320
|
def apply_applicable_mixins( dn, entry )
|
320
|
-
|
321
|
+
schema = self.directory.schema
|
322
|
+
|
323
|
+
ocs = entry['objectClass'].collect do |oc_oid|
|
324
|
+
explicit_oc = schema.object_classes[ oc_oid ]
|
321
325
|
explicit_oc.ancestors.collect {|oc| oc.name }
|
322
326
|
end.flatten.uniq
|
323
327
|
|
@@ -328,7 +332,8 @@ class Treequel::Model < Treequel::Branch
|
|
328
332
|
# inferred by its objectclasses and those that apply to its DN
|
329
333
|
mixins = ( oc_mixins & dn_mixins )
|
330
334
|
|
331
|
-
self.log.debug "
|
335
|
+
self.log.debug "Applying %d mixins to %s: %p" %
|
336
|
+
[ mixins.length, dn, mixins.collect(&:inspect) ]
|
332
337
|
mixins.each {|mod| self.extend(mod) }
|
333
338
|
end
|
334
339
|
|
data/spec/treequel/model_spec.rb
CHANGED
@@ -28,8 +28,13 @@ describe Treequel::Model do
|
|
28
28
|
include Treequel::SpecHelpers,
|
29
29
|
Treequel::Matchers
|
30
30
|
|
31
|
+
SCHEMA_DUMPFILE = Pathname( __FILE__ ).dirname.parent + 'data' + 'schema.yml'
|
32
|
+
SCHEMAHASH = LDAP::Schema.new( YAML.load_file(SCHEMA_DUMPFILE) )
|
33
|
+
|
31
34
|
before( :all ) do
|
32
35
|
setup_logging( :fatal )
|
36
|
+
|
37
|
+
@schema = Treequel::Schema.new( SCHEMAHASH )
|
33
38
|
end
|
34
39
|
|
35
40
|
after( :all ) do
|
@@ -37,9 +42,9 @@ describe Treequel::Model do
|
|
37
42
|
end
|
38
43
|
|
39
44
|
before( :each ) do
|
40
|
-
@top_oc =
|
41
|
-
@iphost_oc =
|
42
|
-
@device_oc =
|
45
|
+
@top_oc = @schema.object_classes[:top]
|
46
|
+
@iphost_oc = @schema.object_classes[:ipHost]
|
47
|
+
@device_oc = @schema.object_classes[:device]
|
43
48
|
|
44
49
|
@iphost_oc.stub!( :ancestors ).and_return([ @iphost_oc, @top_oc ])
|
45
50
|
@device_oc.stub!( :ancestors ).and_return([ @device_oc, @top_oc ])
|
@@ -48,8 +53,8 @@ describe Treequel::Model do
|
|
48
53
|
'dn' => TEST_HOST_DN,
|
49
54
|
'objectClass' => ['ipHost', 'device']
|
50
55
|
}
|
51
|
-
@
|
52
|
-
@directory
|
56
|
+
@directory = mock( "treequel directory", :schema => @schema )
|
57
|
+
@directory.stub!( :convert_to_object ).and_return {|oid,value| value }
|
53
58
|
end
|
54
59
|
|
55
60
|
after( :each ) do
|
@@ -181,6 +186,7 @@ describe Treequel::Model do
|
|
181
186
|
end
|
182
187
|
|
183
188
|
obj = Treequel::Model.new( @directory, TEST_HOST_DN )
|
189
|
+
@directory.stub!( :get_entry ).with( obj ).and_return( @simple_entry )
|
184
190
|
obj.exists? # Trigger the lookup
|
185
191
|
|
186
192
|
obj.should be_a( mixin1 )
|
@@ -223,10 +229,6 @@ describe Treequel::Model do
|
|
223
229
|
ipHost
|
224
230
|
],
|
225
231
|
}
|
226
|
-
schema_dumpfile = Pathname( __FILE__ ).dirname.parent + 'data' + 'schema.yml'
|
227
|
-
hash = YAML.load_file( schema_dumpfile )
|
228
|
-
schemahash = LDAP::Schema.new( hash )
|
229
|
-
@schema = Treequel::Schema.new( schemahash )
|
230
232
|
end
|
231
233
|
|
232
234
|
before( :each ) do
|
@@ -235,14 +237,12 @@ describe Treequel::Model do
|
|
235
237
|
model_objectclasses :ipHost
|
236
238
|
def fqdn; "some.home.example.com"; end
|
237
239
|
end
|
238
|
-
@directory = mock( 'Treequel Directory', :schema => @schema )
|
239
240
|
@directory.stub!( :convert_to_object ).with( Treequel::OIDS::OID_SYNTAX, 'ipHost' ).
|
240
241
|
and_return( 'ipHost' )
|
241
242
|
@directory.stub!( :convert_to_object ).
|
242
243
|
with( Treequel::OIDS::DIRECTORY_STRING_SYNTAX, 'Slappy the Frog' ).
|
243
244
|
and_return( 'Slappy the Frog' )
|
244
245
|
@obj = Treequel::Model.new( @directory, TEST_PERSON_DN )
|
245
|
-
@entry.stub!( :object_classes ).and_return([ @schema.object_classes[:ipHost] ])
|
246
246
|
end
|
247
247
|
|
248
248
|
after( :each ) do
|
@@ -252,12 +252,12 @@ describe Treequel::Model do
|
|
252
252
|
|
253
253
|
it "correctly dispatches to methods added via extension that are called before its " +
|
254
254
|
"entry is loaded" do
|
255
|
-
@directory.
|
255
|
+
@directory.stub!( :get_entry ).with( @obj ).and_return( @entry )
|
256
256
|
@obj.fqdn.should == 'some.home.example.com'
|
257
257
|
end
|
258
258
|
|
259
259
|
it "correctly falls through for methods not added by loading the entry" do
|
260
|
-
@directory.
|
260
|
+
@directory.stub!( :get_entry ).with( @obj ).and_return( @entry )
|
261
261
|
@obj.cn.should == ['Slappy the Frog']
|
262
262
|
end
|
263
263
|
end
|
@@ -286,16 +286,9 @@ describe Treequel::Model do
|
|
286
286
|
apple-user
|
287
287
|
],
|
288
288
|
}
|
289
|
-
|
290
|
-
schema_dumpfile = Pathname( __FILE__ ).dirname.parent + 'data' + 'schema.yml'
|
291
|
-
hash = YAML.load_file( schema_dumpfile )
|
292
|
-
schemahash = LDAP::Schema.new( hash )
|
293
|
-
@schema = Treequel::Schema.new( schemahash )
|
294
289
|
end
|
295
290
|
|
296
291
|
before( :each ) do
|
297
|
-
@directory = mock( 'Treequel Directory', :schema => @schema )
|
298
|
-
@entry.stub!( :object_classes ).and_return([ @schema.object_classes[:ipHost] ])
|
299
292
|
@obj = Treequel::Model.new_from_entry( @entry, @directory )
|
300
293
|
end
|
301
294
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: treequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Granger, Mahlon E. Smith
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
cmlhXe46pZNJgWKbxZah85jIjx95hR8vOI+NAM5iH9kOqK13DrxacTKPhqj5PjwF
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-09-
|
38
|
+
date: 2010-09-21 00:00:00 -07:00
|
39
39
|
default_executable:
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|