Skip to content

Commit 0fee48b

Browse files
authored
Merge pull request #1 from prysmex/v0.3.1
fix specs, add rubocop
2 parents 7a8ac1e + 78e823e commit 0fee48b

23 files changed

+377
-196
lines changed

.github/workflows/test.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
3+
on: [pull_request]
4+
5+
# permissions:
6+
# contents: read
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
# env:
12+
# BUNDLE_ONLY: rubocop
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Ruby 3.2.2
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: 3.2.2
21+
bundler-cache: true
22+
23+
- name: Run Tests
24+
run: bundle exec rake
25+
# run: bundle exec rubocop --parallel

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9-
10-
# rspec failure tracking
11-
.rspec_status
12-
.byebug_history
9+
Gemfile.lock

.rubocop-rspec.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
###########################################################
2+
#################### Rubocop Rspec ########################
3+
###########################################################
4+
5+
# You can find all configuration options for rubocop-rspec here: https://docs.rubocop.org/rubocop-rspec/cops.html
6+
7+
# RSpec/PendingWithoutReason:
8+
# Enabled: false
9+
10+
# RSpec/FilePath:
11+
# Enabled: false

.rubocop.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# see example at https://gist.github.com/jhass/a5ae80d87f18e53e7b56
2+
3+
# <% unless ENV['BYPASS_RUBOCOP_TODO'] %>
4+
# inherit_from:
5+
# <% else %>
6+
# inherit_from:
7+
# - '.rubocop-todo.yml'
8+
# <% end %>
9+
10+
inherit_from:
11+
- .rubocop_todo.yml
12+
- .rubocop-rspec.yml
13+
14+
require:
15+
- rubocop-rspec
16+
- rubocop-rake
17+
- rubocop-performance
18+
19+
AllCops:
20+
NewCops: enable
21+
# TargetRubyVersion: 2.7.8
22+
# TargetRailsVersion: 6.1.4
23+
# Exclude:
24+
# - 'Gemfile.lock'
25+
26+
Naming/VariableNumber:
27+
Enabled: false
28+
29+
Layout/SpaceInsideHashLiteralBraces:
30+
Enabled: false
31+
32+
Layout/EmptyLinesAroundModuleBody:
33+
EnforcedStyle: empty_lines_special
34+
Enabled: false
35+
36+
Layout/TrailingEmptyLines:
37+
Enabled: false
38+
EnforcedStyle: final_blank_line
39+
40+
Layout/EmptyLinesAroundClassBody:
41+
Enabled: false
42+
43+
Style/RaiseArgs:
44+
EnforcedStyle: compact
45+
46+
Naming/MethodParameterName:
47+
Enabled: false
48+
49+
Naming/VariableName:
50+
Enabled: false
51+
52+
Layout/FirstHashElementIndentation:
53+
Enabled: false
54+
55+
Layout/CaseIndentation:
56+
EnforcedStyle: end
57+
58+
Metrics/ParameterLists:
59+
Enabled: false
60+
61+
Style/Lambda:
62+
EnforcedStyle: literal
63+
64+
Layout/IndentationWidth:
65+
Enabled: false
66+
67+
Layout/EndAlignment:
68+
Enabled: false
69+
70+
Layout/ElseAlignment:
71+
Enabled: false
72+
73+
Style/TrivialAccessors:
74+
Enabled: false
75+
76+
Layout/MultilineMethodCallIndentation:
77+
EnforcedStyle: indented

