Skip to content

Commit

Permalink
Make compatible with Ruby 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdavidhamilton committed Feb 23, 2021
1 parent b4df93f commit 08b6a46
Show file tree
Hide file tree
Showing 27 changed files with 224 additions and 108 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
inherit_from: .rubocop_todo.yml
require: rubocop-performance
require: rubocop-rake
require: rubocop-rspec

AllCops:
Include:
- Rakefile
- lib/rom/**/*.rb
- rakelib/*.rake
Exclude:
- '**/.*'
- doc/**/*
Expand Down
143 changes: 102 additions & 41 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-03-08 15:34:14 +0000 using RuboCop version 0.80.1.
# on 2021-02-23 11:22:34 UTC using RuboCop version 1.10.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -20,18 +20,33 @@ Layout/HashAlignment:
- 'lib/rom/ldap/schema/type_builder.rb'

# Offense count: 1
Lint/MissingSuper:
Exclude:
- 'lib/rom/ldap/transaction.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowedMethods.
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
Lint/RedundantSafeNavigation:
Exclude:
- 'lib/rom/ldap/pdu.rb'

# Offense count: 1
# Cop supports --auto-correct.
Lint/SafeNavigationWithEmpty:
Exclude:
- 'lib/rom/ldap/client/operations.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/rom/ldap/restriction_dsl.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
Expand All @@ -42,71 +57,78 @@ Lint/UselessAssignment:
Exclude:
- 'bin/console'

# Offense count: 14
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowComments.
Lint/UselessMethodDefinition:
Exclude:
- 'lib/rom/ldap/associations/one_to_one.rb'

# Offense count: 13
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 48

# Offense count: 2
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 44
Max: 30

# Offense count: 3
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 119

# Offense count: 6
# Offense count: 7
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 13
Max: 17

# Offense count: 17
# Configuration parameters: CountComments, ExcludedMethods.
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 43
Max: 44

# Offense count: 3
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 121
Max: 122

# Offense count: 3
# Offense count: 4
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 11
Max: 16

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/rom-ldap.rb'
- 'examples/Rakefile'

# Offense count: 13
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'lib/rom/ldap/client/operations.rb'
- 'lib/rom/ldap/directory/operations.rb'
- 'lib/rom/ldap/relation/reading.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle.
# SupportedStyles: inline, group
Style/AccessModifierDeclarations:
Exclude:
- 'lib/rom/ldap/extensions/rails_log_subscriber.rb'
- 'lib/rom/ldap/transaction.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'lib/rom/ldap/parsers/attribute.rb'
- 'lib/rom/ldap/schema/type_builder.rb'

# Offense count: 2
# Configuration parameters: .
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
EnforcedStyle: unannotated

# Offense count: 1
# Cop supports --auto-correct.
Style/GlobalStdStream:
Exclude:
- 'lib/rom/ldap/gateway.rb'

# Offense count: 3
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Expand All @@ -115,6 +137,12 @@ Style/GuardClause:
- 'lib/rom/ldap/parsers/filter_syntax.rb'
- 'lib/rom/ldap/socket.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/KeywordParametersOrder:
Exclude:
- 'lib/rom/ldap/client/operations.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand All @@ -124,11 +152,6 @@ Style/Lambda:
- 'lib/rom/ldap/plugin/pagination.rb'
- 'lib/rom/ldap/schema/inferrer.rb'

# Offense count: 1
Style/MethodMissingSuper:
Exclude:
- 'lib/rom/ldap/restriction_dsl.rb'

# Offense count: 1
Style/MissingRespondToMissing:
Exclude:
Expand All @@ -142,6 +165,22 @@ Style/Next:
Exclude:
- 'lib/rom/ldap/client/operations.rb'


# Offense count: 3
# Cop supports --auto-correct.
Style/RedundantRegexpCharacterClass:
Exclude:
- 'lib/rom/ldap/constants.rb'
- 'lib/rom/ldap/parsers/filter_syntax.rb'

# Offense count: 4
# Cop supports --auto-correct.
Style/RedundantRegexpEscape:
Exclude:
- 'lib/rom/ldap/constants.rb'
- 'lib/rom/ldap/parsers/attribute.rb'
- 'lib/rom/ldap/parsers/filter_syntax.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand All @@ -150,7 +189,29 @@ Style/RescueStandardError:
Exclude:
- 'lib/rom/ldap/socket.rb'

# Offense count: 155
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'lib/rom/ldap/directory/env.rb'

