ruby-ldap/ruby-net-ldap — pull request #131 by mtodd (2014-10-15 23:40:39+00:00)
Title: Parse Net::LDAP::PDU when calling Net::LDAP::Connection#read, instrument PDU parsing

This PR reduces the duplication by moving the PDU parsing into the `Net::LDAP::Connection#read` method and instruments PDU parsing to give more visibility into the messages being sent from the server.

Should not result in any behavior change.

I believe this is along similar lines to #116, though not exactly the same.

For what it's worth, I looked at instrumenting the `Net::LDAP::PDU.new` method from the inside but there's no reference to the `instrumentation_service` object to service the instrumentation events (and I didn't want to go the route of a global default handler). This seemed like a good balance and a needed refactoring anyway.

Still to do:

- [ ] unit tests
- [ ] integration tests (optional)
- [ ] cleanup/refactoring of `Net::LDAP::Connection#read` callsites

Many of the `read` callsites look like this:
``` ruby
(pdu = read) or raise Net::LDAP::LdapError, "no bind result"
```

This should be cleaned up, and this PR is a good opportunity to do so.

cc @jch @schaary