treequel 1.0.1 → 1.0.4

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.
Files changed (73) hide show
  1. data/ChangeLog +176 -14
  2. data/LICENSE +1 -1
  3. data/Rakefile +61 -45
  4. data/Rakefile.local +20 -0
  5. data/bin/treequel +502 -269
  6. data/examples/ldap-rack-auth.rb +2 -0
  7. data/lib/treequel.rb +221 -18
  8. data/lib/treequel/branch.rb +410 -201
  9. data/lib/treequel/branchcollection.rb +25 -13
  10. data/lib/treequel/branchset.rb +42 -40
  11. data/lib/treequel/constants.rb +233 -3
  12. data/lib/treequel/control.rb +95 -0
  13. data/lib/treequel/controls/contentsync.rb +138 -0
  14. data/lib/treequel/controls/pagedresults.rb +162 -0
  15. data/lib/treequel/controls/sortedresults.rb +216 -0
  16. data/lib/treequel/directory.rb +212 -65
  17. data/lib/treequel/exceptions.rb +11 -12
  18. data/lib/treequel/filter.rb +1 -12
  19. data/lib/treequel/mixins.rb +83 -47
  20. data/lib/treequel/monkeypatches.rb +29 -0
  21. data/lib/treequel/schema.rb +23 -19
  22. data/lib/treequel/schema/attributetype.rb +33 -3
  23. data/lib/treequel/schema/ldapsyntax.rb +0 -11
  24. data/lib/treequel/schema/matchingrule.rb +0 -11
  25. data/lib/treequel/schema/matchingruleuse.rb +0 -11
  26. data/lib/treequel/schema/objectclass.rb +36 -10
  27. data/lib/treequel/schema/table.rb +159 -0
  28. data/lib/treequel/sequel_integration.rb +7 -7
  29. data/lib/treequel/utils.rb +4 -66
  30. data/rake/documentation.rb +89 -0
  31. data/rake/helpers.rb +375 -307
  32. data/rake/hg.rb +16 -2
  33. data/rake/manual.rb +11 -6
  34. data/rake/packaging.rb +20 -35
  35. data/rake/publishing.rb +22 -62
  36. data/spec/lib/constants.rb +20 -0
  37. data/spec/lib/control_behavior.rb +44 -0
  38. data/spec/lib/matchers.rb +51 -0
  39. data/spec/treequel/branch_spec.rb +88 -29
  40. data/spec/treequel/branchcollection_spec.rb +24 -1
  41. data/spec/treequel/branchset_spec.rb +123 -51
  42. data/spec/treequel/control_spec.rb +48 -0
  43. data/spec/treequel/controls/contentsync_spec.rb +38 -0
  44. data/spec/treequel/controls/pagedresults_spec.rb +138 -0
  45. data/spec/treequel/controls/sortedresults_spec.rb +171 -0
  46. data/spec/treequel/directory_spec.rb +186 -16
  47. data/spec/treequel/mixins_spec.rb +42 -3
  48. data/spec/treequel/schema/attributetype_spec.rb +22 -20
  49. data/spec/treequel/schema/objectclass_spec.rb +67 -46
  50. data/spec/treequel/schema/table_spec.rb +134 -0
  51. data/spec/treequel_spec.rb +277 -15
  52. metadata +89 -108
  53. data/bin/treequel.orig +0 -963
  54. data/examples/ldap-monitor.rb +0 -143
  55. data/examples/ldap-monitor/public/css/master.css +0 -328
  56. data/examples/ldap-monitor/public/images/card_small.png +0 -0
  57. data/examples/ldap-monitor/public/images/chain_small.png +0 -0
  58. data/examples/ldap-monitor/public/images/globe_small.png +0 -0
  59. data/examples/ldap-monitor/public/images/globe_small_green.png +0 -0
  60. data/examples/ldap-monitor/public/images/plug.png +0 -0
  61. data/examples/ldap-monitor/public/images/shadows/large-30-down.png +0 -0
  62. data/examples/ldap-monitor/public/images/tick.png +0 -0
  63. data/examples/ldap-monitor/public/images/tick_circle.png +0 -0
  64. data/examples/ldap-monitor/public/images/treequel-favicon.png +0 -0
  65. data/examples/ldap-monitor/views/backends.erb +0 -41
  66. data/examples/ldap-monitor/views/connections.erb +0 -74
  67. data/examples/ldap-monitor/views/databases.erb +0 -39
  68. data/examples/ldap-monitor/views/dump_subsystem.erb +0 -14
  69. data/examples/ldap-monitor/views/index.erb +0 -14
  70. data/examples/ldap-monitor/views/layout.erb +0 -35
  71. data/examples/ldap-monitor/views/listeners.erb +0 -30
  72. data/rake/rdoc.rb +0 -30
  73. data/rake/win32.rb +0 -190
