Skip to content

Commit

Permalink
Add forwardable module and upgrade rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
dks17 committed Apr 4, 2020
1 parent 1a3e793 commit 62ce76b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
16 changes: 11 additions & 5 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 2019-10-23 10:17:29 -0400 using RuboCop version 0.75.1.
# on 2020-04-04 15:42:00 +0300 using RuboCop version 0.81.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 @@ -14,6 +14,7 @@ Bundler/DuplicatedGem:
- 'Gemfile'

# Offense count: 4
# Configuration parameters: IgnoredMethods.
Metrics/AbcSize:
Max: 21

Expand Down Expand Up @@ -42,10 +43,10 @@ Naming/FileName:
- 'spec/mongoid-locker_spec.rb'

# Offense count: 1
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
Expand Down Expand Up @@ -89,6 +90,11 @@ RSpec/MessageSpies:
RSpec/MultipleExpectations:
Max: 3

# Offense count: 1
RSpec/SubjectStub:
Exclude:
- 'spec/support/delegated_methods_shared_examples.rb'

# Offense count: 2
Style/Documentation:
Exclude:
Expand All @@ -109,5 +115,5 @@ Style/NumericPredicate:
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Layout/LineLength:
Max: 250
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ script:

rvm:
- 2.3.8
- 2.4.5
- 2.5.4
- 2.6.2
- 2.4.7
- 2.5.7
- 2.6.6
- jruby-9.1.17.0
- jruby-9.2.6.0

Expand All @@ -23,7 +23,7 @@ env:

matrix:
include:
- rvm: 2.6.2
- rvm: 2.6.6
env:
- MONGOID_VERSION=7
- COVERAGE=true
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### 2.0.1 (Next)

* [#86](https://github.com/mongoid/mongoid-locker/pull/86): Upgraded to RuboCop 0.81.0 - [@dks17](https://github.com/dks17).
* [#86](https://github.com/mongoid/mongoid-locker/pull/86): Fixed issue with `ruby` `delegate` method - [@dks17](https://github.com/dks17).
* [#86](https://github.com/mongoid/mongoid-locker/pull/86): Update Ruby versions for Travis config - [@dks17](https://github.com/dks17).
* Your contribution here.

### 2.0.0 (2019-10-23)
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ group :development, :test do
gem 'pry-byebug', platforms: :mri

gem 'mongoid-danger', '~> 0.1.1'
gem 'rspec', '~> 3.8'
gem 'rubocop', '0.75.1'
gem 'rubocop-rspec'
gem 'rspec', '~> 3.9'
gem 'rubocop', '0.81.0'
gem 'rubocop-rspec', '1.38.1'
gem 'simplecov', require: false
end
5 changes: 4 additions & 1 deletion lib/mongoid/locker.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'forwardable'
require 'securerandom'

module Mongoid
Expand Down Expand Up @@ -103,6 +104,8 @@ def reset!

# @api private
def included(klass)
klass.extend(Forwardable) unless klass.ancestors.include?(Forwardable)

klass.extend ClassMethods
klass.singleton_class.instance_eval { attr_accessor(*MODULE_METHODS) }

Expand All @@ -114,7 +117,7 @@ def included(klass)
klass.backoff_algorithm = backoff_algorithm
klass.locking_name_generator = locking_name_generator

klass.delegate(*MODULE_METHODS, to: :class)
klass.def_delegators(klass, *MODULE_METHODS)
klass.singleton_class.delegate(*(methods(false) - MODULE_METHODS.flat_map { |method| [method, "#{method}=".to_sym] } - %i[included reset! configure]), to: self)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require 'mongoid-locker'
Mongoid.load! File.join(File.dirname(__FILE__), 'database.yml')

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }

RSpec.configure do |config|
config.include LockerHelpers
Expand Down

0 comments on commit 62ce76b

Please sign in to comment.