.rubocop_todo.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2024-03-19 18:55:09 UTC using RuboCop version 1.62.1.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
11+
Metrics/MethodLength:
12+
Max: 14
13+
14+
# Offense count: 1
15+
RSpec/BeforeAfterAll:
16+
Exclude:
17+
- '**/spec/spec_helper.rb'
18+
- '**/spec/rails_helper.rb'
19+
- '**/spec/support/**/*.rb'
20+
- 'spec/sidekiq_bouncer/bouncer_spec.rb'
21+
22+
# Offense count: 2
23+
# Configuration parameters: CountAsOne.
24+
RSpec/ExampleLength:
25+
Max: 7
26+
27+
# Offense count: 3
28+
# Configuration parameters: AllowedGroups.
29+
RSpec/NestedGroups:
30+
Max: 4
31+
32+
# Offense count: 1
33+
RSpec/SubjectStub:
34+
Exclude:
35+
- 'spec/sidekiq_bouncer/bouncer_spec.rb'
36+
37+
# Offense count: 6
38+
# Configuration parameters: AllowedConstants.
39+
Style/Documentation:
40+
Exclude:
41+
- 'spec/**/*'
42+
- 'test/**/*'
43+
- 'lib/sidekiq_bouncer.rb'
44+
- 'lib/sidekiq_bouncer/bounceable.rb'
45+
- 'lib/sidekiq_bouncer/bouncer.rb'
46+
- 'lib/sidekiq_bouncer/config.rb'

.travis.yml

-7
This file was deleted.

CHANGELOG.md

-13
This file was deleted.

Gemfile

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
source "https://rubygems.org"
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in sidekiq-bouncer.gemspec
46
gemspec
7+
8+
# gem 'bundler', '2.4.22'
9+
gem 'debug', '>= 1.0.0'
10+
gem 'rake', '~> 13.1'
11+
gem 'rspec', '~> 3.9'
12+
13+
# rubocop
14+
gem 'rubocop', '~> 1.62'
15+
gem 'rubocop-performance', '~> 1.20'
16+
gem 'rubocop-rake', '~> 0.6'
17+
gem 'rubocop-rspec', '~> 2.27.1'

Gemfile.lock

-50
This file was deleted.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ class FooWorker
6161
# The default delay is 60 seconds. You can optionally override it.
6262
register_bouncer(delay: optional_delay_override, delay_buffer: optional_delay_buffer_override)
6363

64-
def perform(param1, param2)
65-
return unless self.class.bouncer.let_in?(param1, param2) #pass all args received from perform
64+
def perform(param1, param2, debounce_key = nil)
65+
return unless self.class.bouncer.let_in?(debounce_key) # last argument is added as debounce_key
6666

6767
# Do your thing.
6868
end
6969
end
7070

7171
# Call `.bouncer.debounce(...)` instead of `.perform_in/perform_async(...)`.
72-
FooWorker.bouncer.debounce(param1, param2)
72+
FooWorker.bouncer.debounce(param1, param2, key_or_args_indices: [0, 1])
7373
```
7474

7575
## Development

Rakefile

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
require "bundler/gem_tasks"
2-
require "rspec/core/rake_task"
1+
# frozen_string_literal: true
32

3+
require 'bundler/gem_tasks'
4+
5+
require 'rspec/core/rake_task'
46
RSpec::Core::RakeTask.new(:spec)
57

6-
task :default => :spec
8+
require 'rubocop/rake_task'
9+
RuboCop::RakeTask.new
10+
11+
task default: %i[spec rubocop]

bin/console

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

3-
require "bundler/setup"
4-
require "sidekiq_bouncer"
4+
require 'bundler/setup'
5+
require 'sidekiq_bouncer'
56

67
# You can add fixtures and/or initialization code here to make experimenting
78
# with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "sidekiq_bouncer"
1011
# require "pry"
1112
# Pry.start
1213

13-
require "irb"
14+
require 'irb'
1415
IRB.start(__FILE__)

lib/sidekiq_bouncer.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'sidekiq_bouncer/config'
24
require 'sidekiq_bouncer/version'
35
require 'sidekiq_bouncer/bounceable'
@@ -13,7 +15,7 @@ def config
1315
end
1416

1517
# Yield self to allow configuing in a block
16-
def configure(&block)
18+
def configure(&)
1719
yield config
1820
end
1921
end

lib/sidekiq_bouncer/bounceable.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SidekiqBouncer
24
module Bounceable
35

0 commit comments

Comments
 (0)