@@ -1,41 +0,0 @@
1
- <h2>Server Backends</h2>
2
-
3
- <p><%= subsystem[:description ]%></p>
4
-
5
- <table id="backend-list" class="horizontal">
6
- <thead>
7
- <tr>
8
- <th></th>
9
- <th class="even">Runtime Config?</th>
10
- <th class="odd">Supported Controls</th>
11
- <th class="even">See Also</th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <% backends.each_with_index do |backend, i| %>
16
- <% rowclass = i.divmod(2).last.zero? ? "even" : "odd" %>
17
- <tr class="<%= rowclass %>">
18
- <th><%= backend[:monitoredInfo] %></th>
19
- <td class="even icon">
20
- <% if backend[:monitorRuntimeConfig].first == 'TRUE' %>
21
- <img src="/images/tick.png" width="16" height="16" alt="Yes" />
22
- <% else %>
23
- &nbsp;
24
- <% end %>
25
- </td>
26
- <td class="odd list">
27
- <% if backend[:supportedControl] %>
28
- <%= backend[:supportedControl].
29
- collect {|oid| %{<span class="oid">#{oid}</span>} }.
30
- join(', ') %><br />
31
- <% end %>
32
- </td>
33
- <td class="even">
34
- <% if backend[:seeAlso] %><span class="dn"><%= backend[:seeAlso] %></span><% end %>
35
- </td>
36
- </tr>
37
- <% end %>
38
- </tbody>
39
- </table>
40
-
41
-
@@ -1,74 +0,0 @@
1
- <h2>Server Connections</h2>
2
-
3
- <p><%= subsystem[:description ]%></p>
4
-
5
- <p><%= current[:monitorCounter] %> current connection/s, <%= total[:monitorCounter] %> since startup.</p>
6
-
7
- <h3>Current Connections</h3>
8
-
9
- <table id="connection-list">
10
- <thead>
11
- <tr>
12
- <th class="odd" rowspan="2">#</th>
13
- <th class="even" rowspan="2">Proto</th>
14
- <th class="odd" colspan="4">Ops</th>
15
- <!-- Ops Exec -->
16
- <!-- Ops Pend -->
17
- <!-- Ops Fin -->
18
- <th class="even" colspan="3">Conn</th>
19
- <!-- Conn Read -->
20
- <!-- Conn Write -->
21
- <th class="odd" rowspan="2">Mask</th>
22
- <th class="even" rowspan="2">Authz DN</th>
23
- <th class="odd" rowspan="2">Sockets</th>
24
- <th class="even" rowspan="2">Age</th>
25
- <th class="odd" rowspan="2">Activity</th>
26
- </tr>
27
- <tr>
28
- <!-- # -->
29
- <!-- Proto -->
30
- <th class="odd">Recd</th><!-- Ops -->
31
- <th class="odd">Exec</th>
32
- <th class="odd">Pend</th>
33
- <th class="odd">Fin</th>
34
- <th class="even">Get</th><!-- Conn -->
35
- <th class="even">Read</th>
36
- <th class="even">Write</th>
37
- <!-- Mask -->
38
- <!-- Authz DN -->
39
- <!-- Sockets -->
40
- <!-- Age -->
41
- <!-- Activity -->
42
- </tr>
43
-
44
- </thead>
45
- <tbody>
46
-
47
- <% connections.each_with_index do |conn, i| %>
48
- <% rowclass = i.divmod(2).last.zero? ? "odd" : "even" %>
49
- <tr class="<%= rowclass %>">
50
- <td class="numeric odd"><%= conn[:monitorConnectionNumber].first %></td>
51
- <td class="numeric even"><%= conn[:monitorConnectionProtocol].first %></td>
52
- <td class="numeric odd"><%= conn[:monitorConnectionOpsReceived].first %></td>
53
- <td class="numeric even"><%= conn[:monitorConnectionOpsExecuting].first %></td>
54
- <td class="numeric odd"><%= conn[:monitorConnectionOpsPending].first %></td>
55
- <td class="numeric even"><%= conn[:monitorConnectionOpsCompleted].first %></td>
56
- <td class="numeric odd"><%= conn[:monitorConnectionGet].first %></td>
57
- <td class="numeric even"><%= conn[:monitorConnectionRead].first %></td>
58
- <td class="numeric odd"><%= conn[:monitorConnectionWrite].first %></td>
59
- <td class="even"><%= conn[:monitorConnectionMask].first %></td>
60
- <td class="odd"><%= conn[:monitorConnectionAuthzDN].first %></td>
61
- <td class="diagram even">
62
- <span class="socket local-socket"><%=
63
- conn[:monitorConnectionLocalAddress].first[/IP=(.*)/, 1] %></span>
64
- &#x2190;&#x2192;
65
- <span class="socket peer-socket"><%=
66
- conn[:monitorConnectionPeerAddress].first[/IP=(.*)/, 1] %></span>
67
- </td>
68
- <td class="time odd"><%= time_delta_string(conn[:monitorConnectionStartTime].first) %></td>
69
- <td class="time even"><%= time_delta_string(conn[:monitorConnectionActivityTime].first) %> ago</td>
70
- </tr>
71
- <% end %>
72
- </tbody>
73
- </table>
74
- </dl>
@@ -1,39 +0,0 @@
1
- <h2>Databases</h2>
2
-
3
- <p><%= subsystem[:description ]%></p>
4
-
5
- <table id="database-list" class="horizontal">
6
- <thead>
7
- <tr>
8
- <th></th>
9
- <th class="even">Shadow?</th>
10
- <th class="odd">URI</th>
11
- <th class="even">See Also</th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <% databases.each_with_index do |database, i| %>
16
- <% rowclass = i.divmod(2).last.zero? ? "even" : "odd" %>
17
- <tr class="<%= rowclass %>">
18
- <th><%= database[:monitoredInfo] %></th>
19
- <td class="even icon">
20
- <% if database[:monitorIsShadow].first == 'TRUE' %>
21
- <img src="/images/tick.png" width="16" height="16" alt="Yes" />
22
- <% else %>
23
- &nbsp;
24
- <% end %>
25
- </td>
26
- <td class="odd list">
27
- <% if database[:labeledURI] %>
28
- <span class="uri"><%= database[:labeledURI].first.gsub(/[^\x20-\x7f]/, '') %></span>
29
- <% end %>
30
- </td>
31
- <td class="even">
32
- <% if database[:seeAlso] %><span class="dn"><%= database[:seeAlso] %></span><% end %>
33
- </td>
34
- </tr>
35
- <% end %>
36
- </tbody>
37
- </table>
38
-
39
-
@@ -1,14 +0,0 @@
1
- <h2>The <%= h subsystem[:cn] %> Subsystem</h2>
2
-
3
- <p><%= subsystem[:description].join(' ') %></p>
4
-
5
- <h3>Subsystem</h3>
6
- <pre><%= subsystem.to_ldif %></pre>
7
-
8
- <h3>Contents</h3>
9
- <dl>
10
- <% contents.each do |branch| %>
11
- <dt><%= branch.dn %></dt>
12
- <dd><pre><%= branch.to_ldif %></pre></dd>
13
- <% end %>
14
- </dl>
@@ -1,14 +0,0 @@
1
- <h2>Monitor Datapoints</h2>
2
-
3
- <p>This server is running: <code><%= server_info %></code>.</p>
4
-
5
- <p>Monitor Subsystems</p>
6
-
7
- <dl>
8
- <% for subsystem in datapoints.sort_by {|b| b[:cn].first } %>
9
- <dt><a href="/<%= subsystem[:cn].first.downcase %>"><%= h subsystem[:cn].first %></a></dt>
10
- <dd><%= h subsystem[:description].join(" ") %></dd>
11
- <% end %>
12
- </dl>
13
-
14
-
@@ -1,35 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
-
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
- <title>LDAP Web Monitor</title>
8
-
9
- <link rel="icon" type="image/png" href="/images/treequel-favicon.png" />
10
-
11
- <link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="master"
12
- charset="utf-8">
13
- </head>
14
- <body>
15
-
16
- <div id="content">
17
- <h1>LDAP Web Monitor</h1>
18
-
19
- <div id="homelink">
20
- <a href="/">&#x2191; Top</a>
21
- </div>
22
-
23
- <%= yield %>
24
-
25
- </div>
26
-
27
- <div id="footer">
28
- <p>
29
- <span class="name">Treequel LDAP Web Monitor</span>
30
- <span class="vcsrev">$rev$</span>
31
- </p>
32
- </div>
33
-
34
- </body>
35
- </html>
@@ -1,30 +0,0 @@
1
- <h2>Listeners</h2>
2
-
3
- <p><%= subsystem[:description ]%></p>
4
-
5
- <table id="listener-list" class="horizontal">
6
- <thead>
7
- <tr>
8
- <th></th>
9
- <th class="odd">URI</th>
10
- <th class="even">Socket</th>
11
- </tr>
12
- </thead>
13
- <tbody>
14
- <% listeners.each_with_index do |listener, i| %>
15
- <% rowclass = i.divmod(2).last.zero? ? "even" : "odd" %>
16
- <tr class="<%= rowclass %>">
17
- <th><%= listener[:monitoredInfo] %></th>
18
- <td class="even icon">
19
- <span class="uri"><%= listener[:labeledURI].first.gsub(/[^\x20-\x7f]/, '') %></span>
20
- </td>
21
- <td class="odd list">
22
- <span class="socket"><%=
23
- listener[:monitorConnectionLocalAddress].first[/IP=(.*)/, 1] %></span>
24
- </td>
25
- </tr>
26
- <% end %>
27
- </tbody>
28
- </table>
29
-
30
-
data/rake/rdoc.rb DELETED
@@ -1,30 +0,0 @@
1
- #
2
- # RDoc Rake tasks
3
-
4
- #
5
-
6
- gem 'rdoc', '>= 2.4.3'
7
-
8
- require 'rubygems'
9
- require 'rdoc/rdoc'
10
- require 'rake/clean'
11
- require 'rdoc/task'
12
-
13
- # Append docs/lib to the load path if it exists for a locally-installed Darkfish
14
- DOCSLIB = DOCSDIR + 'lib'
15
- $LOAD_PATH.unshift( DOCSLIB.to_s ) if DOCSLIB.exist?
16
-
17
- # Make relative string paths of all the stuff we need to generate docs for
18
- DOCFILES = Rake::FileList[ LIB_FILES + EXT_FILES + GEMSPEC.extra_rdoc_files ]
19
-
20
-
21
- directory RDOCDIR.to_s
22
- CLOBBER.include( RDOCDIR )
23
-
24
- desc "Build API documentation in #{RDOCDIR}"
25
- RDoc::Task.new do |task|
26
- task.main = "README"
27
- task.rdoc_files.include( DOCFILES )
28
- task.rdoc_dir = RDOCDIR.to_s
29
- task.options = RDOC_OPTIONS
30
- end
data/rake/win32.rb DELETED
@@ -1,190 +0,0 @@
1
- #
2
- # Win32-specific tasks (cross-compiling, etc.)
3
- #
4
- # Thanks to some people that understand this stuff better than me for
5
- # posting helpful blog posts. This stuff is an amalgam of stuff they did:
6
- #
7
- # * Mauricio Fernandez
8
- # http://eigenclass.org/hiki/cross+compiling+rcovrt
9
- #
10
- # * Jeremy Hinegardner
11
- # http://www.copiousfreetime.org/articles/2008/10/12/building-gems-for-windows.html
12
- #
13
- # * Aaron Patterson
14
- # http://tenderlovemaking.com/2008/11/21/cross-compiling-ruby-gems-for-win32/
15
-
16
- require 'rubygems'
17
- require 'rake'
18
- require 'pathname'
19
- require 'rubygems/platform'
20
- require 'rbconfig'
21
- require 'uri'
22
- require 'net/ftp'
23
-
24
- HOMEDIR = Pathname( '~' ).expand_path
25
- RUBYVERSION = '1.8.6-p287'
26
- RUBYVERSION_MAJORMINOR = RUBYVERSION[/^\d+\.\d+/]
27
-
28
- RUBY_DL_BASE = "ftp://ftp.ruby-lang.org/pub/ruby/#{RUBYVERSION_MAJORMINOR}/"
29
- RUBY_DL_URI = URI( RUBY_DL_BASE + "ruby-#{RUBYVERSION}.tar.gz" )
30
-
31
- XCOMPILER_DIR = HOMEDIR + '.ruby_mingw32'
32
-
33
- XCOMPILER_DL = XCOMPILER_DIR + "ruby-#{RUBYVERSION}.tar.gz"
34
- XCOMPILER_SRC = XCOMPILER_DIR + "ruby-#{RUBYVERSION}"
35
-
36
- XCOMPILER_BIN = XCOMPILER_DIR + 'bin'
37
- XCOMPILER_LIB = XCOMPILER_DIR + 'lib'
38
- XCOMPILER_RUBY = XCOMPILER_BIN + 'ruby.exe'
39
-
40
- XCOMPILER_LOAD_PATH = XCOMPILER_LIB + "ruby/#{RUBYVERSION_MAJORMINOR}/i386-mingw32"
41
-
42
- TAR_OPTS = { :compression => :gzip }
43
-
44
- WIN32_GEMSPEC = GEMSPEC.dup
45
- WIN32_GEMSPEC.files += FileList[ EXTDIR + '**.{dll,so}' ]
46
- WIN32_GEMSPEC.platform = Gem::Platform.new( 'i386-mingw32' )
47
- WIN32_GEMSPEC.extensions = []
48
-
49
-
50
- CONFIGURE_CMD = %W[
51
- env
52
- ac_cv_func_getpgrp_void=no
53
- ac_cv_func_setpgrp_void=yes
54
- rb_cv_negative_time_t=no
55
- ac_cv_func_memcmp_working=yes
56
- rb_cv_binary_elf=no
57
- ./configure
58
- --host=i386-mingw32
59
- --target=i386-mingw32
60
- --build=#{Config::CONFIG['build']}
61
- --prefix=#{XCOMPILER_DIR}
62
- ]
63
-
64
- ### Archive::Tar::Reader#extract (as of 0.9.0) is broken w.r.t.
65
- ### permissions, so we have to do this ourselves.
66
- def untar( tarfile, targetdir )
67
- targetdir = Pathname( targetdir )
68
- raise "No such directory: #{targetdir}" unless targetdir.directory?
69
-
70
- reader = Archive::Tar::Reader.new( tarfile.to_s, TAR_OPTS )
71
-
72
- mkdir_p( targetdir )
73
- reader.each( true ) do |header, body|
74
- path = targetdir + header[:path]
75
- # trace "Header is: %p" % [ header ]
76
-
77
- case header[:type]
78
- when :file
79
- trace " #{path}"
80
- path.open( File::WRONLY|File::EXCL|File::CREAT|File::TRUNC, header[:mode] ) do |fio|
81
- bytesize = header[:size]
82
- fio.write( body[0,bytesize] )
83
- end
84
-
85
- when :directory
86
- trace " #{path}"
87
- path.mkpath
88
-
89
- when :link
90
- linktarget = targetdir + header[:dest]
91
- trace " #{path} => #{linktarget}"
92
- path.make_link( linktarget.to_s )
93
-
94
- when :symlink
95
- linktarget = targetdir + header[:dest]
96
- trace " #{path} -> #{linktarget}"
97
- path.make_symlink( linktarget )
98
- end
99
- end
100
-
101
- end
102
-
103
-
104
- begin
105
- require 'archive/tar'
106
-
107
- namespace :win32 do
108
- directory XCOMPILER_DIR.to_s
109
-
110
- file XCOMPILER_DL => XCOMPILER_DIR do
111
- # openuri can't handle this -- passive ftp required?
112
- # run 'wget', '-O', XCOMPILER_DL, RUBY_DL_URI
113
- log "Downloading ruby distro from %s" % [ RUBY_DL_URI ]
114
- ftp = Net::FTP.new( RUBY_DL_URI.host )
115
- ftp.login
116
- ftp.getbinaryfile( RUBY_DL_URI.path, XCOMPILER_DL, 4096 )
117
- ftp.close
118
- end
119
-
120
- directory XCOMPILER_SRC.to_s
121
- task XCOMPILER_SRC => [ XCOMPILER_DIR, XCOMPILER_DL ] do
122
- if XCOMPILER_SRC.exist?
123
- trace "Rake fails. #{XCOMPILER_SRC} already exists."
124
- else
125
- untar( XCOMPILER_DL, XCOMPILER_DIR )
126
- end
127
- end
128
-
129
- file XCOMPILER_RUBY => XCOMPILER_SRC do
130
- Dir.chdir( XCOMPILER_SRC ) do
131
- unless File.exist?( 'Makefile.in.orig' )
132
- File.open( 'Makefile.in.new', IO::CREAT|IO::WRONLY|IO::EXCL ) do |ofh|
133
- IO.readlines( 'Makefile.in' ).each do |line|
134
- next if line.include?( 0.chr )
135
- trace " copying line: %p" % [ line ]
136
- line.sub!( /ALT_SEPARATOR = ".*?"/, "ALT_SEPARATOR = 92.chr" )
137
- ofh.write( line )
138
- end
139
- end
140
-
141
- mv 'Makefile.in', 'Makefile.in.orig'
142
- mv 'Makefile.in.new', 'Makefile.in'
143
- end
144
-
145
- run *CONFIGURE_CMD
146
- run 'make', 'ruby'
147
- run 'make', 'rubyw.exe'
148
- run 'make', 'install'
149
- end
150
- end
151
-
152
- file XCOMPILER_LOAD_PATH => XCOMPILER_RUBY
153
-
154
- desc "Cross-compile the library for Win32 systems, installing a cross-" +
155
- "compiled Ruby if necessary"
156
- task :build => [ EXTDIR, XCOMPILER_LOAD_PATH.to_s ] do
157
- in_subdirectory( EXTDIR ) do
158
- ruby "-I#{XCOMPILER_LOAD_PATH}", 'extconf.rb'
159
- sh 'make'
160
- end
161
- end
162
-
163
- desc "Build a binary gem for win32 systems"
164
- task :gem => ['win32:build', PKGDIR.to_s] + WIN32_GEMSPEC.files do
165
- when_writing( "Creating win32 GEM" ) do
166
- pkgname = WIN32_GEMSPEC.file_name
167
- builder = Gem::Builder.new( WIN32_GEMSPEC )
168
- builder.build
169
- mv pkgname, PKGDIR + pkgname, :verbose => $trace
170
- end
171
- end
172
- end
173
-
174
- rescue LoadError => err
175
- trace "Couldn't load the win32 tasks: %s: %s" % [ err.class.name, err.message ]
176
-
177
- task :no_win32_build do
178
- abort "No win32 build: %s: %s" % [ err.class.name, err.message ]
179
- end
180
-
181
- namespace :win32 do
182
- desc "Build a binary Gem for Win32 systems, installing a cross " +
183
- "compiled Ruby if necessary"
184
- task :gem => :no_win32_build
185
- task :build => :no_win32_build
186
- end
187
-
188
- end
189
-
190
-