From 917d455857dbeb0aa5002f8b9cbabf2fbbb91e0d Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Sun, 18 Apr 2010 23:33:29 -0400 Subject: [PATCH 01/10] Making 'extra_rdoc_files' more robust. --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index a23c8cc..3af7d85 100644 --- a/Rakefile +++ b/Rakefile @@ -33,7 +33,7 @@ Hoe.spec PKG_NAME do self.changes = paragraphs_of(self.history_file, 0..1).join("\n\n") self.description = paragraphs_of(self.readme_file, 2..2).join("\n\n") - extra_rdoc_files << "Hacking.rdoc" + extra_rdoc_files << MANIFEST.grep(/\.rdoc$/) extra_dev_deps << [ "archive-tar-minitar", "~>0.5.1" ] extra_dev_deps << [ "hanna", "~>0.1.2" ] @@ -121,4 +121,4 @@ task :build_manifest do |t| end desc "Run a full set of integration and unit tests" -task :cruise => [:test, :spec] \ No newline at end of file +task :cruise => [:test, :spec] From 70477ecf2149d1d25d26567d51c4d552686873ea Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Sun, 18 Apr 2010 23:52:48 -0400 Subject: [PATCH 02/10] Removing Hanna RDoc template. I like the Hanna template, but want to look at integrating it again later, especially when the frames can be eliminated. For now, we'll use Darkfish, which I think is very ugly. --- Rakefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Rakefile b/Rakefile index 3af7d85..ca9739a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,4 @@ require "rubygems" -require 'hanna/rdoctask' require 'hoe' $LOAD_PATH.unshift('lib') @@ -36,7 +35,6 @@ Hoe.spec PKG_NAME do extra_rdoc_files << MANIFEST.grep(/\.rdoc$/) extra_dev_deps << [ "archive-tar-minitar", "~>0.5.1" ] - extra_dev_deps << [ "hanna", "~>0.1.2" ] extra_dev_deps << [ "hoe-git", "~>1" ] extra_dev_deps << [ "metaid", "~>1" ] clean_globs << "coverage" From 9fb791a06a2dae82f15af16f629c6ad766cbfb4e Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Mon, 19 Apr 2010 01:03:52 -0400 Subject: [PATCH 03/10] Documentation preparation for version 0.2 release. --- Hacking.rdoc | 69 ++++++++++++++++++++++++++++++++++++++--------- History.txt | 6 +++-- README.txt | 76 ++++++++++++++++++++++++++++------------------------ Rakefile | 1 + 4 files changed, 102 insertions(+), 50 deletions(-) diff --git a/Hacking.rdoc b/Hacking.rdoc index d17f1ca..736b32b 100644 --- a/Hacking.rdoc +++ b/Hacking.rdoc @@ -1,16 +1,59 @@ = Hacking Net::LDAP -We welcome your contributions to Net::LDAP. To increase the chances of your -patches being accepted, we recommend that you follow the guidelines below: +We welcome your contributions to Net::LDAP. We accept most contributions, but +there are ways to increase the chance of your patch being accepted quickly. -1. Your code should be formatted like the rest of Net::LDAP. We use a text - wrap of 76 - 78 characters, especially for documentation contents. - Operators should have spaces around them, method definitions should have - parentheses around arguments. Keep the indentation as flat as possible. -2. Your changes should be well-documented and described. -3. You must provide rspec tests for any new or changed features. Rspec has - been chosen as the way forward for tests. -4. You should provide LDIF data for importing into LDAP servers so that the - changes can be tested in situ with more than one real LDAP - server. -5. You should have tested your changes against a real LDAP server. +== Licensing + +Net::LDAP 0.3 and later will be licensed under an MIT-style license; any +contributions after 2010-04-20 must be under this license to be accepted. + +== Formatting + +* Your patches should be formatted like the rest of Net::LDAP. +* We use a text wrap of 76–78 characters, especially for documentation + contents. +* Operators should have spaces around them. +* Method definitions should have parentheses around arguments (and no + parentheses if there are no arguments). +* Indentation should be kept as flat as possible; this may mean being more + explicit with constants. + +== Documentation + +* Documentation: net-ldap[http://net-ldap.rubyforge.org/] + +It is very important that, if you add new methods or objects, your code is +well-documented. The purpose of the changes should be clearly described so that +even if this is a feature we do not use, we can understand its purpose. + +We also encourage documentation-only contributions that improve the +documentation of Net::LDAP. + +== Tests + +The Net::LDAP team uses RSpec for unit testing; all changes must have rspec +tests for any new or changed features. + +Your changes should have been tested against at least one real LDAP server; the +current tests are not sufficient to find all possible bugs. It's unlikely that +they will ever be sufficient given the variations in LDAP server behaviour. + +If you're introducing a new feature, it would be useful to provide LDIF data +for importing into LDAP servers for testing. + +== Development Dependencies + +Net::LDAP uses several libraries during development, all of which can be +installed using RubyGems. + +* *hoe* +* *hoe-git* +* *archive-tar-minitar* +* *metaid* + +== Participation + +* RubyForge: net-ldap[http://rubyforge.org/projects/net-ldap] +* GitHub: RoryO/ruby-net-ldap[http://github.com/RoryO/ruby-net-ldap/] +* Group: ruby-ldap[http://groups.google.com/group/ruby-ldap] diff --git a/History.txt b/History.txt index b066a73..9bfdbdb 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,6 @@ -=== Net::LDAP NEXT / 2010-__-__ +=== Net::LDAP 0.2 / 2010-04-__ +* Added a document describing how to contribute to Net::LDAP most effectively. +* Preparing for a license change for Net::LDAP in the next release. * SSL capabilities will be enabled or disabled based on whether we can load OpenSSL successfully or not. * Moved the core class extensions extensions from being in the Net::LDAP @@ -38,7 +40,7 @@ === Net::LDAP 0.1.1 / 2010-03-18 * Fixing a critical problem with sockets. -=== Net::LDAP 0.1.0 / 2010-03-17 +=== Net::LDAP 0.1 / 2010-03-17 * Small fixes throughout, more to come. * Ruby 1.9 support added. * Ruby 1.8.6 and below support removed. If we can figure out a compatible way diff --git a/README.txt b/README.txt index c598633..b6ff0aa 100644 --- a/README.txt +++ b/README.txt @@ -2,48 +2,54 @@ == Description -Pure Ruby LDAP library. +Net::LDAP for Ruby (also called "net-ldap") is a pure-Ruby LDAP support +library that has been tested against several modern servers, including +OpenLDAP and Active Directory. It supports most LDAP client features and +a subset of server features. + +LDAP (Lightweight Directory Access Protocol) is an Internet protocol for +accessing distributed directory services. LDAP is often used to provide +access and authentication to networked services. + +The current release is mostly compliant with RFCs 2251–2256, 2829–2830, +3377, and 3771. Our roadmap for Net::LDAP 1.0 is to gain full +client compliance with the most recent IETF LDAP RFCs +(4510–4519, plus portions of 4520–4532). + +=== Notice of Impending License Change + +In the next release of Net::LDAP (0.3), we will be changing the license +to an MIT-style license. == Where -=== Issues & Project Homepage +* RubyForge: net-ldap[http://rubyforge.org/projects/net-ldap] +* GitHub: RoryO/ruby-net-ldap[http://github.com/RoryO/ruby-net-ldap/] +* Group: ruby-ldap[http://groups.google.com/group/ruby-ldap] +* Documentation: net-ldap[http://net-ldap.rubyforge.org/] -http://rubyforge.org/projects/net-ldap - -=== Code - -http://github.com/RoryO/ruby-net-ldap/ - -== FEATURES/PROBLEMS - -The Lightweight Directory Access Protocol (LDAP) is an Internet protocol for -accessing distributed directory services. - -Net::LDAP is an LDAP support library written in pure Ruby. It supports most -LDAP client features and a subset of server features as well. - -* Standards-based (going for RFC 4511) -* Portable: 100% Ruby - -== SYNOPSIS - -See Net::LDAP for documentation and usage samples. - -== REQUIREMENTS +== Requirements Net::LDAP requires Ruby 1.8.7-compliant interpreter or better. -== INSTALL +== Install + +Net::LDAP is a pure Ruby library. It does not require any external +compiled libraries. -Net::LDAP is a pure Ruby library. It does not require any external libraries. You can install the RubyGems version of Net::LDAP available from the usual sources. -* gem install net-ldap + gem install net-ldap -Simply require 'net/ldap'. +Simply require either 'net-ldap' or 'net/ldap'. -== CREDITS +For non-RubyGems installations of Net::LDAP, you can use Minero Aoki's +{setup.rb}[http://i.loveruby.net/en/projects/setup/] as the layout of +Net::LDAP is compliant. The setup installer is not included in the +Net::LDAP repository. + +== Credits Net::LDAP was originally developed by: @@ -58,13 +64,13 @@ Contributions since: * Dimitrij Denissenko dimdenis@rubyforge.org * "nowhereman" on GitHub -== LICENSE +== License Copyright (C) 2006 - 2010 by Francis Cianfrocca and other contributors. -Please read the file LICENSE for licensing restrictions on this library. In -the simplest terms, this library is available under the same terms as Ruby -itself. +Please read the file LICENSE for licensing restrictions on this library. +In the simplest terms, this library is available under the same terms as +Ruby itself. -Available under the same terms as Ruby. See LICENSE in the main distribution -for full licensing information. +Available under the same terms as Ruby. See LICENSE in the main +distribution for full licensing information. diff --git a/Rakefile b/Rakefile index ca9739a..137e716 100644 --- a/Rakefile +++ b/Rakefile @@ -33,6 +33,7 @@ Hoe.spec PKG_NAME do self.description = paragraphs_of(self.readme_file, 2..2).join("\n\n") extra_rdoc_files << MANIFEST.grep(/\.rdoc$/) + extra_rdoc_files.flatten! extra_dev_deps << [ "archive-tar-minitar", "~>0.5.1" ] extra_dev_deps << [ "hoe-git", "~>1" ] From 64bcdd09125049a154c34e5668ec63ac4fac3c3f Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Mon, 19 Apr 2010 01:36:54 -0400 Subject: [PATCH 04/10] Removing a stub file, lib/net/ldif.rb. There is no value provided by this stub. --- Manifest.txt | 4 +--- lib/net/ldif.rb | 34 ---------------------------------- test/test_ldif.rb | 1 - 3 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 lib/net/ldif.rb diff --git a/Manifest.txt b/Manifest.txt index 8ce0ded..e29685b 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -19,9 +19,8 @@ lib/net/ldap.rb lib/net/ldap/dataset.rb lib/net/ldap/entry.rb lib/net/ldap/filter.rb +lib/net/ldap/password.rb lib/net/ldap/pdu.rb -lib/net/ldap/psw.rb -lib/net/ldif.rb lib/net/snmp.rb spec/integration/ssl_ber_spec.rb spec/spec.opts @@ -32,7 +31,6 @@ spec/unit/ldap/entry_spec.rb spec/unit/ldap/filter_spec.rb spec/unit/ldap_spec.rb test/common.rb -test/test_ber.rb test/test_entry.rb test/test_filter.rb test/test_ldif.rb diff --git a/lib/net/ldif.rb b/lib/net/ldif.rb deleted file mode 100644 index a7b8db2..0000000 --- a/lib/net/ldif.rb +++ /dev/null @@ -1,34 +0,0 @@ -# $Id$ -# -# Net::LDIF for Ruby -# -# -# -# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# - -# THIS FILE IS A STUB. - -module Net - class LDIF - end -end - - diff --git a/test/test_ldif.rb b/test/test_ldif.rb index c04e1e9..77f8b86 100644 --- a/test/test_ldif.rb +++ b/test/test_ldif.rb @@ -2,7 +2,6 @@ require 'common' -require 'net/ldif' require 'digest/sha1' require 'base64' From b4c2bfe0f92b1695b7bf40d45c1724c278b463f1 Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Mon, 19 Apr 2010 01:52:57 -0400 Subject: [PATCH 05/10] Cleaning up the Net::BER core extension docs. --- lib/net/ber/core_ext.rb | 51 +++++++++++------------------ lib/net/ber/core_ext/array.rb | 2 ++ lib/net/ber/core_ext/bignum.rb | 2 ++ lib/net/ber/core_ext/false_class.rb | 2 ++ lib/net/ber/core_ext/fixnum.rb | 2 ++ lib/net/ber/core_ext/string.rb | 2 ++ lib/net/ber/core_ext/true_class.rb | 2 ++ 7 files changed, 32 insertions(+), 31 deletions(-) diff --git a/lib/net/ber/core_ext.rb b/lib/net/ber/core_ext.rb index 94da38e..6acc35f 100644 --- a/lib/net/ber/core_ext.rb +++ b/lib/net/ber/core_ext.rb @@ -1,29 +1,5 @@ -# NET::BER -# Mixes ASN.1/BER convenience methods into several standard classes. Also -# provides BER parsing functionality. -# -#-- -# Copyright (C) 2006 by Francis Cianfrocca and other contributors. All -# Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#++ - require 'net/ber/ber_parser' +# :stopdoc: class IO include Net::BER::BERParser end @@ -37,36 +13,49 @@ if defined? ::OpenSSL include Net::BER::BERParser end end +# :startdoc: -module Net::BER::Extensions; end +module Net::BER::Extensions # :nodoc: +end require 'net/ber/core_ext/string' +# :stopdoc: class String include Net::BER::BERParser include Net::BER::Extensions::String end require 'net/ber/core_ext/array' -class Array +# :stopdoc: +class Array include Net::BER::Extensions::Array end +# :startdoc: require 'net/ber/core_ext/bignum' -class Bignum +# :stopdoc: +class Bignum include Net::BER::Extensions::Bignum end +# :startdoc: require 'net/ber/core_ext/fixnum' -class Fixnum +# :stopdoc: +class Fixnum include Net::BER::Extensions::Fixnum end +# :startdoc: require 'net/ber/core_ext/true_class' -class TrueClass +# :stopdoc: +class TrueClass include Net::BER::Extensions::TrueClass end +# :startdoc: require 'net/ber/core_ext/false_class' -class FalseClass +# :stopdoc: +class FalseClass include Net::BER::Extensions::FalseClass end +# :startdoc: diff --git a/lib/net/ber/core_ext/array.rb b/lib/net/ber/core_ext/array.rb index 4696a5a..fef386b 100644 --- a/lib/net/ber/core_ext/array.rb +++ b/lib/net/ber/core_ext/array.rb @@ -1,3 +1,5 @@ +## +# BER extensions to the Array class. module Net::BER::Extensions::Array ## # Converts an Array to a BER sequence. All values in the Array are diff --git a/lib/net/ber/core_ext/bignum.rb b/lib/net/ber/core_ext/bignum.rb index b1d9a6f..c2a0f03 100644 --- a/lib/net/ber/core_ext/bignum.rb +++ b/lib/net/ber/core_ext/bignum.rb @@ -1,3 +1,5 @@ +## +# BER extensions to the Bignum class. module Net::BER::Extensions::Bignum ## # Converts a Bignum to an uncompressed BER integer. diff --git a/lib/net/ber/core_ext/false_class.rb b/lib/net/ber/core_ext/false_class.rb index bdbbca9..2de15dc 100644 --- a/lib/net/ber/core_ext/false_class.rb +++ b/lib/net/ber/core_ext/false_class.rb @@ -1,3 +1,5 @@ +## +# BER extensions to +false+. module Net::BER::Extensions::FalseClass ## # Converts +false+ to the BER wireline representation of +false+. diff --git a/lib/net/ber/core_ext/fixnum.rb b/lib/net/ber/core_ext/fixnum.rb index 5d16354..7409ed1 100644 --- a/lib/net/ber/core_ext/fixnum.rb +++ b/lib/net/ber/core_ext/fixnum.rb @@ -1,3 +1,5 @@ +## +# Ber extensions to the Fixnum class. module Net::BER::Extensions::Fixnum ## # Converts the fixnum to BER format. diff --git a/lib/net/ber/core_ext/string.rb b/lib/net/ber/core_ext/string.rb index c0c42c5..1835d9f 100644 --- a/lib/net/ber/core_ext/string.rb +++ b/lib/net/ber/core_ext/string.rb @@ -1,5 +1,7 @@ require 'stringio' +## +# BER extensions to the String class. module Net::BER::Extensions::String ## # Converts a string to a BER string. Universal octet-strings are tagged diff --git a/lib/net/ber/core_ext/true_class.rb b/lib/net/ber/core_ext/true_class.rb index 16ef9da..53975b1 100644 --- a/lib/net/ber/core_ext/true_class.rb +++ b/lib/net/ber/core_ext/true_class.rb @@ -1,3 +1,5 @@ +## +# BER extensions to +true+. module Net::BER::Extensions::TrueClass ## # Converts +true+ to the BER wireline representation of +true+. From 42100871c53622735706ff6dbd9e553d22c0048b Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Mon, 19 Apr 2010 01:53:39 -0400 Subject: [PATCH 06/10] Cleaning up the Net::BER documentation. --- lib/net/ber.rb | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/lib/net/ber.rb b/lib/net/ber.rb index cc4ec74..b4cdad9 100644 --- a/lib/net/ber.rb +++ b/lib/net/ber.rb @@ -1,28 +1,4 @@ -# NET::BER -# Mixes ASN.1/BER convenience methods into several standard classes. Also -# provides BER parsing functionality. -# -#-- -# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#++ - -module Net +module Net # :nodoc: ## # == Basic Encoding Rules (BER) Support Module # @@ -129,7 +105,7 @@ module Net # BMPStringC30: 62 (0x3e, 0b00111110) # module BER - VERSION = '0.1.0' + VERSION = '0.2' ## # Used for BER-encoding the length and content bytes of a Fixnum integer From 5f5031b853051033e5ad45ca0517f14f8cb99242 Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Mon, 19 Apr 2010 01:54:07 -0400 Subject: [PATCH 07/10] Suppressing the Net::SNMP documentation. --- lib/net/snmp.rb | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/lib/net/snmp.rb b/lib/net/snmp.rb index 9184adc..650de4a 100644 --- a/lib/net/snmp.rb +++ b/lib/net/snmp.rb @@ -1,33 +1,5 @@ -# $Id$ -# -# NET::SNMP -# -#---------------------------------------------------------------------------- -# -# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -#--------------------------------------------------------------------------- -# -# - +# :stopdoc: module Net - class SNMP VERSION = '0.1.0' @@ -292,4 +264,4 @@ module Net end end - +# :startdoc: From 59dac76d4742c2deadad0aa0e473e8f6e4e54af1 Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Mon, 19 Apr 2010 01:54:25 -0400 Subject: [PATCH 08/10] Cleaning up Net::LDAP documentation. --- lib/net/ldap.rb | 16 ++-- lib/net/ldap/dataset.rb | 169 +++++++++++++++++---------------------- lib/net/ldap/entry.rb | 24 ------ lib/net/ldap/filter.rb | 22 ----- lib/net/ldap/password.rb | 22 ----- lib/net/ldap/pdu.rb | 28 +------ 6 files changed, 81 insertions(+), 200 deletions(-) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index 8896d28..9454ac6 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -1,12 +1,16 @@ require 'ostruct' -module Net +module Net # :nodoc: class LDAP begin require 'openssl' + ## + # Set to +true+ if OpenSSL is available and LDAPS is supported. HasOpenSSL = true rescue LoadError + # :stopdoc: HasOpenSSL = false + # :startdoc: end end end @@ -19,16 +23,6 @@ require 'net/ldap/dataset' require 'net/ldap/password' require 'net/ldap/entry' -# == Net::LDAP -# -# This library provides a pure-Ruby implementation of the LDAP client -# protocol, per RFC-2251. It can be used to access any server which -# implements the LDAP protocol. -# -# Net::LDAP is intended to provide full LDAP functionality while hiding the -# more arcane aspects the LDAP protocol itself, and thus presenting as -# Ruby-like a programming interface as possible. -# # == Quick-start for the Impatient # === Quick Example of a user-authentication against an LDAP directory: # diff --git a/lib/net/ldap/dataset.rb b/lib/net/ldap/dataset.rb index 342c2e4..8adcf30 100644 --- a/lib/net/ldap/dataset.rb +++ b/lib/net/ldap/dataset.rb @@ -1,25 +1,3 @@ -#---------------------------------------------------------------------------- -# -# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -#--------------------------------------------------------------------------- - ## # An LDAP Dataset. Used primarily as an intermediate format for converting # to and from LDIF strings and Net::LDAP::Entry objects. @@ -28,78 +6,7 @@ class Net::LDAP::Dataset < Hash # Dataset object comments. attr_reader :comments - class << self - class ChompedIO #:nodoc: - def initialize(io) - @io = io - end - def gets - s = @io.gets - s.chomp if s - end - end - - ## - # Reads an object that returns data line-wise (using #gets) and parses - # LDIF data into a Dataset object. - def read_ldif(io) #:yields: entry-type, value Used mostly for debugging. - ds = Net::LDAP::Dataset.new - io = ChompedIO.new(io) - - line = io.gets - dn = nil - - while line - new_line = io.gets - - if new_line =~ /^[\s]+/ - line << " " << $' - else - nextline = new_line - - if line =~ /^#/ - ds.comments << line - yield :comment, line if block_given? - elsif line =~ /^dn:[\s]*/i - dn = $' - ds[dn] = Hash.new { |k,v| k[v] = [] } - yield :dn, dn if block_given? - elsif line.empty? - dn = nil - yield :end, nil if block_given? - elsif line =~ /^([^:]+):([\:]?)[\s]*/ - # $1 is the attribute name - # $2 is a colon iff the attr-value is base-64 encoded - # $' is the attr-value - # Avoid the Base64 class because not all Ruby versions have it. - attrvalue = ($2 == ":") ? $'.unpack('m').shift : $' - ds[dn][$1.downcase.to_sym] << attrvalue - yield :attr, [$1.downcase.to_sym, attrvalue] if block_given? - end - - line = nextline - end - end - - ds - end - - ## - # Creates a Dataset object from an Entry object. Used mostly to assist - # with the conversion of - def from_entry(entry) - dataset = Net::LDAP::Dataset.new - hash = { } - entry.each_attribute do |attribute, value| - next if attribute == :dn - hash[attribute] = value - end - dataset[entry.dn] = hash - dataset - end - end - - def initialize(*args, &block) #:nodoc: + def initialize(*args, &block) # :nodoc: super @comments = [] end @@ -152,6 +59,7 @@ class Net::LDAP::Dataset < Hash ary end + ## # This is an internal convenience method to determine if a value requires # base64-encoding before conversion to LDIF output. The standard approach # in most LDAP tools is to check whether the value is a password, or if @@ -162,13 +70,84 @@ class Net::LDAP::Dataset < Hash # why we handle the simplest cases first. Ideally, we would also test the # first/last byte, but it's a bit harder to do this in a way that's # compatible with both 1.8.6 and 1.8.7. - def value_is_binary?(value) + def value_is_binary?(value) # :nodoc: value = value.to_s return true if value[0] == ?: or value[0] == ?< value.each_byte { |byte| return true if (byte < 32) || (byte > 126) } false end private :value_is_binary? + + class << self + class ChompedIO # :nodoc: + def initialize(io) + @io = io + end + def gets + s = @io.gets + s.chomp if s + end + end + + ## + # Creates a Dataset object from an Entry object. Used mostly to assist + # with the conversion of + def from_entry(entry) + dataset = Net::LDAP::Dataset.new + hash = { } + entry.each_attribute do |attribute, value| + next if attribute == :dn + hash[attribute] = value + end + dataset[entry.dn] = hash + dataset + end + + ## + # Reads an object that returns data line-wise (using #gets) and parses + # LDIF data into a Dataset object. + def read_ldif(io) + ds = Net::LDAP::Dataset.new + io = ChompedIO.new(io) + + line = io.gets + dn = nil + + while line + new_line = io.gets + + if new_line =~ /^[\s]+/ + line << " " << $' + else + nextline = new_line + + if line =~ /^#/ + ds.comments << line + yield :comment, line if block_given? + elsif line =~ /^dn:[\s]*/i + dn = $' + ds[dn] = Hash.new { |k,v| k[v] = [] } + yield :dn, dn if block_given? + elsif line.empty? + dn = nil + yield :end, nil if block_given? + elsif line =~ /^([^:]+):([\:]?)[\s]*/ + # $1 is the attribute name + # $2 is a colon iff the attr-value is base-64 encoded + # $' is the attr-value + # Avoid the Base64 class because not all Ruby versions have it. + attrvalue = ($2 == ":") ? $'.unpack('m').shift : $' + ds[dn][$1.downcase.to_sym] << attrvalue + yield :attr, [$1.downcase.to_sym, attrvalue] if block_given? + end + + line = nextline + end + end + + ds + end + end end require 'net/ldap/entry' unless defined? Net::LDAP::Entry diff --git a/lib/net/ldap/entry.rb b/lib/net/ldap/entry.rb index 539ba0f..003d022 100644 --- a/lib/net/ldap/entry.rb +++ b/lib/net/ldap/entry.rb @@ -1,27 +1,3 @@ -# LDAP Entry (search-result) support classes -# -#---------------------------------------------------------------------------- -# -# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -#--------------------------------------------------------------------------- - ## # Objects of this class represent individual entries in an LDAP directory. # User code generally does not instantiate this class. Net::LDAP#search diff --git a/lib/net/ldap/filter.rb b/lib/net/ldap/filter.rb index fd50cf0..f30f9be 100644 --- a/lib/net/ldap/filter.rb +++ b/lib/net/ldap/filter.rb @@ -1,25 +1,3 @@ -# Copyright (C) 2006 by Francis Cianfrocca and other contributors. All -# Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to: -# Free Software Foundation, Inc. -# 51 Franklin St, Fifth Floor -# Boston, MA 02110-1301 -# USA - ## # Class Net::LDAP::Filter is used to constrain LDAP searches. An object of # this class is passed to Net::LDAP#search in the parameter :filter. diff --git a/lib/net/ldap/password.rb b/lib/net/ldap/password.rb index c21c52d..8d8ba05 100644 --- a/lib/net/ldap/password.rb +++ b/lib/net/ldap/password.rb @@ -1,25 +1,3 @@ -#---------------------------------------------------------------------------- -# -# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -#--------------------------------------------------------------------------- - require 'digest/sha1' require 'digest/md5' diff --git a/lib/net/ldap/pdu.rb b/lib/net/ldap/pdu.rb index fc94025..6da9863 100644 --- a/lib/net/ldap/pdu.rb +++ b/lib/net/ldap/pdu.rb @@ -1,27 +1,3 @@ -# LDAP PDU support classes -# -#---------------------------------------------------------------------------- -# -# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved. -# -# Gmail: garbagecat10 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -#--------------------------------------------------------------------------- - require 'ostruct' ## @@ -261,7 +237,8 @@ end module Net ## - # Handle the renamed constants. + # Handle renamed constants Net::LdapPdu (Net::LDAP::PDU) and + # Net::LdapPduError (Net::LDAP::PDU::Error). def self.const_missing(name) #:nodoc: case name.to_s when "LdapPdu" @@ -275,4 +252,3 @@ module Net end end end # module Net - From 054ead158dc0d2cf92b1125426293c7374f84d0e Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Mon, 19 Apr 2010 01:57:13 -0400 Subject: [PATCH 09/10] Bumping the version for release. --- lib/net/ldap.rb | 2 +- lib/net/snmp.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index 9454ac6..197b496 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -240,7 +240,7 @@ require 'net/ldap/entry' # and then keeps it open while it executes a user-supplied block. # Net::LDAP#open closes the connection on completion of the block. class Net::LDAP - VERSION = "0.1.1" + VERSION = "0.2" class LdapError < StandardError; end diff --git a/lib/net/snmp.rb b/lib/net/snmp.rb index 650de4a..afa9a7d 100644 --- a/lib/net/snmp.rb +++ b/lib/net/snmp.rb @@ -1,7 +1,7 @@ # :stopdoc: module Net class SNMP - VERSION = '0.1.0' + VERSION = '0.2' AsnSyntax = Net::BER.compile_syntax({ :application => { From 40f75e592f67d00d9ba5dfef816389849ba24881 Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Mon, 19 Apr 2010 02:03:28 -0400 Subject: [PATCH 10/10] Updating History.txt. --- History.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/History.txt b/History.txt index 9bfdbdb..c18649d 100644 --- a/History.txt +++ b/History.txt @@ -24,8 +24,15 @@ "(cn:caseExactMatch:=Fred Flintstone)"); provided by "nowhereman". * Added or revised documentation: * Core class extension methods under Net::BER. + * Extensive changes to Net::BER documentation. + * Cleaned up some rdoc oddities, suppressed empty documentation sections + where possible. + * Adding a Hacking document. * Extended unit testing: * Added some unit tests for the BER core extensions. + * The LDIF test data file was split for Ruby 1.9.1 regexp support. + * Added a cruisecontrol.rb task. + * Converted some test/unit tests to specs. * Code clean-up: * Made the formatting of code consistent across all files. * Removed Net::BER::BERParser::TagClasses as it does not appear to be used. @@ -36,6 +43,9 @@ Pdu#result. This may be changed in Net::LDAP 1.0 to return the full Pdu#result, but if we do so, it will be that way for all LDAP calls involving Pdu objects. + * Renamed Net::LDAP::Psw to Net::LDAP::Password with a corresponding filename + change. + * Removed the stub file lib/net/ldif.rb and class Net::LDIF. === Net::LDAP 0.1.1 / 2010-03-18 * Fixing a critical problem with sockets.