# Offense count: 3
# Cop supports --auto-correct.
Style/SlicingWithRange:
Exclude:
- 'lib/rom/ldap/directory/operations.rb'
- 'lib/rom/ldap/directory/password.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/StringConcatenation:
Exclude:
- 'lib/rom/ldap/constants.rb'
- 'lib/rom/ldap/dataset/dsl.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Expand Down
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
## unreleased

<!-- TODO -->
[Compare v0.2.1...master](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.2.1...master)
[Compare v0.2.3...master](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.2.3...master)

# 0.2.3 / 2021-02-xx

### Fixed

- Compatibility with pre-release ROM 6.0 and Ruby 3.0

[Compare v0.2.2...v0.2.3](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.2.2...0.2.3)

# 0.2.2 / 2021-02-21

### Changed

- CI/CD pipeline was failing because OpenDJ service requires more memory than the shared runners provide.
- Yanked 0.2.1 to edit the gem description and credit Net::LDAP team for their part in this gem.

[Compare v0.2.1...v0.2.2](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.2.1...0.2.2)

# 0.2.1 / 2021-02-19

Expand Down
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ source 'https://rubygems.org'

gemspec

gem 'rom', git: 'https://github.com/rom-rb/rom.git', branch: 'master'

group :development do
gem 'awesome_print'
gem 'pry', platforms: %i[jruby rbx]
gem 'pry-byebug', platforms: :mri
gem 'yard-junk'
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'yard-junk'

# WIP
gem 'dry-monitor' # @see bin/console
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This gem makes it easier to use LDAP in your project or even as your primary dat

## Requirements

[ROM-LDAP][rom-ldap] is compatible with versions of [Ruby][ruby] from 2.4 to 2.7.
[ROM-LDAP][rom-ldap] is compatible with versions of [Ruby][ruby] 2.4 and above.



Expand Down
12 changes: 8 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
Simple rudimentary RDMS.
<https://www.openldap.org/doc/admin24/intro.html#LDAP%20vs%20RDBMS>

7. Directory instrumentation using dry-monitor to replace debug logging.
7. **Logging**
Directory instrumentation using dry-monitor to replace debug logging.

8. `rom/devtools` integration.
8. **ROM-RB**
Keep pace with other rom-rb improvements like `rom/devtools` integration.

9. **CI/CD**
Speed up testing by only using OpenLDAP, with other vendors as optional extras (including Microsoft AD LDS).

## ONGOING

- Improve Rspec coverage, currently 90% complete @ v0.1.0
- Improve Yard docs, currently 72% complete @ v0.1.0
- Improve Rspec coverage, currently 90% complete @ v0.2.3
- Improve Yard docs, currently 76% complete @ v0.2.3
- Ensure Rubocop style compliance
2 changes: 1 addition & 1 deletion bin/benchmark
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# Comparison of rom-ldap against ruby-net-ldap
#
Expand All @@ -23,7 +24,6 @@ ENV['LDAPBINDPW'] = 'topsecret'
# ENV['LDAPBINDDN'] = 'uid=admin,ou=system'
# ENV['LDAPBINDPW'] = 'secret'


net_ldap = Net::LDAP.new(
host: ENV['LDAPHOST'],
port: ENV['LDAPPORT'],
Expand Down
21 changes: 2 additions & 19 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# Pry console for testing
#
Expand All @@ -11,25 +12,7 @@ require 'rom-ldap'
require 'rom-repository'
require 'rom-changeset'


config = ROM::Configuration.new(:ldap, nil, extensions: %i[compatibility])

require 'dry/monitor/notifications'
notifications = Dry::Monitor::Notifications.new(:console)

config.plugin :ldap, relations: :instrumentation do |c|
c.notifications = notifications
end

require 'dry/monitor/ldap/logger'
# Dry::Monitor::LDAP::Logger.new(Logger.new($stdout)).subscribe(notifications)
monitor = Dry::Monitor::LDAP::Logger.new(Logger.new($stdout))
# require 'rouge/themes/ldap'
# monitor.config.theme = ::Rouge::Themes::LDAP.new
require 'rouge/themes/magritte'
monitor.config.theme = ::Rouge::Themes::Magritte.new

monitor.subscribe(notifications)
config = ROM::Configuration.new(:ldap, extensions: %i[compatibility])

config.relation(:entries) do
schema('(objectClass=*)', infer: true) do
Expand Down
Loading

0 comments on commit 08b6a46

Please sign in to comment.